/* --- 1. CONFIGURACIÓN GENERAL --- */
:root {
    /* Paleta Dark Mode Premium */
    --bg-main: #020617;       /* Navy muy oscuro */
    --bg-card: rgba(30, 41, 59, 0.3); 
    --bg-card-hover: rgba(30, 41, 59, 0.6);
    --bg-input: rgba(255,255,255,0.05);
    --bg-nav: rgba(15, 23, 42, 0.9);
    
    /* Textos */
    --text-main: #f1f5f9;     
    --text-muted: #94a3b8;    
    --text-inverse: #0f172a;  

    /* Colores de Marca */
    --primary: #3b82f6;       /* Azul */
    --accent: #06b6d4;        /* Cian (Principal) */
    --success: #10b981;       /* Verde */
    --danger: #ef4444;        /* Rojo (Para alertas/toasts, no botones) */

    /* UI & Bordes */
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(6, 182, 212, 0.5);
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* Configuración de Fondos */
    --bg-aurora-opacity: 0.25; 
    --bg-noise-opacity: 0.05;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- 2. FONDOS AMBIENTALES ANIMADOS --- */
.bg-noise {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    opacity: var(--bg-noise-opacity);
}

.bg-gradient-1, .bg-gradient-2 {
    position: fixed; border-radius: 50%; filter: blur(100px); z-index: -2;
    opacity: var(--bg-aurora-opacity);
    animation: floatBg 15s infinite alternate ease-in-out;
}
.bg-gradient-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: var(--primary); }
.bg-gradient-2 { bottom: -10%; right: -10%; width: 50vw; height: 50vw; background: var(--accent); animation-delay: -5s; }

@keyframes floatBg {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 20px) scale(1.1); }
    100% { transform: translate(-20px, 40px) scale(1); }
}

/* --- 3. HEADER SIMÉTRICO (GRID) --- */
.app-container { max-width: 1300px; margin: 0 auto; padding: 20px; }
header { margin-bottom: 30px; }

.header-row {
    display: grid;
    /* Grid de 3 columnas: Izquierda (Logo) | Centro (Buscador) | Derecha (Botón) */
    grid-template-columns: 1fr minmax(300px, 600px) 1fr;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

/* Columna Izquierda: Logo */
.logo-area { 
    display: flex; align-items: center; 
    gap: 12px; height: 40px; justify-self: start; 
}
.logo-img { height: 45px; width: auto; display: block; }
.divider-v { width: 1px; height: 26px; background: var(--border-glass); display: block; opacity: 0.5; }
.brand-name { 
    font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1.4rem;
    letter-spacing: -0.5px; color: white; margin-top: -3px; line-height: 1;
}

/* Columna Central: Buscador Moderno */
.search-container { width: 100%; justify-self: center; }

.search-bar {
    width: 100%; 
    background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border-glass);
    border-radius: 50px; padding: 0 20px; height: 48px;
    display: flex; align-items: center; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
}
.search-bar:focus-within { 
    border-color: var(--accent); background: rgba(6, 182, 212, 0.05); 
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.15), 0 10px 30px rgba(0,0,0,0.2); transform: translateY(-1px);
}
.search-bar i { color: var(--text-muted); font-size: 1rem; margin-right: 12px; transition: color 0.3s; }
.search-bar:focus-within i { color: var(--accent); }
.search-bar input {
    width: 100%; height: 100%; background: transparent; border: none;
    color: var(--text-main); font-family: 'Outfit', sans-serif; outline: none; font-size: 1rem;
}
.search-bar input::placeholder { color: rgba(148, 163, 184, 0.5); }

/* Columna Derecha: Botón Salir (Alineado a la derecha) */
.header-actions {
    display: flex;
    justify-content: flex-end;
}

/* Navegación */
.nav-wrapper { display: flex; justify-content: center; }
.category-nav {
    background: var(--bg-nav); padding: 4px; border-radius: 12px; 
    border: 1px solid var(--border-glass); display: inline-flex; gap: 5px; backdrop-filter: blur(5px);
}
.nav-btn {
    background: transparent; border: none; padding: 8px 25px;
    border-radius: 8px; color: var(--text-muted);
    font-family: 'Outfit', sans-serif; font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 8px;
    position: relative; overflow: hidden;
}
.nav-btn:active { transform: scale(0.95); }
.nav-btn.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 2px 10px rgba(6,182,212,0.3); }
.nav-btn:hover:not(.active) { color: var(--text-main); background: rgba(255,255,255,0.05); }

/* --- 4. DASHBOARD & BARRA --- */
.dashboard-header { 
    display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 35px; gap: 25px; 
}
h1 { font-size: 2.2rem; font-weight: 700; margin-bottom: 5px; letter-spacing: -0.5px; color: white; }
.subtitle { color: var(--text-muted); font-size: 1rem; }

.progress-card {
    background: rgba(30, 41, 59, 0.4); border: 1px solid var(--border-glass);
    padding: 25px 30px; border-radius: 20px; width: 100%; margin-top: 5px;
    position: relative; overflow: hidden; backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.3);
}

.progress-header-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 15px; }
.progress-title-group { display: flex; flex-direction: column; gap: 4px; }
.progress-label { font-size: 0.9rem; font-weight: 700; color: white; letter-spacing: 0.5px; text-transform: uppercase; }
.progress-subtext { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }

.progress-percent-big { 
    font-size: 2.5rem; font-weight: 800; line-height: 1;
    background: linear-gradient(135deg, white, var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(6, 182, 212, 0.3);
}

.progress-track { 
    width: 100%; height: 14px; background: rgba(0, 0, 0, 0.3);
    border-radius: 10px; overflow: hidden; margin-bottom: 15px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.05);
}
.progress-fill { 
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); 
    border-radius: 10px; position: relative; width: 0%;
    transition: width 1.5s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.5);
}
.progress-fill::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent);
    border-radius: 10px 10px 0 0;
}
.progress-glow {
    position: absolute; right: 0; top: 0; bottom: 0; width: 10px;
    background: white; filter: blur(5px); opacity: 0.7;
}

.progress-footer-row { display: flex; justify-content: flex-end; }
.certificate-badge { 
    color: var(--text-main); font-weight: 600; font-size: 0.85rem;
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(6, 182, 212, 0.1); padding: 6px 14px; border-radius: 8px;
    border: 1px solid rgba(6, 182, 212, 0.2); transition: all 0.3s ease;
}
.certificate-badge:hover { background: rgba(6, 182, 212, 0.2); box-shadow: 0 0 15px rgba(6, 182, 212, 0.15); transform: translateY(-1px); }
.certificate-badge i { color: var(--accent); font-size: 1rem; }

/* --- 5. SECCIÓN HERO --- */
.featured-section { margin-bottom: 40px; width: 100%; }

.hero-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(6, 182, 212, 0.3); border-radius: 24px;
    padding: 30px; display: flex; justify-content: space-between; align-items: center;
    position: relative; overflow: hidden; box-shadow: 0 15px 40px -10px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    --mouse-x: 0px; --mouse-y: 0px;
}
.hero-card::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(1000px circle at var(--mouse-x) var(--mouse-y), rgba(6, 182, 212, 0.08), transparent 40%);
    opacity: 0; transition: opacity 0.5s; pointer-events: none; z-index: 1;
}
.hero-card:hover::before { opacity: 1; }
.hero-card:hover { transform: translateY(-3px); box-shadow: 0 20px 50px -10px rgba(6, 182, 212, 0.15); border-color: var(--accent); }

.hero-bg-icon {
    position: absolute; right: -20px; bottom: -40px;
    font-size: 10rem; color: rgba(255,255,255,0.03);
    z-index: 0; transform: rotate(-15deg); pointer-events: none;
}

.hero-content { position: relative; z-index: 2; max-width: 65%; }
.hero-label-group { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.hero-badge {
    background: var(--accent); color: #020617; font-size: 0.75rem; font-weight: 700; 
    text-transform: uppercase; letter-spacing: 1px; padding: 5px 12px; border-radius: 6px;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.4); animation: pulseBadge 2s infinite;
}
@keyframes pulseBadge { 0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(6, 182, 212, 0); } 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); } }

.hero-date { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; }
.hero-title { font-size: 1.8rem; font-weight: 700; color: white; margin-bottom: 8px; line-height: 1.2; }
.hero-desc { color: #cbd5e1; font-size: 1rem; line-height: 1.5; max-width: 90%; }

.hero-action { position: relative; z-index: 2; }
.btn-hero {
    background: white; color: var(--primary); border: none; padding: 15px 35px; 
    border-radius: 50px; font-weight: 700; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; gap: 10px; transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
.btn-hero:hover { transform: scale(1.05); background: var(--accent); color: #020617; box-shadow: 0 0 30px rgba(6, 182, 212, 0.5); }

/* --- 6. GRID DE TARJETAS --- */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 15px; padding-bottom: 50px; }

.card {
    background: var(--bg-card); border: 1px solid var(--border-glass); 
    border-radius: var(--radius); padding: 20px; 
    display: flex; flex-direction: column; gap: 15px;
    min-height: 260px; position: relative; overflow: hidden;
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    --mouse-x: 0px; --mouse-y: 0px;
}
.card::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(800px circle at var(--mouse-x) var(--mouse-y), rgba(255, 255, 255, 0.06), transparent 40%);
    opacity: 0; transition: opacity 0.5s; pointer-events: none; z-index: 1;
}
.card:hover::before { opacity: 1; }
.card:hover { transform: translateY(-5px); border-color: rgba(255,255,255,0.2); box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5); }

.card-meta, .status-row, .card-content, .card-btn { position: relative; z-index: 2; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-base { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 8px; border-radius: 6px; font-weight: 600; }
.pill-date { color: var(--text-muted); background: rgba(255, 255, 255, 0.08); }
.pill-topic { color: var(--accent); background: rgba(6, 182, 212, 0.1); border: 1px solid rgba(6, 182, 212, 0.2); }

.status-row { display: flex; }
.status-indicator { font-size: 0.7rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }

.active { color: var(--accent); } .active .dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: glowDot 2s infinite; }
.completed { color: var(--success); } .completed .dot { background: var(--success); }
.locked { color: var(--text-muted); opacity: 1; } .locked .dot { background: var(--text-muted); }

@keyframes glowDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.card-content { flex-grow: 1; display: flex; flex-direction: column; gap: 10px; }
.card-title { font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- 7. BOTONES --- */
.card-btn {
    width: 100%; padding: 12px; border-radius: 12px; border: none;
    font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 0.95rem;
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.card-btn:active { transform: scale(0.96); }

.card-btn.btn-active { background: var(--accent); color: #020617; }
.card-btn.btn-active:hover { background: #0891b2; box-shadow: 0 0 15px rgba(6,182,212,0.3); }

.card-btn.btn-completed { background: transparent; border: 2px solid var(--success); color: var(--success); }
.card-btn.btn-completed:hover { background: var(--success); color: #020617; }

.card-btn.btn-locked { 
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid var(--border-glass); 
    color: var(--text-muted); 
    cursor: not-allowed; 
    opacity: 0.6;
    font-weight: 500;
}
.card-btn.btn-locked:active { transform: none; }
.card-btn.btn-locked i { opacity: 0.7; }

.card.is-locked { opacity: 0.75; }
.card.is-locked:hover { background: var(--bg-card); border-color: var(--border-glass); transform: none; box-shadow: none; }

/* --- 8. MODAL --- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 100; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s; backdrop-filter: blur(5px); }
.modal-glass { 
    background: #0f172a; width: 95%; max-width: 800px; border-radius: 16px; 
    border: 1px solid #334155; padding: 25px; position: relative; 
    transform: scale(0.90); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    color: #f8fafc; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.close-modal-btn { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: #64748b; background: none; border: none; cursor: pointer; transition: color 0.2s; }
.close-modal-btn:hover { color: white; }
.video-wrapper { position: relative; padding-bottom: 56.25%; height: 0; background: #000; border-radius: 12px; margin: 20px 0; border: 1px solid #334155; overflow: hidden; }
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.modal-footer { text-align: center; }

/* Botón Marcar Vista */
.btn-glow { 
    background: var(--accent); color: #000; border: none; padding: 12px 35px; border-radius: 50px; 
    font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-glow:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(6,182,212,0.4); }
.btn-glow:active { transform: scale(0.95); }

/* --- 9. ENCUESTA --- */
.survey-box { 
    background: rgba(6, 182, 212, 0.08); border: 1px solid rgba(6, 182, 212, 0.2); 
    padding: 20px; border-radius: 16px; margin-top: 15px; 
}
.survey-content { display: flex; align-items: center; justify-content: space-between; gap: 15px; text-align: left; }
.survey-content h3 { font-size: 1.2rem; color: #fff; margin-bottom: 4px; }
.survey-content p { color: rgba(255,255,255,0.7); font-size: 0.9rem; }

.btn-survey { 
    background: var(--accent); color: #020617; border: none; 
    padding: 12px 30px; border-radius: 50px; font-weight: 700; 
    text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem;
    transition: var(--transition); box-shadow: 0 4px 15px rgba(6,182,212,0.2); white-space: nowrap;
}
.btn-survey:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(6,182,212,0.4); }
.btn-survey:active { transform: scale(0.98); }

/* --- 10. TOAST NOTIFICATIONS --- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { 
    background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(10px); 
    color: white; padding: 15px 20px; border-radius: 12px; 
    border: 1px solid var(--border-glass); 
    display: flex; align-items: center; gap: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    min-width: 300px;
}
.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error { border-left: 4px solid var(--text-muted); }
.toast.toast-info { border-left: 4px solid var(--accent); }

@keyframes slideInRight { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(50px); } }

/* --- 11. EMPTY STATE --- */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-muted); animation: fadeIn 0.5s; }
.empty-state i { font-size: 4rem; margin-bottom: 20px; opacity: 0.2; }
.empty-state h3 { font-size: 1.5rem; color: white; margin-bottom: 10px; }
.empty-state p { font-size: 1rem; max-width: 400px; margin: 0 auto; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================= */
/* ESTILOS NUEVOS Y CORRECCIONES DE LAYOUT */
/* ========================================= */

.welcome-title { font-size: 2.2rem; font-weight: 800; color: white; margin-bottom: 5px; }
.welcome-title span { color: var(--accent); }

/* Modal Intro */
.intro-box { text-align: center; max-width: 450px; }

/* Input Nombre */
.glass-input {
    width: 100%; padding: 12px; margin: 15px 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    color: white; border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    outline: none; transition: 0.3s;
}
.glass-input:focus { border-color: var(--accent); background: rgba(255,255,255,0.08); }

/* Botón Principal (Cian) */
.btn-primary-glow { 
    background: var(--accent); color: #020617; 
    padding: 10px 25px; border-radius: 50px; 
    font-weight: 700; border: none; cursor: pointer; 
    display: inline-flex; align-items: center; gap: 8px; 
    font-family: 'Outfit', sans-serif; transition: 0.3s;
}
.btn-primary-glow:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(6,182,212,0.4); }

/* Botón Secundario (Cancelar) */
.btn-secondary {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border-glass); 
    padding: 10px 20px; border-radius: 50px; font-weight: 600; cursor: pointer; transition: 0.3s; font-family: 'Outfit', sans-serif;
}
.btn-secondary:hover { border-color: white; color: white; background: rgba(255,255,255,0.05); }

/* Layout de botones en modal */
.modal-actions-row { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }

.full-width { width: 100%; justify-content: center; }

/* --- 12. RESPONSIVE CORREGIDO --- */
@media (max-width: 768px) {
    .app-container { padding: 15px; }
    
    /* Header Responsive: Grid de 2 filas para acomodar el botón arriba */
    .header-row { 
        display: grid;
        grid-template-columns: 1fr auto; /* Fila 1: Logo (Izq) - Botón (Der) */
        grid-template-rows: auto auto;   /* Fila 1: Arriba - Fila 2: Buscador */
        gap: 15px;
        align-items: center;
    }

    /* Logo a la izquierda */
    .logo-area { 
        grid-column: 1 / 2;
        grid-row: 1;
        justify-content: flex-start; 
    }

    /* Botón Salir a la derecha */
    .header-actions {
        grid-column: 2 / 3;
        grid-row: 1;
        justify-self: end;
    }
    
    /* Buscador abajo ocupando todo el ancho */
    .search-container { 
        grid-column: 1 / -1; 
        grid-row: 2;
        width: 100%; 
        max-width: 100%;
    } 
    
    /* Opcional: Solo icono en móvil para que se vea limpio */
    #logoutBtn span { display: none; }
    #logoutBtn { padding: 10px; border-radius: 50%; }

    /* Otros ajustes móviles */
    .nav-wrapper { margin-bottom: 15px; }
    .progress-header-row { align-items: flex-start; }
    .progress-percent-big { font-size: 2rem; }
    .progress-footer-row { justify-content: flex-start; }
    .hero-card { flex-direction: column; align-items: flex-start; gap: 20px; text-align: left; }
    .hero-content { max-width: 100%; }
    .hero-action { width: 100%; }
    .btn-hero { width: 100%; justify-content: center; }
    .hero-bg-icon { font-size: 8rem; right: -10px; bottom: 10px; opacity: 0.5; }
    .grid-container { grid-template-columns: 1fr; gap: 12px; }
    .card { min-height: auto; padding: 18px; }
    .survey-content { flex-direction: column; text-align: center; gap: 20px; }
    .btn-survey { width: 100%; justify-content: center; }
    #toast-container { right: 10px; left: 10px; }
    .toast { min-width: auto; }
}