:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --primary: #2563eb;
    --text: #1f2937;
    --muted: #6b7280;
    --radius: 14px;
}

[data-theme="dark"] {
    --bg: #454545;
    --surface: #111827;
    --primary: #60a5fa;
    --text: #e5e7eb;
    --muted: #9ca3af;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: system-ui;
    background: var(--bg);
    color: var(--text);
}

button {
    cursor: pointer;
}

/* TOPBAR */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;

    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: #0f172a;
    color: white;

    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

/* ===== BRAND ===== */

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

/* ===== NAV ===== */

.nav {
    display: flex;
    align-items: center;
}

.nav a {
    margin: 0 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: white;
    font-weight: 500;
}

.nav a:hover {
    color: #60a5fa;
}

.nav a.active {
    color: #60a5fa;
}

/* ===== ICON BUTTONS ===== */
.iconBtnGrp {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ===== MENU BUTTON ===== */

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
}

/* ================= MOBILE ================= */

@media (max-width: 768px) {

    .menu-btn {
        display: block;
    }

    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;

        background: #0f172a;
        flex-direction: column;
        align-items: flex-start;

        padding: 12px 0;
        gap: 6px;

        transform: translateY(-10px);
        opacity: 0;
        pointer-events: none;
        transition: all 0.25s ease;
    }

    .nav.show {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav a {
        width: 100%;
        padding: 12px 24px;
        margin: 0;
    }

    .nav a span {
        margin-left: 8px;
    }
}

/* LAYOUT */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 64px);
    /* allow growth */
}

/* ================= NEW DASHBOARD ================= */

.overview-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.overview-item {
    background: var(--surface);
    padding: 22px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.overview-item .label {
    font-size: .8rem;
    color: var(--muted);
}

.overview-item .value {
    font-size: 1.6rem;
    font-weight: 700;
}

.dashboard-section {
    margin-top: 28px;
}

.program-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.program {
    background: var(--surface);
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .05);
}

.program span {
    font-size: .85rem;
    color: var(--muted);
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.activity {
    background: var(--surface);
    padding: 14px 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .05);
}

.activity i {
    color: var(--primary);
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.insight-card {
    background: var(--surface);
    padding: 18px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .05);
}

.insight-card.good span {
    color: #16a34a;
    font-weight: 600;
}

.insight-card.warn span {
    color: #dc2626;
    font-weight: 600;
}


/* ================= SIDEBAR ================= */
.sidebar {
    position: sticky;
    top: 64px;
    /* navbar height */

    height: 90vh;
    /* fixed viewport height */
    max-height: 90vh;

    background: var(--surface);
    padding: 28px;
    border-right: 1px solid #e5e7eb;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    overflow-y: auto;
    /* internal scroll */
    overscroll-behavior: contain;

    border-radius: 0 16px 16px 0;
    /* optional polish */
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-section h5 {
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.6;
    margin: 12px 10px;
    text-transform: uppercase;
}

/* ===== BUTTONS ===== */

.sidebar button {
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 12px 14px;
    margin: 4px 0;
    border-radius: 6px;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 10px;

    font-size: 0.95rem;
    transition: all 0.2s ease;
}

/* Hover */
.sidebar button:hover {
    background: rgba(96, 165, 250, 0.12);
    color: var(--primary);
}

/* ===== ACTIVE STATE ===== */

.sidebar button.active {
    background: rgba(96, 165, 250, 0.18);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 #60a5fa;
}

/* Icon color sync */
.sidebar button.active i {
    color: var(--primary);
}

/* ===== FOOTER ===== */

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    font-size: 0.8rem;
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* MAIN */
.main {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 50px;
}

.page {
    display: none
}

.page.active {
    display: block
}

/* FLEX */
.flex-metrics {
    display: flex;
    gap: 24px;
    flex-wrap: wrap
}

.metric {
    flex: 1;
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius);
    text-align: center
}

.metric span {
    font-size: 1.6rem;
    font-weight: 700
}

/* SEARCH BOX */
.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    max-width: 420px;
    margin-bottom: 16px;
}

.search-box i {
    color: var(--muted);
    font-size: 0.95rem;
}

.search-box input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.95rem;
    background: transparent;
    color: var(--text);
}

.search-box:focus-within {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .25);
}

/* NO DATA STATE */
.no-data {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.no-data i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: .6;
}

.no-data p {
    margin: 0;
    font-size: .95rem;
}


/* GRID */
.grid-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.insight {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    text-align: center
}

/* ================= LESSON SYSTEM ================= */

/* LIST VIEW */
.lesson-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.lesson-item {
    background: var(--surface);
    padding: 22px;
    border-radius: 14px;
    cursor: pointer;
    transition: .25s;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.lesson-item h4 {
    margin: 0 0 6px;
}

.lesson-item p {
    margin: 0;
    font-size: .9rem;
    color: var(--muted);
}

.lesson-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, .12);
}

/* DETAIL VIEW */
.lesson-list-view {
    display: none
}

.lesson-list-view.active {
    display: block
}

.lesson-detail-view {
    display: none
}

.lesson-detail-view.active {
    display: block
}

.lesson-detail-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .08);
    margin-top: 20px;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* MEDIA */
#lessonMedia {
    margin-top: 18px;
}

#lessonMedia audio {
    width: 100%;
}

#lessonMedia .video-box {
    max-height: 50vh;
}

/* Responsive */
@media(max-width:600px) {
    .lesson-detail-card {
        padding: 24px;
    }
}


/* VIDEO FIX */
.video-box {
    width: 100%;
    max-width: 100%;
    max-height: 50vh;
    /* prevents vertical overflow */
    overflow: hidden;
    border-radius: 12px;
    margin-top: 16px;

    display: flex;
    justify-content: center;
    align-items: center;
}

.video-box video {
    width: 100%;
    height: 100%;
    max-height: 50vh;
    object-fit: contain;
    /* no cropping, no overflow */
    border-radius: 12px;
    background: black;
}

/* PROFILE */
.profile-card {
    display: flex;
    gap: 30px;
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    flex-wrap: wrap
}

.profile-pic {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover
}

.profile-stats {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

/* ================= TABLE UI ================= */

.table-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .06);
    overflow: hidden;
}

/* Header */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
}

.count-badge {
    background: rgba(37, 99, 235, .1);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: .75rem;
}

/* Wrapper */
.table-wrap {
    overflow-x: auto;
}

/* Table */
.pro-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* Head */
.pro-table thead th {
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
    padding: 14px 18px;
    font-size: .85rem;
    color: var(--text);
    border-bottom: 1px solid #e5e7eb;
}

/* Body */
.pro-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    font-size: .9rem;
}

/* Zebra */
.pro-table tbody tr:nth-child(even) {
    background: var(--surface);
}

/* Hover */
.pro-table tbody tr:hover {
    background: var(--surface);
    transition: .2s;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.status.active {
    background: rgba(34, 197, 94, .12);
    color: #16a34a;
}

.status.inactive {
    background: rgba(239, 68, 68, .12);
    color: #dc2626;
}


/* RESPONSIVE */
@media(max-width:1000px) {
    .app {
        grid-template-columns: 1fr
    }

    .sidebar {
        display: none
    }
}

@media(max-width:600px) {
    .topbar {
        gap: 10px
    }

    .video-box {
        max-height: 40vh;
    }

    .video-box video {
        max-height: 40vh;
    }
}