/* 
   LR ACADEMIA - HOJA DE ESTILOS MAESTRA
   Stack: CSS3 Moderno (Variables, Grid, Flexbox)
   Diseño: Mobile-First / Responsive
*/

:root {
    /* Paleta de Colores de Marca */
    --primary-blue: #0F4C81;
    --light-blue: #3A86FF;
    --red-alert: #E63946;
    --orange-accent: #FF7A18;
    --dark-text: #1A202C;
    --gray-text: #4A5568;
    --bg-light: #F5F7FA;
    --white: #FFFFFF;
    --border: #E2E8F0;

    /* Espaciado y Layout */
    --container-max: 1200px;
    --header-height: 70px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

/* =========================================
   1. RESET & BASE
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--dark-text);
    line-height: 1.6;
    font-size: 16px;
    padding-top: var(--header-height); /* Espacio para header fijo */
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Utilidades */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 20px;
}

.section-padding {
    padding: 60px 0;
}

.hidden {
    display: none !important;
}

.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* =========================================
   2. COMPONENTES DE UI
   ========================================= */

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: var(--white);
}
.btn-primary:hover {
    background-color: #0A365C;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #EDF2F7;
    color: var(--primary-blue);
}
.btn-secondary:hover {
    background-color: #E2E8F0;
}

.btn-outline {
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    background: transparent;
    padding: 8px 20px;
}
.btn-outline:hover {
    background-color: var(--primary-blue);
    color: var(--white);
}

.btn-text {
    background: none;
    border: none;
    color: var(--light-blue);
    cursor: pointer;
    font-weight: 500;
}
.btn-text:hover { text-decoration: underline; }

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

.full-width { width: 100%; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    background-color: #EBF8FF;
    color: var(--light-blue);
}
.badge-admin {
    background-color: #FFF5F5;
    color: var(--red-alert);
}

/* Loaders */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-light);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    color: var(--primary-blue);
    font-weight: 600;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #E2E8F0;
    border-top: 4px solid var(--orange-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-inline {
    width: 100%;
    text-align: center;
    padding: 40px;
    color: var(--gray-text);
    font-style: italic;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   3. HEADER & NAVEGACIÓN
   ========================================= */
.main-header {
    height: var(--header-height);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 1.1rem;
}
.logo .highlight { color: var(--orange-accent); }

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a {
    margin: 0 10px;
    color: var(--gray-text);
    font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--primary-blue); }

.auth-controls { position: relative; }

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    padding: 15px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}
.user-dropdown span {
    font-weight: 700;
    color: var(--primary-blue);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 5px;
    display: block;
}

/* =========================================
   4. VISTAS (LANDING & PÚBLICO)
   ========================================= */
.hero {
    background: linear-gradient(135deg, #FFFFFF 0%, #F0F4F8 100%);
    padding: 80px 0;
    border-bottom: 1px solid var(--border);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}

.hero-text h1 {
    font-size: 2.8rem;
    line-height: 1.1;
    color: var(--primary-blue);
    margin-bottom: 20px;
}

.hero-text p {
    font-size: 1.1rem;
    color: var(--gray-text);
    margin-bottom: 30px;
}

/* Grid de Cursos */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.course-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}
.course-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.card-img {
    height: 180px;
    background-color: #E2E8F0;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.no-img { color: #A0AEC0; font-weight: 500; }

.card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-body h3 {
    margin-bottom: 10px;
    color: var(--dark-text);
    font-size: 1.2rem;
}

.card-desc {
    color: var(--gray-text);
    font-size: 0.9rem;
    flex: 1; /* Empuja el footer hacia abajo */
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--orange-accent);
}

/* =========================================
   5. DASHBOARD ALUMNO & PLAYER
   ========================================= */
.progress-container {
    background: #EDF2F7;
    height: 8px;
    border-radius: 4px;
    margin: 10px 0 5px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--light-blue);
    width: 0%;
    transition: width 0.5s ease;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--white);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    max-width: 600px;
    margin: 40px auto;
}
.empty-state svg {
    margin-bottom: 20px;
    stroke: var(--gray-text);
}

/* Player Layout */
.player-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    min-height: calc(100vh - var(--header-height));
}

.player-sidebar {
    background: var(--white);
    border-right: 1px solid var(--border);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: #F8FAFC;
}
.sidebar-header h4 { font-size: 1rem; margin-top: 10px; }

.module-item { border-bottom: 1px solid var(--border); }
.module-title {
    padding: 15px 20px;
    background: #F1F5F9;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.lesson-list li {
    padding: 12px 20px 12px 35px;
    cursor: pointer;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
    transition: 0.2s;
    position: relative;
}
.lesson-list li:hover { background: #F8FAFC; }
.lesson-list li.active { border-left-color: var(--light-blue); background: #EBF8FF; }
.lesson-list li.completed { color: #718096; text-decoration: line-through; }
.lesson-list li.completed::before {
    content: '✓';
    position: absolute;
    left: 10px;
    color: var(--light-blue);
    text-decoration: none;
    font-weight: bold;
}

.player-content {
    padding: 40px;
    background: #F1F5F9;
}

.video-wrapper {
    background: #000;
    aspect-ratio: 16/9;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-placeholder {
    color: white;
    text-align: center;
}
.video-placeholder p { margin-top: 10px; opacity: 0.8; }

.video-wrapper iframe { width: 100%; height: 100%; }

.lesson-meta {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.success-box {
    background: #F0FFF4;
    border: 1px solid #C6F6D5;
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 20px;
}

/* =========================================
   6. ADMIN PANEL
   ========================================= */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.admin-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}
.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-text);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.tab-btn.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* Tablas Admin */
.table-responsive {
    overflow-x: auto;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th, .admin-table td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    background: #F7FAFC;
    color: var(--gray-text);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

/* Editor Forms */
.editor-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.card h3 { margin-bottom: 15px; font-size: 1.1rem; color: var(--primary-blue); }

.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}
.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}
.form-input:focus {
    border-color: var(--light-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.image-upload-preview {
    height: 150px;
    background: #F7FAFC;
    border: 2px dashed #CBD5E0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 4px;
    overflow: hidden;
}

/* =========================================
   7. MODALES & TOASTS
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 76, 129, 0.8); /* Azul oscuro transparente */
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--white);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius);
    padding: 30px;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease-out;
}
@keyframes modalSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #A0AEC0;
}

.auth-tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.auth-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.auth-tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    font-size: 0.9rem;
}
.toast-success { background: #48BB78; }
.toast-error { background: var(--red-alert); }
.toast-info { background: var(--primary-blue); }

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .hero-grid { grid-template-columns: 1fr; text-align: center; }
    .hero-img { display: none; }
    
    .player-layout { grid-template-columns: 1fr; }
    .player-sidebar { display: none; } /* En móvil se simplifica para demo */
    
    .editor-grid { grid-template-columns: 1fr; }
    
    .main-nav .nav-links { display: none; } /* Menu hamburguesa no implementado por simplicidad, solo botones */
    
    .header-content { padding: 0 15px; }
}