/* ==========================================================================
   VARIABLES DE DISEÑO (SaaS Premium Academy)
   ========================================================================== */
:root {
    --bg-main: #f1f5f9;         /* Gris claro de fondo sutil */
    --bg-card: #ffffff;         /* Blanco puro para tarjetas */
    --text-main: #1e293b;       /* Texto principal */
    --text-muted: #64748b;      /* Gris secundario para descripciones */
    --border-color: #e2e8f0;    /* Bordes sutiles modernos */
    
    /* Paleta de Colores de Marca y Estados */
    --azul-marino: #0f172a;     /* Azul Marino Profundo Premium */
    --primary: #2563eb;         /* Azul Eléctrico Corporativo */
    --primary-hover: #1d4ed8;
    --success: #28a745;         /* Verde Éxito */
    --success-hover: #218838;
    --warning: #f59e0b;         /* Ámbar / Notas */
    --danger: #dc3545;          /* Rojo / Salir */
    
    /* Perfiles de Usuario */
    --bg-sergio: #1e3a8a;
    --bg-jairo: #334155;
}

/* ==========================================================================
   RESET Y ESTILOS GENERALES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

main {
    padding: 20px;
    min-height: 75vh;
}

.container {
    max-width: 1200px;
    margin: auto;
}

/* Forzar el cambio de Negro a Azul Marino en elementos globales de Bootstrap */
.bg-dark, .card-header.bg-dark {
    background-color: var(--azul-marino) !important;
}

/* Elementos de Texto */
h1 { 
    color: var(--azul-marino); 
    margin-bottom: 10px; 
}
p { color: var(--text-muted); }

.badge-2026 {
    display: inline-block;
    background-color: var(--primary);
    color: #ffffff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    margin-bottom: 15px;
    text-transform: uppercase;
}

/* ==========================================================================
   HEADER PRINCIPAL: BARRA PREMIUM AZUL MARINO
   ========================================================================== */
.header-principal {
    background-color: var(--azul-marino) !important;
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.contenedor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.nav-principal {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-nav {
    color: #cbd5e1;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s ease;
}

.btn-nav:hover, .btn-nav.active {
    color: #ffffff !important;
    background-color: var(--primary) !important;
}

/* Bloque de Sesión de Usuario */
.right-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: #334155;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.btn-logout {
    font-size: 12px;
    color: #f87171;
    text-decoration: none;
    font-weight: bold;
    padding: 6px 10px;
    transition: color 0.2s ease;
}

.btn-logout:hover {
    color: #ef4444;
}

/* ==========================================================================
   VISTAS DE ACCESO (LOGIN)
   ========================================================================== */
.login-container {
    max-width: 500px;
    margin: 100px auto;
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 15px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.login-container h2 {
    color: var(--azul-marino);
    margin-bottom: 10px;
}

.login-container p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.login-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.btn-login-sergio {
    flex: 1;
    padding: 20px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    font-weight: bold;
    border-radius: 8px;
    text-align: center;
    transition: background 0.2s ease;
}
.btn-login-sergio:hover { background-color: var(--primary-hover); }

.btn-login-jairo {
    flex: 1;
    padding: 20px;
    background: #7c3aed;
    color: white;
    text-decoration: none;
    font-weight: bold;
    border-radius: 8px;
    text-align: center;
    transition: filter 0.2s ease;
}
.btn-login-jairo:hover { filter: brightness(90%); }

/* ==========================================================================
   TARJETAS Y BOTONES DEL MENÚ PRINCIPAL (WELCOME CARD)
   ========================================================================== */
.card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.welcome-card {
    background: var(--bg-card);
    max-width: 850px;
    margin: 40px auto;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.welcome-title {
    color: #1e3a8a;
    margin-top: 0;
    margin-bottom: 5px;
}

.welcome-subtitle {
    color: #475569;
    margin-bottom: 20px;
}

.grid-home {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 25px;
}

.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 20px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.card-blue { border-top: 4px solid #3b82f6; }
.card-purple { border-top: 4px solid #a855f7; }
.card-amber { border-top: 4px solid #f59e0b; }
.card-green { border-top: 4px solid #22c55e; }

.menu-card {
    text-align: center;
    padding: 50px 20px;
}

.btn {
    display: block;
    width: 100%;
    padding: 16px 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    text-decoration: none;
    color: #ffffff;
    font-weight: bold;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(90%);
}

.btn-success { background-color: var(--success); }
.btn-casos { background-color: #fd7e14; }
.btn-teoria { background-color: #6f42c1; }

.btn-back {
    display: inline-block;
    width: auto;
    background-color: #6c757d;
    padding: 10px 25px;
    margin-top: 20px;
}

.main-btn {
    font-size: 1.1em;
    padding: 18px;
    margin-bottom: 10px;
    display: block;
    text-decoration: none;
    border-radius: 10px;
    text-align: center;
    color: white;
    font-weight: bold;
}

/* ==========================================================================
   DASHBOARD: REJILLA DE BLOQUES Y SIMULACRO
   ========================================================================== */
.banner-simulacro {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #e7f3ff 0%, #d2e7ff 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid #b6d4fe;
    text-align: center;
}

.btn-simulacro {
    background: var(--success);
    color: white !important;
    padding: 15px 30px;
    display: inline-block;
    text-decoration: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.2em;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}
.btn-simulacro:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
}

.grid-temas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.bloque-card {
    border: 1px solid var(--border-color) !important;
    background: var(--bg-card) !important;
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02) !important;
    text-align: left !important;
}

.bloque-titulo {
    color: var(--primary);
    font-size: 1.15em;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wrapper-tests {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.pildora-test {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
    min-width: 90px;
    flex: 1 1 calc(25% - 10px); 
}

.btn-test-link {
    background: var(--primary);
    color: white !important;
    padding: 6px 12px;
    font-size: 0.85em;
    font-weight: bold;
    text-decoration: none;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 6px;
    transition: background 0.2s ease;
}
.btn-test-link:hover { background: var(--primary-hover); }

.puntos-historial {
    font-size: 0.75em;
    font-weight: bold;
    margin-right: 4px;
}

/* ==========================================================================
   EJECUCIÓN DE EXAMEN (MOTOR DE TEST)
   ========================================================================== */
.marcador {
    position: sticky;
    top: 10px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-bottom: 25px;
    color: var(--azul-marino);
    font-weight: bold;
}

.btn-finalizar-top {
    background-color: var(--primary) !important;
    color: white !important;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}
.btn-finalizar-top:hover { background-color: var(--primary-hover) !important; }

.pregunta-titulo {
    font-size: 1.1em;
    font-weight: bold;
    display: block;
    margin-bottom: 20px;
    color: var(--text-main);
}

.opcion {
    padding: 12px 15px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    margin-top: 8px;
    border-radius: 8px;
    background: var(--bg-card);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.opcion:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Estados de Validación de Respuestas */
.correcta {
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
    color: #155724 !important;
    font-weight: bold;
}

.incorrecta {
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
    color: #721c24 !important;
}

.correcta-blanca {
    background-color: #fff3cd !important;
    border: 2px solid #ffeeba !important;
    color: #856404 !important;
    font-weight: bold;
}

.info-extra {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ced4da;
    font-size: 0.9em;
}
.info-extra strong { color: var(--text-main); }

/* ==========================================================================
   ESTILOS RENDERIZADO MARKDOWN (Temario de Teoría y Tablas de Simulacro)
   ========================================================================== */
.contenido-markdown {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #1e293b;
    text-align: left;
}

.contenido-markdown h1, .contenido-markdown h2, .contenido-markdown h3 {
    color: var(--primary);
    margin-top: 1.8rem;
    margin-bottom: 1rem;
    font-weight: 600;
}
.contenido-markdown h1 { font-size: 1.8rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
.contenido-markdown h2 { font-size: 1.4rem; }

.contenido-markdown table {
    width: 100%;
    margin: 1.5rem 0; /* Ajustado ligeramente el margen */
    border-collapse: collapse;
    background-color: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.contenido-markdown table th {
    background-color: #f8fafc;
    color: #334155;
    font-weight: 600;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
}
.contenido-markdown table td {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}
.contenido-markdown table tr:nth-child(even) { background-color: #f8fafc; }

.contenido-markdown blockquote {
    background-color: #fef3c7;
    border-left: 4px solid var(--warning);
    padding: 12px 16px;
    margin: 1.5rem 0;
    border-radius: 0 6px 6px 0;
    color: #78350f;
}
.contenido-markdown blockquote p { margin-bottom: 0; }

.list-group-item.active {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.sidebar-teoria {
    max-height: 75vh;
    overflow-y: auto;
}

footer { 
    background-color: #e2e8f0; 
    text-align: center; 
    padding: 15px; 
    font-size: 13px; 
    color: #64748b; 
    margin-top: 40px; 
}

/* ==========================================================================
   MEDIA QUERIES (SOPORTE RESPONSIVE & REORDENACIÓN EN MÓVIL)
   ========================================================================== */
.aviso-construccion {
    background-color: #fff3cd;
    color: #856404;
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #ffeeba;
    text-align: center;
}

@media (max-width: 768px) {
    body { padding: 0px; }
    main { padding: 12px; }
    .grid-temas { grid-template-columns: 1fr; }
    .pildora-test { flex: 1 1 calc(50% - 10px); }
    
    /* 📱 REORDENACIÓN DE TABLAS EN MENÚ 4 (SIMULACRO) */
    /* Forzamos a que el contenedor markdown ordene sus elementos de forma vertical */
    .contenido-markdown {
        display: flex;
        flex-direction: column;
    }
    
    /* Hacemos que cada tabla sea un bloque responsive independiente */
    .contenido-markdown table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        margin: 10px 0; /* Espaciado vertical más limpio para móvil */
    }
    
    .contenido-markdown table th,
    .contenido-markdown table td {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    
    /* 📱 ESTRATEGIA DE REORDENACIÓN EN HEADER */
    .contenedor-header {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .right-nav {
        order: -1 !important;
        width: 100%;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #334155;
        padding-bottom: 8px;
    }

    .nav-principal {
        justify-content: center;
        width: 100%;
    }

    .btn-nav {
        flex: 1 1 calc(50% - 8px);
        text-align: center;
    }

    .grid-home { 
        grid-template-columns: 1fr; 
    }
}