/* =========================================
   1. CONFIGURACIÓN BASE Y VARIABLES 
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap');

:root {
    --primary: #2b6cb0; /* Azul Institucional */
    --primary-hover: #2c5282;
    --primary-gradient: linear-gradient(180deg, #2b6cb0 0%, #2c5282 100%);
    --secondary: #c53030; /* Rojo Institucional */
    --white: #ffffff;
    --light-bg: #f7fafc; /* Fondo suave */
    --border-color: #d1d9e0;
    --text-dark: #333333;
    --text-muted: #666666;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-strong: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Open Sans', Arial, sans-serif;
    background-color: var(--light-bg);
    background-image: radial-gradient(#dce6ed 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-dark);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* GLOBAL RESPONSIVE FIXES (SENIOR PATCH) */
img, iframe, video, canvas { max-width: 100%; height: auto; }
input, select, textarea { max-width: 100%; }

/* Clase específica para el layout con sidebar lateral (Admin) */
body.layout-flex {
    display: flex; /* 💡 MEJORA: Usar Flexbox para un layout más robusto y moderno. */
}

/* El contenido principal ahora está a la derecha */
.main-content {
    flex-grow: 1; /* Ocupa el espacio restante */
    min-height: 100vh;
    padding-bottom: 60px; /* Espacio para el footer */
    position: relative;
    width: calc(100% - var(--sidebar-width)); /* Previene que el contenido se desborde en algunos casos */
}

/* Sidebar lateral izquierda */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0; /* Evita que el sidebar se encoja */
    background: #1a1a1a; /* Fondo oscuro institucional */
    height: 100vh; /* Ocupa toda la altura de la ventana */
    position: sticky; /* Se mantiene fijo al hacer scroll en el main-content */
    top: 0;
    overflow-y: auto; /* Scroll independiente para menús largos */
    overflow-x: hidden; /* Evita scroll horizontal feo */
    z-index: 1000;
    border-right: 3px solid var(--primary);
}

/* Estilo de Scrollbar para Sidebar (Evita línea blanca cortada) */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: #1a1a1a; }
.sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.container {
    padding: 30px;
    max-width: 100%;
}

/* 💡 FOOTER - Ajustado para el nuevo layout Flex */
footer.platform-footer {
    position: absolute; /* Se posiciona relativo al .main-content */
    bottom: 0; /* Se pega al final */
    left: 0; /* Abarca todo el ancho del .main-content */
    right: 0; /* Abarca todo el ancho del .main-content */
    background: #e9eff3;
    box-shadow: 0 -1px 0 var(--border-color);
    z-index: 100;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 15px;
}

/* =========================================
   2. LAYOUT Y UTILIDADES
   ========================================= */

.auth-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 100vh; /* Asegura centrado vertical en Login/Registro */
}

/* =========================================
   3. COMPONENTES DE UI
   ========================================= */

.btn, button[type="submit"] {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: var(--primary-gradient);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid #004a80;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    width: auto;
}

.btn:hover, button[type="submit"]:hover {
    background: #004a80;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-sm { padding: 4px 10px; font-size: 0.75rem; margin-right: 5px; }
.btn-danger { background: linear-gradient(180deg, #d9534f 0%, #c9302c 100%); border-color: #ac2925; }
.btn-success { background: linear-gradient(180deg, #5cb85c 0%, #449d44 100%); border-color: #398439; }
.btn-secondary { background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%); color: #333; border-color: #ccc; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }

.link-action { display: block; margin-top: 15px; color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.link-action:hover { text-decoration: underline; }

.form-box {
    background: var(--white);
    padding: 2rem;
    width: 100%;
    max-width: 450px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    text-align: center;
    margin-bottom: 30px;
}

.input-group { margin-bottom: 1rem; text-align: left; }
label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: 700; color: #444; }
input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    background-color: #fff;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 4px rgba(0, 86, 145, 0.2);
}

.badge { padding: 3px 8px; border-radius: 3px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-active { background: #e6f4ea; color: #1e7e34; border: 1px solid #c3e6cb; }
.badge-pending { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.badge-blocked { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* =========================================
   4. HEADER Y NAVEGACIÓN (ESTILO SMART SCHOOLS)
   ========================================= */

header {
    background: #ffffff; 
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.logo-container {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    font-size: 1.2rem;
    line-height: 1.3;
    font-weight: 800;
    color: var(--secondary) !important; /* Rojo Institucional */
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: -1px;
}
.logo span { color: var(--primary); } /* Azul Institucional */

/* NAV VERTICAL DERECHA */
.admin-nav {
    display: flex; 
    flex-direction: column;
    gap: 5px;
    padding: 15px;
    background: transparent;
    overflow: visible;
}

.admin-nav a, .nav-dropdown-btn {
    text-align: left;
    white-space: nowrap; 
    padding: 12px 15px; 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: #bbbbbb;
    background: transparent;
    text-decoration: none !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    width: 100%;
}

.admin-nav a i, .nav-dropdown-btn i { color: inherit; font-size: 1.1rem; }

.admin-nav a:hover, .admin-nav a.active, .nav-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
}

.admin-nav a.active {
    background: var(--primary);
    color: #ffffff !important;
}

/* 🚀 MENÚ DESPLEGABLE PROFESIONAL (ACORDEÓN) */
.nav-item-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
}

.dropdown-content {
    display: none; /* Se activa con hover en sidebar */
    background: rgba(0,0,0,0.3);
    padding: 5px 0 5px 20px;
    list-style: none;
}

.dropdown-content li a {
    background: transparent;
    box-shadow: none;
    padding: 10px 15px;
    font-size: 0.8rem;
    color: #999 !important;
}

.dropdown-content li a:hover {
    color: #fff !important;
}

/* =========================================
   5. TARJETAS Y GRID (CONTENEDORES)
   ========================================= */

.dashboard-widgets {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.course-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 20px; 
    margin-top: 15px;
}

.course-card-premium, .stat-card, .stat-card-wide, .table-responsive {
    background: var(--white);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
}

/* TABLAS RESPONSIVAS (CRÍTICO PARA ADMIN EN MÓVIL) */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Suavidad nativa en iOS */
}

/* =========================================
   6. PANEL ADMINISTRADOR (REJILLA DE MÉTRICAS)
   ========================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    border-top: none;
    border-left: 5px solid var(--primary);
    display: flex;
    flex-direction: column;
}

.stat-card h3 { font-size: 1.8rem; color: var(--text-dark); margin: 0; font-weight: 800; }
.stat-card p { font-size: 0.75rem; text-transform: none; font-weight: 600; color: var(--text-muted); margin-top: 5px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px; text-align: left; font-size: 0.85rem; border-bottom: 1px solid #f0f0f0; }
th { background-color: #fafafa; color: var(--text-dark); font-weight: 700; border-bottom: 2px solid var(--border-color); }

/* RESPONSIVE */
@media (max-width: 1024px) {
    :root { --sidebar-width: 70px; }
    .sidebar span, .logo span, .sidebar .logo { display: none; }
    .admin-nav a { justify-content: center; padding: 15px 0; }
    .admin-nav a i { margin: 0; font-size: 1.4rem; }
    .main-content { width: calc(100% - var(--sidebar-width)); }
    .dashboard-widgets { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    body.layout-flex { display: flex; flex-direction: column; }
    
    /* 1. SIDEBAR: SE CONVIERTE EN BARRA SUPERIOR STICKY (TIPO APP) */
    .sidebar { 
        width: 100%; 
        height: auto;
        order: 1; 
        position: sticky; /* Se queda pegada arriba al hacer scroll */
        top: 0;
        border-right: none; 
        border-bottom: 3px solid var(--primary);
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    .sidebar span { display: inline; } /* Restaurar texto en móvil para mejor UX */
    
    .main-content { order: 2; margin-left: 0; padding-bottom: 0; }
    
    /* 2. NAVEGACIÓN: SCROLL HORIZONTAL FLUIDO */
    .admin-nav { 
        flex-direction: row; 
        overflow-x: auto; 
        white-space: nowrap; /* Evita que los iconos bajen de línea */
        padding: 10px 5px;
        -webkit-overflow-scrolling: touch;
    }
    .admin-nav a { 
        flex-direction: column; /* Icono arriba, texto abajo */
        padding: 8px 15px; 
        font-size: 0.7rem; 
        text-align: center;
        flex: 0 0 auto; /* No encoger elementos */
    }
    .admin-nav a i { margin-bottom: 5px; font-size: 1.2rem; }

    /* 3. GRID Y CONTENEDORES: UNA SOLA COLUMNA */
    .stats-grid { grid-template-columns: 1fr; gap: 15px; } 
    .dashboard-widgets { display: flex; flex-direction: column; }
    .container { padding: 15px; margin-bottom: 20px; }
    
    /* 4. FOOTER: DEJA DE FLOTAR PARA NO ESTORBAR */
    footer.platform-footer { 
        position: static !important; 
        width: 100%; 
        margin-top: 20px;
        border-top: 1px solid #ddd;
        padding-bottom: 30px; /* Espacio extra al final */
    }
}

/* =========================================
   7. ESTILOS LOGIN / REGISTER (MODERNO & GLOW)
   ========================================= */
body.auth-body {
    background: #0f172a; /* Fondo oscuro profundo */
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.auth-body header {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

body.auth-body .logo {
    color: #fff !important;
    text-shadow: 0 0 15px rgba(0, 114, 188, 0.8); /* Logo iluminado */
}

body.auth-body .auth-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

body.auth-body .form-box {
    background: rgba(30, 41, 59, 0.6); /* Cristal oscuro */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    /* EFECTO RELIEVE Y BORDE ILUMINADO */
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05), 
        0 0 30px rgba(0, 114, 188, 0.2), 
        0 20px 50px rgba(0, 0, 0, 0.5);
    color: #fff;
    max-width: 420px;
    transform: translateY(0);
    transition: all 0.3s ease;
    border-top: none !important; /* Reseteo de estilos viejos */
}

body.auth-body .form-box:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.1), 
        0 0 40px rgba(0, 114, 188, 0.4), 
        0 30px 60px rgba(0, 0, 0, 0.6);
}

body.auth-body h2 {
    color: #fff !important;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body.auth-body label {
    color: #cbd5e1;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.auth-body input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 10px;
    padding: 14px;
    transition: 0.3s;
}

body.auth-body input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 114, 188, 0.25);
    background: rgba(15, 23, 42, 0.9);
}

body.auth-body .btn {
    background: linear-gradient(135deg, #0072bc 0%, #005691 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 114, 188, 0.4);
    font-size: 1rem;
    padding: 14px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

body.auth-body .btn:hover {
    box-shadow: 0 0 25px rgba(0, 114, 188, 0.6);
    transform: scale(1.02);
}

body.auth-body .platform-footer {
    background: transparent;
    border-top: none;
    color: rgba(255, 255, 255, 0.3);
    position: relative !important;
    left: 0;
    box-shadow: none;
}