:root { 
    /* Paleta Slate & Cyan Refinada */
    --bg: #0f172a; 
    --panel: #1e293b; 
    --primary: #06b6d4; /* Cian Vibrante */
    --success: #10b981; /* Esmeralda */
    --danger: #f43f5e; /* Rosa/Rojo moderno */
    --text: #f8fafc; 
    --border: #334155; 
    --primary-glow: rgba(6, 182, 212, 0.15);
}

body { 
    background: var(--bg); 
    color: var(--text); 
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif; 
    margin: 0; 
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Pantalla de Login Profesional */
#loginScreen { 
    position: fixed; 
    width: 100%; 
    height: 100%; 
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 2000; 
}

.login-box { 
    background: var(--panel); 
    padding: 48px; 
    border-radius: 24px; 
    border: 1px solid var(--border); 
    text-align: center; 
    width: 380px; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Contenedor Principal */
.container { 
    max-width: 1400px; 
    margin: 32px auto; 
    background: var(--panel); 
    border: 1px solid var(--border); 
    border-radius: 24px; 
    display: none; 
    overflow: hidden; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Header con Identidad Visual */
.header { 
    background: #020617; 
    padding: 20px 32px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 2px solid var(--primary); 
}

.logo { 
    height: 42px; 
    transition: transform 0.3s ease;
}
.logo:hover { transform: scale(1.05); }

/* Controles de Búsqueda */
.controls { 
    padding: 24px 32px; 
    display: flex; 
    gap: 24px; 
    background: #111827; 
    border-bottom: 1px solid var(--border); 
    align-items: flex-end; 
}

.search-group { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    flex: 1; 
}

.search-group label { 
    font-size: 10px; 
    color: var(--primary); 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 0.1em;
}

/* Tabla de Trabajo Optimizada */
table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0;
}

th { 
    background: #0f172a; 
    color: var(--primary); 
    padding: 20px; 
    text-align: left; 
    font-size: 11px; 
    text-transform: uppercase; 
    font-weight: 900;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

td { 
    padding: 16px 20px; 
    border-bottom: 1px solid var(--border); 
    font-size: 14px;
    transition: background 0.2s ease;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Botones con Estilo App Moderna */
.btn { 
    padding: 10px 20px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: 700; 
    cursor: pointer; 
    border: none; 
    color: white; 
    text-decoration: none; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.btn:active { transform: scale(0.95); }

.btn-success { 
    background: var(--success); 
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover { background: #059669; box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3); }

.btn-primary { 
    background: var(--primary); 
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}
.btn-primary:hover { background: #0891b2; box-shadow: 0 6px 16px rgba(6, 182, 212, 0.3); }

.btn-danger { 
    background: var(--danger); 
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
}
.btn-danger:hover { background: #e11d48; box-shadow: 0 6px 16px rgba(244, 63, 94, 0.3); }

/* Inputs Modernos */
input { 
    background: #020617; 
    border: 1px solid var(--border); 
    color: white; 
    padding: 12px 16px; 
    border-radius: 12px; 
    outline: none; 
    font-size: 14px;
    transition: all 0.2s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Reporte Estilo Papel - Profesionalizado */
#modalReporte { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(2, 6, 23, 0.96); 
    z-index: 1000; 
    overflow-y: auto; 
    padding: 40px 0; 
}

.report-paper { 
    background: white; 
    color: #1e293b; 
    width: 210mm; 
    min-height: 297mm; 
    margin: auto; 
    padding: 25mm; 
    box-sizing: border-box; 
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.report-header { 
    display: flex; 
    justify-content: space-between; 
    border-bottom: 3px solid #0f172a; 
    padding-bottom: 20px; 
    align-items: center; 
}

.report-data-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 16px; 
    margin: 32px 0; 
    background: #f8fafc; 
    padding: 24px; 
    font-size: 14px; 
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.rep-textarea { 
    width: 100%; 
    border: 1px solid #e2e8f0; 
    padding: 24px; 
    font-size: 17px; 
    min-height: 400px; 
    margin-top: 16px; 
    font-family: 'Georgia', serif; 
    resize: none; 
    color: #0f172a; 
    line-height: 1.7;
    border-radius: 12px;
    outline: none;
}

.rep-textarea:focus { border-color: #06b6d4; }

.floating-menu { 
    position: fixed; 
    right: 40px; 
    top: 40px; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
}

/* Sección de Firma Limpia */
.signature-section { 
    margin-top: 60px; 
    text-align: left !important;
    padding: 32px 0;
    border-top: 1px solid #f1f5f9;
}

.signature-line { 
    border-top: 2px solid #0f172a; 
    width: 280px; 
    margin-top: 48px; 
    padding-top: 12px; 
}

#firmaDoc { 
    font-size: 18px; 
    font-weight: 800; 
    display: block; 
    color: #0f172a;
    letter-spacing: -0.01em;
}

#firmaEsp, #firmaRM { 
    font-size: 14px; 
    display: block; 
    color: #64748b; 
    margin-top: 2px;
}

@media print { 
    .no-print { display: none !important; } 
    body { background: white; } 
    #modalReporte { position: absolute; top:0; left:0; display:block; padding: 0; } 
    .report-paper { box-shadow: none; width: 100%; margin: 0; padding: 15mm; } 
    .floating-menu { display: none; }
}
/* =========================================
   DISEÑO MODERNO (VISTA DE LISTAS ANCHAS)
========================================= */
.dashboard-grid {
    display: flex;
    flex-direction: column; /* Esto fuerza a que sea una lista hacia abajo */
    gap: 15px;
    padding: 0 0 20px 0;
}

.estudio-card {
    background: #11151c; /* Fondo súper oscuro premium */
    border-radius: 12px;
    padding: 15px 25px;
    display: flex;
    flex-direction: row; /* Elementos de izquierda a derecha */
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border-left: 6px solid #444; /* El borde que cambia de color por estado */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.estudio-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 212, 255, 0.05);
}

.card-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1; /* Distribuye el espacio equitativamente */
}

.card-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
}

.card-value {
    font-size: 14px;
    color: #ffffff;
    font-weight: bold;
    text-transform: uppercase;
}

.card-id-value { color: #00ff9d; /* Verde/Cyan brillante para el ID */ }

.card-modality {
    background: #1e293b;
    color: #94a3b8;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
    border: 1px solid #334155;
}

.card-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

/* Botones Redondeados (Píldoras) */
.btn-dicom {
    background: #2563eb;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.btn-informar {
    background: #ffffff;
    color: #f59e0b;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}
body {
    background-color: #06090f !important; /* Negro/Azul abismal */
    background-image: none !important;
}

.container {
    background: transparent !important;
    border: none !important;
    max-width: 1300px;
    margin-top: 30px;
}

/* =========================================
   HEADER Y CONTROLES (PANEL FLOTANTE PREMIUM)
========================================= */
.header-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #111827 0%, #0d141f 100%); /* Degradado sutil */
    padding: 20px 30px 15px 30px;
    border-radius: 16px 16px 0 0; /* Bordes redondos arriba */
    border: 1px solid #1f2937;
    border-bottom: 1px solid #1a2332;
    margin-bottom: 0; /* Lo unimos con los filtros de abajo */
}

.logo-modern { height: 45px; object-fit: contain; }
.user-profile-modern { display: flex; align-items: center; gap: 15px; }
.user-info-text { display: flex; flex-direction: column; text-align: right; }
.user-name-text { font-weight: bold; font-size: 15px; color: #fff; }
.user-role-text { font-size: 11px; color: #10b981; font-weight: bold; letter-spacing: 1px; }

.btn-clave { background: #1f2937; color: #94a3b8; padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 11px; font-weight: bold; transition: 0.2s; }
.btn-clave:hover { background: #334155; color: white; }

.btn-logout-modern { background: transparent; border: 1px solid #334155; color: #ef4444; border-radius: 50%; width: 40px; height: 40px; font-size: 16px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.btn-logout-modern:hover { background: #ef4444; color: white; border-color: #ef4444; }

/* Controles de Filtro (Caja unida al header) */
.filters-modern {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #0d141f; /* Mismo color base del header */
    padding: 15px 30px 25px 30px;
    border-radius: 0 0 16px 16px; /* Bordes redondos abajo */
    border: 1px solid #1f2937;
    border-top: none;
    margin-bottom: 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5); /* Sombra intensa para flotar */
}
.search-icon-wrapper { display: flex; align-items: center; background: #0d1219; border: 1px solid #1f2937; border-radius: 20px; padding-left: 15px; flex: 2; transition: 0.2s; }
.search-icon-wrapper:focus-within { border-color: #10b981; }
.search-icon-wrapper .main-search { border: none; background: transparent; flex: 1; margin: 0; }
.search-icon-wrapper .main-search:focus { border: none; }

.input-modern {
    background: #0d1219;
    border: 1px solid #1f2937;
    color: white;
    padding: 12px 18px;
    border-radius: 20px;
    outline: none;
    font-size: 13px;
    transition: 0.2s;
}
.input-modern:focus { border-color: #10b981; }
.select-modern { flex: 1; appearance: none; cursor: pointer; color: #94a3b8; }
.select-modern option { background: #0d1219; color: white; }

.btn-refresh-modern {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 12px;
    width: 45px;
    height: 45px;
    font-size: 22px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-refresh-modern:hover { background: #059669; transform: rotate(90deg); }

/* Título de Lista */
.titulo-lista-modern { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.titulo-lista-modern h2 { margin: 0; color: white; font-size: 18px; font-weight: bold; }
.badge-modern { background: #064e3b; color: #10b981; padding: 3px 8px; border-radius: 10px; font-size: 10px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
/* =========================================
/* =========================================================
   MÓDULO DE DICTADO POR VOZ (UI & ANIMACIONES)
========================================================= */
.section-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    margin-top: 15px;
}

.btn-dictate {
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease-in-out;
}

.btn-dictate:hover { background-color: #e2e8f0; }

/* Estado: Escuchando (Latido suave) */
.btn-dictate.is-recording {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Ocultar elementos de dictado al imprimir o generar PDF */
@media print {
    .btn-dictate { display: none !important; }
    .section-title-wrapper { margin-top: 5px; margin-bottom: 2px; }
}
/* =========================================================
   MÓDULO DE HISTORIAL DEL PACIENTE (PANEL IZQUIERDO)
========================================================= */
.report-layout-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
}

/* Panel Izquierdo */
.sidebar-historial {
    width: 280px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 15px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    max-height: 85vh;
    overflow-y: auto;
}

.sidebar-title {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #1e293b;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 8px;
}

/* Tarjetas de estudios previos */
.historial-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.historial-item:hover {
    background: #e0f2fe;
    border-color: #bae6fd;
}

.historial-item.actual {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
}

.historial-fecha { font-size: 11px; color: #64748b; font-weight: bold; }
.historial-desc { font-size: 12px; color: #334155; margin: 4px 0; }
.historial-btn {
    font-size: 11px; color: #0284c7; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; cursor: pointer;
}
.historial-btn:hover { color: #0369a1; text-decoration: underline; }

/* Ocultar el panel izquierdo al imprimir o generar PDF */
@media print {
    .sidebar-historial { display: none !important; }
    .report-layout-container { display: block; }
}
/* =========================================================
   MODAL DE REPORTE PREVIO (VENTANA FLOTANTE RÁPIDA)
========================================================= */
.modal-flotante-overlay {
    display: none; 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px);
    z-index: 99999; justify-content: center; align-items: center;
}

.modal-flotante-box {
    background: #ffffff; width: 600px; max-width: 90%; 
    border-radius: 10px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden; display: flex; flex-direction: column;
    border-top: 4px solid #0ea5e9;
}

.modal-flotante-header {
    background: #f8fafc; padding: 15px 20px; border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}

.modal-flotante-body {
    padding: 20px; max-height: 60vh; overflow-y: auto; font-size: 13px; color: #334155;
}

.modal-flotante-close {
    background: #ef4444; color: white; border: none; padding: 6px 12px; 
    border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 12px;
}

.modal-flotante-close:hover { background: #dc2626; }
/* ==========================================
   DISEÑO DEL REPORTE (FLEXBOX LIMPIO)
   ========================================== */
.report-layout-container {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 30px; /* Separación perfecta entre historial y hoja */
    width: 100%;
    margin: 0;
}

.sidebar-historial {
    width: 280px;
    flex-shrink: 0; /* Evita que la barra se encoja */
}

.report-paper {
    flex-grow: 1; /* Toma todo el espacio sobrante a la derecha */
    max-width: 850px;
    margin: 0 !important; /* Anula cualquier margen viejo */
}
