/* ==========================================================================
   SOMA — CSS GLOBAL
   ÍNDICE DE ORGANIZACIÓN
   1. Variables y estilos base (modo claro por defecto)
   2. Variables y sobreescrituras de modo oscuro (body.dark-mode / html.dark-mode)
   3. Estructura global, contenedores y cabeceras
   4. Index y login
   5. Gestión de terapeutas
   6. Historial y fichas de pacientes
   7. Documentación
   8. Componentes compartidos, formularios y modales
   9. Tester / sesiones / ciclos
   10. Chat privado
   11. Ajustes finales y excepciones específicas
   12. Reglas responsive para móvil/tablet (@media)

   NOTA: Se conserva el orden de cascada de las reglas existentes porque
   hay sobreescrituras posteriores con !important. Reordenar todas las reglas
   solo por tema puede cambiar el aspecto y romper páginas.
   ========================================================================== */
:root,
html:not(.dark-mode),
html:not(.dark-mode) body {
    --bg-body: #ece8e1;
    --texto-principal: #332d27;
    --texto-secundario: #7a7167;
    --texto-titulos: #1f1a16;

    --bg-card: rgba(247, 244, 238, 0.95);
    --border-card: rgba(216, 209, 198, 0.85);
    --shadow-card: 0 4px 18px rgba(60, 50, 40, 0.05);

    --bg-btn-primary: #3d352e;
    --texto-btn-primary: #f7f4ee;
    --bg-btn-primary-hover: #29231e;

    --bg-btn-secondary: #dfd8ce;
    --texto-btn-secondary: #332d27;
    --bg-btn-secondary-hover: #d2c9bd;

    --bg-subbox: #e5ded4;
    --border-subbox: #d3cbbe;

    --badge-energia-bg: #dbe7df;
    --badge-energia-txt: #22422c;
    --badge-energia-border: #bfd4c6;

    --ciclo-border: #8c8072;
    --ciclo-bg: #f2eee6;

    --decreto-bg: #ede7dc;
    --decreto-border: #d4cbbe;
    --decreto-txt: #332d27;
    --decreto-tit: #22422c;
}

html.dark-mode,
html.dark-mode body,
body.dark-mode {
    background-color: #0c0a14 !important;
    background-image: url('bg_negro.jpg') !important;
    background-size: cover !important;
    background-position: center !important;
    background-attachment: fixed !important;
    color: #e2e8f0 !important;

    --bg-body: #0c0a14 !important;
    --texto-principal: #e2e8f0 !important;
    --texto-secundario: #94a3b8 !important;
    --texto-titulos: #f8fafc !important;

    --bg-card: rgba(22, 27, 38, 0.96) !important;
    --border-card: rgba(148, 163, 184, 0.14) !important;
    --shadow-card: 0 4px 25px rgba(0, 0, 0, 0.45) !important;

    --bg-btn-primary: #1e293b !important;
    --texto-btn-primary: #f8fafc !important;
    --bg-btn-primary-hover: #334155 !important;

    --bg-btn-secondary: #1e293b !important;
    --texto-btn-secondary: #f1f5f9 !important;
    --bg-btn-secondary-hover: #334155 !important;

    --bg-subbox: rgba(15, 23, 42, 0.8) !important;
    --border-subbox: rgba(148, 163, 184, 0.12) !important;

    --badge-energia-bg: rgba(56, 178, 172, 0.16) !important;
    --badge-energia-txt: #5eead4 !important;
    --badge-energia-border: rgba(94, 234, 212, 0.3) !important;

    --ciclo-border: #38bdf8 !important;
    --ciclo-bg: rgba(15, 23, 42, 0.7) !important;

    --decreto-bg: rgba(15, 23, 42, 0.85) !important;
    --decreto-border: rgba(148, 163, 184, 0.15) !important;
    --decreto-txt: #e2e8f0 !important;
    --decreto-tit: #5eead4 !important;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Montserrat', sans-serif; 
}

/* ==========================================================================
   FONDOS Y CUERPO PRINCIPAL
   ========================================================================== */
body { 
    background-color: var(--bg-body); 
    color: var(--texto-principal); 
    margin: 0 !important;
    padding: 0 !important; /* <- Esto quita el hueco de arriba de la web */
    font-size: 15px; 
    min-height: 100vh; 
    overflow-x: hidden; 
    display: flex; 
    flex-direction: column; 
    box-sizing: border-box;
    align-items: center; 
    background-image: url('bg_gris.jpeg'); /* Con la E, como el original */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}


/* Apaga el fondo de los contenedores internos para no sumar dobles transparencias */
.contenedor-general .container {
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
}





/* ==========================================================================
   CONTENEDOR GENERAL ÚNICO (Efecto "papel vegetal": Blanco limpio sin mareos)
   ========================================================================== */
.contenedor-general {
    background: rgba(252, 250, 247, 0.90) !important; /* Subimos a 90% para un blanco/crema sólido y limpio */
    backdrop-filter: none !important; /* Cero desenfoque (adiós mareos) */
    -webkit-backdrop-filter: none !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    border-top: none !important; 
    border-radius: 0 0 20px 20px !important; 
    padding: 20px !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15) !important; 
    width: 100%;
    max-width: 1000px;
    margin: 0 auto !important;
    box-sizing: border-box;
}

body.dark-mode .contenedor-general {
    background: rgba(18, 19, 22, 0.90) !important; /* Gris muy oscuro al 90% */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-top: none !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
}

/* Unificamos la cabecera y el cuerpo para que sean una sola lámina limpia */
.contenedor-general .container, 
.contenedor-general .cabecera-axioma {
    background-color: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
}

.contenedor-general .container, 
.contenedor-general .cabecera-axioma,
.container .cabecera-axioma {
    background-color: transparent !important;
}

body.dark-mode { background-image: url('bg_negro.jpg'); }

/* Limitar tamaño de SVGs para que no haya sustos */
svg { max-width: 24px; max-height: 24px; width: auto; height: auto; display: inline-block; vertical-align: middle; }

/* Contenedor estándar (Tester, Gestión, Historial) */
.container { 
    width: 94%; 
    max-width: 900px !important; /* ← Forzamos la reducción aquí */
    margin: 0 auto; 
    flex: 1; 
}

.header-principal {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    margin-bottom: 24px;
    position: relative;
    text-align: center;
}

/* ==========================================================================
   1. PÁGINA DE INICIO (INDEX) Y LOGIN
   ========================================================================== */
.index-body { padding: 0; display: flex; align-items: center; justify-content: center; }
.main-wrapper { width: 100%; display: flex; justify-content: center; align-items: center; padding: 20px; flex: 1; }

.dashboard-container, .login-card {
    width: 100%; max-width: 440px; margin: auto;
    background: var(--bg-card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-card); border-radius: 20px;
    padding: 30px 24px; box-shadow: var(--shadow-card); text-align: center;
}

.header-index { margin-bottom: 25px; text-align: center; }
.header-index .subtitulo { font-size: 11px; letter-spacing: 3px; color: var(--texto-secundario); font-weight: 600; text-transform: uppercase; display: block; }
.header-index h1 { font-size: 34px; font-weight: 300; letter-spacing: 2px; color: var(--texto-titulos); margin-top: 5px; }

.menu-btn {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; padding: 16px; margin-bottom: 12px;
    background: var(--bg-body); border: 1px solid var(--border-subbox);
    border-radius: 12px; font-size: 16px; font-weight: 700;
    color: var(--texto-titulos); text-decoration: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03); transition: all 0.2s;
}


/* ==========================================================================
   ARREGLO DEFINITIVO BOTONES INDEX (Modo Oscuro y Movimiento)
   ========================================================================== */

/* 1. Botones quietos: anulamos cualquier efecto de salto o encogimiento */
.main-index-card .menu-btn,
.menu-btn {
    transform: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
}
.main-index-card .menu-btn:hover,
.menu-btn:hover {
    transform: none !important; 
}

/* Los colores del menú en modo oscuro se definen en las sobreescrituras
   específicas del index al final de la hoja. Se elimina aquí una lista de
   selectores incompleta que no tenía bloque de declaraciones. */

/* 4. Botón Gestión (Maestro) con su borde punteado clásico */
html.dark-mode .main-index-card .btn-gestion,
body.dark-mode .main-index-card .btn-gestion {
    background-color: transparent !important;
    color: #cbd5e1 !important;
    border: 1px dashed rgba(255, 255, 255, 0.3) !important;
}
html.dark-mode .main-index-card .btn-gestion:hover,
body.dark-mode .main-index-card .btn-gestion:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
}


.menu-btn:hover { transform: translateY(-2px); background: var(--bg-subbox); }
.menu-btn-primary { background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: none; }
.menu-btn-primary:hover { background: var(--bg-btn-primary-hover); }
.menu-btn svg { width: 22px; height: 22px; fill: currentColor; }

.logout-link { display: inline-block; margin-top: 15px; font-size: 13px; color: var(--texto-secundario); text-decoration: none; font-weight: 600; padding: 6px 12px; border: 1px dashed var(--border-subbox); border-radius: 6px; }
.logout-link:hover { color: var(--texto-titulos); background: var(--bg-subbox); }

.input-login, .input-elegante-modal { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid var(--border-subbox); border-radius: 10px; font-size: 14px; background: var(--bg-body); color: var(--texto-principal); outline: none; }

/* ==========================================================================
   2. PÁGINA GESTIÓN DE TERAPEUTAS
   ========================================================================== */
.header-panel { 
    display: flex; align-items: center; justify-content: space-between; 
    background: var(--bg-card); backdrop-filter: blur(10px); 
    padding: 18px 22px; border-radius: 14px; 
    box-shadow: var(--shadow-card); border: 1px solid var(--border-card); 
    margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.titulo-seccion h1 { font-size: 22px; font-weight: 700; color: var(--texto-titulos); }
.titulo-seccion p { font-size: 13px; color: var(--texto-secundario); margin-top: 2px; }

.badge-maestro { background: var(--badge-energia-bg); color: var(--badge-energia-txt); border: 1px solid var(--badge-energia-border); padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }

.alerta-exito { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); padding: 12px; border-radius: 8px; margin-bottom: 20px; font-weight: 600; text-align: center; font-size: 14px; }
.alerta-error { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); padding: 12px; border-radius: 8px; margin-bottom: 20px; font-weight: 600; text-align: center; font-size: 14px; }

.terapeuta-card, .card-seccion { 
    background: var(--bg-card); backdrop-filter: blur(10px); 
    border-radius: 12px; padding: 18px 20px; 
    border: 1px solid var(--border-card); box-shadow: var(--shadow-card); 
    margin-bottom: 14px; 
}
.terapeuta-summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.terapeuta-summary strong { font-size: 16px; color: var(--texto-titulos); }
.terapeuta-details { display: none; margin-top: 16px; border-top: 1px solid var(--border-subbox); padding-top: 16px; }

.grid-stats-terapeuta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.stat-mini-box {
    background: rgba(255, 255, 255, 0.7);
    padding: 8px 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(235, 220, 204, 0.6);
}

.stat-mini-box span {
    font-size: 10px;
    font-weight: 700;
    color: #8c7d70;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.stat-mini-box strong {
    font-size: 15px;
    font-weight: 700;
    color: #2b231e;
    display: block;
}

.stat-mini-box small {
    font-size: 10px;
    color: #8c7d70;
    display: block;
}

.stat-mini-full {
    grid-column: span 4;
}


.grid-permisos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.check-item { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--texto-principal); }
.check-antidifusion { color: #ef4444; font-weight: 600; }
.check-bloquear-usuario { color: #ef4444; font-weight: 800; background: rgba(239,68,68,0.1); padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(239,68,68,0.3); }

.box-gestion-premium { background: var(--bg-subbox); border: 1px solid var(--border-subbox); border-radius: 10px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.box-gestion-premium.is-premium { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); }
.input-date-premium { padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border-subbox); font-size: 13px; background: var(--bg-body); color: var(--texto-titulos); outline: none; }
.btn-retirar-premium { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }

.input-aviso-txt, .textarea-aviso-txt { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-subbox); background: var(--bg-body); color: var(--texto-titulos); outline: none; font-size: 14px; }
.box-aviso-activo { background: var(--bg-subbox); border: 1px solid var(--border-subbox); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.box-aviso-activo.aviso-completado { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); }

/* ==========================================================================
   3. PÁGINA HISTORIAL DE PACIENTES
   ========================================================================== */
#listaPacientes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 15px; margin-bottom: 30px; }


.client-card { background: var(--bg-card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-card); border: 1px solid var(--border-card); display: flex; flex-direction: column; height: 100%; }
.client-card.pendiente { border-left: 4px solid #f29900; }
.badge-pendiente { display: inline-block; background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 6px; margin-bottom: 6px; align-self: flex-start; }
.client-name { font-size: 18px; font-weight: 600; color: var(--texto-titulos); margin-bottom: 6px; }
.client-info-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; font-size: 14px; color: var(--texto-secundario); border-top: 1px solid var(--border-subbox); padding-top: 10px; margin-top: auto; }

.client-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-icono-accion { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-btn-secondary); border: none; display: inline-flex; align-items: center; justify-content: center; color: var(--texto-principal); cursor: pointer; text-decoration: none; }
.btn-icono-accion.btn-descartar { background: rgba(229, 62, 62, 0.2); color: #ef4444; }
.btn-link-testaje { color: var(--texto-btn-primary); text-decoration: none; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 3px; padding: 6px 12px; background: var(--bg-btn-primary); border-radius: 8px; }
.btn-link-testaje.reanudar { background: #fef3c7; color: #92400e; }

/* ==========================================================================
   4. PÁGINA DOCUMENTACIÓN (PDFs)
   ========================================================================== */
.search-box-docs { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; }
#inputBuscadorDocs { flex: 1; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border-card); background: var(--bg-card); color: var(--texto-titulos); font-size: 15px; box-shadow: var(--shadow-card); outline: none; }
.btn-upload-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--bg-btn-primary); color: var(--texto-btn-primary); display: flex; align-items: center; justify-content: center; font-size: 20px; border: none; cursor: pointer; box-shadow: var(--shadow-card); }
.btn-upload-bloqueado { background: var(--bg-subbox); color: var(--texto-secundario); cursor: not-allowed; }

.lista-documentos { display: flex; flex-direction: column; gap: 10px; }
.doc-item { background: var(--bg-subbox); border: 1px solid var(--border-subbox); border-radius: 10px; padding: 12px 16px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.doc-item.pinned { border-left: 4px solid var(--ciclo-border); background: var(--bg-card); }
.doc-nombre { color: var(--texto-titulos); text-decoration: none; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.doc-acciones { display: flex; gap: 6px; }

/* ==========================================================================
   5. COMPONENTES COMUNES, BOTONES Y MODALES GLOBALES
   ========================================================================== */
.header-historial { 
    display: flex; align-items: center; margin-bottom: 16px; background: var(--bg-card); backdrop-filter: blur(12px); 
    padding: 14px 18px; border-radius: 12px; box-shadow: var(--shadow-card); border: 1px solid var(--border-card); 
}
.paciente-info h1 { font-size: 20px; font-weight: 700; color: var(--texto-titulos); margin-bottom: 2px; }
.paciente-info p { font-size: 13px; color: var(--texto-secundario); }

.btn-volver { 
    background: var(--bg-btn-primary); color: var(--texto-btn-primary); 
    padding: 8px 14px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 600; 
    margin-right: 14px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; 
}
.btn-volver:hover { background: var(--bg-btn-primary-hover); }

.btn-tema-toggle {
    background: var(--bg-btn-secondary); color: var(--texto-btn-secondary); border: 1px solid var(--border-card);
    border-radius: 10px; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; cursor: pointer; box-shadow: var(--shadow-card);
}
.btn-tema-toggle:hover { background: var(--bg-btn-secondary-hover); }

.btn-guardar-item { 
    background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: none; padding: 8px 18px; 
    border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; 
}
.btn-guardar-item:hover { background: var(--bg-btn-primary-hover); }

/* Buscador genérico de historial / chat */
.tools-box { display: flex; flex-direction: row; gap: 10px; margin-bottom: 18px; align-items: center; }
.search-bar { flex: 2; display: flex; align-items: center; background: var(--bg-card); backdrop-filter: blur(10px); border-radius: 10px; padding: 8px 14px; box-shadow: var(--shadow-card); border: 1px solid var(--border-card); }
.search-bar input { border: none; outline: none; width: 100%; font-size: 14px; background: transparent; color: var(--texto-principal); }
.search-bar input::placeholder { color: var(--texto-secundario); }
.sort-select { flex: 1; padding: 9px 12px; font-size: 13px; font-weight: 500; border-radius: 10px; border: 1px solid var(--border-card); background: var(--bg-card); color: var(--texto-principal); outline: none; cursor: pointer; }

/* Modales Popups para toda la web */
.modal-overlay { 
    display: none; position: fixed !important; top: 0 !important; left: 0 !important; 
    width: 100vw !important; height: 100vh !important; background: rgba(0,0,0,0.65); 
    backdrop-filter: blur(5px); justify-content: center; align-items: center; padding: 20px; z-index: 100000 !important; 
}
.modal-content, .modal-box { 
    background: var(--bg-card); border-radius: 16px; width: 100%; max-width: 440px; 
    padding: 24px; text-align: left; border: 1px solid var(--border-card); 
    box-shadow: var(--shadow-card); color: var(--texto-principal); margin: auto; 
}
.modal-content h3, .modal-box-header h3 { margin-bottom: 14px; font-size: 18px; font-weight: 700; color: var(--texto-titulos); }
.modal-buttons { display: flex; gap: 10px; margin-top: 14px; }
.btn-cancelar { flex: 1; padding: 10px 14px; border: 1px solid var(--border-card); border-radius: 8px; font-size: 13.5px; cursor: pointer; font-weight: 700; background: var(--bg-btn-secondary); color: var(--texto-btn-secondary); }
.btn-guardar { flex: 1; padding: 10px 14px; border: none; border-radius: 8px; font-size: 13.5px; cursor: pointer; font-weight: 700; background: var(--bg-btn-primary); color: var(--texto-btn-primary); }

.modal-input-search { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-subbox); outline: none; margin-bottom: 12px; font-size: 13.5px; background: var(--bg-subbox); color: var(--texto-titulos); }
.modal-lista-terapeutas { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.item-ter-modal { padding: 10px 12px; border-radius: 8px; background: var(--bg-subbox); border: 1px solid var(--border-subbox); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--texto-principal); }
.item-ter-modal:hover { border-color: var(--border-card); }

/* ==========================================================================
   RESTO DE ESTILOS EXISTENTES PARA TESTER E HISTORIAL (No tocar)
   ========================================================================== */
.btn-importar { background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: none; padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow-card); white-space: nowrap; }

.stats-box { display: flex; gap: 10px; background: var(--bg-card); backdrop-filter: blur(10px); padding: 12px; border-radius: 12px; box-shadow: var(--shadow-card); border: 1px solid var(--border-card); margin-bottom: 16px; }
.stat-item { flex: 1; text-align: center; padding: 8px; background: var(--bg-subbox); border-radius: 8px; border: 1px solid var(--border-subbox); }
.stat-item strong { display: block; color: var(--texto-secundario); font-size: 10px; text-transform: uppercase; margin-bottom: 2px; }
.stat-valor { font-size: 15px; font-weight: 700; color: var(--texto-titulos); }

.sesion-card { background: var(--bg-card); backdrop-filter: blur(10px); border-radius: 12px; padding: 14px 18px; box-shadow: var(--shadow-card); border: 1px solid var(--border-card); display: flex; flex-direction: column; }
.sesion-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--texto-titulos); cursor: pointer; user-select: none; }
.badge-energia { background: var(--badge-energia-bg); color: var(--badge-energia-txt); border: 1px solid var(--badge-energia-border); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge-energia.low { background: rgba(229, 62, 62, 0.15); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.35); }
.toggle-icon { background: var(--bg-btn-secondary); color: var(--texto-secundario); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; margin-left: 8px; }

.sesion-body { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border-subbox); }
.permisos-box { background: var(--bg-subbox); border: 1px solid var(--border-subbox); border-radius: 8px; padding: 10px; margin-bottom: 12px; font-size: 12px; color: var(--texto-secundario); line-height: 1.5; }
.info-row { margin-bottom: 5px; font-size: 13px; line-height: 1.4; color: var(--texto-principal); }
.info-row strong { color: var(--texto-titulos); }

.ciclo-box { background: var(--ciclo-bg); border-left: 4px solid var(--ciclo-border); padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; border-right: 1px solid var(--border-subbox); border-top: 1px solid var(--border-subbox); border-bottom: 1px solid var(--border-subbox); }
.ciclo-titulo { font-size: 10px; font-weight: 700; color: var(--texto-secundario); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; }

.obs-form { margin-top: auto; border-top: 1px solid var(--border-subbox); padding-top: 12px; }
.obs-textarea { width: 100%; border: 1px solid var(--border-subbox); border-radius: 8px; padding: 8px 10px; font-size: 13px; min-height: 60px; background: var(--bg-subbox); color: var(--texto-principal); outline: none; margin-top: 4px; }
.obs-textarea:focus { border-color: var(--texto-secundario); }

.btn-acciones-inferior { display: flex; gap: 8px; margin-top: 8px; }
.btn-guardar-obs { background: var(--bg-btn-secondary); color: var(--texto-btn-secondary); border: 1px solid var(--border-card); padding: 8px; border-radius: 6px; font-weight: 700; font-size: 12px; cursor: pointer; flex: 1; }
.btn-guardar-obs:hover { background: var(--bg-btn-secondary-hover); }
.btn-accion-mini { padding: 8px; border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; flex: 1; border: none; }
.btn-borrar { background: rgba(229, 62, 62, 0.2); color: #ef4444; }
.btn-exportar { background: var(--bg-btn-secondary); color: var(--texto-btn-secondary); }

footer { width: 100%; padding: 16px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: relative; z-index: 10; margin-top: auto; }
footer p { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--texto-secundario); margin: 0; }


.paciente-card-item { display: flex !important; flex-direction: row !important; justify-content: space-between !important; align-items: center !important; gap: 12px; background: var(--bg-card); border: 1px solid var(--border-card); box-shadow: var(--shadow-card); border-radius: 12px; padding: 14px 18px; }
.paciente-card-item .btn-volver { margin-right: 0 !important; background: var(--bg-btn-secondary) !important; color: var(--texto-btn-secondary) !important; padding: 8px 14px !important; font-size: 13px !important; border-radius: 8px !important; }
.paciente-card-item .btn-volver:hover { background: var(--bg-btn-secondary-hover) !important; }

/* ==========================================================================
   ESTILOS DEL MÓDULO DE CHAT PRIVADO
   ========================================================================== */
.chat-layout { display: flex; width: 100%; background: var(--bg-card); backdrop-filter: blur(12px); border-radius: 14px; border: 1px solid var(--border-card); box-shadow: var(--shadow-card); overflow: hidden; height: 72vh; min-height: 520px; margin-bottom: 25px; }
.chat-sidebar { width: 300px; min-width: 280px; border-right: 1px solid var(--border-card); background: var(--bg-subbox); display: flex; flex-direction: column; height: 100%; }
.sidebar-header { padding: 12px 16px; border-bottom: 1px solid var(--border-card); display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); }
.btn-nuevo-chat { background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: 1px solid var(--border-card); padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.lista-contactos { overflow-y: auto; flex: 1; }
.contacto-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; cursor: pointer; text-decoration: none; color: var(--texto-principal); border-bottom: 1px solid var(--border-subbox); transition: background 0.15s; }
.contacto-item:hover { background: rgba(255, 255, 255, 0.04); }
.contacto-item.active { background: var(--bg-card); border-left: 4px solid var(--ciclo-border); }
.contacto-info { flex: 1; overflow: hidden; padding-right: 8px; }
.contacto-nombre { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--texto-titulos); }
.contacto-nombre.unread { font-weight: 800; }
.contacto-preview { font-size: 11.5px; color: var(--texto-secundario); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.contacto-preview.unread { font-weight: 700; color: var(--texto-principal); }
.contacto-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.contacto-hora { font-size: 10px; color: var(--texto-secundario); }
.badge-leidos { background: #b91c1c; color: #fff; font-size: 10.5px; font-weight: 800; min-width: 19px; height: 19px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; box-shadow: 0 2px 5px rgba(185, 28, 28, 0.4); }
.chat-vacio-aviso { padding: 26px 16px; text-align: center; color: var(--texto-secundario); font-size: 13px; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-body); height: 100%; overflow: hidden; }
.chat-header-user { padding: 12px 18px; background: var(--bg-card); border-bottom: 1px solid var(--border-card); font-weight: 700; color: var(--texto-titulos); display: flex; justify-content: space-between; align-items: center; }
.chat-online-badge { font-size: 11px; color: #10b981; font-weight: 600; margin-left: 8px; }
.btn-borrar-conversacion { background: none; border: 1px solid rgba(239, 68, 68, 0.4); color: #ef4444; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; }
.mensajes-contenedor { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-cargando { text-align: center; color: var(--texto-secundario); font-size: 13px; margin-top: 20px; }
.burbuja { max-width: 72%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; word-break: break-word; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04); position: relative; }
.burbuja.propia { align-self: flex-end; background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: 1px solid var(--border-card); border-bottom-right-radius: 2px; }
.burbuja.ajena { align-self: flex-start; background: var(--bg-card); color: var(--texto-principal); border: 1px solid var(--border-card); border-bottom-left-radius: 2px; }
.burbuja-footer { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 9.5px; opacity: 0.7; margin-top: 4px; }
.btn-edit-lapiz { background: none; border: none; cursor: pointer; font-size: 11px; padding: 0 2px; color: inherit; }
.img-adjunta { max-width: 250px; max-height: 200px; border-radius: 8px; display: block; margin-top: 4px; cursor: pointer; }
.chat-input-bar { padding: 10px 16px; background: var(--bg-card); border-top: 1px solid var(--border-card); display: flex; gap: 8px; align-items: center; position: relative; }
.chat-input-bar input[type="text"] { flex: 1; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border-subbox); outline: none; font-size: 14px; background: var(--bg-subbox); color: var(--texto-titulos); }
.btn-clip { background: var(--bg-subbox); color: var(--texto-titulos); border: 1px solid var(--border-subbox); width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; }
.btn-enviar { background: var(--bg-btn-primary); color: var(--texto-btn-primary); border: 1px solid var(--border-card); padding: 10px 18px; border-radius: 8px; font-weight: 700; cursor: pointer; }
#previewAdjunto { position: absolute; top: -32px; left: 16px; background: var(--bg-card); color: var(--texto-titulos); border: 1px solid var(--border-card); padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; display: none; align-items: center; gap: 6px; }
#previewAdjunto button { border: none; background: none; cursor: pointer; font-weight: 700; color: inherit; }
.chat-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--texto-secundario); padding: 40px; text-align: center; }
.chat-empty-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--bg-subbox); border: 1px solid var(--border-subbox); display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 16px; }
.chat-empty-state h3 { font-size: 18px; font-weight: 700; color: var(--texto-titulos); margin-bottom: 6px; }
.chat-empty-state p { font-size: 13.5px; max-width: 340px; line-height: 1.5; }

/* ==========================================================================
   SOBREESCRITURAS FINALES (Ancho y Cabecera)
   ========================================================================== */

/* Contenedor del banner superior */
.header-principal {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-card) !important;
    box-shadow: var(--shadow-card) !important;
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 24px;
    position: relative;
    text-align: center;
    display: block;
}

/* Estilos de los textos y botones del banner */
.header-principal .btn-volver-header {
    position: absolute; 
    left: 16px; 
    top: 50%; 
    transform: translateY(-50%); 
    width: 44px; 
    height: 44px; 
    border-radius: 10px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    background: var(--bg-btn-secondary);
    color: var(--texto-btn-secondary);
    text-decoration: none;
    border: 1px solid var(--border-card);
}

.header-principal .btn-volver-header:hover {
    background: var(--bg-btn-secondary-hover);
}

.header-principal .header-titulos .subtitulo {
    font-size: 11px; 
    letter-spacing: 3px; 
    text-transform: uppercase; 
    font-weight: 600; 
    display: block;
    color: var(--texto-secundario);
}

.header-principal .header-titulos h1 {
    font-size: 32px; 
    font-weight: 300; 
    letter-spacing: 2px; 
    line-height: 1.1; 
    margin: 2px 0;
    color: var(--texto-titulos);
}

.header-principal .header-titulos h1 .bold {
    font-weight: 800;
}

.header-principal .header-titulos .seccion {
    font-size: 13px; 
    font-weight: 700; 
    letter-spacing: 0.5px; 
    display: block; 
    text-transform: uppercase;
    color: var(--texto-principal);
}

.header-principal .header-opciones {
    position: absolute; 
    right: 16px; 
    top: 50%; 
    transform: translateY(-50%); 
    display: flex; 
    align-items: center; 
    gap: 8px;
}

.cabecera-axioma {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
    padding: 18px 20px;
    border-radius: 14px;
    
    /* Aquí está el fondo y los bordes del contenedor: */
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-card);
}


.cabecera-axioma {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--border-card) !important;
    box-shadow: var(--shadow-card) !important;
    border-radius: 14px !important;
    padding: 18px 20px !important;
    margin-bottom: 24px !important;
    position: relative !important;
    min-height: 85px !important; /* Asegura altura mínima */
}

/* Títulos centrales */
.header-titulos {
    text-align: center;
}

.cabecera-axioma .header-titulos .subtitulo {
    font-size: 11px; 
    letter-spacing: 3px; 
    text-transform: uppercase; 
    font-weight: 600; 
    display: block;
    color: var(--texto-secundario);
}

.cabecera-axioma .header-titulos h1 {
    font-size: 32px; 
    font-weight: 300; 
    letter-spacing: 2px; 
    line-height: 1.1; 
    margin: 2px 0;
    color: var(--texto-titulos);
}

.cabecera-axioma .header-titulos h1 .bold {
    font-weight: 800;
}

.cabecera-axioma .header-titulos .seccion {
    font-size: 13px; 
    font-weight: 700; 
    letter-spacing: 0.5px; 
    display: block; 
    text-transform: uppercase;
    color: var(--texto-principal);
}

/* Botón Home a la izquierda */
.cabecera-axioma .btn-volver-header {
    position: absolute; 
    left: 20px; 
    top: 50%; 
    transform: translateY(-50%); 
    width: 44px; 
    height: 44px; 
    border-radius: 10px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    background: var(--bg-btn-secondary);
    color: var(--texto-btn-secondary);
    text-decoration: none;
    border: 1px solid var(--border-card);
}

.cabecera-axioma .btn-volver-header:hover {
    background: var(--bg-btn-secondary-hover);
}

/* Opciones a la derecha */
.cabecera-axioma .header-opciones {
    position: absolute; 
    right: 20px; 
    top: 50%; 
    transform: translateY(-50%); 
    display: flex; 
    align-items: center; 
    gap: 8px;
}

/* ==========================================================================
   SOBREESCRITURAS FINALES: INDEX (Menú Principal)
   ========================================================================== */


/* Centrado y apilado en la pantalla */
.index-body {
    display: flex;
    flex-direction: column; /* ← Esto apila la tarjeta y el logo verticalmente */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 15px; /* Reducido un poco para móviles */
}

.index-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column; /* Asegura que el contenido interno siga apilado */
    align-items: center;
}

.main-index-card {
    width: 100%;
    max-width: 380px !important; 
    background: var(--bg-card) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-card) !important;
    border-radius: 20px;
    padding: 24px 20px 16px 20px !important; /* ← Menos aire abajo (16px) */
    box-shadow: var(--shadow-card) !important;
    text-align: center;
}

/* Reducimos el espacio entre los botones del menú */
.main-index-card .menu-btn {
    margin-bottom: 8px; /* ← Antes estaba en 12px o 15px */
    padding: 14px; /* ← Botones un poco más finos (antes 16px) */
}

/* Tamaño del logo más pequeño */
.footer-index img {
    height: 50px !important; /* ← Logo más pequeño (antes 55px) */
    width: auto;
    display: block;
    object-fit: contain;
    margin: 0 auto;
}

.footer-index .enlace-logo {
    display: inline-block;
    margin-bottom: 8px;
}


.footer-index p {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--texto-secundario);
    margin: 0;
}

/* --- Magia del cambio de color del Logo --- */
/* Por defecto (Modo Claro), ocultamos el logo oscuro */
.logo-dark {
    display: none !important;
}

/* En Modo Oscuro, ocultamos el claro y mostramos el oscuro */
body.dark-mode .logo-light {
    display: none !important;
}

body.dark-mode .logo-dark {
    display: block !important;
}

/* Títulos del Index */
.main-index-card .header-index {
    margin-bottom: 25px;
}
.main-index-card .header-index h1 {
    font-size: 38px;
    font-weight: 300;
    letter-spacing: 2px;
    color: var(--texto-titulos);
    margin: 5px 0 0 0;
}
.main-index-card .header-index .bold {
    font-weight: 800;
}

/* Fila de Bienvenida y Botón Sol/Luna */
.bienvenida-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.bienvenida-box .saludo-texto {
    font-weight: 400;
    font-size: 16px;
    letter-spacing: 1px;
    color: var(--texto-principal);
    margin: 0;
}

.bienvenida-box .link-perfil {
    font-weight: 700;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
    transition: opacity 0.2s;
}
.bienvenida-box .link-perfil:hover {
    opacity: 0.7;
}

/* Ajustes del botón de tema en el index */
.btn-tema-toggle.mini {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
}
.btn-tema-toggle.mini.bloqueado {
    opacity: 0.85;
}

/* Alerta de perfil guardado */
.alerta-perfil {
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #137333;
    background: #e6f4ea;
    padding: 8px 14px;
    border-radius: 8px;
    display: inline-block;
}

/* Estilo específico para el botón de Gestión Maestro */
.btn-gestion {
    border: 1px dashed var(--border-subbox) !important;
    margin-top: 12px !important;
    background: transparent !important;
}
.btn-gestion:hover {
    background: var(--bg-subbox) !important;
    border-color: var(--texto-secundario) !important;
}

/* ==========================================================================
   HISTORIAL — MODO OSCURO (TONOS AZULADOS SLATE / SOMA ORIGINAL)
   ========================================================================== */

/* 1. Fondo de cápsula continuo (elimina huecos y transparencias hacia la pared) */
body.dark-mode .contenedor-general {
    background-color: rgba(22, 25, 32, 0.96) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
}

/* 2. Cabecera integrada sin caja flotante desalineada */
body.dark-mode header,
body.dark-mode .cabecera-axioma,
body.dark-mode .header-historial {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

body.dark-mode header h1,
body.dark-mode .header-historial h1,
body.dark-mode .paciente-info h1,
body.dark-mode .cabecera-axioma h1 {
    color: #f8fafc !important;
}

body.dark-mode header span,
body.dark-mode .header-historial span,
body.dark-mode .cabecera-axioma span {
    color: #94a3b8 !important;
}

/* 3. Cajas principales y estadísticas en gris azulado pizarra */
body.dark-mode .stats-box,
body.dark-mode .sesion-card {
    background: rgba(26, 29, 36, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3) !important;
    color: #e2e8f0 !important;
}

body.dark-mode .stat-item {
    background: rgba(30, 41, 59, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
}

body.dark-mode .stat-item strong {
    color: #94a3b8 !important;
}

body.dark-mode .stat-valor {
    color: #f8fafc !important;
}

/* 4. Cabeceras de sesión e insignias en azul */
body.dark-mode .sesion-header span {
    color: #f8fafc !important;
}

body.dark-mode .badge-energia {
    background: rgba(30, 41, 59, 0.9) !important;
    color: #93c5fd !important;
    border: 1px solid rgba(147, 197, 253, 0.25) !important;
}

body.dark-mode .duracion-pill {
    background: rgba(30, 41, 59, 0.6) !important;
    border: 1px dashed rgba(147, 197, 253, 0.25) !important;
    color: #93c5fd !important;
}

body.dark-mode .permisos-box {
    background: rgba(18, 19, 22, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    color: #cbd5e1 !important;
}

body.dark-mode .permisos-box strong {
    color: #f8fafc !important;
}

/* 5. Ciclos clínicos: línea y títulos en azul cielo (adiós al lila) */
body.dark-mode .ciclo-box {
    background: rgba(30, 41, 59, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-left: 4px solid #38bdf8 !important;
}

body.dark-mode .ciclo-titulo {
    color: #38bdf8 !important;
}

body.dark-mode .sintoma-titulo {
    color: #f8fafc !important;
}

body.dark-mode .info-row {
    color: #cbd5e1 !important;
}

body.dark-mode .info-row strong {
    color: #f8fafc !important;
}

body.dark-mode .cunning-texto {
    color: #cbd5e1 !important;
    border-top: 1px dashed rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .cunning-texto strong {
    color: #f8fafc !important;
}

/* 6. Formulario de observaciones y botones */
body.dark-mode .obs-form strong {
    color: #e2e8f0 !important;
}

body.dark-mode .obs-textarea {
    background: rgba(18, 19, 22, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc !important;
}

body.dark-mode .btn-guardar-obs,
body.dark-mode .btn-exportar {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .btn-guardar-obs:hover,
body.dark-mode .btn-exportar:hover {
    background: #334155 !important;
}

/* ==========================================================================
   NUEVO CONTENEDOR ENCAPSULADO PARA VISTA INDIVIDUAL DE PACIENTE
   ========================================================================== */

.contenedor-paciente-individual {
    background: rgba(255, 255, 255, 0.5) !important; /* Blanco al 50% en claro */
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05) !important;
    width: 100%;
    margin-bottom: 30px;
}

/* Modo oscuro para el contenedor individual */
body.dark-mode .contenedor-paciente-individual {
    background: rgba(18, 19, 22, 0.5) !important; /* Negro al 50% en oscuro */
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

/* Quitar el margen inferior de la cabecera si está dentro de este contenedor */
.contenedor-paciente-individual .header-historial {
    margin-bottom: 20px !important;
}


/* Reducción general de márgenes en elementos internos para ganar finura */
.contenedor-general .cabecera-axioma,
.contenedor-general .header-historial {
    margin-bottom: 14px !important;
    padding: 14px 16px !important;
}

.contenedor-general .tools-box {
    margin-bottom: 14px !important;
}

.contenedor-general .stats-box {
    margin-bottom: 14px !important;
    padding: 10px !important;
}







/* ==========================================================================
   FORZADO ABSOLUTO: CÁPSULA (75% Transparencia, Blanco Puro y sin fondos extra)
   ========================================================================== */

/* 1. Quitamos cualquier fondo fantasma del contenedor exterior */
div.container {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* 2. La cápsula principal: 75% de opacidad y BLANCO PURO */
div.container .contenedor-general,
.contenedor-general {
    background-color: rgba(255, 255, 255, 0.75) !important; /* Más transparente y blanco limpio */
    backdrop-filter: none !important; 
    -webkit-backdrop-filter: none !important; 
    border: 1px solid rgba(255, 255, 255, 0.6) !important; 
    border-radius: 20px !important; 
    padding: 20px !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15) !important; 
    margin: 30px auto 40px auto !important; 
    max-width: 1000px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}


/* 4. ELIMINAR EL FONDO EXTRA DE AXIOMA EN TODOS LOS MODOS */
div.container .contenedor-general .cabecera-axioma,
.contenedor-general .cabecera-axioma,
body.dark-mode div.container .contenedor-general .cabecera-axioma,
body.dark-mode .contenedor-general .cabecera-axioma,
body.dark-mode .cabecera-axioma {
    background-color: transparent !important;
    background: transparent !important; /* ¡Esto mata el recuadro del modo oscuro! */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* 5. Ajuste para móviles */


/* ==========================================================================
   ARREGLO: COLOR DE TARJETAS DE HISTORIAL EN MODO OSCURO (Neutro)
   ========================================================================== */
body.dark-mode .paciente-card-item {
    background-color: rgba(26, 29, 36, 0.95) !important; /* Gris oscuro neutro, igual que el buscador */
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .paciente-card-item:hover {
    background-color: rgba(35, 40, 48, 0.95) !important; /* Se ilumina un poco al pasar el ratón */
    border-color: rgba(255, 255, 255, 0.15) !important;
}

/* ==========================================================================
   ARREGLO: ETIQUETAS DE TERAPEUTA EN MODO OSCURO
   ========================================================================== */
body.dark-mode .paciente-card-item span[style*="background"],
body.dark-mode .paciente-card-item span[style*="background-color"] {
    background: rgba(30, 41, 59, 0.9) !important; /* Fondo gris azulado oscuro */
    color: #93c5fd !important; /* Texto azul claro legible */
    border-color: rgba(147, 197, 253, 0.2) !important; /* Borde sutil */
}


/* ==========================================================================
   ARREGLO DEFINITIVO: MÓDULO DE CHAT (Modos Claro y Oscuro)
   ========================================================================== */

/* 1. MODO OSCURO PARA EL CHAT */
body.dark-mode .chat-layout {
    background: rgba(26, 29, 36, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
}

body.dark-mode .chat-sidebar {
    background: rgba(18, 19, 22, 0.85) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .sidebar-header,
body.dark-mode .chat-header-user,
body.dark-mode .chat-input-bar {
    background: rgba(26, 29, 36, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #f8fafc !important;
}

body.dark-mode .chat-main {
    background: rgba(18, 19, 22, 0.5) !important;
}

body.dark-mode .contacto-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #e2e8f0 !important;
}

body.dark-mode .contacto-item:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}

body.dark-mode .contacto-item.active {
    background: rgba(51, 65, 85, 0.6) !important;
    border-left: 4px solid #38bdf8 !important;
}

body.dark-mode .contacto-nombre {
    color: #f8fafc !important;
}

body.dark-mode .contacto-preview {
    color: #94a3b8 !important;
}

body.dark-mode .chat-input-bar input[type="text"],
body.dark-mode .btn-clip {
    background: rgba(18, 19, 22, 0.8) !important;
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .burbuja.ajena {
    background: rgba(30, 41, 59, 0.9) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}


/* 2. MODO CLARO PARA EL CHAT (Asegurando limpieza y contraste) */
body:not(.dark-mode) .chat-layout {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-card) !important;
}

body:not(.dark-mode) .chat-sidebar {
    background: var(--bg-subbox) !important;
    border-right: 1px solid var(--border-card) !important;
}

body:not(.dark-mode) .sidebar-header,
body:not(.dark-mode) .chat-header-user,
body:not(.dark-mode) .chat-input-bar {
    background: var(--bg-card) !important;
    color: var(--texto-titulos) !important;
}

body:not(.dark-mode) .chat-main {
    background: var(--bg-body) !important;
}



/* =====================================================================
   RESPONSIVE — MÓVIL Y TABLET
   Reglas @media agrupadas al final para facilitar su mantenimiento.
   ===================================================================== */

@media (max-width: 768px) {
    .contenedor-general {
        padding-left: 12px !important;
        padding-right: 12px !important;
        border-radius: 0 0 16px 16px !important;
    }

     body.index-body,
    body.login-body {
        justify-content: flex-start !important; /* Alinea los elementos desde arriba */
        padding-top: 25px !important; /* Margen superior elegante para que no pegue al navegador */
        min-height: 100vh;
    }
    
    .login-wrapper-main,
    .main-index-card,
    .login-card {
        margin-top: 0 !important;
        margin-bottom: 20px !important;
    }
    
    /* Arreglo: Evita que los selects de fecha de Maestro se amontonen */
    .cabecera-axioma, 
    .header-principal {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 55px 15px 15px 15px !important; /* Espacio arriba para el botón home */
        position: relative !important;
        min-height: auto !important;
    }
    
   .header-opciones {
        position: relative !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        width: auto !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important;
        margin-top: 10px !important;
    }

    /* Botón Home absoluto arriba a la izquierda en móvil */
    .cabecera-axioma .btn-volver-header,
    .header-principal .btn-volver-header {
        position: absolute !important;
        top: 12px !important;
        left: 12px !important;
        transform: none !important;
    }
    
    .header-opciones form {
        display: flex !important;
        flex-direction: column !important; /* Apila mes y año */
        width: 100% !important;
        gap: 8px !important;
    }
    
    /* Forzar que el botón de la luna (y otros botones de opciones) conserven su tamaño compacto y cuadrado */
    .btn-tema-toggle {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        max-width: 38px !important;
        flex: 0 0 38px !important;
    }
}

@media (min-width: 600px) { #listaPacientes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (min-width: 768px) {
    .sesiones-grid {
        display: flex !important;
        flex-direction: column !important; /* Si deseas tarjetas completas en ancho o pasarlo a grid multi-columna, ajusta aquí */
        gap: 16px !important;
        width: 100% !important;
    }

    .sesion-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
    /* El historial y listados respiran unos milímetros por los lados */
    .contenedor-general, .container {
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
        border-radius: 0 0 16px 16px;
    }

    .chat-layout {
        display: block !important;
        position: relative;
        overflow: hidden;
    }
/* Por defecto en móvil, si hay chat activo, ocultamos la barra lateral y mostramos el chat (o viceversa) */
    .chat-sidebar {
        width: 100% !important;
        display: <?php echo ($contacto_activo > 0) ? 'none' : 'block'; ?>;
    }
    .chat-main {
        width: 100% !important;
        display: <?php echo ($contacto_activo > 0) ? 'flex' : 'none'; ?>;
    }

    .contenedor-general {
        margin-top: 0 !important;
        min-height: calc(100vh - 10px);
        border-radius: 0;
    }
    
    /* Organiza los botones de gestión y bloques en móvil para que no se pisen */
    .gestion-layout, .login-box {
        padding: 10px;
        box-sizing: border-box;
    }

    div.container .contenedor-general,
    .contenedor-general {
        margin: 15px auto 20px auto !important; 
        border-radius: 16px !important;
        padding: 16px 12px !important;
    }
}

/* Estilo unificado para botones y elementos bloqueados (Función VIP) */
.btn-bloqueado-vip, 
.btn-upload-bloqueado, 
.btn-tema-toggle.bloqueado {
    opacity: 0.5 !important;
    filter: grayscale(100%) !important;
    cursor: not-allowed !important;
    background-color: var(--bg-subbox) !important;
    border-color: var(--border-subbox) !important;
    pointer-events: auto !important; /* Permite hacer clic para abrir el modal publicitario */
}

.btn-bloqueado-vip:hover, 
.btn-upload-bloqueado:hover, 
.btn-tema-toggle.bloqueado:hover {
    opacity: 0.7 !important;
    filter: grayscale(80%) !important;
}

/* ==========================================================================
   ESTRUCTURA Y POSICIONAMIENTO RESPONSIVE (LOGIN Y MODALES)
   ========================================================================== */
html.login-html, body.login-body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body.login-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
    padding: 20px 15px;
}

.login-wrapper-main {
    width: 100%;
    max-width: 400px;
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.login-footer-area {
    width: 100%;
    text-align: center;
    padding: 10px 0;
    margin-top: auto;
}

.login-footer-area img {
    height: 75px !important;
    width: auto;
    display: block;
    margin: 0 auto;
}
/* Posicionamiento para que el modal comience arriba y permita scroll completo */
.modal-overlay-soma {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999999 !important;
    justify-content: center !important;
    align-items: flex-start !important; /* ← Cambiado de center a flex-start para que empiece arriba */
    overflow-y: auto !important; /* ← Habilita el desplazamiento en toda la capa */
    padding: 20px 12px !important;
    box-sizing: border-box;
}

.modal-box-soma {
    max-width: 440px;
    width: 100%;
    margin: 0 auto 30px auto !important; /* Margen superior a 0 para que pegue arriba y espacio abajo */
    box-sizing: border-box;
}

/* =====================================================================
   ALTURA DE LA VISTA PRINCIPAL
   La tarjeta es el único elemento que ocupa el espacio entre los márgenes;
   el contenido largo se desplaza dentro de ella, no en la página.
   ===================================================================== */
html {
    min-height: 100%;
    height: auto;
}

body {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Las cuatro páginas usan este wrapper directo del body. */
body > .container {
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

body > .container > .contenedor-general {
    height: calc(100% - 30px) !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 15px auto !important;
    box-sizing: border-box !important;
    overflow-x: hidden;
    overflow-y: auto;
}

@media (max-width: 767px) {
    body > .container > .contenedor-general {
        height: calc(100% - 16px) !important;
        margin: 8px auto !important;
    }
}

/* La página crece con el contenido y deja espacio para el footer */
body > .container {
    height: auto !important;
    min-height: 0 !important;
    flex: 1 0 auto !important;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
}

body > .container > .contenedor-general {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 1 0 auto !important;
    overflow: visible !important;
}

/* ==========================================================================
   ARREGLO MÓVIL: HERRAMIENTAS Y FILTROS EN HISTORIAL (APILADOS SIN ESTIRAR)
   ========================================================================== */
@media (max-width: 768px) {
    .tools-box {
        display: flex !important;
        flex-direction: column !important; /* Apila todos los elementos en vertical */
        align-items: stretch !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .tools-box .search-bar,
    .tools-box .sort-select,
    .tools-box .btn-importar {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ==========================================================================
   CORRECCIÓN DE INPUTS Y TEXTOS EN MODO OSCURO
   ========================================================================== */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .input-elegante,
body.dark-mode .input-login,
body.dark-mode .modal-input-search,
body.dark-mode .input-aviso-txt,
body.dark-mode .textarea-aviso-txt,
body.dark-mode .sort-select {
    background-color: rgba(18, 19, 22, 0.9) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #94a3b8 !important;
}

/* Tarjetas principales con relieve tridimensional y sombra suave */
.login-card, .main-index-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    /* Sombra profunda y realista combinada con un halo de luz sutil en el borde */
    box-shadow: 0 20px 40px -15px rgba(43, 35, 30, 0.35), 
                0 0 15px rgba(0, 0, 0, 0.08) !important;
}

/* Refuerzo específico para el modo oscuro */
body.dark-mode .login-card, 
body.dark-mode .main-index-card {
    background-color: rgba(26, 29, 36, 0.95) !important;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.8), 
                0 0 20px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* ==========================================================================
   RENDERIZADO INSTANTÁNEO DESDE EL <HEAD> (SIN DESTELLO BLANCO NI NEGRO)
   ========================================================================== */
html:not(.dark-mode),
html:not(.dark-mode) body {
    background-color: #ece8e1 !important;
    background-image: url('bg_gris.jpeg') !important;
    background-size: cover !important;
    background-position: center !important;
    background-attachment: fixed !important;
}

html.dark-mode div.container .contenedor-general,
html.dark-mode .contenedor-general,
body.dark-mode div.container .contenedor-general,
body.dark-mode .contenedor-general {
    background-color: rgba(22, 25, 32, 0.96) !important;
    border: 1px solid rgba(148, 163, 184, 0.12) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
}

html.dark-mode .login-card,
html.dark-mode .main-index-card,
html.dark-mode .stats-box,
html.dark-mode .sesion-card,
html.dark-mode .paciente-card-item,
html.dark-mode .chat-layout,
body.dark-mode .login-card,
body.dark-mode .main-index-card,
body.dark-mode .stats-box,
body.dark-mode .sesion-card,
body.dark-mode .paciente-card-item,
body.dark-mode .chat-layout {
    background-color: rgba(26, 29, 36, 0.95) !important;
    border: 1px solid rgba(148, 163, 184, 0.12) !important;
    color: #e2e8f0 !important;
}

html.dark-mode .cabecera-axioma,
html.dark-mode .header-historial,
html.dark-mode header.header-index,
body.dark-mode .cabecera-axioma,
body.dark-mode .header-historial,
body.dark-mode header.header-index {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

html.dark-mode .logo-light,
body.dark-mode .logo-light { display: none !important; }
html.dark-mode .logo-dark,
body.dark-mode .logo-dark { display: block !important; }

/* --- NUEVO DISEÑO COMPACTO PARA HISTORIAL DE PACIENTES --- */

/* --- TARJETA PACIENTE COMPACTA Y RECOGIDA --- */
.grid-pacientes-compacto {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)); /* Pasamos a 3 columnas para que se acorten */
    gap: 12px;
    margin-top: 10px;
}
@media (max-width: 1100px) {
    .grid-pacientes-compacto {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 columnas en tablets */
    }
}
@media (max-width: 650px) {
    .grid-pacientes-compacto {
        grid-template-columns: 1fr; /* 1 columna en móvil */
    }
}

.card-paciente-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 10px 14px; /* Un poco más compactas en altura */
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    color: var(--texto-principal);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
}
.card-paciente-pill:hover {
    transform: translateY(-2px);
    border-color: #0284c7;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
    background: var(--bg-subbox);
}

.pill-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.pill-nombre {
    font-size: 14px;
    font-weight: 700;
    color: var(--texto-titulos);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--texto-secundario);
}

.pill-fecha strong {
    color: var(--texto-principal);
    font-weight: 600;
}

.pill-terapeuta {
    background: rgba(2, 132, 199, 0.08);
    color: #0284c7;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}
body.dark-mode .pill-terapeuta {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
}

.pill-arrow {
    font-size: 15px;
    font-weight: 700;
    color: var(--texto-secundario);
    margin-left: 8px;
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
}
.card-paciente-pill:hover .pill-arrow {
    transform: translateX(3px);
    color: #0284c7;
}


/* Panel de filtros superior unificado */
.panel-filtros-moderno {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-subbox);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
body.dark-mode .panel-filtros-moderno {
    background: rgba(18, 19, 22, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.barra-alfabeto-clean {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: space-between;
    overflow-x: auto;
    padding: 4px 0 2px 0;
    scrollbar-width: none;
}
.barra-alfabeto-clean::-webkit-scrollbar {
    display: none;
}
.btn-letra-clean {
    flex: 1;
    min-width: 26px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--texto-secundario);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
    white-space: nowrap;
}
.btn-letra-clean:hover {
    background: var(--bg-subbox);
    color: var(--texto-titulos);
}
.btn-letra-clean.active {
    background: var(--bg-btn-primary) !important;
    color: var(--texto-btn-primary) !important;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
body.dark-mode .btn-letra-clean {
    color: #94a3b8;
}
body.dark-mode .btn-letra-clean:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}
body.dark-mode .btn-letra-clean.active {
    background: #38bdf8 !important;
    color: #0f172a !important;
}

/* ==========================================================================
   ESTILO GLOBAL Y ELEGANTE PARA ICONOS SUPERIORES (CASITA Y LUNA/SOL)
   ========================================================================== */
.cabecera-axioma .btn-volver-header,
.cabecera-axioma .header-opciones {
    position: absolute !important;
    top: 14px !important;
    transform: none !important;
}

.cabecera-axioma .btn-volver-header {
    left: 16px !important;
}

.cabecera-axioma .header-opciones {
    right: 16px !important;
}

.cabecera-axioma .btn-volver-header,
.btn-tema-toggle {
    width: 36px !important;
    height: 32px !important;
    border-radius: 8px !important;
    background: rgba(61, 53, 46, 0.06) !important;
    border: 1px solid rgba(61, 53, 46, 0.12) !important;
    color: var(--texto-titulos, #1f1a16) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.15s ease !important;
    box-shadow: none !important;
}

.cabecera-axioma .btn-volver-header:hover,
.btn-tema-toggle:hover {
    background: var(--bg-btn-primary, #3d352e) !important;
    color: var(--texto-btn-primary, #f7f4ee) !important;
    border-color: transparent !important;
    transform: translateY(-1px);
}

/* Modo oscuro global para los iconos superiores */
body.dark-mode .cabecera-axioma .btn-volver-header,
body.dark-mode .btn-tema-toggle {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f8fafc !important;
}

body.dark-mode .cabecera-axioma .btn-volver-header:hover,
body.dark-mode .btn-tema-toggle:hover {
    background: #38bdf8 !important;
    color: #0f172a !important;
    border-color: transparent !important;
}

.cabecera-axioma .btn-volver-header svg,
.btn-tema-toggle svg {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
    margin: auto !important;
}

/* ==========================================================================
   DISEÑO MODERNO Y ELEGANTE PARA DOCUMENTACIÓN
   ========================================================================== */

/* 1. Tarjetas de documentos unificadas al estilo "píldora" clínica */
.lista-documentos {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.doc-item {
    background: var(--bg-card, rgba(247, 244, 238, 0.95)) !important;
    border: 1px solid var(--border-card, rgba(216, 209, 198, 0.85)) !important;
    border-radius: 12px !important;
    padding: 12px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02) !important;
    transition: all 0.15s ease !important;
}

.doc-item:hover {
    transform: translateY(-1px);
    border-color: #0284c7 !important;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08) !important;
    background: var(--bg-subbox, #e5ded4) !important;
}

.doc-item.pinned {
    border-left: 4px solid #38bdf8 !important;
}

/* 2. Nombre del documento limpio y legible */
.doc-nombre {
    color: var(--texto-titulos, #1f1a16) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.doc-nombre:hover {
    color: #0284c7 !important;
}

/* 3. Acciones de los documentos (botones minimalistas) */
.doc-acciones {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
}

.doc-acciones .btn-accion-mini {
    width: 30px !important;
    height: 30px !important;
    border-radius: 6px !important;
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    color: var(--texto-secundario, #7a7167) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
}

.doc-acciones .btn-accion-mini:hover {
    background: var(--bg-btn-primary, #3d352e) !important;
    color: var(--texto-btn-primary, #f7f4ee) !important;
    border-color: transparent !important;
}

/* 4. Modo Oscuro perfecto para Documentación */
body.dark-mode .doc-item {
    background: rgba(26, 29, 36, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .doc-item:hover {
    background: rgba(35, 40, 48, 0.95) !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

body.dark-mode .doc-nombre {
    color: #f8fafc !important;
}

body.dark-mode .doc-nombre:hover {
    color: #38bdf8 !important;
}

body.dark-mode .doc-acciones .btn-accion-mini {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #94a3b8 !important;
}

body.dark-mode .doc-acciones .btn-accion-mini:hover {
    background: #38bdf8 !important;
    color: #0f172a !important;
}

/* ==========================================================================
   SINCRONIZACIÓN TOTAL HTML.DARK-MODE Y MODO CLARO (CERO FOGONAZOS)
   ========================================================================== */

/* 1. Forzar que las tarjetas de pacientes y textos obedezcan a html.dark-mode al instante */
html.dark-mode .card-paciente-pill,
body.dark-mode .card-paciente-pill,
html.dark-mode .paciente-card-item,
body.dark-mode .paciente-card-item {
    background: rgba(22, 27, 38, 0.96) !important;
    border: 1px solid rgba(148, 163, 184, 0.14) !important;
    color: #e2e8f0 !important;
}

html.dark-mode .pill-nombre,
body.dark-mode .pill-nombre {
    color: #f8fafc !important;
}

html.dark-mode .pill-meta,
body.dark-mode .pill-meta {
    color: #94a3b8 !important;
}

html.dark-mode .pill-fecha strong,
body.dark-mode .pill-fecha strong {
    color: #e2e8f0 !important;
}

html.dark-mode .pill-terapeuta,
body.dark-mode .pill-terapeuta {
    background: rgba(56, 189, 248, 0.14) !important;
    color: #38bdf8 !important;
}

html.dark-mode .panel-filtros-moderno,
body.dark-mode .panel-filtros-moderno {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(148, 163, 184, 0.1) !important;
}

html.dark-mode .search-bar,
body.dark-mode .search-bar,
html.dark-mode select.sort-select,
body.dark-mode select.sort-select,
html.dark-mode input[type="text"],
html.dark-mode input[type="number"],
html.dark-mode input[type="password"],
html.dark-mode select,
html.dark-mode textarea {
    background-color: rgba(15, 23, 42, 0.9) !important;
    color: #f8fafc !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
}

html.dark-mode .btn-letra-clean,
body.dark-mode .btn-letra-clean {
    color: #94a3b8 !important;
}

html.dark-mode .btn-letra-clean.active,
body.dark-mode .btn-letra-clean.active {
    background: #38bdf8 !important;
    color: #0f172a !important;
}

/* 2. Limpieza instantánea cuando se pasa a MODO CLARO (html:not(.dark-mode)) */
html:not(.dark-mode) .contenedor-general {
    background-color: rgba(255, 255, 255, 0.78) !important;
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12) !important;
}

html:not(.dark-mode) .card-paciente-pill,
html:not(.dark-mode) .paciente-card-item,
html:not(.dark-mode) .sesion-card,
html:not(.dark-mode) .stats-box,
html:not(.dark-mode) .main-index-card {
    background: rgba(247, 244, 238, 0.95) !important;
    border: 1px solid rgba(216, 209, 198, 0.85) !important;
    color: #332d27 !important;
}

html:not(.dark-mode) .pill-nombre { color: #1f1a16 !important; }
html:not(.dark-mode) .pill-meta { color: #7a7167 !important; }
html:not(.dark-mode) .pill-fecha strong { color: #332d27 !important; }
html:not(.dark-mode) .search-bar,
html:not(.dark-mode) .sort-select {
    background: rgba(247, 244, 238, 0.95) !important;
    color: #332d27 !important;
    border: 1px solid rgba(216, 209, 198, 0.85) !important;
}

/* ==========================================================================
   ARREGLO MODO OSCURO: INPUT PROGRAMA COLECTIVO LIBRE
   ========================================================================== */
body.dark-mode #inputProgColectivoLibre,
html.dark-mode #inputProgColectivoLibre {
    background-color: rgba(15, 23, 42, 0.9) !important;
    color: #f8fafc !important;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
}

body.dark-mode #inputProgColectivoLibre::placeholder,
html.dark-mode #inputProgColectivoLibre::placeholder {
    color: #94a3b8 !important;
}

/* ==========================================================================
   ARREGLO MODO OSCURO: CAJAS DE ENTRADA Y TEXTOS EN ORÍGENES
   ========================================================================== */
body.dark-mode div[id^="cajaInputOtro_"],
body.dark-mode div[id^="cajaInputEnergetico_"],
body.dark-mode div[id^="cajaSelectColectivo_"],
body.dark-mode .st-caja-programas-colectivos {
    background-color: rgba(26, 29, 36, 0.95) !important;
    border-color: rgba(148, 163, 184, 0.15) !important;
    color: #e2e8f0 !important;
}

body.dark-mode div[id^="cajaInputOtro_"] label,
body.dark-mode div[id^="cajaInputEnergetico_"] label,
body.dark-mode div[id^="cajaSelectColectivo_"] label,
body.dark-mode .st-caja-programas-colectivos label {
    color: #f8fafc !important;
}

/* Sesiones plegadas más compactas y elegantes */
.sesion-card {
    transition: all 0.2s ease;
}

.sesion-card:hover {
    border-color: rgba(67, 97, 238, 0.4) !important;
}

/* ==========================================================================
   ESTILO CLÁSICO DE SESIÓN (INSPIRADO EN LA APP SOMA ORIGINAL)
   ========================================================================== */
.titulo-ordinal-badge {
    background: rgba(61, 53, 46, 0.1);
    color: var(--texto-titulos);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

body.dark-mode .titulo-ordinal-badge,
html.dark-mode .titulo-ordinal-badge {
    background: rgba(56, 189, 248, 0.15) !important;
    color: #f8fafc !important;
}

.ficha-original-soma {
    margin-bottom: 14px;
}

.linea-original-soma {
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-subbox);
    font-size: 13.5px;
    color: var(--texto-principal);
}

.linea-original-soma strong {
    color: var(--texto-titulos);
    margin-right: 4px;
}

.bloque-sintomas-original {
    padding: 10px 4px 12px 4px;
    border-bottom: 2px dashed var(--border-card);
    margin-bottom: 14px;
    font-size: 13px;
}

.bloque-sintomas-original strong {
    display: block;
    margin-bottom: 6px;
    color: var(--texto-titulos);
}

.lista-sintomas-num {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--texto-principal);
    margin-bottom: 12px;
}

.nota-testaje-original {
    font-style: italic;
    font-size: 12.5px;
    color: var(--texto-principal);
    opacity: 0.9;
}

.sintoma-header-original {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--texto-titulos);
    margin: 14px 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tiempo-eliminacion-original {
    margin-top: 12px;
    padding: 10px 4px;
    border-top: 1px solid var(--border-subbox);
    border-bottom: 1px solid var(--border-subbox);
}

.tiempo-eliminacion-original span {
    display: block;
    font-style: italic;
    font-size: 12.5px;
    color: var(--texto-secundario);
    margin-bottom: 3px;
}

.tiempo-eliminacion-original strong {
    font-size: 13px;
    font-weight: 800;
    color: var(--texto-titulos);
}

body.dark-mode .linea-original-soma,
html.dark-mode .linea-original-soma {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    color: #e2e8f0 !important;
}

body.dark-mode .bloque-sintomas-original,
html.dark-mode .bloque-sintomas-original {
    border-bottom-color: rgba(255, 255, 255, 0.18) !important;
}

body.dark-mode .sintoma-header-original,
html.dark-mode .sintoma-header-original {
    color: #38bdf8 !important;
}

/* ==========================================================================
   DISEÑO CLÍNICO ELEGANTE — HISTORIAL DE SESIONES
   ========================================================================== */

/* Tarjeta contenedora de cada sesión con relieve y profundidad */
.sesion-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-card) !important;
    border-radius: 14px !important;
    padding: 0 !important; /* Quitamos padding global para que el header y el body gestionen sus propios espacios */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02) !important;
    margin-bottom: 14px !important;
    overflow: hidden !important;
    transition: all 0.2s ease !important;
}

.sesion-card:hover {
    border-color: rgba(2, 132, 199, 0.4) !important;
    box-shadow: 0 8px 25px rgba(2, 132, 199, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

/* Cabecera de la sesión (Barra superior elegante al hacer clic) */
.sesion-header {
    padding: 14px 18px !important;
    background: rgba(0, 0, 0, 0.015);
    border-bottom: 1px solid transparent;
    transition: background 0.15s ease;
}

.sesion-card:hover .sesion-header {
    background: rgba(2, 132, 199, 0.03);
}

/* Cuerpo desplegable con un fondo ligeramente diferenciado */
.sesion-body {
    padding: 16px 18px !important;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid var(--border-subbox) !important;
}

body.dark-mode .sesion-body {
    background: rgba(15, 23, 42, 0.3) !important;
}

/* Insignia del número ordinal (Ej: 50ª SESIÓN) */
.titulo-ordinal-badge {
    background: var(--bg-btn-primary);
    color: var(--texto-btn-primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

body.dark-mode .titulo-ordinal-badge {
    background: #38bdf8 !important;
    color: #0f172a !important;
}

/* Sub-bloques OPE con tarjetitas internas flotantes */
.ciclo-box {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-subbox) !important;
    border-left: 4px solid #0284c7 !important;
    border-radius: 10px !important;
    padding: 14px 16px !important;
    margin-bottom: 12px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

body.dark-mode .ciclo-box {
    background: rgba(22, 27, 38, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-left: 4px solid #38bdf8 !important;
}

.ciclo-titulo {
    font-size: 10.5px;
    font-weight: 800;
    color: #0284c7;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

body.dark-mode .ciclo-titulo {
    color: #38bdf8 !important;
}

/* Bloque de síntomas iniciales con aspecto de tarjeta de notas clínica */
.bloque-sintomas-original {
    background: rgba(2, 132, 199, 0.04);
    border: 1px solid rgba(2, 132, 199, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 13px;
}

body.dark-mode .bloque-sintomas-original {
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid rgba(56, 189, 248, 0.15);
}

.bloque-sintomas-original strong {
    color: #0284c7;
    font-size: 11.5px;
    letter-spacing: 1px;
}

body.dark-mode .bloque-sintomas-original strong {
    color: #38bdf8;
}