:root {
    --primary: #1777F1;      
    --secondary: #4394F6;    
    --text-dark: #242933;    
    --text-muted: #A3AED0;   
    --text-sidebar: #475569; 
    --bg-color: #F4F7FE;     
    --card-bg: rgba(255, 255, 255, 0.85); 
    --card-border: rgba(255, 255, 255, 0.5);
    --shadow: 0px 4px 20px rgba(112, 144, 176, 0.08);
    --border-light: rgba(163, 174, 208, 0.2);
    --radius-lg: 24px;
    --radius-md: 16px;
    --base-font-size: 14px;
    --ui-scale: 1;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-dark); min-height: 100vh; overflow-x: hidden; font-size: calc(14px * var(--ui-scale, 1)); }

.toast-container { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 420px; background: rgba(255,255,255,0.92); border: 1px solid var(--border-light); box-shadow: 0 10px 30px rgba(0,0,0,0.12); border-radius: 12px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; }
.toast .toast-icon { width: 28px; height: 28px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.toast .toast-body { flex: 1; }
.toast .toast-title { font-weight: 800; font-size: 13px; margin-bottom: 2px; color: var(--text-dark); }
.toast .toast-msg { font-size: 12px; color: var(--text-sidebar); line-height: 1.35; }
.toast .toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.toast.toast-success .toast-icon { background: rgba(16,185,129,0.12); color: #10b981; }
.toast.toast-error .toast-icon { background: rgba(239,68,68,0.10); color: #ef4444; }

@media (max-width: 768px) {
    .toast-container { top: 12px; right: 12px; left: 12px; }
    .toast { max-width: none; width: 100%; }
}

.course-progress-card { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; }
.course-progress-title { font-weight: 800; font-size: calc(13px * var(--ui-scale, 1)); color: var(--text-dark); }
.course-progress-subtitle { font-size: calc(12px * var(--ui-scale, 1)); color: var(--text-muted); }
.course-complete-btn { background: #10b981; padding: 10px 14px; }
.course-completed-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: calc(13px * var(--ui-scale, 1)); background: rgba(16, 185, 129, 0.1); color: #10b981; border-radius: 10px; font-weight: 800; }

.course-details-panel { margin-top: 10px; padding: 12px; }
.course-detail-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border-light); padding-bottom: 8px; margin-bottom: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.course-detail-tab { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text-muted); font-weight: 700; font-size: calc(12px * var(--ui-scale, 1)); padding: 8px 6px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.course-detail-tab.active { color: var(--primary); background: rgba(23, 119, 241, 0.08); }
.course-detail-tab-lessons { display: none; }
.course-detail-panel { display: none; }
.course-detail-panel.active { display: block; }
.course-detail-section-title { font-weight: 800; font-size: calc(13px * var(--ui-scale, 1)); color: var(--text-dark); margin-bottom: 8px; }
.course-detail-empty { color: var(--text-muted); font-size: calc(12px * var(--ui-scale, 1)); margin: 0; }
.course-progress-inline { display: flex; flex-direction: column; gap: 10px; }
.course-progress-inline-text { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.course-progress-bar-wrap { width: 100%; }
.course-progress-bar { height: 8px; background: rgba(163,174,208,0.25); border-radius: 999px; overflow: hidden; }
.course-progress-bar > div { height: 100%; background: var(--primary); }
.course-progress-action { display: flex; justify-content: flex-end; }
.course-detail-lessons-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lesson-list-mobile { max-height: 320px; overflow-y: auto; padding-right: 4px; }


.bg-mesh {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -2;
    background: radial-gradient(circle at top left, #E4EEFA 0%, transparent 40%),
                radial-gradient(circle at bottom right, #8ABBF8 0%, transparent 40%);
    opacity: 0.4;
}

#blob {
    background: linear-gradient(to right, #1777F1, #8ABBF8); border-radius: 50%;
    position: fixed; left: 50%; top: 50%; height: 350px; width: 350px; 
    transform: translate(-50%, -50%); z-index: -1; filter: blur(120px); opacity: 0.2; pointer-events: none;
}

.page-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; }
.page-wrapper.page-wrapper-tight { padding-left: 5px; padding-right: 5px; padding-top: 10px; padding-bottom: 10px; }

.page-wrapper.page-wrapper-tight .app-container { width: 100%; max-width: calc(100vw - 10px); }
.page-wrapper.page-wrapper-tight .app-container { padding: 5px; gap: 12px; }
.page-wrapper.page-wrapper-tight .right-panel.glass-card { background: rgba(244, 247, 254, 0.55); }

.auth-card { max-width: 480px; width: 100%; margin: auto; padding: 40px 36px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand-logo { max-height: 72px; max-width: 100%; object-fit: contain; display: block; margin: 0 auto 12px; }
.auth-brand-name { color: var(--primary); font-weight: 700; font-size: 1.35rem; margin: 0; line-height: 1.3; }
.auth-error { color: #dc2626; margin-bottom: 16px; font-size: 13px; text-align: center; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; }
.password-field-wrapper { position: relative; }
.password-field-wrapper .password-input { padding-right: 44px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px 8px; font-size: 16px; line-height: 1; }
.password-toggle:hover { color: var(--primary); }

.app-container {
    display: grid; 
    grid-template-columns: 240px 1fr; 
    gap: 20px; 
    width: 100%; max-width: 1800px; 
    height: 96vh; min-height: 800px; 
    background: rgba(244, 247, 254, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 20px; 
    box-shadow: 0 10px 40px rgba(112, 144, 176, 0.15); 
}

.app-container.has-right-panel {
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr) minmax(0, 250px);
}

.app-container.has-right-panel .sidebar,
.app-container.has-right-panel .right-panel {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.app-container.has-right-panel .sidebar {
    max-width: 240px;
}

.app-container.has-right-panel .right-panel {
    max-width: 250px;
}

.glass-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 15px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }


.sidebar { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; height: 100%; padding-right: 5px; z-index: 100; position: relative;}

/* Make left sidebar match right-panel "glass" look on course pages */
.app-container.has-right-panel .sidebar {
    background: rgba(244, 247, 254, 0.55);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 10px;
}
.close-sidebar-btn { display: none; background: none; border: none; font-size: 20px; color: var(--text-dark); position: absolute; right: 10px; top: 10px; cursor: pointer; padding: 10px; }

.user-profile { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; margin-top: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #8ABBF8); display: flex; justify-content: center; align-items: center; color: white; font-weight: bold; font-size: 16px; flex-shrink: 0;}
.user-info h4 { font-size: 14px; color: var(--text-dark); }
.user-info p { font-size: 11px; color: var(--text-muted); }

.nav-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; font-weight: 600; margin: 10px 0 5px 0; display: block; }
.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.nav-item { 
    display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; 
    color: var(--text-sidebar); font-weight: 600; cursor: pointer; transition: 0.2s; font-size: calc(13px * var(--ui-scale, 1)); text-decoration: none; 
}
.nav-item i { width: 16px; text-align: center; }
.nav-item:hover { background: rgba(23, 119, 241, 0.05); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(23, 119, 241, 0.3); }


.main-content { display: flex; flex-direction: column; gap: 12px; height: 100%; overflow-y: auto; padding-right: 10px; }


.header { display: flex; align-items: flex-start; gap: 15px; flex-shrink: 0; }
.hamburger-btn { display: none; background: white; border: 1px solid var(--border-light); border-radius: 8px; width: 40px; height: 40px; justify-content: center; align-items: center; font-size: 18px; color: var(--primary); cursor: pointer; box-shadow: var(--shadow); flex-shrink: 0; }
.header-text h1 { font-size: calc(24px * var(--ui-scale, 1)); color: var(--text-dark); margin-bottom: 4px; }
.header-text p { color: var(--primary); font-weight: 600; font-size: calc(13px * var(--ui-scale, 1)); text-transform: uppercase; }


.player-wrapper { position: relative; width: 100%; max-height: 68vh; aspect-ratio: 16 / 9; margin: 0 auto; background-color: #000; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); flex-shrink: 0; }
.player-wrapper:fullscreen { max-height: none !important; width: 100% !important; height: 100% !important; border-radius: 0; }
.player-wrapper:-webkit-full-screen { max-height: none !important; width: 100% !important; height: 100% !important; border-radius: 0; }
#youtube-player { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.video-shield { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; background: transparent; }
.video-cover { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 20; background-color: #1e293b; color: #f8fafc; display: flex; align-items: center; justify-content: center; font-size: 2vw; font-weight: 600; }
.custom-controls { position: absolute; bottom: 0; left: 0; width: 100%; height: 44px; display: flex; align-items: center; gap: 10px; background: #0f172a; padding: 0 15px; z-index: 30; }
.custom-controls button, .custom-controls select { flex-shrink: 0; }
.custom-controls button { background: none; color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 4px; border-radius: 50%; transition: background 0.2s; }
.custom-controls button:hover { background-color: rgba(255, 255, 255, 0.1); }
.custom-controls button .material-symbols-outlined { font-size: 20px; }
.time-display { color: white; font-size: calc(12px * var(--ui-scale, 1)); font-weight: 500; min-width: 80px; text-align: center; white-space: nowrap;}
.custom-controls select { background-color: transparent; color: white; border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; padding: 2px 4px; font-size: calc(12px * var(--ui-scale, 1)); outline: none; cursor: pointer; }
.custom-controls select option { background-color: #1e293b; }
input[type="range"] { flex-grow: 1; cursor: pointer; accent-color: #1777F1; height: 4px; min-width: 30px; }
.mobile-rotate-btn { display: none !important; }
.desktop-fullscreen-btn { display: flex !important; }


.course-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border-light); padding-bottom: 10px; margin-top: 5px; overflow-x: auto; flex-shrink: 0;}
.tab { font-size: calc(14px * var(--ui-scale, 1)); font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: 0.2s;}
.tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: -11px; }

.course-description { font-size: calc(14px * var(--ui-scale, 1)); color: var(--text-dark); line-height: 1.6; margin-top: 5px; flex-shrink: 0; }


.right-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; min-width: 0; }
.curriculum-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-shrink: 0;}
.curriculum-header h3 { font-size: calc(16px * var(--ui-scale, 1)); color: var(--text-dark); }
.progress-text { font-size: calc(12px * var(--ui-scale, 1)); color: var(--primary); font-weight: 600; }

.lesson-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overflow-x: hidden; padding-right: 5px; min-width: 0; }
.lesson-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: white; border-radius: 12px; border: 1px solid var(--border-light); cursor: pointer; transition: 0.2s;}
.lesson-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.lesson-item.active { border-color: var(--primary); background: rgba(23, 119, 241, 0.07); box-shadow: 0 8px 22px rgba(23, 119, 241, 0.12); position: relative; }
.lesson-item.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 999px; background: var(--primary); }
.lesson-item.active .lesson-info h4 { color: var(--primary); }
.lesson-item.active:hover { transform: none; }

.lesson-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-color); display: flex; justify-content: center; align-items: center; color: var(--text-muted); font-size: 14px; flex-shrink: 0;}
.lesson-item.active .lesson-icon { background: var(--primary); color: white; }
.lesson-item.completed .lesson-icon { background: #34C759; color: white; }

.lesson-info h4 { font-size: calc(13px * var(--ui-scale, 1)); color: var(--text-dark); margin-bottom: 4px; overflow-wrap: anywhere; word-break: break-word; }
.lesson-info p { font-size: calc(11px * var(--ui-scale, 1)); color: var(--text-muted); }


@media (max-width: 1100px) {
    .app-container { grid-template-columns: 240px 1fr; }
    .right-panel { display: none; } 

    .app-container.course-player .course-detail-tab-lessons { display: inline-flex; }
    .app-container.course-player .right-panel { display: none !important; }
}

@media (max-width: 768px) {
    .page-wrapper { padding: 0; display: block; }
    
    .app-container { 
        display: flex; flex-direction: column; 
        height: auto; min-height: 100vh;
        width: 100%; max-width: 100vw; overflow-x: hidden; overflow-wrap: break-word;
        padding: 15px; gap: 15px; border-radius: 0;
        background: rgba(244, 247, 254, 0.95); border: none; box-shadow: none;
    }

    /* Course player: denser layout on mobile */
    .app-container.course-player {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-top: 8px;
        padding-bottom: 10px;
        gap: 10px;
    }
    
    
    .hamburger-btn { display: flex; }
    
    .sidebar { 
        position: fixed; top: 0; left: -300px; 
        width: 280px; height: 100vh; 
        background: var(--bg-color); 
        padding: 20px; box-shadow: 2px 0 20px rgba(0,0,0,0.1);
        transition: left 0.3s ease; z-index: 100;
    }
    
    .sidebar.show { left: 0; }
    .close-sidebar-btn { display: block; }
    
    
    .main-content { overflow: visible; padding-right: 0; height: auto;}
    
    
    .header { flex-direction: column; align-items: stretch; gap: 15px; margin-bottom: 20px !important; }
    .app-container.course-player .header { gap: 10px; margin-bottom: 10px !important; }
    .header .hamburger-btn { align-self: flex-start; }
    .header-text h1 { font-size: 18px; }
    .header > div[style*="margin-left: auto"] { margin-left: 0 !important; flex-direction: column; width: 100%; align-items: stretch !important; gap: 10px !important; }
    .header > div[style*="margin-left: auto"] > div { width: 100% !important; }
    .header input[type="text"] { width: 100% !important; }
    .header .btn { width: 100%; justify-content: center; }
    
    
.player-wrapper { max-height: unset; width: 100%; aspect-ratio: 16 / 9; }
.video-cover { font-size: 5vw; }
.custom-controls { padding: 0 6px; gap: 4px; height: 30px; background: #0f172a;}
.time-display { font-size: 10px; min-width: 60px;}
.custom-controls button { padding: 2px; }
.custom-controls button .material-symbols-outlined { font-size: 18px; }
.desktop-fullscreen-btn { display: none !important; }
.mobile-rotate-btn { display: flex !important; } 
    
    
    .right-panel { 
        display: flex; height: auto; overflow: visible; margin-top: 4px; padding: 12px;
    }
    .app-container.course-player .right-panel { display: none !important; }
    .curriculum-header { margin-bottom: 10px; }
    .lesson-list { max-height: 360px; overflow-y: auto; padding-right: 4px; } 

    .lesson-item { padding: 10px; border-radius: 12px; }
    .lesson-icon { width: 34px; height: 34px; }

    .app-container.course-player .course-progress-card { margin-top: 8px; padding: 10px 12px; }

    .app-container.course-player .course-details-panel { margin-top: 8px; padding: 10px; }
    .app-container.course-player .course-detail-tab { font-size: calc(11px * var(--ui-scale, 1)); padding: 7px 5px; }
    .app-container.course-player .course-complete-btn { padding: 8px 12px; font-size: calc(12px * var(--ui-scale, 1)); }
    .app-container.course-player .course-completed-pill { padding: 8px 12px; font-size: calc(12px * var(--ui-scale, 1)); }
}


.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }


.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.admin-stat-card { display: flex; flex-direction: column; gap: 8px; justify-content: center; align-items: center; text-align: center; padding: 30px 20px !important; }
.admin-stat-card h3 { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px;}
.admin-stat-card h2 { font-size: 36px; color: var(--primary); font-weight: 700;}

.admin-header-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.admin-table-wrapper { overflow-x: auto; width: 100%; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 15px; border-bottom: 1px solid var(--border-light); font-size: calc(13px * var(--ui-scale, 1)); color: var(--text-dark); white-space: nowrap; }
.admin-table th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.admin-table tr:hover { background: rgba(255,255,255,0.4); }

.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 6px; font-size: calc(12px * var(--ui-scale, 1)); font-weight: 600; color: var(--text-sidebar); text-transform: uppercase; }
.form-control { width: 100%; padding: 12px 15px; border-radius: 10px; border: 1px solid var(--border-light); background: rgba(255,255,255,0.7); outline: none; font-family: 'Inter'; font-size: calc(14px * var(--ui-scale, 1)); transition: 0.2s; box-sizing: border-box; }
.form-control:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(23,119,241,0.1); }
textarea.form-control { resize: vertical; min-height: 100px; }

.btn { padding: 12px 24px; border-radius: 10px; border: none; background: var(--primary); color: white; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: calc(14px * var(--ui-scale, 1)); display: inline-flex; align-items: center; gap: 8px; text-decoration: none;}
.btn:hover { box-shadow: 0 6px 20px rgba(23, 119, 241, 0.3); transform: translateY(-2px); }
.btn-sm { padding: 8px 14px; font-size: calc(12px * var(--ui-scale, 1)); border-radius: 8px; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3); }
.btn-secondary { background: white; color: var(--text-sidebar); border: 1px solid var(--border-light); }
.btn-secondary:hover { background: #f8fafc; box-shadow: var(--shadow); }

@media (min-width: 769px) {
    .app-container.admin-layout { grid-template-columns: 240px 1fr !important; }
}

.admin-table-wrapper { overflow-x: auto; overflow-y: auto; max-height: 400px; width: 100%; }
.admin-table th { position: sticky; top: 0; background: #fff; z-index: 10; }


.admin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}
.dashboard-grid-full {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}
@media (max-width: 1024px) {
    .admin-grid, .dashboard-grid, .dashboard-grid-full { grid-template-columns: 1fr !important; }
}
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}


.admin-split-card { display: flex; flex-direction: row; padding: 0 !important; margin-top: 10px; overflow: hidden; min-height: 600px; }
.admin-split-sidebar { width: 250px; background: rgba(244, 247, 254, 0.5); border-right: 1px solid var(--border-light); padding: 20px; flex-shrink: 0; }
.admin-split-content { flex-grow: 1; padding: 30px; overflow-y: auto; background: white;}

@media (max-width: 768px) {
    .admin-split-card { flex-direction: column; min-height: auto; }
    .admin-split-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-light); padding: 15px; }
    .admin-split-content { padding: 15px; }
}
