/* ==========================================
   LLM Plataforma - Estilos Principales
   ========================================== */

:root {
    --primary: #2979ff;
    --secondary: #00bfa5;
    --bg: #f0f2f5;
    --bg-dark: #1a1a2e;
    --bg-light: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2d3436;
    --text-muted: #636e72;
    --border: #e0e3e8;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #3498db;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.85; }

/* ===== LAYOUT ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
}
.card-header h3 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.card-body { padding: 1.5rem; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-light); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-basico { background: #d1ecf1; color: #0c5460; }
.badge-intermedio { background: #fff3cd; color: #856404; }
.badge-avanzado { background: #f8d7da; color: #721c24; }
.badge-admin { background: #cce5ff; color: #004085; }
.badge-editor { background: #d4edda; color: #155724; }
.badge-user { background: #e2e3e5; color: #383d41; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.4rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(41,121,255,0.1);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:600px){ .form-grid-2 { grid-template-columns: 1fr; } }

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.close { font-size: 1.5rem; cursor: pointer; background: none; border: none; color: var(--text-muted); }
.close:hover { color: var(--text); }

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 0.75rem 1rem; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); text-transform: uppercase; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table tr:hover { background: var(--bg-light); }
.table-responsive { overflow-x: auto; }
.cell-info { display: flex; align-items: center; gap: 0.75rem; }
.cell-info small { display: block; color: var(--text-muted); font-size: 0.8rem; }
.cell-color { width: 4px; height: 36px; border-radius: 4px; }
.actions { display: flex; gap: 0.4rem; }
.btn-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 8px;
    cursor: pointer; color: var(--text-muted);
    background: transparent;
    transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-light); color: var(--text); }
.text-danger { color: var(--danger) !important; }
.text-danger:hover { background: #fde8e8 !important; }
.text-muted { color: var(--text-muted); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

/* ===== PROGRESS ===== */
.progress-track { display: flex; align-items: center; gap: 0.75rem; }
.progress-bar { flex: 1; height: 8px; background: #e9ecef; border-radius: 10px; overflow: hidden; }
.progress-bar div { height: 100%; background: var(--primary); border-radius: 10px; transition: width 0.5s ease; }

/* ===== TABLE TOOLBAR ===== */
.table-toolbar { margin-bottom: 1rem; }
.table-toolbar input { width: 100%; max-width: 400px; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.5rem; }

/* ===== FLEX HELPERS ===== */
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }

/* ==========================================
   ADMIN LAYOUT
   ========================================== */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 250px;
    background: var(--bg-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}
.admin-sidebar.collapsed { width: 60px; }
.admin-sidebar.collapsed .sidebar-header h2,
.admin-sidebar.collapsed .sidebar-header small,
.admin-sidebar.collapsed .nav-item span { display: none; }
.admin-sidebar.collapsed .nav-item { justify-content: center; padding: 0.8rem; }
.admin-sidebar.collapsed .sidebar-header { padding: 1rem 0; text-align: center; }

.sidebar-header { padding: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 1.2rem; }
.sidebar-header small { font-size: 0.75rem; opacity: 0.6; }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(41,121,255,0.3); color: #fff; border-right: 3px solid var(--primary); }
.nav-item.logout { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.1); }
.nav-item i { width: 20px; text-align: center; }
.sidebar-nav hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 0.5rem 1rem; }

.admin-main { flex: 1; margin-left: 250px; transition: margin-left 0.3s; min-height: 100vh; display: flex; flex-direction: column; }
.admin-sidebar.collapsed + .admin-main { margin-left: 60px; }

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.admin-topbar h1 { font-size: 1.3rem; }

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    color: var(--text);
    display: none;
}
.admin-content { padding: 2rem; flex: 1; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
}
.stat-card i { font-size: 2rem; color: var(--primary); }
.stat-card h3 { font-size: 1.8rem; font-weight: 700; }
.stat-card p { font-size: 0.85rem; color: var(--text-muted); }

.admin-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media(max-width:768px){ .admin-grid-2 { grid-template-columns: 1fr; } }

.list-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border: none; }
.list-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.list-info { flex: 1; }
.list-info strong { display: block; font-size: 0.9rem; }
.list-info small { font-size: 0.8rem; color: var(--text-muted); }

/* ==========================================
   USER PORTAL
   ========================================== */
.user-nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-brand { font-size: 1.2rem; }
.nav-links { display: flex; align-items: center; gap: 0.5rem; }
.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active { background: var(--bg-light); color: var(--text); }
.mobile-toggle { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 0.4rem; }

.user-main { padding: 2rem 0; min-height: calc(100vh - 60px); }

.welcome-section { margin-bottom: 2rem; }
.welcome-section h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.welcome-section p { color: var(--text-muted); }

.section-tabs { display: flex; gap: 0.5rem; margin-bottom: 2rem; }
.tab {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    background: var(--bg-light);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.tab.active { background: var(--primary); color: #fff; }
.tab:hover:not(.active) { background: var(--border); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.course-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid var(--border);
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.course-img {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.course-img img { width: 100%; height: 100%; object-fit: cover; }
.course-body { padding: 1rem; }
.course-body .badge { margin-bottom: 0.5rem; }
.course-body h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.course-body p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.8rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.8rem; }
.course-progress { display: flex; align-items: center; gap: 0.75rem; }
.course-progress span { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* ===== CERTIFICATE LIST ===== */
.cert-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.cert-info { flex: 1; }
.cert-info h4 { font-size: 1rem; }
.cert-info p { font-size: 0.85rem; color: var(--text-muted); }
.cert-info small { font-size: 0.75rem; color: var(--text-muted); }

/* ===== LOGIN PAGE ===== */
.login-body {
    background: linear-gradient(135deg, var(--bg-dark) 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}
.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { text-align: center; font-size: 1.5rem; margin-bottom: 0.3rem; }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }
.login-card .form-group label { font-size: 0.8rem; }
.login-card .btn-block { margin-top: 0.5rem; }

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-top: 1rem;
}
.google-btn:hover { background: var(--bg-light); }
.google-btn img { width: 20px; }

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-link a { font-weight: 600; }

/* ===== MODULOS ADMIN ===== */
.modulo-form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.modulo-form input { flex: 1; padding: 0.6rem; border: 1px solid var(--border); border-radius: 8px; }

.modulo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.modulo-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
}
.modulo-header strong { flex: 1; }
.modulo-lecciones { padding: 0.5rem 0; }

.leccion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}
.leccion-item:hover { background: var(--bg-light); }
.leccion-icon { width: 24px; text-align: center; color: var(--text-muted); }
.leccion-info { flex: 1; }
.leccion-info strong { display: block; font-size: 0.9rem; }
.leccion-info small { font-size: 0.75rem; color: var(--text-muted); }

.user-avatar-sm {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-avatar-lg { composes: user-avatar-sm; }

/* ===== RESPONSIVE ===== */
@media(max-width:768px) {
    .admin-sidebar {
        width: 60px;
        transform: translateX(-100%);
    }
    .admin-sidebar.open { transform: translateX(0); width: 250px; }
    .sidebar-toggle { display: block; }
    .admin-main { margin-left: 0; }

    .nav-links { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0.5rem; }
    .nav-links.show { display: flex; }
    .mobile-toggle { display: block; }

    .courses-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
