/* ==========================================================================
   YUD CLÍNICO — SISTEMA DE DISEÑO CLÍNICO (HEALTHCARE DESIGN SYSTEM)
   EHR & Inteligencia Artificial Médica | Matsumoto 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: 22px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.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;
}
