/* ==========================================================================
   YUD CLÍNICO — SISTEMA DE DISEÑO CLÍNICO (HEALTHCARE DESIGN SYSTEM)
   EHR & Inteligencia Artificial Médica | DAATÍAN HealthTech
   Cumplimiento: NOM-004-SSA3-2012 / NOM-024-SSA3-2012
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Superficies & Fondo Clínico (Asepsia y Descanso Ocular) */
    --bg-body: #f8fafc;           /* Slate 50: Calma visual, cero deslumbramiento */
    --bg-surface: #ffffff;        /* Blanco Hospitalario Puro: Tarjetas, notas y modales */
    --bg-sidebar: #ffffff;        /* Barra lateral limpia y ergonómica */
    --bg-subtle: #f1f5f9;         /* Slate 100: Fondos de cabecera de tablas y badges */
    
    /* Bordes & Separadores */
    --border-color: #e2e8f0;      /* Slate 200: Separación limpia de módulos médicos */
    --border-subtle: #f1f5f9;     /* Slate 100 */
    --border-focus: #0d9488;      /* Teal 600: Foco activo */

    /* Colores Primarios de Marca (Salud & Confianza Institucional) */
    --primary-teal: #0d9488;       /* Teal Sanitario: Sanidad, batas quirúrgicas y salud */
    --primary-teal-hover: #0f766e; /* Teal 700 */
    --primary-teal-light: #f0fdfa; /* Teal 50: Selección activa, hover médico */
    --accent-blue: #0284c7;        /* Azul Médico 600: Rigor científico y confianza */
    --accent-blue-hover: #0369a1;  /* Azul 700 */
    --accent-blue-light: #f0f9ff;  /* Azul 50 */
    --accent-gradient: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);

    /* Tipografía y Contraste de Alta Legibilidad (WCAG AAA) */
    --text-primary: #0f172a;      /* Slate 900: Contraste máximo para evitar errores de dosis */
    --text-secondary: #334155;    /* Slate 700: Notas clínicas y evolución */
    --text-muted: #64748b;        /* Slate 500: Etiquetas, códigos CIE-10 y metadatos */
    --text-placeholder: #94a3b8;  /* Slate 400 */

    /* Semántica Médica (Triage & Signos Vitales) */
    --status-success: #059669;    /* Verde Clínico: Signos normales, receta activa */
    --status-success-bg: #ecfdf5;
    --status-success-border: #a7f3d0;

    --status-warning: #d97706;    /* Ámbar Preventivo: Vacunas pendientes, seguimiento */
    --status-warning-bg: #fffbeb;
    --status-warning-border: #fde68a;

    --status-danger: #dc2626;     /* Rojo Alerta: Alergia grave, hipertensión, urgencia */
    --status-danger-bg: #fef2f2;
    --status-danger-border: #fecaca;

    --status-ai: #6366f1;         /* Índigo Asistente: Dictado por voz, sugerencias IA */
    --status-ai-bg: #eef2ff;
    --status-ai-border: #c7d2fe;

    /* Dimensiones y Sombras */
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-modal: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ==========================================================================
   RESET & TIPOGRAFÍA BASE
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'tnum' on, 'cv05' on; /* Números tabulares para dosis y presión */
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   BARRA LATERAL DE NAVEGACIÓN (CLINICAL SIDEBAR)
   ========================================================================== */
aside.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    box-shadow: 1px 0 4px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    z-index: 50;
}

.brand-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 22px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.brand-title h2 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: var(--text-primary);
    line-height: 1.15;
}

.brand-title span {
    font-size: 0.68rem;
    color: var(--primary-teal);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-teal-light);
    color: var(--primary-teal);
    border-left: 3px solid var(--primary-teal);
    font-weight: 700;
}

.nav-item .icon {
    font-size: 1.15rem;
}

/* Tarjeta del Médico en la base del Sidebar */
.doctor-badge-bottom {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.doc-avatar {
    width: 38px;
    height: 38px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.2);
}

.doc-info p {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.doc-info span {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==========================================================================
   ÁREA PRINCIPAL DE CONTENIDO
   ========================================================================== */
main.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 40px;
    max-width: 1400px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.top-bar h1 {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.top-bar p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ==========================================================================
   BOTONES CLÍNICOS
   ========================================================================== */
.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    border: none;
    padding: 11px 22px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-teal);
    color: var(--primary-teal);
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-outline:hover {
    background: var(--primary-teal-light);
}

.btn-danger {
    background: var(--status-danger);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* ==========================================================================
   TARJETAS DE MÉTRICAS Y ESTADÍSTICAS
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-teal);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.stat-number {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1;
}

.stat-footer {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--status-success);
    font-weight: 600;
}

/* ==========================================================================
   CAJAS DE CONTENIDO Y TARJETAS MÉDICAS
   ========================================================================== */
.content-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
}

.box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 14px;
}

.box-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==========================================================================
   TABLAS CLÍNICAS (HISTORIAL, RECETAS, PACIENTES)
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table.yud-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

table.yud-table th {
    background-color: var(--bg-body);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

table.yud-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

table.yud-table tr:hover td {
    background: var(--bg-body);
}

/* ==========================================================================
   BADGES Y ESTADOS CLÍNICOS
   ========================================================================== */
.badge-alert {
    background: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid var(--status-danger-border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-ok {
    background: var(--status-success-bg);
    color: var(--status-success);
    border: 1px solid var(--status-success-border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-warn {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border: 1px solid var(--status-warning-border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-ai {
    background: var(--status-ai-bg);
    color: var(--status-ai);
    border: 1px solid var(--status-ai-border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ==========================================================================
   ÁREA DE CONSULTA Y DICTADO POR VOZ CON IA
   ========================================================================== */
.voice-ai-banner {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(2, 132, 199, 0.04));
    border: 1px solid rgba(13, 148, 136, 0.25);
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Botón Principal de Iniciar / Finalizar Consulta */
.btn-consultation-main {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #ffffff;
    font-size: 0.96rem;
    font-weight: 700;
    padding: 13px 22px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.35);
    transition: all 0.25s ease;
    white-space: nowrap;
}

.btn-consultation-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.45);
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
}

.btn-consultation-main.recording {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.45);
    animation: pulseRecordingBtn 1.8s infinite;
}

.btn-consultation-main.recording:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

@keyframes pulseRecordingBtn {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70% { box-shadow: 0 0 0 14px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Ecualizador animado de onda de audio en vivo */
.audio-wave-container {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 18px;
    padding: 2px 7px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 20px;
    vertical-align: middle;
}

.wave-bar {
    display: inline-block;
    width: 3px;
    height: 100%;
    background: #10b981;
    border-radius: 2px;
    animation: waveBarAnim 1s ease-in-out infinite alternate;
}

.wave-bar:nth-child(1) { animation-delay: 0.1s; height: 35%; }
.wave-bar:nth-child(2) { animation-delay: 0.3s; height: 85%; }
.wave-bar:nth-child(3) { animation-delay: 0s; height: 55%; }
.wave-bar:nth-child(4) { animation-delay: 0.4s; height: 100%; }
.wave-bar:nth-child(5) { animation-delay: 0.2s; height: 45%; }

@keyframes waveBarAnim {
    0% { transform: scaleY(0.25); }
    100% { transform: scaleY(1); }
}

.btn-outline-teal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 11px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-outline-teal:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
    background: rgba(13, 148, 136, 0.04);
}

.mic-btn-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--primary-teal);
    color: var(--primary-teal);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.2);
    transition: all 0.25s ease;
}

.mic-btn-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(13, 148, 136, 0.3);
}

.mic-btn-circle.recording {
    background: var(--status-danger);
    border-color: #ef4444;
    color: #ffffff;
    animation: pulseRecording 1.5s infinite;
}

@keyframes pulseRecording {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70% { box-shadow: 0 0 0 16px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.voice-desc {
    flex: 1;
}

.voice-desc h3 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 700;
}

.voice-desc p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================================================
   FORMULARIOS Y CAMPOS CLÍNICOS
   ========================================================================== */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.88rem;
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

/* ==========================================================================
   BLOQUES DE CONSULTA SOAP (SUBJETIVO, OBJETIVO, ANÁLISIS, PLAN)
   ========================================================================== */
.soap-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.soap-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.soap-tag.s { background: #e0f2fe; color: #0369a1; } /* Subjetivo */
.soap-tag.o { background: #dcfce7; color: #15803d; } /* Objetivo */
.soap-tag.a { background: #ede9fe; color: #6d28d9; } /* Análisis */
.soap-tag.p { background: #ccfbf1; color: #0f766e; } /* Plan */

/* ==========================================================================
   MODALES CLÍNICOS
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

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

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--shadow-modal);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 14px;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ==========================================================================
   TRANSICIÓN ENTRE VISTAS
   ========================================================================== */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   COMPONENTES CLÍNICOS AVANZADOS (EXPEDIENTE, CAJA, BÓVEDA, VACUNAS)
   ========================================================================== */

/* Tabs de Navegación Interna */
.clinical-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
}

.clinical-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.clinical-tab-btn:hover {
    color: var(--primary-teal);
    background: var(--primary-teal-light);
    border-radius: 6px 6px 0 0;
}

.clinical-tab-btn.active {
    color: var(--primary-teal);
    border-bottom: 2px solid var(--primary-teal);
    font-weight: 700;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Modales Grandes para Expediente y Bóveda */
.modal-card.modal-lg {
    max-width: 960px;
    width: 95%;
}

/* Semáforos y Pills de Estado */
.pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.pill-green {
    background: var(--status-success-bg);
    color: var(--status-success);
    border: 1px solid var(--status-success-border);
}

.pill-yellow {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border: 1px solid var(--status-warning-border);
}

.pill-red {
    background: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid var(--status-danger-border);
}

.pill-blue {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    border: 1px solid #bae6fd;
}

.pill-gray {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Botón Verde Oficial de WhatsApp */
.btn-whatsapp {
    background: #25D366;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn-whatsapp:hover {
    background: #1eb956;
    color: #ffffff;
    transform: translateY(-1px);
}

/* Área de Carga de Archivos Clínicos (Drag & Drop / Bóveda) */
.dropzone-box {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    background: var(--bg-body);
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 20px;
}

.dropzone-box:hover {
    border-color: var(--primary-teal);
    background: var(--primary-teal-light);
}

/* Tarjetas de Corte de Caja */
.cashier-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cashier-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.cashier-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.cashier-card-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    font-feature-settings: 'tnum' on;
}

/* Contenedor de Curva de Crecimiento */
.growth-curve-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

/* ==========================================================================
   CABECERA MÓVIL & RESPONSIVIDAD PARA TELÉFONOS, IPADS Y TABLETS
   ========================================================================== */
.mobile-app-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    z-index: 80;
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.btn-hamburger {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    font-weight: 700;
    transition: all 0.15s ease;
}

.btn-hamburger:hover, .btn-hamburger:active {
    background: var(--primary-teal-light);
    border-color: var(--primary-teal);
    color: var(--primary-teal);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo-sm {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

.mobile-brand-text {
    display: flex;
    flex-direction: column;
}

.mobile-brand-text strong {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.mobile-brand-text span {
    font-size: 0.62rem;
    color: var(--primary-teal);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-sidebar-close {
    display: none;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: all 0.15s ease;
}

.btn-sidebar-close:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- BARRA INFERIOR DE ACCESO RÁPIDO MÓVIL (BOTTOM NAV BAR) --- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    z-index: 85;
    padding: 0 4px;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.06);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 6px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 1;
    max-width: 72px;
}

.bottom-nav-item svg {
    stroke: var(--text-muted);
    transition: all 0.15s ease;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--primary-teal);
}

.bottom-nav-item.active svg {
    stroke: var(--primary-teal);
    stroke-width: 2.4;
    transform: scale(1.08);
}

/* --- REGLAS RESPONSIVAS PARA PANTALLAS MENORES O IGUALES A 1024px (Tablets, iPad, Teléfonos) --- */
@media (max-width: 1024px) {
    .mobile-app-header {
        display: flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .btn-sidebar-close {
        display: flex;
    }

    aside.sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 290px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        background: #ffffff;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.25);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    aside.sidebar.mobile-open {
        transform: translateX(0);
    }

    main.main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px 20px 88px 20px !important; /* Espacio superior para header y espacio inferior para bottom nav */
        margin-top: 60px !important;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 20px;
    }

    .top-bar h1 {
        font-size: 1.35rem;
    }

    .top-bar p {
        font-size: 0.82rem;
    }

    .top-bar .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* --- REGLAS RESPONSIVAS ADICIONALES PARA TELÉFONOS (max-width: 640px) --- */
@media (max-width: 640px) {
    main.main-content {
        padding: 16px 14px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .box-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .box-header button,
    .box-header .btn-primary,
    .box-header .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .content-box {
        padding: 16px 14px;
        border-radius: 12px;
    }

    .form-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 12px;
    }

    table.yud-table {
        min-width: 520px; /* Permite scroll horizontal suave sin romper las columnas */
    }

    .modal-card {
        width: 95% !important;
        padding: 18px 14px !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
    }

    /* Grabación de voz en consulta médica */
    .voice-control-box {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .voice-btn-group {
        width: 100%;
        justify-content: center;
    }

    .cashier-summary-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Estilos de Perfil Asistente & Roles */
.stat-card.stat-assistant-only {
    border-color: #bae6fd;
}
.stat-card.stat-assistant-only:hover {
    border-color: #0284c7;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
}
.pill-badge.pill-blue {
    background: #e0f2fe;
    color: #0284c7;
}


