/* ==========================================================================
   CORRIGETEA - SISTEMA INTEGRAL DE PRUEBAS PSICOLÓGICAS Y CORRECCIONES
   Estilos Principales, Responsividad, Récords y Editor de Ficha Técnica
   (Escalado +15% de legibilidad clínica y confort visual)
   ========================================================================== */

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-body: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 5px 18px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.14);
}

[data-theme="dark"] {
    --bg-body: #090d16;
    --card-bg: #131b2e;
    --card-border: #1e293b;
    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --primary-light: rgba(2, 132, 199, 0.15);
}

html {
    font-size: 18.5px; /* Base 15% ampliada */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 3.5rem;
    font-size: 1rem;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, .brand-title, .test-card-title, .test-card-code {
    font-family: 'Outfit', 'Inter', sans-serif;
}

.corrigetea-container {
    max-width: 1620px;
    margin: 0 auto;
    padding: 1.1rem 1.4rem;
}

/* --- HEADER SUPERIOR --- */
.corrigetea-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0284c7, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.35rem;
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.32);
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}

/* --- BARRA UNIFICADA SUPERIOR: PESTAÑAS Y GESTIÓN DE PACIENTE --- */
.corrigetea-top-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* --- PESTAÑAS DE NAVEGACIÓN --- */
.nav-tabs-wrapper {
    display: inline-flex;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
}

.nav-tab-btn {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}
.nav-tab-btn:hover {
    color: var(--primary);
    background: #f1f5f9;
}
.nav-tab-btn.active {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: white;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.32);
}

.tab-badge {
    background: rgba(255,255,255,0.28);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 800;
}
.nav-tab-btn:not(.active) .tab-badge {
    background: #e2e8f0;
    color: #334155;
}

/* --- BANNER Y CÁPSULA DE PACIENTE ACTIVO (MINIMALISTA) --- */
#activePatientBanner {
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

.patient-compact-capsule {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 4px 10px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.patient-compact-capsule.empty-mode {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}
.patient-compact-capsule.empty-mode:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.patient-compact-capsule.active-unreg {
    background: linear-gradient(90deg, #fffbeb 0%, #ffffff 100%);
    border: 1.5px solid #fcd34d;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}

.patient-compact-capsule.active-reg {
    background: linear-gradient(90deg, #f0f9ff 0%, #ffffff 100%);
    border: 1.5px solid #7dd3fc;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

.capsule-mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding-right: 8px;
    border-right: 1px solid #e2e8f0;
    user-select: none;
}

.mode-pill {
    font-size: 0.72rem;
    font-weight: 800;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 3px 8px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

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

.capsule-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-compact-amber {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #f59e0b;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
    transition: all 0.2s ease;
}
.btn-compact-amber:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.35);
}

.btn-compact-blue {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-compact-blue:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.patient-compact-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.patient-mini-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    color: white;
    flex-shrink: 0;
}
.patient-mini-avatar.unreg-avatar {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}
.patient-mini-avatar.reg-avatar {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.patient-mini-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.patient-mini-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.patient-mini-name {
    font-weight: 800;
    font-size: 0.88rem;
    color: #0f172a;
    font-family: 'Outfit', sans-serif;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.mini-tag.tag-amber {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}
.mini-tag.tag-cyan {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.patient-mini-sub {
    display: flex;
    gap: 8px;
    font-size: 0.74rem;
    color: #64748b;
}
.patient-mini-sub span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-compact-ghost {
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}
.btn-compact-ghost:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-compact-danger-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 0.78rem;
    cursor: pointer;
    border: 1px solid #fecaca;
    background: #fff1f2;
    color: #e11d48;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.btn-compact-danger-icon:hover {
    background: #ffe4e6;
    color: #be123c;
    border-color: #fda4af;
    transform: scale(1.05);
}

/* Clases para compatibilidad de banners completos */
.patient-banner-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border: 2px solid #38bdf8;
    border-radius: var(--radius-md);
    padding: 1.1rem 1.5rem;
    color: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    flex-wrap: wrap;
    gap: 14px;
    animation: fadeIn 0.25s ease;
}

.patient-banner-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.patient-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.patient-info-summary {
    flex: 1;
    min-width: 280px;
}

.patient-name-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
}

.patient-type-badge {
    font-size: 0.775rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 14px;
}

.badge-registered {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.badge-unregistered {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.patient-meta-row {
    display: flex;
    gap: 18px;
    font-size: 0.885rem;
    color: #94a3b8;
    margin-top: 4px;
    flex-wrap: wrap;
}

.patient-actions-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* --- BOTONES --- */
.btn-primary-sm, .btn-secondary-sm, .btn-subtle {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary-sm {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.38);
}
.btn-primary-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(2, 132, 199, 0.48);
}

.btn-secondary-sm {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}
.btn-secondary-sm:hover {
    background: #e2e8f0;
}

.btn-subtle {
    background: rgba(255,255,255,0.15);
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.25);
}
.btn-subtle:hover {
    background: rgba(255,255,255,0.25);
    color: white;
}

.btn-danger-subtle {
    color: #f87171;
    border-color: rgba(239,68,68,0.4);
}
.btn-danger-subtle:hover {
    background: rgba(239,68,68,0.2);
    color: #fca5a5;
}

/* --- BARRA DE BÚSQUEDA Y CATEGORÍAS --- */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.65rem;
    flex-wrap: wrap;
}

.search-box-wrapper {
    position: relative;
    flex: 1;
    min-width: 320px;
}

.search-input-field {
    width: 100%;
    padding: 9px 36px 9px 40px;
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 0.92rem;
    outline: none;
    transition: all 0.2s ease;
}
.search-input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.18);
}

.search-icon-inside {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.05rem;
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted, #64748b);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
    z-index: 10;
    user-select: none;
    box-shadow: none;
}
.search-clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: translateY(-50%) scale(1.1);
}
.search-clear-btn:active {
    transform: translateY(-50%) scale(0.92);
}

.category-chips-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.category-chips-row::-webkit-scrollbar {
    height: 4px;
}
.category-chips-row::-webkit-scrollbar-track {
    background: transparent;
}
.category-chips-row::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.corrigetea-chip {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s ease;
    user-select: none;
}
.corrigetea-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f9ff;
}
.corrigetea-chip.active {
    background: linear-gradient(135deg, var(--primary), #0284c7);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.35);
}

/* ==========================================================================
   GRID DE PRUEBAS ULTRA-MODERNO (AMPLIADO Y MÁS CÓMODO)
   ========================================================================== */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(370px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.corrigetea-test-card {
    background: #ffffff;
    border: 1px solid #d4d7dd;
    border-top: 1px solid #edf0f4;
    border-bottom: 2px solid #b4bcc8;
    border-radius: 8px;
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), inset 0 1px 0 #ffffff;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative;
    overflow: hidden;
}
.corrigetea-test-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07), inset 0 1px 0 #ffffff;
    border-color: #94a3b8;
    border-top-color: #cbd5e1;
    border-bottom-color: #64748b;
}

.test-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 1rem;
}

.test-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    flex-shrink: 0;
}

.test-card-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.test-code-badge {
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: -0.2px;
    padding: 3px 10px;
    border-radius: 7px;
    display: inline-block;
}

.test-card-area {
    font-size: 0.825rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 3px;
}

/* Botón Engranito de Ficha Técnica */
.btn-card-gear {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.btn-card-gear:hover {
    background: #e0f2fe;
    border-color: #7dd3fc;
    color: #0284c7;
    transform: rotate(45deg);
}

.test-card-title {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.test-card-desc {
    font-size: 0.895rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Metadata Pills */
.test-meta-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.test-meta-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 4px 10px;
    font-size: 0.825rem;
    font-weight: 600;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.test-meta-pill i {
    color: var(--primary);
    font-size: 0.85rem;
}

/* Badge de Récord Histórico en la tarjeta */
.test-eval-record-badge {
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #334155;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.test-eval-record-badge:hover {
    background: #f0f9ff;
    border-color: #7dd3fc;
    color: #0284c7;
}

.badge-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    display: inline-block;
}
.badge-status-dot.active {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16,185,129,0.6);
}

.btn-record-link {
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Acciones de la Tarjeta */
.test-card-actions {
    display: flex;
    gap: 10px;
}

.btn-card-records {
    flex: 1;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.885rem;
    font-weight: 700;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}
.btn-card-records:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-launch-test {
    flex: 1.35;
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-launch-test:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(0,0,0,0.28);
}

/* --- TABLAS DE HISTORIAL Y RÉCORDS --- */
.history-table-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

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

.history-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 800;
    padding: 14px 18px;
    border-bottom: 1.5px solid var(--card-border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-main);
}

.history-table tr:hover {
    background: #f8fafc;
}

.test-pill {
    background: #f1f5f9;
    color: #0f172a;
    padding: 5px 12px;
    border-radius: 7px;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-block;
}

.badge-status-pill {
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-completed {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.status-progress {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.score-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid #bae6fd;
}

/* --- MODALES --- */
.corrigetea-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.corrigetea-modal-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 680px;
    overflow: hidden;
    animation: slideUp 0.25s ease;
}

.modal-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--card-border);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    color: #64748b;
    cursor: pointer;
}
.btn-close-modal:hover {
    color: #0f172a;
}

.patient-modal-list {
    max-height: 52vh;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.patient-modal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.15rem;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}
.patient-modal-item:hover {
    background: #f0f9ff;
    border-color: #7dd3fc;
}
.patient-modal-item.selected {
    background: #e0f2fe;
    border-color: #0284c7;
}

.patient-avatar-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
}

/* --- TOAST --- */
.corrigetea-toast {
    position: fixed;
    bottom: 26px;
    right: 26px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    z-index: 999999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
    display: none;
    animation: slideUp 0.25s ease;
}
.toast-success { background: #10b981; }
.toast-info { background: #0284c7; }
.toast-error { background: #ef4444; }

/* --- CONTENEDOR TEST RUNNER (FULLSCREEN WORKSPACE OVERLAY) --- */
#testRunnerContainer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    background: #f8fafc !important;
    z-index: 9999999 !important;
    display: none;
    flex-direction: column;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.runner-header-bar {
    display: none !important;
}

.runner-iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    border: none !important;
    background: #f8fafc !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    z-index: 1 !important;
}

/* ==========================================================================
   🌙 CONTROLES FLOTANTES DISCRETOS MEDIA LUNA (TEST RUNNER)
   ========================================================================== */
.medialuna-dock {
    position: fixed;
    top: 0;
    z-index: 10000000;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-top: none;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    color: #f1f5f9;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    box-sizing: border-box;
}

/* Media Luna Izquierda: Volver a CorrigeTEA y Título */
.medialuna-dock-left {
    left: 20px;
    padding: 5px 14px;
    opacity: 0.42;
    transform: translateY(-2px);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.medialuna-dock-left:hover {
    opacity: 1;
    transform: translateY(0);
    background: rgba(15, 23, 42, 0.96);
    border-color: rgba(56, 189, 248, 0.75);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 16px rgba(56, 189, 248, 0.25);
    padding: 7px 18px;
}

.medialuna-dock-left .medialuna-label {
    display: none;
    font-size: 0.85rem;
    font-weight: 700;
    margin-left: 6px;
}

.medialuna-dock-left:hover .medialuna-label {
    display: inline;
}

.medialuna-dock-left .medialuna-title-badge {
    display: none;
    font-size: 0.82rem;
    font-weight: 700;
    color: #38bdf8;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.medialuna-dock-left:hover .medialuna-title-badge {
    display: inline-block;
}

/* Media Luna Derecha: Imprimir / Guardar PDF, Info Paciente y Cambiar */
.medialuna-dock-right {
    right: 20px;
    opacity: 0.42;
    transform: translateY(-2px);
    cursor: pointer;
}

.medialuna-dock-right:hover {
    opacity: 1;
    transform: translateY(0);
    background: rgba(15, 23, 42, 0.96);
    border-color: rgba(56, 189, 248, 0.75);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 16px rgba(56, 189, 248, 0.25);
}

.medialuna-dock-right .medialuna-peek {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    color: #38bdf8;
    font-size: 0.85rem;
}

.medialuna-dock-right .medialuna-expanded {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
}

.medialuna-dock-right:hover .medialuna-peek {
    display: none;
}

.medialuna-dock-right:hover .medialuna-expanded {
    display: flex;
}

/* Botones y Badges dentro de Media Luna */
.medialuna-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.medialuna-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    color: #ffffff;
}

.medialuna-patient-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
}

/* --- ANIMACIONES --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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


/* --- ESTILOS DE BOTONES DE ACCIÓN DEL TEST RUNNER (IMPRIMIR / GUARDAR) --- */
.btn-runner-action {
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    text-decoration: none;
}

.btn-runner-print {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff !important;
    border: 1px solid #38bdf8;
}
.btn-runner-print:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.45);
}

.btn-runner-save {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff !important;
    border: 1px solid #34d399;
}
.btn-runner-save:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.45);
}


/* BOTÓN MODIFICAR PACIENTE EN BARRA SUPERIOR (CAPTURA 2) */
.btn-header-modificar-paciente {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff !important;
    padding: 7px 16px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}
.btn-header-modificar-paciente:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.45);
}
.btn-header-modificar-paciente:active {
    transform: translateY(0);
}

/* 🔔 Insignias y Contadores de Google Sheets */
.badge-card-gsheet {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff !important;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 9999px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    animation: pulseGlow 2.5s infinite;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.badge-card-gsheet:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6);
}

.sidebar-counter-badge {
    animation: pulseGlowRed 2.2s infinite;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes pulseGlowRed {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

