:root {
    --bg-page: #ffffff;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --border-light: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-placeholder: #94a3b8;
    --brand-blue: #0284c7;
    --brand-blue-hover: #0369a1;
    --brand-blue-surface: #e0f2fe;
    --bubble-user: #f1f5f9;
    --danger: #dc2626;
    --danger-surface: #fee2e2;
    --shadow-dock: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.16);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
    --bg-page: #0b0f17;
    --bg-surface: #111827;
    --bg-elevated: #1a2234;
    --border-light: #1f293d;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-placeholder: #64748b;
    --brand-blue: #38bdf8;
    --brand-blue-hover: #0284c7;
    --brand-blue-surface: #0c2842;
    --bubble-user: #1e293b;
    --danger: #ef4444;
    --danger-surface: #451a1a;
    --shadow-dock: 0 8px 25px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 24px 50px rgba(0, 0, 0, 0.7);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* NAVBAR */
.top-navbar {
    height: 52px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-light);
    z-index: 20;
}

.navbar-left, .navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
    margin-left: 6px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.btn-icon:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}

/* DRAWER LATERAL */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 99;
    display: none;
}

.sidebar-backdrop.active {
    display: block;
}

.sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-light);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.sidebar-drawer.active {
    transform: translateX(0);
}

.drawer-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.drawer-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
}

.drawer-subtitle {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--brand-blue);
    letter-spacing: 0.6px;
}

.drawer-body {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.drawer-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-placeholder);
    letter-spacing: 0.8px;
    padding: 4px 10px;
    margin-bottom: 6px;
}

.drawer-menu-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.drawer-menu-btn:hover {
    background: var(--bg-surface);
}

.drawer-menu-btn.danger {
    color: var(--danger);
}

.drawer-footer {
    padding: 14px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ÁREA DE MENSAJES */
.chat-viewport {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 160px;
}

.chat-thread {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* BIENVENIDA CON AVATAR */
.welcome-box {
    text-align: center;
    padding: 60px 16px 20px;
    max-width: 580px;
    margin: 0 auto;
}

.welcome-avatar-img {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.welcome-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.welcome-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* BURBUJAS DE MENSAJES */
.msg-box {
    width: 100%;
    line-height: 1.65;
    font-size: 0.95rem;
}

.msg-box.user {
    align-self: flex-end;
    max-width: 85%;
    background: var(--bubble-user);
    color: var(--text-main);
    border-radius: 18px 18px 4px 18px;
    padding: 12px 18px;
    border: 1px solid var(--border-light);
}

.msg-box.ai {
    background: transparent;
    color: var(--text-main);
    padding: 6px 0;
}

.msg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.msg-body {
    white-space: pre-wrap;
    word-break: break-word;
}

/* DOCK FLOTANTE MINIMALISTA */
.dock-wrapper {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    padding: 0 16px;
    z-index: 40;
}

.dock-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 10px 14px;
    box-shadow: var(--shadow-dock);
    position: relative;
}

.dock-meta-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pill-badge {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.evidence-staging-badge {
    background: var(--brand-blue-surface);
    color: var(--brand-blue);
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 600;
}

.dock-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dock-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.95rem;
    resize: none;
    max-height: 140px;
    line-height: 1.45;
}

.dock-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--brand-blue);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.dock-send-btn:hover {
    background: var(--brand-blue-hover);
}

.dock-disclaimer {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-placeholder);
    margin-top: 6px;
}

/* POPUPS FLOTANTES */
.attach-popup, .directriz-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-modal);
    z-index: 50;
    padding: 6px;
}

.attach-popup.active, .directriz-popup.active {
    display: flex;
    flex-direction: column;
}

.attach-popup {
    left: 14px;
    width: 220px;
    gap: 2px;
}

.attach-opt-btn, .directriz-popup-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.84rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}

.attach-opt-btn:hover, .directriz-popup-item:hover {
    background: var(--bg-surface);
}

.directriz-popup {
    left: 14px;
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
}

.popup-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-placeholder);
    padding: 4px 8px 8px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 4px;
}

/* MODALES BASE */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal-sheet {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 90%;
    max-width: 620px;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-sheet-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.modal-sheet-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-sheet-footer {
    padding: 12px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-surface);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-input, .form-select {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    color: var(--text-main);
    font-size: 0.88rem;
    outline: none;
}

.evidence-textarea {
    width: 100%;
    height: 260px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.5;
    outline: none;
    resize: vertical;
}

.btn-solid {
    background: var(--brand-blue);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 14px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger-text {
    background: transparent;
    color: var(--danger);
    border: none;
    padding: 8px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.rag-docs-list {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.rag-doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.84rem;
}

/* =====================================================================
   TARJETA DE LOGIN GLASSMORPHISM EXACTA
   ===================================================================== */
.modal-overlay#loginModal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(7, 11, 17, 0.82) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 99999 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
}

.modal-overlay#loginModal.active {
    display: flex !important;
}

.modal-overlay#loginModal .login-card {
    background: rgba(43, 53, 64, 0.68) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 20px !important;
    width: 90% !important;
    max-width: 440px !important;
    padding: 38px 32px 34px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 16px !important;
    text-align: center !important;
    position: relative !important;
    z-index: 100000 !important;
}

.login-logo-circle {
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: rgba(0, 143, 122, 0.18) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 2px !important;
    border: 1px solid rgba(0, 143, 122, 0.35) !important;
}

.login-title {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    margin-bottom: 8px !important;
}

.login-title .brand-title-main {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    color: #008f7a !important;
    letter-spacing: -0.3px !important;
}

.login-title .brand-title-sub {
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    color: #008f7a !important;
}

.login-card .login-input {
    width: 100% !important;
    background: rgba(26, 36, 48, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    padding: 13px 16px !important;
    font-size: 0.92rem !important;
    outline: none !important;
}

.login-card .login-input:focus {
    border-color: #008f7a !important;
    background: rgba(26, 36, 48, 0.85) !important;
    box-shadow: 0 0 0 2px rgba(0, 143, 122, 0.25) !important;
}

.btn-primary-acceso {
    width: 100% !important;
    background: #006056 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 13px 18px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    margin-top: 6px !important;
    transition: background 0.2s ease !important;
}

.btn-primary-acceso:hover {
    background: #007367 !important;
}


/* --- ANIMACIÓN PREPROCESO Y CORRECCIÓN DE SCROLL (IA-JUDICIAL) --- */
@keyframes spin_gear {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse_soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.gear-spinning {
    display: inline-block;
    animation: spin_gear 2s linear infinite;
}

.pulse-badge {
    display: inline-block;
    animation: pulse_soft 1.4s ease-in-out infinite;
}

/* Espaciado inferior generoso para que el contenido jamás quede oculto por el dock */
.chat-viewport, #mainWorkspace {
    padding-bottom: 240px !important;
    scroll-behavior: smooth !important;
}


/* ESTILOS DEL SELECTOR DE EVIDENCIA Y MONITOR DE CONTEXTO */
.evidence-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 80px;
    width: 330px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: var(--shadow-modal);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.evidence-popup.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.evidence-popup-header {
    padding: 10px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
}

.meter-bar-track {
    width: 100%;
    height: 7px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

[data-theme="dark"] .meter-bar-track {
    background: #1e293b;
}

.meter-bar-fill {
    height: 100%;
    transition: width 0.25s ease, background-color 0.25s ease;
}

.evidence-popup-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.evidence-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.evidence-item-row:hover {
    background: var(--bg-surface);
}

.evidence-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.evidence-item-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.evidence-item-tokens {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ESTILO PROFESIONAL PARA BOTÓN NUEVA SESIÓN (+) */
#btnNewChat {
    background: rgba(14, 165, 233, 0.12) !important;
    color: #0284c7 !important;
    border: 1px solid rgba(2, 132, 199, 0.3) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    font-size: 1.25rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease-in-out !important;
    margin-left: 8px !important;
}

#btnNewChat:hover {
    background: #0284c7 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35) !important;
    transform: scale(1.05) !important;
}

/* ==============================================================================
   REFINAMIENTO CINEMÁTICO, SINUOSIDAD Y PROFUNDIDAD PERICIAL
   ============================================================================== */

/* 1. Backdrop Cinemático con Desenfoque Orgánico */
.sidebar-backdrop, .modal-backdrop, .modal-overlay {
    backdrop-filter: blur(10px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(140%) !important;
    background: rgba(15, 23, 42, 0.38) !important;
    transition: opacity 280ms cubic-bezier(0.16, 1, 0.3, 1), visibility 280ms !important;
}

/* 2. Sidebar Drawer: Entrada Elástica Saturada */
.sidebar-drawer {
    transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 20px 0 50px -10px rgba(0, 0, 0, 0.25) !important;
    will-change: transform;
}

.drawer-menu-btn {
    transition: background-color 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1), color 180ms ease !important;
}

.drawer-menu-btn:hover {
    transform: translateX(4px) !important;
}

.drawer-menu-btn:active {
    transform: translateX(2px) scale(0.98) !important;
}

/* 3. Modales: Elevación con Profundidad Tridimensional */
.modal-sheet, .login-card {
    border-radius: 18px !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.8) inset !important;
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1), opacity 260ms ease-out !important;
    will-change: transform, opacity;
}

.modal-backdrop:not(.active) .modal-sheet,
.modal-overlay:not(.active) .login-card {
    transform: translateY(16px) scale(0.96) !important;
    opacity: 0 !important;
}

.modal-backdrop.active .modal-sheet,
.modal-overlay.active .login-card {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
}

/* 4. Popups del Dock: Despliegue Anclado Tipo Burbuja Elástica */
.directriz-popup, .evidence-popup, .attach-popup {
    transform-origin: bottom center !important;
    border-radius: 14px !important;
    box-shadow: 0 20px 35px -8px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(226, 232, 240, 0.9) !important;
    transition: opacity 200ms ease, transform 240ms cubic-bezier(0.2, 0.9, 0.3, 1.15) !important;
    will-change: transform, opacity;
}

/* 5. Micro-interacción Táctil en Píldoras y Botones */
.pill-badge {
    transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease, box-shadow 180ms ease !important;
}

.pill-badge:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05) !important;
}

.pill-badge:active {
    transform: translateY(1px) scale(0.96) !important;
}

.dock-action-btn, .dock-send-btn {
    transition: transform 120ms cubic-bezier(0.16, 1, 0.3, 1), background-color 180ms ease, box-shadow 180ms ease !important;
}

.dock-action-btn:active, .dock-send-btn:active {
    transform: scale(0.92) !important;
}

/* 6. Suavizado en Lista de Comandos y Directrices */
.directriz-item, .rag-doc-item {
    transition: background-color 160ms ease, transform 160ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.directriz-item:hover, .rag-doc-item:hover {
    transform: translateX(3px) !important;
}




/* ==============================================================================
   RESPONSIVIDAD CANÓNICA Y CENTRADO PERFECTO EN MÓVIL (CHATVCC)
   ============================================================================== */

/* Base para el dock en todas las resoluciones */
.dock-wrapper {
    position: fixed !important;
    bottom: 16px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 24px) !important;
    max-width: 720px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    z-index: 100 !important;
    pointer-events: none !important; /* Permite clicks a través de los bordes transparentes */
}

.dock-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    pointer-events: auto !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 10px 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

@media (max-width: 640px) {
    .dock-wrapper {
        bottom: 8px !important;
        width: calc(100% - 16px) !important;
    }

    .dock-card {
        padding: 8px 10px !important;
        border-radius: 14px !important;
    }

    /* Barra de Píldoras: Distribución flexible que nunca se desborda */
    .dock-meta-bar {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        margin-bottom: 6px !important;
    }

    .dock-meta-bar::-webkit-scrollbar {
        display: none !important;
    }

    .pill-badge {
        flex: 0 0 auto !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        padding: 4px 8px !important;
        font-size: 0.72rem !important;
        max-width: 130px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        border-radius: 20px !important;
    }

    .pill-badge span:nth-child(2) {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 80px !important;
        display: inline-block !important;
    }

    /* Fila de Input y Botón de Envío */
    .dock-input-row {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .dock-action-btn {
        flex: 0 0 32px !important;
        width: 32px !important;
        height: 32px !important;
    }

    .dock-textarea {
        flex: 1 1 auto !important;
        font-size: 0.88rem !important;
        line-height: 1.35 !important;
        padding: 4px 0 !important;
    }

    .dock-send-btn {
        flex: 0 0 36px !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Disclaimer procesal en móvil */
    .dock-disclaimer {
        font-size: 0.62rem !important;
        line-height: 1.2 !important;
        margin-top: 4px !important;
        text-align: center !important;
        padding: 0 4px !important;
    }

    /* Popups adaptados */
    .directriz-popup, .evidence-popup, .attach-popup, #commandsPopup {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        width: calc(100% - 24px) !important;
        bottom: 74px !important;
        box-sizing: border-box !important;
    }
}

/* ==============================================================================
   AJUSTE DE PROPORCIÓN EQUILIBRADA PARA LAS 3 PÍLDORAS DEL DOCK
   ============================================================================== */
.dock-meta-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
}

.dock-meta-bar::-webkit-scrollbar {
    display: none !important;
}

.pill-badge {
    flex: 0 1 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 5px 10px !important;
    font-size: 0.78rem !important;
    white-space: nowrap !important;
    border-radius: 12px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    cursor: pointer !important;
}

.pill-badge span:nth-child(2) {
    max-width: 140px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

@media (max-width: 640px) {
    .dock-meta-bar {
        gap: 6px !important;
        margin-bottom: 4px !important;
    }

    .pill-badge {
        padding: 4px 7px !important;
        font-size: 0.70rem !important;
    }

    .pill-badge span:nth-child(2) {
        max-width: 80px !important;
    }
}

/* ==============================================================================
   REGLAS ESPECÍFICAS PARA EL MODAL DIDÁCTICO HOW-TO
   ============================================================================== */
#helpModalBackdrop {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(8px) saturate(130%) !important;
    -webkit-backdrop-filter: blur(8px) saturate(130%) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
}

#helpModalBackdrop.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

#helpModalBackdrop .modal-sheet {
    background: #ffffff !important;
    color: #1e293b !important;
    width: 100% !important;
    max-width: 740px !important;
    max-height: 88vh !important;
    border-radius: 18px !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35) !important;
    display: flex !important;
    flex-direction: column !important;
    opacity: 1 !important;
    transform: none !important;
    overflow: hidden !important;
}

#helpModalBackdrop .modal-sheet-body {
    overflow-y: auto !important;
    padding: 18px 20px !important;
    color: #334155 !important;
}

/* ==============================================================================
   ESTILOS ROBUSTOS PARA EL MODAL DE AYUDA (SÓLIDO, CENTRADO Y AISLADO)
   ============================================================================== */
#helpModalBackdrop {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    z-index: 999999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
}

#helpModalBackdrop.active {
    display: flex !important;
}

.help-card-container {
    background: #ffffff !important;
    width: 100% !important;
    max-width: 720px !important;
    max-height: 85vh !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45) !important;
    border: 1px solid #cbd5e1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    animation: helpPopIn 220ms cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes helpPopIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.help-header {
    padding: 16px 20px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: #f8fafc !important;
}

.help-btn-close {
    background: transparent !important;
    border: none !important;
    font-size: 1.3rem !important;
    cursor: pointer !important;
    color: #64748b !important;
    padding: 4px 8px !important;
    line-height: 1 !important;
    border-radius: 6px !important;
    transition: background 150ms ease !important;
}

.help-btn-close:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

.help-content-scroll {
    padding: 18px 20px !important;
    overflow-y: auto !important;
}

.help-footer {
    padding: 12px 20px !important;
    border-top: 1px solid #e2e8f0 !important;
    text-align: right !important;
    background: #f8fafc !important;
}

.help-btn-primary {
    padding: 8px 22px !important;
    background: #0284c7 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: background 150ms ease !important;
}

.help-btn-primary:hover {
    background: #0369a1 !important;
}

/* Saneamiento de modales opacos */
.modal-backdrop.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-backdrop.active .modal-sheet {
    opacity: 1 !important;
    transform: none !important;
    background: #ffffff !important;
}

#usersModalBackdrop.active {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.7) !important;
    backdrop-filter: blur(8px) !important;
    z-index: 99999 !important;
    align-items: center !important;
    justify-content: center !important;
}

#usersModalBackdrop.active .modal-sheet {
    opacity: 1 !important;
    transform: none !important;
    background: #ffffff !important;
}

/* MODALES CON CONTENEDOR OPACO Y SIN BOTONES DESBORDADOS */
.modal-backdrop {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 99999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
}

.modal-backdrop.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-backdrop .modal-sheet {
    background: #ffffff !important;
    color: #1e293b !important;
    width: 100% !important;
    border-radius: 16px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45) !important;
    opacity: 1 !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}


/* ========================================================================== */
/* MODAL DE LOGIN INSTITUCIONAL DARK GLASSMORPHISM                             */
/* ========================================================================== */
.modal-overlay#loginModal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 14, 23, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay#loginModal.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-overlay#loginModal .login-card {
    background: rgba(22, 30, 44, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    padding: 32px 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    position: relative;
    z-index: 10001;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay#loginModal.active .login-card {
    transform: scale(1) translateY(0);
}

/* Isotipo institucional estrictamente acotado */
.modal-overlay#loginModal .login-logo {
    width: 80px !important;
    height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
    object-fit: contain !important;
    border-radius: 50%;
    background: rgba(13, 92, 85, 0.2);
    padding: 8px;
    border: 1px solid rgba(13, 92, 85, 0.4);
    margin-bottom: 4px;
    display: block;
}

.modal-overlay#loginModal .login-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.modal-overlay#loginModal .login-title .brand-title-main {
    font-size: 1.35rem;
    font-weight: 800;
    color: #107569;
    letter-spacing: -0.5px;
}

.modal-overlay#loginModal .login-title .brand-title-sub {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0d9488;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.modal-overlay#loginModal .input-field {
    width: 100%;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f1f5f9;
    padding: 12px 14px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.modal-overlay#loginModal .input-field:focus {
    border-color: #107569;
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 0 0 2px rgba(16, 117, 105, 0.25);
}

.modal-overlay#loginModal .input-field::placeholder {
    color: #64748b;
}

.modal-overlay#loginModal .btn-primary-acceso {
    width: 100%;
    background: #0d5c55;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
    z-index: 10002;
    position: relative;
}

.modal-overlay#loginModal .btn-primary-acceso:hover {
    background: #11736a;
    transform: translateY(-1px);
}

.modal-overlay#loginModal .btn-primary-acceso:active {
    transform: translateY(0);
}


/* ========================================================================== */
/* CONTROL DE APILAMIENTO Y TELONES (SIN BLOQUEOS RESIDUALES)                */
/* ========================================================================== */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    display: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 290px;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.sidebar-drawer.active {
    transform: translateX(0) !important;
}

.modal-backdrop, .modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.modal-backdrop.active, .modal-overlay.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-sheet, .modal-card {
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 640px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.97) translateY(8px);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-sheet, .modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

/* === REFUERZO ESTRUCTURAL MODAL RAG (SCROLL Y VISIBILIDAD) === */
#ragModal .modal-sheet {
    max-height: 88vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#ragModal .modal-sheet-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    padding-right: 14px;
}

#ragModal .modal-sheet-body::-webkit-scrollbar {
    width: 6px;
}

#ragModal .modal-sheet-body::-webkit-scrollbar-track {
    background: transparent;
}

#ragModal .modal-sheet-body::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

#ragModal .modal-sheet-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === SANEAMIENTO CONTENEDOR Y SCROLL MODAL RAG === */
#ragModal .modal-sheet {
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#ragModal .modal-sheet-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
    max-height: 60vh !important;
}

#ragModal .rag-docs-list {
    overflow-y: auto !important;
    min-height: 120px;
    max-height: 48vh !important;
}

#ragModal #ragEditorContent {
    min-height: 180px;
    max-height: 42vh;
    overflow-y: auto;
}

/* === SCROLLBAR ACTIVA Y FLUIDA EN EDITOR DOGMÁTICO RAG === */
#ragEditorContent {
    overflow-y: auto !important;
    min-height: 200px !important;
    max-height: 42vh !important;
    resize: vertical !important;
    scrollbar-width: thin !important;
    scrollbar-color: var(--border-light) transparent !important;
}

#ragEditorContent::-webkit-scrollbar {
    width: 6px !important;
}

#ragEditorContent::-webkit-scrollbar-track {
    background: transparent !important;
}

#ragEditorContent::-webkit-scrollbar-thumb {
    background: var(--border-light) !important;
    border-radius: 4px !important;
}

#ragEditorContent::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted) !important;
}

/* === CONFINAMIENTO Y SCROLL ESTRICTO PARA CATÁLOGO RAG === */
#ragDocsList {
    max-height: 180px !important;
    min-height: 110px !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: var(--border-light) transparent !important;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-surface);
}

#ragDocsList::-webkit-scrollbar {
    width: 6px !important;
}

#ragDocsList::-webkit-scrollbar-thumb {
    background: var(--border-light) !important;
    border-radius: 4px !important;
}

#ragDocsList::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted) !important;
}

/* === ESTILOS EDITOR VISUAL WYSIWYG RAG === */
.rag-wysiwyg-content {
    min-height: 220px !important;
    max-height: 40vh !important;
    overflow-y: auto !important;
    background: var(--bg-surface) !important;
    color: var(--text-main) !important;
    padding: 14px 16px !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 8px !important;
    font-size: 0.92rem !important;
    line-height: 1.6 !important;
    outline: none !important;
    cursor: text !important;
    box-sizing: border-box !important;
    scrollbar-width: thin !important;
    scrollbar-color: var(--border-light) transparent !important;
}

.rag-wysiwyg-content:focus {
    border-color: var(--brand-blue) !important;
}

.rag-wysiwyg-content:empty:before {
    content: attr(data-placeholder);
    color: var(--text-placeholder);
    pointer-events: none;
    display: block;
}

.rag-wysiwyg-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 12px 0 6px 0;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
}

.rag-wysiwyg-content blockquote {
    border-left: 4px solid var(--brand-blue);
    padding: 6px 14px;
    margin: 8px 0;
    background: var(--brand-blue-surface);
    color: var(--text-main);
    font-style: italic;
    border-radius: 0 4px 4px 0;
}

.rag-wysiwyg-content ul {
    margin: 8px 0 8px 24px;
    padding: 0;
}

.rag-wysiwyg-content li {
    margin-bottom: 4px;
}

.rag-wysiwyg-content strong, .rag-wysiwyg-content b {
    font-weight: 700;
    color: var(--text-main);
}

.rag-wysiwyg-content em, .rag-wysiwyg-content i {
    font-style: italic;
}

/* === SANEAMIENTO DE FONDO Y LÍNEAS DEL DOCK (BLANCO PURO) === */
body, 
main, 
.chat-viewport, 
#mainWorkspace {
    background-color: #ffffff !important;
    border-bottom: none !important;
}

.dock-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.dock-disclaimer {
    background: transparent !important;
    border: none !important;
    border-top: none !important;
    box-shadow: none !important;
    color: var(--text-placeholder) !important;
    padding-top: 6px !important;
    margin-top: 4px !important;
}

/* Suprimir cualquier divisor horizontal parásito al pie del chat */
.chat-viewport::after,
main::after,
.dock-wrapper::before {
    display: none !important;
    content: none !important;
    border: none !important;
}

/* === FORZADO DE BLANCO PURO Y REMOCIÓN DE LÍNEAS / FONDOS GRISES === */
html,
body,
main,
#mainWorkspace,
.chat-viewport,
.chat-thread {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.dock-wrapper {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.dock-disclaimer {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-top: none !important;
    outline: none !important;
    box-shadow: none !important;
    margin-top: 6px !important;
    padding: 0 !important;
    color: var(--text-placeholder) !important;
}

.chat-viewport::before,
.chat-viewport::after,
main::before,
main::after,
.dock-wrapper::before,
.dock-wrapper::after {
    display: none !important;
    content: none !important;
    border: none !important;
    background: transparent !important;
}

/* === FORZADO DE BLANCO PURO Y REMOCIÓN DE LÍNEAS / FONDOS GRISES === */
html,
body,
main,
#mainWorkspace,
.chat-viewport,
.chat-thread {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.dock-wrapper {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.dock-disclaimer {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-top: none !important;
    outline: none !important;
    box-shadow: none !important;
    margin-top: 6px !important;
    padding: 0 !important;
    color: var(--text-placeholder) !important;
}

.chat-viewport::before,
.chat-viewport::after,
main::before,
main::after,
.dock-wrapper::before,
.dock-wrapper::after {
    display: none !important;
    content: none !important;
    border: none !important;
    background: transparent !important;
}


/* === ANULACIÓN COMPLETA DE FONDOS GRISES Y LÍNEAS BAJO DOCK === */
html,
body,
main,
#mainWorkspace,
.chat-viewport,
.chat-thread,
footer,
.chat-footer {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.dock-wrapper {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.dock-disclaimer {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-top: none !important;
    box-shadow: none !important;
    outline: none !important;
    margin-top: 6px !important;
    padding: 0 !important;
    color: var(--text-placeholder) !important;
}

.chat-viewport::before,
.chat-viewport::after,
main::before,
main::after,
.dock-wrapper::before,
.dock-wrapper::after,
#mainWorkspace::before,
#mainWorkspace::after {
    display: none !important;
    content: none !important;
    border: none !important;
    background: transparent !important;
}

/* === ELIMINACIÓN TOTAL DE BORDES Y LÍNEAS HORIZONTALES EN EL DOCK === */
html, body, main, #mainWorkspace, .chat-viewport, .chat-thread {
    background-color: #ffffff !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
}

.dock-wrapper, .dock-disclaimer {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    background: transparent !important;
}


/* =====================================================================
   SHIMMER PILL - PULSO NEURONAL EFÍMERO (PROCESAMIENTO DE INFERENCIA)
   ===================================================================== */
.shimmer-pill-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    margin: 4px 0;
}

.shimmer-pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #0284c7;
    animation: neuralPulse 1.6s infinite ease-in-out;
}

.shimmer-pill-bar {
    width: 90px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #e2e8f0 25%, #bae6fd 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmerSweep 1.8s infinite linear;
}

@keyframes neuralPulse {
    0%, 100% { transform: scale(0.85); opacity: 0.4; }
    50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 6px rgba(2, 132, 199, 0.5); }
}

@keyframes shimmerSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* =====================================================================
   ESTILO REFORZADO PARA MENÚ DE ADJUNTOS (ATTACH POPUP)
   ===================================================================== */
.attach-popup {
    display: none;
    position: absolute;
    bottom: 56px;
    left: 12px;
    width: 230px !important;
    background: #ffffff;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    padding: 6px;
    flex-direction: column !important;
    gap: 4px;
    z-index: 1050;
}

.attach-popup.active {
    display: flex !important;
}

.attach-opt-btn {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-main, #0f172a);
    text-align: left;
    transition: background 0.15s ease;
}

.attach-opt-btn:hover {
    background: #f1f5f9;
}

.attach-opt-btn .opt-icon {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==============================================================================
   CÁPSULA FORENSE COMPACTA (ALTERNATIVA 1)
   ============================================================================== */
.evidence-capsule {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #10b981;
    border-radius: 8px;
    padding: 8px 14px;
    margin: 6px 0;
    transition: all 0.2s ease;
}

.evidence-capsule:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    border-left-color: #059669;
}

.capsule-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.capsule-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.capsule-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.capsule-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.capsule-meta {
    font-size: 0.72rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.badge-ram {
    background: #dcfce7;
    color: #166534;
    font-weight: 700;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-capsule-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #0284c7;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.btn-capsule-action:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

/* ==============================================================================
   CÁPSULA DE CARGA COMPACTA CON PULSO SHIMMER (DURANTE INFERENCIA WHISPER/OCR)
   ============================================================================== */
.loading-capsule {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #0284c7;
    border-radius: 8px;
    padding: 8px 14px;
    margin: 6px 0;
}

.loading-capsule-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.loading-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #0284c7;
    animation: neuralPulse 1.4s infinite ease-in-out;
    flex-shrink: 0;
}

.loading-capsule-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.loading-capsule-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
}

.loading-capsule-meta {
    font-size: 0.72rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.loading-shimmer-track {
    width: 110px;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, #e2e8f0 20%, #38bdf8 50%, #e2e8f0 80%);
    background-size: 200% 100%;
    animation: shimmerSweep 1.6s infinite linear;
    flex-shrink: 0;
}

@keyframes neuralPulse {
    0%, 100% { transform: scale(0.85); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 8px rgba(2, 132, 199, 0.6); }
}

@keyframes shimmerSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==============================================================================
   AVATAR DINÁMICO DEL OPERADOR (BURBUJA DE CHAT Y MODAL DE REGISTRO)
   ============================================================================== */
.user-meta-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar-micro {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.user-avatar-initials {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0284c7;
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.avatar-upload-box {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    margin-bottom: 12px;
}

.avatar-preview-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.avatar-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* CORRECCIÓN Z-INDEX Y CLICS EN LOGIN */
.modal-overlay, .modal-backdrop {
    z-index: 99999 !important;
    pointer-events: auto !important;
}
.login-card, .modal-sheet, .modal-card {
    z-index: 100000 !important;
    pointer-events: auto !important;
}
.login-card input, .login-card button, .modal-card input, .modal-card button {
    position: relative !important;
    z-index: 100002 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}
