/* ==========================================================================
   SIMULADOR CAP - HOJA DE ESTILOS PRINCIPAL
   ========================================================================== */

/* =========================================
   1. VARIABLES GLOBALES (PALETA)
   ========================================= */
:root {
    --bg-body: #f0f2f5;
    --bg-header: #1e293b;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #1c75bc;        
    --primary-light: #3498db;  
    --primary-hover: #155e96;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f59e0b;
    --info: #3498db;

    --login-bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #2c3e50 100%);
    --btn-gradient-login: linear-gradient(135deg, #3498db 0%, #1c75bc 100%);
    --btn-shadow-login: 0 8px 18px rgba(28, 117, 188, 0.4);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* =========================================
   2. RESETEO Y BASE
   ========================================= */
body, html {
    margin: 0; padding: 0; min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex; flex-direction: column;
}

/* Scrollbar Corporativo */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* =========================================
   3. UTILIDADES GLOBALES (Espaciados, Textos, Flex)
   ========================================= */
/* Display / Visibilidad */
.hidden, .hidden-element { display: none !important; }
.ws-nowrap, .white-space-nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.opacity-50 { opacity: 0.5; }

/* Márgenes */
.m-0, .margin-0 { margin: 0; }
.mt-0, .m-top-0 { margin-top: 0; }
.mt-5, .margin-t-5 { margin-top: 5px; }
.mt-10, .margin-t-10 { margin-top: 10px; }
.mt-15, .margin-t-15 { margin-top: 15px; }
.mt-20, .margin-t-20 { margin-top: 20px; }
.mt-25, .margin-t-25 { margin-top: 25px; }
.mb-5, .m-bottom-0 { margin-bottom: 5px; } /* Ajuste de nombre para consistencia */
.margin-b-15 { margin-bottom: 15px; }
.margin-b-30 { margin-bottom: 30px; }

/* Paddings */
.p-20 { padding: 20px; }
.p-30 { padding: 30px; }
.pl-10 { padding-left: 10px; }
.padding-12 { padding: 12px; }

/* Flexbox */
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-row { display: flex; flex-direction: row; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap-10, .gap-10 { display: flex; gap: 10px; }
.justify-center { justify-content: center; }
.flex-centro-gap { display: flex; gap: 8px; justify-content: center; }

/* Textos y Colores */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.align-middle, .td-centro-vertical { vertical-align: middle; text-align: center; }

.font-bold { font-weight: bold; }
.fs-11 { font-size: 1.1em; }
.fs-90 { font-size: 0.9em; }
.fs-85 { font-size: 0.85em; }
.fs-80 { font-size: 0.8em; }

.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-info { color: var(--info); }
.text-main { color: var(--text-main); }

/* Anchos */
.w-100 { width: 100%; }
.w-50 { width: 50px; }
.min-w-250 { min-width: 250px; }
.min-w-150 { min-width: 150px; }
.fixed-w-200 { width: 200px; flex-shrink: 0; }

/* Misc */
.no-underline { text-decoration: none; }
.link-fuerte { color: var(--primary); text-decoration: none; font-weight: bold; }
.divisor-dashed { border: none; border-top: 1px dashed var(--border-color); margin: 15px 0; }
.border-l-info { border-left: 3px solid var(--info); }

/* =========================================
   4. LAYOUT PRINCIPAL (Header y Container)
   ========================================= */
.top-bar {
    background-color: var(--bg-header); color: #f8fafc;
    position: sticky; top: 0; z-index: 1000;
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 25px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.nav-links { display: flex; gap: 25px; align-items: center; }
.nav-links a { color: #f8fafc; text-decoration: none; font-weight: bold; font-size: 1.05em; transition: color 0.2s; }
.nav-links a:hover { color: var(--info); }
.nav-links a.active { color: #a7f3d0; }

.container {
    width: 85%; max-width: 1600px;
    margin: 40px auto; padding: 35px;
    background: var(--card-bg); border-radius: 20px;
    box-shadow: var(--shadow); box-sizing: border-box;
}

.container-ampliado { width: 95%; max-width: 1600px; margin: 0 auto; padding: 20px; }
.layout-columnas { display: flex; gap: 25px; align-items: flex-start; flex-wrap: wrap; }

.columna-derecha { flex: 1; min-width: 400px; display: flex; flex-direction: column; height: calc(100vh - 250px); }

/* Dropdown Navbar */
.nav-dropdown { position: relative; display: inline-block; padding-bottom: 15px; margin-bottom: -15px; }
.nav-dropbtn { background: transparent; color: #f8fafc; font-size: 1.05em; font-weight: bold; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; gap: 5px; transition: color 0.2s; }
.nav-dropdown:hover .nav-dropbtn { color: var(--info); }
.nav-dropdown-content { display: none; position: absolute; background-color: var(--bg-header); min-width: 200px; box-shadow: 0px 10px 25px rgba(0,0,0,0.5); z-index: 1001; border-radius: 8px; top: 100%; left: 0; border: 1px solid rgba(255,255,255,0.1); overflow: hidden; }
.nav-dropdown-content a { color: #f8fafc; padding: 14px 18px; display: block; font-size: 0.95em; transition: background 0.2s, padding-left 0.2s; border-bottom: 1px solid rgba(255,255,255,0.05); }
.nav-dropdown-content a:last-child { border-bottom: none; }
.nav-dropdown-content a:hover { background-color: rgba(255, 255, 255, 0.05); color: var(--primary-light); padding-left: 24px; }
.nav-dropdown:hover .nav-dropdown-content { display: block; animation: dropFade 0.2s ease-out; }
@keyframes dropFade { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   5. BOTONES Y BADGES
   ========================================= */
.btn {
    padding: 12px 22px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: bold; font-size: 0.95em; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-cancel { background-color: var(--text-muted); color: white; }
.btn-cancel:hover { background: #475569; }
.btn-warning { background-color: var(--warning); color: white; }
.btn-warning:hover { background-color: #d97706; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background-color: #64748b; color: white; border: none; }
.btn-secondary:hover { background-color: #475569; }
.btn-info { background: var(--info); color: white; }
.btn-info-custom { background-color: #17a2b8; color: white; border: none; }
.btn-purple { background: #8b5cf6; color: white; }

.btn-small, .btn-small-action { padding: 8px 15px; font-size: 0.9em; border-radius: 6px; cursor: pointer; }
.btn-secondary-small { background: #64748b; color: white; padding: 5px 10px; font-size: 0.8em; border: none; border-radius: 4px; cursor: pointer; transition: 0.2s; }
.btn-secondary-small:hover { background: #475569; }
.btn-px { padding: 6px 15px; }
.btn-sm { padding: 6px 10px; font-size: 0.9em; }

.btn-toggle-info { background: none; border: none; color: var(--text-muted); text-decoration: underline; cursor: pointer; font-size: 0.9em; padding: 5px; margin-top: 10px; transition: 0.2s; }
.btn-toggle-info:hover { color: var(--primary); }
.disabled-btn { opacity: 0.7; cursor: not-allowed; }

/* Botones full-width */
.btn-full-width { width: 100%; padding: 12px; font-weight: bold; box-sizing: border-box; }
.btn-full-width-disabled { width: 100%; padding: 12px; font-weight: bold; box-sizing: border-box; opacity: 0.7; }

/* Badges y Pills */
.badge { background: rgba(255,255,255,0.2); padding: 3px 8px; border-radius: 4px; font-size: 0.8em; font-weight: bold; margin-left: 8px; }
.badge-tipo { background-color: var(--bg-header); color: white; padding: 4px 10px; border-radius: 6px; font-size: 0.7em; margin-left: 10px; vertical-align: middle; }
.badge-status { padding: 4px 8px; border-radius: 4px; font-size: 0.8em; color: white; }
.badge-yes { background: var(--success); }
.badge-no { background: var(--danger); }
.badge-permiso { background: var(--bg-header); color: white; }
.badge-premium-star { color: #f59e0b; font-weight: bold; margin-left: 5px; }

.status-pill { padding: 4px 8px; border-radius: 20px; font-size: 0.8em; font-weight: bold; }
.pill-alumno { background: #e0f2fe; color: #0369a1; }
.pill-profe { background: #fef3c7; color: #92400e; }

.badge-contador { padding: 5px 10px; border-radius: 8px; font-weight: bold; font-size: 0.9em; }
.badge-profe { background: rgba(52, 152, 219, 0.1); color: var(--info); border: 1px solid rgba(52, 152, 219, 0.2); }
.badge-alumno { background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.2); }

/* =========================================
   6. FORMULARIOS E INPUTS
   ========================================= */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-weight: 600; font-size: 0.8em; color: var(--text-muted); margin-bottom: 4px; }
.form-control { width: 100%; padding: 8px 12px; border: 2px solid var(--border-color); border-radius: 8px; box-sizing: border-box; font-size: 0.95em; background: var(--bg-body); color: var(--text-main); transition: border-color 0.2s; }
.form-control:focus { border-color: var(--primary); outline: none; }

.checkbox-custom { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; }
.input-color-custom { height: 42px; padding: 2px; cursor: pointer; width: 100%; }
.input-file-sm { max-width: 250px; font-size: 0.85em; padding: 5px; }
.input-disabled { background: var(--bg-body); cursor: not-allowed; }

.form-group-separator { margin-top: 10px; border-top: 1px dashed var(--border-color); padding-top: 15px; }
.form-section-title { margin-top: 15px; padding-top: 15px; border-top: 2px solid var(--border-color); }
.form-section-title h3 { margin: 0 0 15px 0; color: var(--primary); }
.form-group-inline { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }

/* =========================================
   7. TABLAS, TOOLBARS Y FILTROS
   ========================================= */
.table-wrapper {
    max-height: 60vh; overflow-y: auto; overflow-x: auto;
    border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    background: var(--card-bg); border: 1px solid var(--border-color);
}
table { width: 100%; border-collapse: collapse; background: var(--card-bg); }
th {
    background: var(--bg-body); padding: 18px 15px; font-weight: 700;
    color: var(--text-muted); font-size: 0.8em; text-transform: uppercase;
    text-align: left; border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
td { padding: 18px 15px; border-top: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }
table tbody tr { cursor: pointer; transition: background-color 0.15s; }
table tbody tr:hover td { background-color: var(--bg-body); }
table tbody tr.selected { background-color: #e0f2fe !important; box-shadow: inset 4px 0 0 var(--primary); }
table tbody tr.selected td { color: #0369a1; }

.tabla-header { border-bottom: 2px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; }
.tabla-title { font-size: 1.3em; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.empty-table-msg { padding: 40px; text-align: center; }
.empty-table-warning { color: var(--warning); text-align: center; }

/* Toolbars Modernizados */
.table-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 20px; margin-bottom: 20px; width: 100%;
}
.table-toolbar-boxed {
    background: var(--card-bg); padding: 20px; border-radius: 12px;
    border: 1px solid var(--border-color); display: flex; gap: 15px; flex-wrap: wrap; align-items: center;
}

.search-input {
    flex: 1; min-width: 300px; max-width: 400px;
    padding: 10px 15px; border: 2px solid var(--border-color); border-radius: 6px;
    font-size: 1em; background: var(--bg-body); color: var(--text-main);
    outline: none; transition: 0.2s;
}
.search-input:focus { border-color: var(--primary); }

.toolbar-actions { display: flex; flex: 3; gap: 10px; flex-wrap: wrap; }
.toolbar-actions .btn { flex: 1; min-width: 130px; text-align: center; white-space: nowrap; padding: 10px 5px; }
.toolbar-actions-col { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.table-actions, .table-actions-row { display: flex; gap: 10px; }

/* Filtro Alfabético */
.alpha-filter, #filtro-letras {
    display: flex; flex-wrap: wrap; justify-content: center;
    width: 100%; gap: 4px; margin-bottom: 20px;
}
.alpha-btn {
    background: var(--bg-body); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 6px 2px; border-radius: 4px;
    cursor: pointer; font-weight: bold; transition: all 0.2s ease;
    flex: 1 1 0; min-width: 30px; text-align: center; box-sizing: border-box;
}
#filtro-letras .alpha-btn:first-child { flex: 2 1 0; min-width: 70px; }
.alpha-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.alpha-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 0 8px rgba(0,0,0,0.2); }

.select-filtro { min-width: 160px; cursor: pointer; background-color: var(--bg-body); }
.select-filtro:focus { border-color: var(--primary); outline: none; }

/* =========================================
   8. PÁGINA DE LOGIN
   ========================================= */
.login-body { background: var(--login-bg-gradient); background-size: 400% 400%; animation: gradientBG 15s ease infinite; justify-content: center; align-items: center; padding: 20px; }
@keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.login-container { width: 90%; max-width: 420px; }
.login-card { background: var(--card-bg); padding: 45px 35px; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); text-align: center; border: 1px solid rgba(255,255,255,0.05); }
.login-header h2 { margin: 0 0 10px 0; color: var(--text-main); font-size: 1.85em; font-weight: 700; }
.login-header p { margin: 0 0 35px 0; color: var(--text-muted); font-size: 1em; }
.form-group-login { text-align: left; margin-bottom: 22px; }
.form-group-login label { display: block; font-weight: 600; font-size: 0.9em; color: var(--text-muted); margin-bottom: 8px; }
.login-input { width: 100%; padding: 14px 18px; border: 2px solid var(--border-color); border-radius: 10px; box-sizing: border-box; font-size: 1.05em; transition: all 0.25s ease; background-color: var(--bg-body); color: var(--text-main); }
.login-input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15); outline: none; background-color: var(--card-bg); }
.login-btn { width: 100%; padding: 15px; background: var(--btn-gradient-login); color: white; border: none; border-radius: 10px; font-size: 1.15em; font-weight: 700; cursor: pointer; transition: all 0.3s ease; margin-top: 15px; box-shadow: var(--btn-shadow-login); text-transform: uppercase; letter-spacing: 0.5px; }
.login-btn:hover { background: linear-gradient(135deg, #1c75bc 0%, #155e96 100%); box-shadow: 0 10px 22px rgba(28, 117, 188, 0.5); transform: translateY(-2px); }
.login-btn:active { transform: translateY(1px) scale(0.98); box-shadow: 0 4px 10px rgba(28, 117, 188, 0.3); }
.login-card-footer { margin-top: 25px; font-size: 0.8em; color: var(--text-muted); line-height: 1.5; }
.login-copyright { margin-top: 35px; border-top: 1px solid var(--border-color); padding-top: 20px; font-size: 0.85em; color: var(--text-muted); opacity: 0.8; }
.login-error { background-color: #fee2e2; color: #b91c1c; padding: 12px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9em; font-weight: 600; border: 1px solid #fecaca; }

/* =========================================
   9. DASHBOARD Y TARJETAS INFORMATIVAS
   ========================================= */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; }
.dashboard-grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.dashboard-grid-modos { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 40px; }
.grid-secciones { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }

.stat-card {
    background: var(--card-bg); padding: 25px; border-radius: 16px;
    border: 1px solid var(--border-color); text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
.stat-val { font-size: 2.5em; font-weight: bold; color: var(--primary); }
.stat-val-success { font-size: 2em; font-weight: bold; color: var(--success); }
.dashboard-icon { font-size: 2.5em; margin-bottom: 10px; }

.info-box-dashboard { text-align: center; margin-bottom: 30px; }
.info-box-dashboard h1 { margin: 0; }
.info-box-dashboard p { color: var(--text-muted); }

/* Efecto Hover en cajas generales (Mis preguntas, Historial) */
main.container > div[style*="border-radius: 16px"] {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
main.container > div[style*="border-radius: 16px"]:hover {
    transform: translateY(-4px); box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05); 
}

/* Tarjetas de Sección BD */
.card-seccion { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 2px 4px rgba(0,0,0,0.02); transition: transform 0.2s, border-color 0.2s; }
.card-seccion:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); border-color: var(--primary); }
.card-seccion-title { background: rgba(52, 152, 219, 0.08); color: var(--primary); font-weight: 600; font-size: 0.85em; text-align: center; padding: 10px 8px; border-bottom: 1px solid rgba(52, 152, 219, 0.15); border-radius: 8px 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-seccion-content { padding: 15px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.total-numero { font-size: 1.8em; font-weight: 800; color: var(--text-main); line-height: 1; }
.total-texto { font-size: 0.75em; text-transform: uppercase; color: var(--text-muted); margin-top: 6px; letter-spacing: 0.5px; }

/* Contenedores de Secciones (Historial, Favoritas...) */
.seccion-dashboard-container { background: var(--card-bg); border: 1px solid var(--border-color); border-left: 5px solid var(--primary); border-right: 5px solid var(--primary); padding: 25px; border-radius: 16px; margin-bottom: 40px; }
.seccion-titulo-toggle { margin-top: 0; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.badge-toggle { font-size: 0.8em; color: var(--text-muted); padding: 5px 10px; background: var(--bg-body); border-radius: 8px; font-weight: normal; }

/* Alertas Dashboard */
.msg-vacio { color: var(--text-muted); text-align: center; margin: 0; padding: 10px; }
.aviso-warning { font-size: 0.85em; color: var(--warning); font-weight: bold; background: #fffbeb; padding: 10px; border-radius: 6px; border: 1px solid #fde68a; margin-top: 15px; }
.aviso-limite-diario { background-color: #fef2f2; border: 2px solid #f87171; color: #b91c1c; padding: 20px; border-radius: 12px; margin-bottom: 25px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.aviso-limite-diario h3 { margin-top: 0; font-size: 1.4em; }
.aviso-limite-diario p { margin-bottom: 0; font-size: 1.05em; }
.test-guardado-alerta { background-color: #fffbeb; border: 2px dashed #f59e0b; padding: 20px; border-radius: 12px; text-align: center; margin-bottom: 30px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.alerta-titulo-warning { margin-top: 0; color: #d97706; margin-bottom: 5px; }
.alerta-nombre-examen { margin-top: 0; margin-bottom: 15px; font-weight: bold; color: var(--text-main); font-size: 1.1em; }
.btn-continuar-test { display: inline-block; width: 100%; max-width: 400px; padding: 12px; font-weight: bold; box-sizing: border-box; white-space: normal; }
.sin-fallos-badge { display: block; width: 100%; background: var(--bg-body); padding: 12px; border-radius: 8px; color: var(--text-muted); font-weight: bold; text-align: center; box-sizing: border-box; }

.pregunta-fav-item {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.pregunta-fav-item:hover { transform: translateY(-4px); box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

/* Fila interactiva Exámenes Oficiales */
.row-examen-oficial { cursor: pointer; transition: 0.2s; }
.row-examen-oficial:hover { background: rgba(52, 152, 219, 0.05) !important; }
.row-examen-oficial.selected-row { background: rgba(52, 152, 219, 0.15) !important; border-left: 4px solid var(--primary) !important; }

/* =========================================
   10. SIMULADOR DE TEST (test.php y Resultados)
   ========================================= */
#contenedor-test { width: 85%; max-width: 1200px; margin: 10px auto; padding: 0 15px; }
.cabecera-test { display: flex; justify-content: space-between; align-items: center; background: var(--card-bg); padding: 10px 20px; border-radius: 16px; border: 1px solid var(--border-color); margin-bottom: 10px; box-shadow: var(--shadow); flex-wrap: wrap; gap: 10px; }

/* Indicadores de arriba (Aciertos, Fallos, Tiempo) */
.caja-indicador { display: flex; flex-direction: column; align-items: stretch; justify-content: center; border-radius: 12px; min-width: 180px; overflow: hidden; background-color: var(--card-bg); border: 2px solid var(--border-color); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.caja-indicador .titulo-caja { font-size: 0.9em; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; margin: 0; padding: 8px; color: white; text-align: center; }
.caja-indicador .valor-caja { font-size: 2em; font-weight: bold; font-family: monospace; line-height: 1; padding: 10px 15px; text-align: center; color: var(--text-main); background-color: var(--card-bg); }
.caja-azul { border-color: #3b82f6; } .caja-azul .titulo-caja { background-color: #3b82f6; } 
.caja-verde { border-color: #10b981; } .caja-verde .titulo-caja { background-color: #10b981; }
.caja-roja { border-color: #ef4444; } .caja-roja .titulo-caja { background-color: #ef4444; }
.caja-naranja { border-color: #f59e0b; } .caja-naranja .titulo-caja { background-color: #f59e0b; }

.botones-der { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.botones-der .fila-superior { display: flex; gap: 8px; }
.txt-total-container { font-size: 0.6em; opacity: 0.8; }
.btn-imprimir { background: #8b5cf6; color: white; font-size: 0.85em; flex: 1; padding: 8px; }
.btn-guardar { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; font-size: 0.85em; flex: 1; padding: 8px; }
.btn-finalizar-cabecera { width: 100%; font-size: 1.05em; font-weight: bold; padding: 12px; }
.btn-volver-res-cabecera { width: 100%; font-weight: bold; padding: 12px; }

/* Tarjeta Pregunta */
.pregunta-card { background: var(--card-bg); padding: 15px; border-radius: 16px; border: 1px solid var(--border-color); box-shadow: var(--shadow); position: relative; margin-bottom: 10px; width: 100%; box-sizing: border-box; }
.pregunta-meta { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); font-size: 0.9em; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.meta-acciones { display: flex; gap: 15px; align-items: center; }
.btn-icon { background: none; border: none; cursor: pointer; }
.btn-icon-copiar { font-size: 1.2em; }
.btn-icon-fav { font-size: 1.8em; line-height: 1; outline: none; }
.enunciado { font-size: 1.25em; font-weight: 600; line-height: 1.3; color: var(--text-main); margin-bottom: 15px; }

/* Opciones de Respuesta */
.opciones-grid { display: flex; flex-direction: column; gap: 8px; }
.opcion { display: flex; align-items: center; padding: 10px; background: var(--bg-body); border: 2px solid var(--border-color); border-radius: 10px; cursor: pointer; transition: all 0.2s; color: var(--text-main); font-size: 1em; }
.opcion:hover:not(.bloqueado) { border-color: var(--primary); background: var(--card-bg); }
.letra-opcion { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: #334155; color: white; border-radius: 50%; margin-right: 12px; font-weight: bold; flex-shrink: 0; }
.opcion.seleccionada { border-color: #fb923c; background: rgba(251, 146, 60, 0.15); }
.opcion.seleccionada .letra-opcion { background: #fb923c; }
.opcion.acertada { border-color: #22c55e; background: rgba(34, 197, 94, 0.05); }
.opcion.acertada .letra-opcion { background: #22c55e; }
.opcion.fallada { border-color: #ef4444; background: rgba(239, 68, 68, 0.05); }
.opcion.fallada .letra-opcion { background: #ef4444; }
.opcion.bloqueado { pointer-events: none; cursor: not-allowed; opacity: 0.8; }

.nav-buttons { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; }
.btn-nav { padding: 10px 20px; }
.label-auto-avance { cursor: pointer; font-size: 0.9em; color: var(--text-muted); display: flex; align-items: center; gap: 8px; user-select: none; }
.chk-auto-avance { transform: scale(1.2); }

/* Panel Inferior (Botonera 1-100) */
.panel-inferior { background: var(--card-bg); padding: 10px 10px 5px; border-radius: 16px; border: 1px solid var(--border-color); text-align: center; box-shadow: var(--shadow); overflow-x: auto; }
.grid-numeros { display: grid; grid-template-columns: repeat(25, 34px); gap: 6px; justify-content: center; margin-bottom: 5px; }
.btn-n { width: 100%; height: 34px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.85em; font-weight: bold; cursor: pointer; transition: all 0.1s; }
.btn-n.btn-especifica { background: #3498db; color: white; border-color: #2980b9; }
.btn-n.btn-comun { background: #bae6fd; color: #0c4a6e; border-color: #7dd3fc; }
.btn-n.sin-contestar { background: #cbd5e1 !important; color: #475569 !important; border-color: #94a3b8 !important; opacity: 1 !important; }
.btn-n.actual { box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.5); transform: scale(1.1); z-index: 2; border-color: #f39c12; }
.btn-n.respondida { background: #ffedd5 !important; color: #c2410c !important; border-color: #fdba74 !important; opacity: 1 !important; }
.btn-n.bien { background: #22c55e !important; color: white !important; border-color: #16a34a !important; opacity: 1 !important; }
.btn-n.mal { background: #ef4444 !important; color: white !important; border-color: #dc2626 !important; opacity: 1 !important; }

/* Leyenda del Test */
.leyenda-zonas { display: flex; justify-content: center; gap: 15px; font-size: 0.8em; color: var(--text-muted); font-weight: 600; flex-wrap: wrap; margin-top: 5px;}
.leyenda-item { display: flex; align-items: center; gap: 6px; }
.cuadrado-color { width: 12px; height: 12px; border-radius: 4px; }
.c-especifica { background: #3498db; border: 1px solid #2980b9; }
.c-comun { background: #bae6fd; border: 1px solid #7dd3fc; }
.c-sin-contestar { background: #cbd5e1; border: 1px solid #94a3b8; }

/* Pantalla de Resultados Finales */
.pantalla-resultados { padding: 20px; }
.res-titulo-principal { text-align: center; color: var(--text-main); font-size: 2.5em; margin-bottom: 15px; }
.res-contenedor-tarjeta { max-width: 700px; margin: 0 auto; background: var(--card-bg); padding: 40px; border-radius: 20px; border: 1px solid var(--border-color); box-shadow: 0 10px 30px rgba(0,0,0,0.1); text-align: center; }
.res-header { margin-bottom: 30px; }
.res-apto-texto { font-size: 3.5em; margin: 0; text-transform: uppercase; letter-spacing: 2px; }
.res-nota-texto { margin: 15px 0 0 0; color: var(--text-main); font-size: 1.6em; }
.res-nota-valor { font-weight: bold; color: #3498db; font-size: 1.5em; }
.res-nota-total { font-size: 0.7em; color: var(--text-muted); }
.res-separador { border: 0; border-top: 2px dashed var(--border-color); margin: 30px 0; }

.res-grid-estadisticas { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin-bottom: 35px; }
.res-tarjeta { padding: 20px 10px; border-radius: 16px; transition: transform 0.2s; border: 2px solid transparent; }
.res-tarjeta:hover { transform: translateY(-5px); }
.res-tarjeta.aciertos { background: rgba(16, 185, 129, 0.05); border-color: rgba(16, 185, 129, 0.3); }
.res-tarjeta.fallos { background: rgba(239, 68, 68, 0.05); border-color: rgba(239, 68, 68, 0.3); }
.res-tarjeta.blancos { background: var(--bg-body); border-color: var(--border-color); }
.res-tarjeta.tiempo { background: rgba(52, 152, 219, 0.05); border-color: rgba(52, 152, 219, 0.3); }
.res-valor { font-size: 2.5em; font-weight: bold; line-height: 1; }
.res-valor.tiempo { font-size: 2em; line-height: 1.25; color: #3498db; }
.res-valor.aciertos { color: var(--success); }
.res-valor.fallos { color: var(--danger); }
.res-valor.blancos { color: var(--text-main); }
.res-etiqueta { font-size: 0.9em; text-transform: uppercase; margin-top: 10px; font-weight: bold; }
.res-etiqueta.aciertos { color: var(--success); }
.res-etiqueta.fallos { color: var(--danger); }
.res-etiqueta.blancos { color: var(--text-muted); }
.res-etiqueta.tiempo { color: #3498db; }
.res-penalizacion { font-size: 0.85em; color: var(--danger); margin-top: 5px; font-weight: bold; opacity: 0.8; }

.res-acciones { display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.res-btn-accion { padding: 15px 30px; font-size: 1.1em; flex: 1; border-radius: 12px; font-weight: bold; transition: transform 0.2s; color: white; }
.res-btn-accion:hover { transform: scale(1.02); }
.btn-revisar { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 15px rgba(16,185,129,0.3); }
.btn-volver-menu { background: linear-gradient(135deg, #3b82f6, #2563eb); box-shadow: 0 4px 15px rgba(59,130,246,0.3); }

.error-historial { padding: 40px; text-align: center; font-family: sans-serif; }
.error-fatal { background: #fef2f2; color: #b91c1c; padding: 30px; margin: 20px; border-radius: 10px; font-family: sans-serif; }

/* =========================================
   11. EDITOR Y GESTIÓN DE EXÁMENES / IMPORTACIÓN
   ========================================= */
.page-header-flex { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; margin-bottom: 25px;}
.btn-mapa { background: #3b82f6; color: white; white-space: nowrap; font-size: 1.05em; padding: 10px 20px; box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3); }

/* Editor Header Box */
.editor-header-box { background: var(--bg-body); border: 2px solid var(--primary); padding: 20px; border-radius: 12px; margin-bottom: 20px; }
.editor-title-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; flex-wrap: wrap; gap: 15px; }
.editor-title { display: flex; align-items: center; gap: 10px; flex: 1; color: var(--text-main); margin: 0; }
.editor-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.counter-highlight { color: var(--warning); font-size: 1.2em; font-weight: bold; }
.scroll-editor { max-height: 400px; overflow-y: auto; }
.search-preguntas-box { background: var(--card-bg); padding: 25px; border-radius: 12px; border: 1px solid var(--border-color); }

/* PDFs y Archivos */
.pdf-adjunto-box { background: var(--card-bg); border: 1px dashed var(--primary); padding: 15px; border-radius: 8px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }
.pdf-info h4 { margin: 0 0 5px 0; color: var(--text-main); }
.pdf-info p { margin: 0; font-size: 0.85em; color: var(--text-muted); }
.btn-pdf-view { background: #10b981; color: white; text-decoration: none; }

/* Contadores y Listas */
.examenes-counter { font-size: 0.95rem; color: var(--text-main); background-color: var(--card-bg); padding: 12px 18px; border-radius: 8px; border-left: 4px solid var(--primary); border-top: 1px solid var(--border-color); border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); margin-bottom: 15px; display: inline-block; font-weight: 500; }
.examenes-counter strong { color: var(--primary); font-size: 1.05rem; }

/* Estilos de Importación (Extractor PDF) */
.import-box { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 25px; margin-bottom: 20px; }
.textarea-pdf { width: 100%; height: 250px; background: var(--bg-body); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; font-family: monospace; resize: vertical; outline: none; box-sizing: border-box; }
.textarea-pdf:focus { border-color: var(--primary); }

.q-row { display: flex; gap: 15px; padding: 15px; border-bottom: 1px solid var(--border-color); align-items: center; }
.q-row:nth-child(even) { background: rgba(0,0,0,0.02); }
.q-num { font-weight: bold; width: 40px; color: var(--primary); }
.q-text { flex: 1; font-size: 0.9em; line-height: 1.4; }
.q-text-warning { color: var(--warning); font-weight: bold; }
.q-text-normal { color: var(--text-main); font-weight: normal; }
.q-enlace-ok { color: var(--success); font-size: 0.85em; margin-top: 5px; }

.status-badge { padding: 5px 10px; border-radius: 6px; font-weight: bold; font-size: 0.85em; white-space: nowrap; }
.status-ok { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-fail { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.resultado-modal-item { background: var(--bg-body); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 10px; overflow: hidden; transition: 0.2s; }
.resultado-modal-item:hover { border-color: var(--primary); }

.pdf-upload-zone { background: rgba(52, 152, 219, 0.05); border: 2px dashed var(--primary); border-radius: 10px; padding: 20px; text-align: center; margin-bottom: 20px; transition: 0.3s; }
.pdf-upload-zone:hover { background: rgba(52, 152, 219, 0.1); }
.pdf-input { display: none; }
.pdf-label { cursor: pointer; display: inline-block; background: var(--primary); color: white; padding: 10px 20px; border-radius: 8px; font-weight: bold; }

.q-actions-container { display:flex; flex-direction:column; gap:5px; align-items:flex-end; }
.q-actions-mini { display: flex; gap: 4px; }
.btn-mini { background: transparent; border: 1px solid var(--border-color); padding: 4px 8px; font-size: 0.85em; color: var(--text-main); cursor: pointer; border-radius: 4px; transition: 0.2s;}
.btn-mini:hover { background: rgba(255,255,255,0.1); }
.btn-delete-row { color: #ef4444; border-color: rgba(239,68,68,0.3); }
.btn-cambiar { background: var(--bg-header); color: white; padding: 6px 12px; font-size: 0.85em; width: 100%; }
.btn-buscar-manual { padding: 6px 12px; font-size: 0.85em; width: 100%; }

.filtro-pendientes-container { background: rgba(245, 158, 11, 0.1); border: 1px dashed var(--warning); padding: 10px 15px; border-radius: 8px; margin-bottom: 15px; }
.filtro-pendientes-label { cursor: pointer; font-weight: bold; color: var(--warning); font-size: 0.9em; user-select: none; display: flex; align-items: center; gap: 8px; }

/* Ajuste específico para la tabla de Editor de Exámenes */
#tabla-preguntas-añadidas table td, 
#tabla-preguntas-añadidas table th { padding: 6px 10px !important; }
#tabla-preguntas-añadidas .btn { padding: 4px 8px !important; font-size: 0.85em !important; }


/* =========================================
   12. MODALES Y TOASTS
   ========================================= */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.8); z-index: 99999; justify-content: center;
    align-items: center; backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--card-bg); padding: 35px; border-radius: 15px; width: 90%;
    max-width: 750px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: 85vh; overflow-y: auto; position: relative; z-index: 100000;
}
.modal-sm, .modal-small { max-width: 400px; }
.modal-wrapper { max-width: 450px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.modal-header h2 { margin: 0; font-size: 1.3em; color: var(--text-main); }
.modal-body { overflow-y: auto; }
.btn-close-modal { background: rgba(239, 68, 68, 0.1); border: none; font-size: 1.2em; cursor: pointer; color: var(--danger); width: 35px; height: 35px; border-radius: 50%; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.btn-close-modal:hover { background: var(--danger); color: white; }

.modal-finalizar-content { max-width: 450px; text-align: center; }
.modal-icono { font-size: 3.5em; margin-bottom: 10px; }
.modal-titulo { color: var(--primary); margin-top: 0; }
.modal-texto { color: var(--text-main); font-size: 1.1em; line-height: 1.5; margin-bottom: 25px; }
.modal-acciones-flex { display: flex; gap: 15px; justify-content: center; margin-top: 25px; }
.modal-actions { margin-top: 20px; display: flex; gap: 15px; justify-content: flex-end; }

/* Modales de Confirmación Destructiva */
.modal-confirm { max-width: 450px !important; text-align: center; }
.modal-icon-danger { font-size: 3.5em; margin-bottom: 10px; }
.modal-text-confirm { margin: 20px 0; font-size: 1.1em; color: var(--text-main); line-height: 1.5; }
.texto-confirmacion-eliminar { color: var(--text-muted); font-size: 1.05em; margin-bottom: 25px; line-height: 1.5; }
.modal-actions-confirm { display: flex; gap: 15px; justify-content: center; margin-top: 30px; }
.warning-box { font-size: 0.85em; color: var(--warning); font-weight: bold; background: #fffbeb; padding: 10px; border-radius: 6px; border: 1px solid #fde68a; }

/* Toasts de Notificación */
#toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 999999; width: 90%; max-width: 420px; }
.toast { padding: 16px 25px; border-radius: 12px; color: white; font-weight: 600; margin-top: 12px; box-shadow: 0 12px 24px rgba(0,0,0,0.2); text-align: center; animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
.toast.warning { background: var(--warning); } /* Por si lo usas */

/* =========================================
   13. COMPONENTES EXTRA (Mapa, Drag&Drop, Tablón, Chat Fijo)
   ========================================= */

/* Mapa interactivo y Leyenda */
.tarjeta-tabla { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px; padding: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.mapa-wrapper { flex: 1; min-width: 400px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px; padding: 20px; text-align: center; position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

#mapa-tooltip {
    display: none; position: absolute; background: var(--text-main); color: var(--bg-body);
    padding: 6px 14px; border-radius: 6px; font-weight: bold; font-size: 0.9em; pointer-events: none; 
    z-index: 100; box-shadow: 0 4px 8px rgba(0,0,0,0.2); white-space: nowrap;
}

.comunidad-interactiva { fill: var(--bg-body); stroke: var(--text-muted); stroke-width: 50; cursor: pointer; transition: fill 0.2s ease, stroke 0.2s ease, transform 0.2s; transform-origin: center; }
.comunidad-interactiva.con-examenes { fill: #93c5fd; } 
.comunidad-interactiva.sin-examenes { fill: #fca5a5; } 
.comunidad-interactiva:hover { fill: var(--primary) !important; stroke: var(--text-main) !important; }
.comunidad-interactiva.activa { fill: #22c55e !important; stroke: var(--text-main) !important; }

.mapa-leyenda { display: flex; justify-content: center; gap: 20px; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-color); font-size: 0.9em; color: var(--text-main); }
.color-box { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border-color); }
.color-box.examenes { background-color: #93c5fd; }
.color-box.sin-examenes { background-color: #fca5a5; }
.color-box.seleccionada { background-color: #22c55e; }

/* Drag & Drop */
.draggable-row { transition: background-color 0.2s, border-top 0.2s; background-color: var(--card-bg); }
.draggable-row.dragging { opacity: 0.4; background-color: var(--border-color); }
.draggable-row.drag-over { border-top: 3px solid var(--primary); }
.drag-handle { cursor: grab; user-select: none; }
.drag-handle:active { cursor: grabbing; }

/* Tablón Animado */
@keyframes avisoTablon {
    0% { opacity: 1; transform: scale(1); box-shadow: 0 0 0px transparent; }
    50% { opacity: 0.5; transform: scale(1.02); box-shadow: 0 0 0px var(--warning); border-color: var(--warning); }
    100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0px transparent; }
}
.tablon-novedad { animation: avisoTablon 1.2s ease-in-out infinite; }

/* Corrección Chat Fijo */
#chat-widget, .chat-container {
    position: fixed !important; top: 80px !important; bottom: 20px !important; 
    max-height: calc(100vh - 100px) !important; height: auto !important; 
    border-radius: 12px; display: flex; flex-direction: column;
}
#chat-widget .contactos-lista, #chat-widget .mensajes-lista,
.chat-container .contactos-lista, .chat-container .mensajes-lista {
    overflow-y: auto !important;
}

/* =========================================
   14. MODO OSCURO (DARK MODE)
   ========================================= */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-header: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

body.dark-mode .welcome-box, body.dark-mode .stat-card { background-color: var(--card-bg); border-color: var(--border-color); }
body.dark-mode .stat-card h3 { color: var(--text-main); }
body.dark-mode table tbody tr.selected { background-color: #0c4a6e !important; box-shadow: inset 4px 0 0 #38bdf8; }
body.dark-mode table tbody tr.selected td { color: #e0f2fe !important; }

/* Sombras Profundas y Resaltes */
body.dark-mode .stat-card,
body.dark-mode .pregunta-fav-item,
body.dark-mode main.container > div[style*="border-radius: 16px"] {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -1px rgba(0, 0, 0, 0.5) !important;
}
body.dark-mode .stat-card:hover,
body.dark-mode .pregunta-fav-item:hover,
body.dark-mode main.container > div[style*="border-radius: 16px"]:hover {
    transform: translateY(-4px); 
    box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.9), 0 4px 6px -2px rgba(0, 0, 0, 0.7) !important; 
    border-color: rgba(255, 255, 255, 0.15) !important; 
}

/* Opciones de Test Oscuras */
body.dark-mode .letra-opcion { background: #475569; color: #f8fafc; }
body.dark-mode .opcion.seleccionada .letra-opcion { background: #ea580c; }
body.dark-mode .btn-n.respondida { background: #7c2d12 !important; color: #fdba74 !important; border-color: #9a3412 !important; opacity: 1 !important; }
body.dark-mode .opcion.acertada .letra-opcion { background: #22c55e; }
body.dark-mode .opcion.fallada .letra-opcion { background: #ef4444; }

body.dark-mode input[type="date"] { color-scheme: dark; }
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

/* Mapa Test Oscuro */
body.dark-mode .btn-n.btn-especifica { background: #0284c7; color: #f0f9ff; border-color: #0369a1; }
body.dark-mode .btn-n.btn-comun { background: #075985; color: #e0f2fe; border-color: #0c4a6e; }
body.dark-mode .btn-n.sin-contestar { background: #334155 !important; color: #94a3b8 !important; border-color: #1e293b !important; }
body.dark-mode .c-especifica { background: #0284c7; border-color: #0369a1; }
body.dark-mode .c-comun { background: #075985; border-color: #0c4a6e; }
body.dark-mode .c-sin-contestar { background: #334155; border-color: #1e293b; }

/* Botones y Alertas */
body.dark-mode .btn-warning { background-color: #9a3412; color: #ffffff; border: 1px solid #7c2d12; }
body.dark-mode .btn-warning:hover { background-color: #7c2d12; }
body.dark-mode .test-guardado-alerta { background-color: #2d1d00; border-color: #9a3412; box-shadow: 0 4px 15px rgba(0,0,0,0.4); }
body.dark-mode .test-guardado-alerta h3 { color: #fbbf24 !important; }

/* Scroll y Botón Flotante */
body.dark-mode ::-webkit-scrollbar-track { background: var(--bg-header); }
body.dark-mode ::-webkit-scrollbar-thumb { background: #0284c7; }

#btn-dark-mode {
    position: fixed; bottom: 20px; left: 20px; width: 55px; height: 55px; border-radius: 50%; 
    background: #1e293b; color: #f8fafc; border: 2px solid #3b82f6; font-size: 26px; cursor: pointer; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.4); z-index: 99999; display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, background 0.3s;
}
#btn-dark-mode:hover { transform: scale(1.1); }
body.dark-mode #btn-dark-mode { background: #f59e0b; border-color: #d97706; color: #0f172a; text-shadow: 0 0 2px rgba(255,255,255,0.2); }

/* Mapa Oscuro (Regiones) */
body.dark-mode .comunidad-interactiva { fill: #1e293b; stroke: #475569; }
body.dark-mode .comunidad-interactiva.con-examenes { fill: #1e3a8a; } 
body.dark-mode .comunidad-interactiva.sin-examenes { fill: #7f1d1d; } 
body.dark-mode .comunidad-interactiva:hover { fill: var(--primary) !important; stroke: #f1f5f9 !important; }
body.dark-mode .comunidad-interactiva.activa { fill: #22c55e !important; stroke: #f1f5f9 !important; }
body.dark-mode .color-box.examenes { background-color: #1e3a8a; }
body.dark-mode .color-box.sin-examenes { background-color: #7f1d1d; }


/* =========================================
   PERFIL: SUBIDA DE FOTO Y TOGGLE PREMIUM
   ========================================= */

/* Subida de foto circular */
.profile-upload-container {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-body);
    border: 3px dashed var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.05);
}
.profile-upload-container:hover {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.05);
}
.profile-file-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; z-index: 10;
}
.profile-upload-preview {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    color: var(--text-muted); background-size: cover; background-position: center;
    transition: 0.2s;
}
.profile-upload-preview.has-image { border: none; }
.profile-upload-preview.has-image .upload-icon,
.profile-upload-preview.has-image .upload-text {
    opacity: 0; /* Oculta el texto si hay imagen */
    transition: 0.2s;
}
.profile-upload-container:hover .profile-upload-preview.has-image::after {
    content: "Cambiar"; position: absolute; background: rgba(0,0,0,0.6);
    color: white; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-weight: bold;
}
.upload-icon { font-size: 2em; margin-bottom: 5px; }
.upload-text { font-size: 0.8em; font-weight: bold; }

/* Tarjeta Premium Toggle */
.premium-card-toggle input { display: none; }
.premium-card-content {
    display: flex; align-items: center; gap: 15px; padding: 15px;
    background: var(--bg-body); border: 2px solid var(--border-color);
    border-radius: 12px; cursor: pointer; transition: all 0.3s ease;
}
.premium-card-content .premium-icon { font-size: 1.8em; filter: grayscale(1); transition: 0.3s; }
.premium-card-content .premium-text { flex: 1; display: flex; flex-direction: column; }
.premium-card-content .premium-text strong { color: var(--text-main); font-size: 1.05em; transition: 0.3s; }
.premium-card-content .premium-text span { font-size: 0.8em; color: var(--text-muted); }
.premium-switch {
    width: 45px; height: 24px; background: #cbd5e1; border-radius: 20px;
    position: relative; transition: 0.3s;
}
.premium-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    background: white; border-radius: 50%; transition: 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Estado Activado (Premium) */
.premium-card-toggle input:checked + .premium-card-content {
    background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.02));
    border-color: #f59e0b; box-shadow: 0 4px 15px rgba(245,158,11,0.15);
}
.premium-card-toggle input:checked + .premium-card-content .premium-icon { filter: grayscale(0); transform: scale(1.1); }
.premium-card-toggle input:checked + .premium-card-content .premium-text strong { color: #d97706; }
.premium-card-toggle input:checked + .premium-card-content .premium-switch { background: #f59e0b; }
.premium-card-toggle input:checked + .premium-card-content .premium-switch::after { left: 24px; }


/* =========================================
   15. RESPONSIVE Y MEDIA QUERIES (Siempre al final)
   ========================================= */

@media print { 
    .no-print { display: none !important; } 
}

/* 📱 TABLETS (PANTALLAS MEDIANAS: 769px - 1024px) */
@media (max-width: 1024px) {
    /* Contenedores Principales */
    .container { width: 96% !important; padding: 25px; margin: 25px auto; }
    
    /* Grids */
    .dashboard-grid, .dashboard-grid-stats, .dashboard-grid-modos { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 15px; }
    .stat-card { padding: 20px; }
    
    /* Barras de herramientas */
    .table-toolbar, .table-toolbar-boxed { flex-direction: column; align-items: stretch; gap: 15px; }
    .search-input { max-width: 100%; width: 100%; }
    .table-actions-row, .toolbar-actions, .toolbar-actions-col { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: flex-end; flex-direction: row; }
    
    /* Editor de Exámenes */
    .editor-title-row { flex-direction: column; align-items: flex-start; }
    
    /* Tablas y Test */
    th, td { padding: 12px 10px; font-size: 0.9em; }
    .grid-numeros { grid-template-columns: repeat(auto-fit, minmax(32px, 1fr)); }
    #contenedor-test { width: 95%; }
}

/* 📱 MÓVILES (PANTALLAS PEQUEÑAS: HASTA 768px) */
@media (max-width: 768px) {
    /* Layout Base */
    .form-grid { grid-template-columns: 1fr; }
    .container { width: 95% !important; padding: 15px; margin: 10px auto; }
    
    /* Header ultra compacto */
    .top-bar { flex-direction: column; gap: 8px; padding: 10px; }
    .nav-links { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 5px; }
    .nav-links a { padding: 6px 10px; font-size: 0.9em; }
    .user-info { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-size: 0.85em; }
    .user-info span[style*="margin: 0 10px"] { display: none !important; }

    /* Modales adaptados al móvil */
    .modal-content { padding: 20px; width: 95%; max-height: 90vh; }
    .modal-acciones-flex { flex-direction: column; gap: 10px; }
    
    /* Botones y formularios en bloque */
    .toolbar-actions .btn { width: 100% !important; }
    .form-group-inline { flex-direction: column; align-items: stretch; }

    /* Ocultar elementos innecesarios durante el examen (test.php) */
    body.page-test .top-bar { display: none !important; }
    body.page-test #btn-dark-mode { display: none !important; }
    body.page-test #btn-toggle-chat, body.page-test #chat-widget, body.page-test .chat-container, body.page-test #chat-flotante { display: none !important; }

    /* Layout Test Móvil */
    body.page-test #contenedor-test { margin-top: 5px; padding: 0 5px; width: 100%; }
    .cabecera-test { flex-direction: row; padding: 8px; gap: 8px; }
    .caja-indicador { flex: 1; min-width: 45%; margin-bottom: 0; }
    .caja-indicador .valor-caja { font-size: 1.3em !important; padding: 5px !important; }
    .botones-der { width: 100%; flex-direction: row; gap: 8px; }
    .botones-der .btn { flex: 1; padding: 10px; font-size: 0.9em; }
    
    .test-guardado-alerta .btn { box-sizing: border-box; white-space: normal; height: auto; line-height: 1.4; }
}