/* ==========================================
   1. RESET Y VARIABLES GLOBALES
   ================================---------- */
:root {
    --bg-primary: #F4F6F8;
    --bg-card: #FFFFFF;
    --text-main: #1E293B;
    --text-secondary: #64748B;
    --accent-color: #6E8A3D; /* Verde corporativo elegante */
    --accent-hover: #5A7232;
    --border-color: #E2E8F0;
    --border-strong: #CBD5E1;
    --sidebar-bg: #FFFFFF;
    --danger-bg: #FCEBEB;
    --danger-text: #A32D2D;
    --radius: 10px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
}

/* ==========================================
   2. DISEÑO DE AUTENTICACIÓN (LOGIN)
   ================================---------- */
.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-box {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--text-main);
}

.auth-logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(110, 138, 61, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

/* ==========================================
   3. LAYOUT DEL SISTEMA (DASHBOARD & SIDEBAR)
   ================================---------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
}

.sidebar-brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-menu {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.menu-item:hover, .menu-item.active {
    background-color: var(--bg-primary);
    color: var(--accent-color);
}

.main-content {
    margin-left: 260px; /* Ancho del sidebar */
    flex-grow: 1;
    padding: 2.5rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ==========================================
   4. COMPONENTES DEL PORTAL Y CATÁLOGO
   ================================---------- */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-sub {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    margin-bottom: 2rem;
}

.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input {
    flex-grow: 1;
    max-width: 400px;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    background: white;
}

.search-input:focus {
    border-color: var(--accent-color);
}

/* Grid de Cursos */
.cursos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.curso-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.curso-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-color);
}

.curso-icon {
    width: 48px;
    height: 48px;
    background: rgba(110, 138, 61, 0.1);
    color: var(--accent-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.curso-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.curso-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ==============================================================
   DISEÑO RESPONSIVE Y MENÚ MÓVIL (PANTALLAS PEQUEÑAS)
============================================================== */

/* Fondo oscuro para cuando el menú esté abierto en el celular */
.fondo-menu {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background: rgba(0,0,0,0.5); 
    z-index: 998; 
    backdrop-filter: blur(2px);
}

.fondo-menu.activo { 
    display: block; 
}

/* Botón de Hamburguesa oculto por defecto en PC */
.btn-menu-movil { 
    display: none; 
}

/* ==============================================================
   DISEÑO MÓVIL: BARRA DE NAVEGACIÓN INFERIOR (TIPO APP)
============================================================== */

/* Ocultar barra superior en PC */
.topbar-movil { display: none; }

/* ==============================================================
   DISEÑO MÓVIL: TOP BAR + BOTTOM NAV (SCROLL HORIZONTAL)
============================================================== */
@media (max-width: 768px) {
    
    /* 1. MOSTRAR Y ESTILIZAR LA BARRA SUPERIOR */
    .topbar-movil {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        top: 0; left: 0; width: 100%; height: 60px;
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        z-index: 999;
        padding: 0 15px;
        box-sizing: border-box;
    }
    .topbar-logo { display: flex; align-items: center; gap: 8px; font-weight: bold; font-size: 14px; color: #334155; }
    .topbar-logo img { height: 30px; width: auto; }
    .topbar-user { font-size: 13px; color: #64748B; font-weight: 500; }

    /* 2. OCULTAR DATOS EN LA BARRA INFERIOR (Logo y Usuario original) */
    /* Si tu perfil tiene otra clase, agrégala a esta lista */
    .sidebar .logo, .sidebar h2, .sidebar .perfil, .sidebar-header {
        display: none !important;
    }

    /* 3. BARRA INFERIOR DESLIZABLE (Scroll Horizontal) */
    .sidebar { 
        position: fixed !important;
        top: auto !important; 
        bottom: 0 !important; 
        left: 0 !important; 
        width: 100% !important; 
        height: 65px !important; 
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start !important; /* Alineado a la izquierda para poder deslizar */
        align-items: center !important;
        z-index: 999;
        background: white !important;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.08);
        padding: 0 5px !important;
        
        /* Habilitar el deslizamiento horizontal con el dedo */
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ocultar la barra gris de scroll visualmente para que se vea limpio */
    .sidebar::-webkit-scrollbar { display: none; }
    .sidebar { -ms-overflow-style: none; scrollbar-width: none; }

    /* 4. ICONOS DEL MENÚ (Ajustados para deslizar) */
    .sidebar a, .sidebar .menu-item {
        display: inline-flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        min-width: 70px !important; /* Ancho fijo para que no se apachurren */
        flex: 0 0 auto !important; /* Evita que el navegador los encoja */
        padding: 0 !important;
        margin: 0 !important;
        font-size: 0 !important; 
        background: transparent !important;
    }

    .sidebar a i, .sidebar .menu-item i {
        font-size: 1.5rem !important;
        margin: 0 !important;
        color: #64748B; 
    }

    .sidebar a.activo i, .sidebar a:hover i {
        color: #10B981 !important; 
    }

    /* 5. AJUSTAR EL CONTENIDO PRINCIPAL */
    .main-content {
        margin-left: 0 !important; 
        width: 100% !important;
        padding: 1rem !important;
        margin-top: 65px !important; /* Espacio para la barra de arriba */
        margin-bottom: 75px !important; /* Espacio para la barra de abajo */
    }

    /* 6. Ajustar tablas y formularios */
    div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; gap: 1rem !important; }
    table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
    .btn { width: 100%; text-align: center; justify-content: center; margin-bottom: 5px; }

    .sidebar-brand{
        display: none !important;
    }

    .sidebar-menu{
        display: block !important;
    }

    .sidebar-footer{
        display: none !important;
    }
}