*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-w: 250px;
    --topbar-h: 64px;
    --red: #bc3030;
    --red-light: #f4d2d2;
    --orange: #ff7f11;
    --text: #222;
    --muted: #888;
    --border: #ececec;
}

body {
    font-family: "Poppins", sans-serif;
    background: #f7f8fc;
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* OVERLAY */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 200;
}
.sidebar-overlay.open {
    display: block;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 300;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
    height: 70px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-logo img {
    height: 100%;
    width: 75%;
    object-fit: contain;
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--muted);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.nav-item:hover {
    background: var(--red-light);
    color: var(--red);
}
.nav-item.active {
    background: var(--red-light);
    color: var(--red);
}
.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-bottom {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.upgrade-btn {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 22px;
    padding: 11px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-bottom: 12px;
    font-family: "Poppins", sans-serif;
}
.logout-link {
    display: block;
    text-align: center;
    color: var(--red);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* MAIN */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

/* TOPBAR */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 99;
    gap: 12px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    flex-wrap: nowrap;
}

.dropdown {
    position: relative;
    min-width: 180px;
}
.dropdown-selected {
    border: 2px solid var(--orange);
    border-radius: 12px;
    padding: 5px 14px;
    font-size: 15px;
    color: var(--orange);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: "Poppins", sans-serif;
}
.chevron-down-d {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.dropdown-options {
    position: absolute;
    width: 100%;
    top: calc(100% + 6px);
    left: 0;
    border: 2px solid #eee;
    border-radius: 10px;
    background: #fff;
    display: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    z-index: 200;
}
.dropdown-option {
    padding: 11px 16px;
    cursor: pointer;
    font-size: 14px;
}
.dropdown-option:hover {
    background: #fddabb;
}
.notif-btn {
    width: 44px;
    height: 44px;
    background: #fff;
    border: 1.5px solid #aaa;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.notif-dot {
    position: absolute;
    top: 5px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #f44;
    border-radius: 50%;
    border: 1.5px solid #fff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-shrink: 0;
}
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f5a623, #e05a5a);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-text {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-size: 15px;
    font-weight: 500;
    color: #222;
    line-height: 1.2;
    white-space: nowrap;
}
.user-grade {
    font-size: 13px;
    font-weight: 500;
    color: #888;
    white-space: nowrap;
}
.chevron-down {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* CONTENT */
.content {
    padding: 28px 40px 40px 40px;
}

.subject-section {
    margin-bottom: 32px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    font-size: 24px;
    font-weight: 500;
    color: #000;
}
.explore-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #4f46e5;
    font-size: 0.85rem;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.explore-link:hover {
    color: #e05a5a;
}

.chapter-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.chapter-card {
    background: #eef2ff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 4px 12px rgba(163, 183, 249, 0.41);
    cursor: pointer;
    transition:
        box-shadow 0.2s,
        transform 0.2s;
    display: flex;
    flex-direction: column;
}
.chapter-card:hover {
    box-shadow: 0 8px 24px rgba(163, 183, 249, 0.6);
    transform: translateY(-2px);
}
.chapter-card.english {
    background: #ffefee;
    box-shadow: 0 4px 12px rgba(255, 180, 176, 0.4);
}
.chapter-card.english:hover {
    box-shadow: 0 8px 24px rgba(255, 140, 134, 0.5);
}
.chapter-card.maths {
    background: #ffeffd;
    box-shadow: 0 4px 12px rgba(255, 180, 253, 0.4);
}
.chapter-card.maths:hover {
    box-shadow: 0 8px 24px rgba(255, 140, 252, 0.5);
}

.chapter-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 10px;
    background: #dde4ff;
    display: block;
    flex-shrink: 0;
}

.chapter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 500;
    margin: 12px 4px 10px;
    color: #2a2a2a;
    flex: 1;
}

.game-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.game-icon img {
    width: 100%;
    height: 100%;
}

.chapter-actions {
    display: flex;
    gap: 6px;
    justify-content: stretch;
}
.chapter-actions button {
    flex: 1;
    border: none;
    background: #c6d3fd;
    padding: 10px 6px;
    border-radius: 10px;
    font-size: 13px;
    font-family: "Poppins", sans-serif;
    cursor: pointer;
    color: #1a1a1a;
    transition: background 0.2s;
    white-space: nowrap;
}
.chapter-actions button:hover {
    background: #9eb0db;
}

.chapter-card.english .chapter-actions button {
    background: #fdd5d2;
}
.chapter-card.english .chapter-actions button:hover {
    background: #f7beba;
}
.chapter-card.maths .chapter-actions button {
    background: #ffc9f8;
}
.chapter-card.maths .chapter-actions button:hover {
    background: #fdb5f4;
}

.explore-row {
    text-align: right;
    margin-top: 12px;
}

/* ══════════════════════════════
       RESPONSIVE
    ══════════════════════════════ */

/* Tablet: icon-only sidebar rail */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 70px;
    }

    .nav-item span {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
        gap: 0;
    }
    .sidebar-bottom {
        padding: 12px 10px;
    }
    .upgrade-btn {
        font-size: 0;
        padding: 12px;
        border-radius: 50%;
    }
    .upgrade-btn::before {
        content: "★";
        font-size: 16px;
    }
    .logout-link {
        font-size: 0;
    }
    .logout-link::before {
        content: "↩";
        font-size: 18px;
    }
    .sidebar-logo img {
        width: 100%;
    }

    .content {
        padding: 24px 24px 40px 24px;
    }
}

/* Mobile: off-canvas drawer */
@media (max-width: 680px) {
    :root {
        --sidebar-w: 250px;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    }

    .nav-item span {
        display: inline;
    }
    .nav-item {
        justify-content: flex-start;
        padding: 11px 14px;
        gap: 11px;
    }
    .sidebar-bottom {
        padding: 16px 20px;
    }
    .upgrade-btn {
        font-size: 0.78rem;
        padding: 11px 14px;
        border-radius: 22px;
    }
    .upgrade-btn::before {
        content: "";
        font-size: 0;
    }
    .logout-link {
        font-size: 0.88rem;
    }
    .logout-link::before {
        content: "";
    }
    .sidebar-logo img {
        width: 75%;
    }
    .sidebar-close {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }
    .hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .dropdown {
        display: none;
    }
    .topbar {
        padding: 0 16px;
    }

    .content {
        padding: 20px 16px 40px 16px;
    }

    /* single column on very small phones */
    /* .chapter-container {
        grid-template-columns: 1fr;
      } */
}
