@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-base: #060911;
    --bg-surface: #0b0f19;
    --bg-card: rgba(16, 22, 36, 0.75);
    --bg-card-hover: rgba(22, 30, 48, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(99, 102, 241, 0.3);
    
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.2);
    
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==============================================================================
   ULTRA-SMOOTH CUSTOM SCROLLBAR DESIGN
   ============================================================================== */
html {
    scroll-behavior: smooth;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4f46e5 0%, #8b5cf6 50%, #06b6d4 100%);
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6366f1 0%, #a855f7 50%, #22d3ee 100%);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.8);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 var(--bg-base);
}

/* TOP PROGRESS LOADER BAR */
#topProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--primary-gradient);
    width: 0%;
    z-index: 9999;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px #6366f1;
}

/* APP SHELL LAYOUT */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR DASHBOARD NAVIGATION */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-badge {
    background: var(--primary-gradient);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-glow);
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.brand-name span {
    color: var(--accent-cyan);
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #6366f1;
}

.nav-section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 12px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    transform: translateX(3px);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-left: 3px solid var(--primary);
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* MAIN CONTENT AREA */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOP HEADER */
.app-header {
    height: 72px;
    background: rgba(11, 15, 25, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.search-bar {
    position: relative;
    max-width: 460px;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input {
    width: 100%;
    height: 44px;
    background: rgba(18, 24, 38, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    padding: 0 48px 0 44px;
    color: #f8fafc;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    backdrop-filter: blur(12px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.search-input::placeholder {
    color: #64748b;
    font-size: 0.85rem;
}

.search-input:focus {
    background: rgba(22, 30, 48, 0.95);
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #818cf8;
    font-size: 0.95rem;
    pointer-events: none;
}

.search-kbd {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.72rem;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* CONTENT CONTAINER */
.page-content {
    padding: 32px;
    flex: 1;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
}

/* STATS METRIC CARDS */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.metric-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-accent);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
    opacity: 0.7;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.metric-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-icon-badge {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.metric-trend {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* COURSE DATA CARDS */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.course-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
}

.course-thumb-wrap {
    position: relative;
    height: 180px;
    overflow: hidden;
}

.course-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.course-card:hover .course-thumb {
    transform: scale(1.05);
}

.course-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #34d399;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.course-body {
    padding: 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.course-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    line-height: 1.4;
}

.course-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
    flex: 1;
    line-height: 1.6;
}

.course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* BUTTONS */
.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* PAGINATION COMPONENT */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 36px;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.page-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* SKELETON LOADING SHIMMER */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==============================================================================
   MOBILE-FIRST RESPONSIVE STYLES (iOS / Android / Tablet)
   ============================================================================== */
.mobile-hamburger-btn {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: #fff;
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mobile-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: auto;
}

.mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 99;
}

@media (max-width: 900px) {
    .mobile-hamburger-btn {
        display: flex;
    }
    
    .mobile-close-btn {
        display: block;
    }

    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
        width: 290px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
    }

    .app-sidebar.mobile-open {
        transform: translateX(0);
    }

    .mobile-backdrop.active {
        display: block;
    }

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .app-header {
        padding: 0 16px;
        gap: 10px;
    }

    .page-content {
        padding: 16px;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .course-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Lesson Player Mobile Grid */
    div[style*="grid-template-columns: 320px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Sandbox Mobile Grid */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .sandbox-header-btn {
        display: none;
    }
}

@media (max-width: 540px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .admin-header-btn {
        display: none;
    }
}
