/* =====================================================================
   Student sidebar (#mobile-sidebar in base::frontend.layout — the same
   element is the desktop column and the phone drawer).
   A reskin only: the markup is untouched, so most rules beat inline
   styles with !important. Removing the <link> restores the old look.
   Matches the dashboard layer (student-dashboard-pro.css): flat cards,
   brand green #165D31, 10px items, a mint fill for the current page.
   ===================================================================== */

#mobile-sidebar {
    --ss-green: #165D31;
    --ss-mint: #EAF5EE;
    --ss-hover: #F3F6F4;
    --ss-ink: #1D2939;
    --ss-text: #344054;
    --ss-muted: #667085;
    --ss-line: #E6EBE8;
    --ss-card: #FFFFFF;
    /* icons are mixed-colour SVGs: flatten to one gray, tint green for the current page */
    --ss-icon: brightness(0) opacity(.62);
    --ss-icon-on: brightness(0) invert(27%) sepia(15%) saturate(2300%) hue-rotate(100deg) brightness(93%) contrast(89%);
}

.active-dark-mode #mobile-sidebar {
    --ss-green: #7BCF99;
    --ss-mint: rgba(123, 207, 153, .13);
    --ss-hover: rgba(255, 255, 255, .05);
    --ss-ink: #F2F4F3;
    --ss-text: #D0D5DD;
    --ss-muted: #98A2B3;
    --ss-line: #2A2A2A;
    --ss-card: #1C1C1C;
    --ss-icon: brightness(0) invert(.78);
    --ss-icon-on: brightness(0) invert(80%) sepia(18%) saturate(800%) hue-rotate(84deg) brightness(92%);
}

/* ---------- the column ---------- */
@media (min-width: 992px) {
    #mobile-sidebar.sidebar {
        border: 1px solid var(--ss-line);
        background: var(--ss-card) !important;
    }
}

#mobile-sidebar .sidebar-content {
    padding: 16px 8px !important;
    background: var(--ss-card) !important;
}

/* ---------- menu rows ---------- */
#mobile-sidebar .sidebar-item,
#mobile-sidebar .sidebar-item:hover {
    background: transparent !important;
}

#mobile-sidebar .sidebar-item + .sidebar-item {
    margin-top: 2px;
}

#mobile-sidebar .side-inner-item,
#mobile-sidebar .head-subjects-div {
    position: relative;
    min-height: 40px;
    padding: 8px 10px !important;
    border-radius: 10px !important;
    gap: 10px;
    transition: background-color .15s;
}

#mobile-sidebar .sidebar-item:hover .side-inner-item,
#mobile-sidebar .head-subjects-div:hover {
    background: var(--ss-hover) !important;
}

#mobile-sidebar .side-inner-item > img,
#mobile-sidebar .head-subjects-div img {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    filter: var(--ss-icon);
}

#mobile-sidebar .sidebar-menu-item {
    color: var(--ss-text) !important;
    font-size: 14px;
    font-weight: 500;
    line-height: 22px;
}

/* the current page: mint fill, green text and icon, a short bar on the start edge */
#mobile-sidebar .side-item-selected {
    background: var(--ss-mint) !important;
}

#mobile-sidebar .side-item-selected::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 3px;
    background: var(--ss-green);
}

#mobile-sidebar .side-item-selected > img {
    filter: var(--ss-icon-on);
}

#mobile-sidebar .sidebar-menu-active {
    color: var(--ss-green) !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 22px;
}

/* ---------- curricula (التحصيلي / القدرات) and their subjects ---------- */
#mobile-sidebar .sidebar-curriculum-section + .sidebar-curriculum-section,
#mobile-sidebar .sidebar-curriculum-section {
    margin-top: 2px;
}

#mobile-sidebar .head-subjects-div .sidebar-menu-item {
    font-weight: 600 !important;
    color: var(--ss-ink) !important;
}

#mobile-sidebar .head-subjects-div [class^="sidebar-curriculum-arrow-"] {
    width: 14px !important;
    height: 14px !important;
    filter: var(--ss-icon);
}

/* a guide line ties the subjects to their curriculum */
#mobile-sidebar [class^="sidebar-subjects-"] {
    margin: 2px 0 6px;
    margin-inline-start: 18px;
    padding-inline-start: 4px !important;
    border-inline-start: 1px solid var(--ss-line);
    gap: 1px;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a > div {
    min-height: 36px;
    padding: 6px 8px !important;
    border-radius: 8px !important;
    gap: 8px;
    transition: background-color .15s;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a:hover > div {
    background: var(--ss-hover);
}

#mobile-sidebar [class^="sidebar-subjects-"] > a > div > img {
    width: 18px !important;
    height: 18px !important;
    margin-inline-end: 0 !important;
    border-radius: 5px;
    object-fit: cover;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a > div > div:first-child {
    width: 18px !important;
    height: 18px !important;
    border-radius: 5px !important;
    background: var(--ss-mint) !important;
    color: var(--ss-green) !important;
}

#mobile-sidebar .sidebar-subject-name {
    color: var(--ss-text) !important;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45 !important;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a:hover .sidebar-subject-name {
    color: var(--ss-ink) !important;
}

#mobile-sidebar .sidebar-subject-count {
    min-width: 22px;
    padding: 0 6px;
    border: 0 !important;
    border-radius: 6px;
    background: var(--ss-hover) !important;
    color: var(--ss-muted) !important;
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
}

/* ---------- student code (dashboard only) ---------- */
#mobile-sidebar div:has(> .sidebar-student-code-label) {
    padding: 10px 12px !important;
    border: 1px dashed color-mix(in srgb, var(--ss-green) 40%, transparent) !important;
    border-radius: 12px !important;
    background: var(--ss-mint) !important;
    gap: 2px !important;
}

#mobile-sidebar .sidebar-student-code-label {
    color: var(--ss-muted) !important;
    font-size: 11.5px;
}

#mobile-sidebar .sidebar-student-code {
    color: var(--ss-ink) !important;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

#mobile-sidebar .copy-icon {
    font-size: 16px !important;
    color: var(--ss-green) !important;
}

/* ---------- upgrade card ---------- */
#mobile-sidebar a > div:has(> .sidebar-upgrade-title) {
    padding: 14px !important;
    border-radius: 14px !important;
    background: #165D31 !important;
}

#mobile-sidebar .sidebar-upgrade-title {
    font-size: 14.5px;
    font-weight: 600;
}

#mobile-sidebar .sidebar-upgrade-description {
    color: rgba(255, 255, 255, .8);
    line-height: 1.6;
}

#mobile-sidebar div:has(> .sidebar-upgrade-button) {
    padding: 6px 8px 6px 14px !important;
    padding-inline-start: 14px !important;
    padding-inline-end: 6px !important;
    border-radius: 9px !important;
    background: #fff;
    transition: transform .12s;
}

#mobile-sidebar a:hover div:has(> .sidebar-upgrade-button) {
    transform: translateY(-1px);
}

#mobile-sidebar .sidebar-upgrade-button {
    color: #165D31;
    font-size: 13px;
    font-weight: 700;
}

#mobile-sidebar div:has(> .sidebar-upgrade-button) > div:last-child {
    background: #EAF5EE !important;
    color: #165D31;
}

/* ---------- logged-out: register / login ----------
   side by side they overflow the narrow desktop column, so they stack there */
@media (min-width: 992px) {
    #mobile-sidebar .drawer-auth-actions {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    #mobile-sidebar .drawer-auth-btn {
        height: 40px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
    }
}

/* =====================================================================
   Motion. Everything plays once (on load, on opening the phone drawer,
   on expanding a curriculum) or on hover; nothing loops, so the sidebar
   never pulls the eye away from the page.
   ===================================================================== */
#mobile-sidebar {
    --ss-ease: cubic-bezier(.2, .8, .2, 1);
    --ss-spring: cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes ss-row-in {
    from { opacity: 0; transform: translateX(var(--ss-from, 10px)); }
}

@keyframes ss-bar-in {
    from { transform: scaleY(0); }
}

@keyframes ss-pop {
    0% { transform: scale(.6); opacity: 0; }
    70% { transform: scale(1.08); opacity: 1; }
}

@keyframes ss-nudge {
    0%, 100% { transform: none; }
    35% { transform: rotate(-10deg) scale(1.12); }
    70% { transform: rotate(4deg); }
}

@keyframes ss-shine {
    from { transform: translateX(-120%) skewX(-18deg); }
    to { transform: translateX(220%) skewX(-18deg); }
}

@keyframes ss-hop {
    0%, 100% { transform: none; }
    40% { transform: translateY(-6px) rotate(-3deg); }
    70% { transform: translateY(1px); }
}

html[dir="ltr"] #mobile-sidebar { --ss-from: -10px; }

/* rows slide in one after another: on load (desktop column) and each time the phone drawer opens */
@media (min-width: 992px) {
    #mobile-sidebar .sidebar-item,
    #mobile-sidebar .sidebar-curriculum-section {
        animation: ss-row-in .45s var(--ss-ease) backwards;
    }
}

#mobile-sidebar.mobile-active .sidebar-item,
#mobile-sidebar.mobile-active .sidebar-curriculum-section {
    animation: ss-row-in .45s var(--ss-ease) backwards;
}

#mobile-sidebar .sidebar-item:nth-child(1), #mobile-sidebar .sidebar-curriculum-section:nth-child(1) { animation-delay: .04s; }
#mobile-sidebar .sidebar-item:nth-child(2), #mobile-sidebar .sidebar-curriculum-section:nth-child(2) { animation-delay: .08s; }
#mobile-sidebar .sidebar-item:nth-child(3), #mobile-sidebar .sidebar-curriculum-section:nth-child(3) { animation-delay: .12s; }
#mobile-sidebar .sidebar-item:nth-child(4), #mobile-sidebar .sidebar-curriculum-section:nth-child(4) { animation-delay: .16s; }
#mobile-sidebar .sidebar-item:nth-child(5), #mobile-sidebar .sidebar-curriculum-section:nth-child(5) { animation-delay: .2s; }
#mobile-sidebar .sidebar-item:nth-child(6), #mobile-sidebar .sidebar-curriculum-section:nth-child(6) { animation-delay: .24s; }
#mobile-sidebar .sidebar-item:nth-child(7), #mobile-sidebar .sidebar-curriculum-section:nth-child(7) { animation-delay: .28s; }
#mobile-sidebar .sidebar-item:nth-child(8), #mobile-sidebar .sidebar-curriculum-section:nth-child(8) { animation-delay: .32s; }
#mobile-sidebar .sidebar-item:nth-child(9) { animation-delay: .36s; }
#mobile-sidebar .sidebar-item:nth-child(10) { animation-delay: .4s; }
#mobile-sidebar .sidebar-item:nth-child(n+11) { animation-delay: .44s; }

/* the current page's bar grows in after its row has landed */
#mobile-sidebar .side-item-selected::before {
    transform-origin: center;
    animation: ss-bar-in .4s var(--ss-spring) .45s backwards;
}

/* hover: the icon gives a small nod, the label leans in */
#mobile-sidebar .side-inner-item > div,
#mobile-sidebar .head-subjects-div .sidebar-menu-item {
    transition: transform .25s var(--ss-ease), color .15s;
}

#mobile-sidebar .sidebar-item:hover .side-inner-item > img,
#mobile-sidebar .head-subjects-div:hover > div > img {
    animation: ss-nudge .5s var(--ss-ease);
}

#mobile-sidebar .sidebar-item:hover .side-inner-item > div,
#mobile-sidebar .head-subjects-div:hover .sidebar-menu-item {
    transform: translateX(calc(var(--ss-from, 10px) * -.3));
}

#mobile-sidebar .sidebar-item:active .side-inner-item,
#mobile-sidebar .head-subjects-div:active {
    transform: scale(.98);
}

/* expanding a curriculum: its subjects drop in one by one, the counts pop */
#mobile-sidebar [class^="sidebar-subjects-"] > a {
    animation: ss-row-in .35s var(--ss-ease) backwards;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a:nth-child(2) { animation-delay: .05s; }
#mobile-sidebar [class^="sidebar-subjects-"] > a:nth-child(3) { animation-delay: .1s; }
#mobile-sidebar [class^="sidebar-subjects-"] > a:nth-child(n+4) { animation-delay: .15s; }

#mobile-sidebar .sidebar-subject-count {
    animation: ss-pop .4s var(--ss-spring) .25s backwards;
}

#mobile-sidebar [class^="sidebar-subjects-"] > a > div > img,
#mobile-sidebar [class^="sidebar-subjects-"] > a > div > div:first-child {
    transition: transform .25s var(--ss-spring);
}

#mobile-sidebar [class^="sidebar-subjects-"] > a:hover > div > img,
#mobile-sidebar [class^="sidebar-subjects-"] > a:hover > div > div:first-child {
    transform: scale(1.12) rotate(-4deg);
}

/* the curriculum arrow turns with a little spring (its rotation is set inline by the toggle) */
#mobile-sidebar [class^="sidebar-curriculum-arrow-"] {
    transition: transform .4s var(--ss-spring) !important;
}

/* upgrade card: a light sweep and the key mascot hops, on hover only */
#mobile-sidebar a > div:has(> .sidebar-upgrade-title) {
    position: relative;
    overflow: hidden;
    transition: transform .25s var(--ss-ease), box-shadow .25s;
}

#mobile-sidebar a > div:has(> .sidebar-upgrade-title)::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
}

#mobile-sidebar a:hover > div:has(> .sidebar-upgrade-title) {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -14px rgba(22, 93, 49, .6);
}

#mobile-sidebar a:hover > div:has(> .sidebar-upgrade-title)::after {
    animation: ss-shine .9s var(--ss-ease);
}

#mobile-sidebar div:has(> a > div > .sidebar-upgrade-title) > div:first-child img {
    transform-origin: bottom center;
}

#mobile-sidebar div:has(> a > div > .sidebar-upgrade-title):hover > div:first-child img {
    animation: ss-hop .7s var(--ss-ease);
}

/* student code: the copy icon springs when pressed */
#mobile-sidebar .copy-icon {
    display: inline-block;
    transition: transform .3s var(--ss-spring);
}

#mobile-sidebar .copy-icon:hover {
    transform: scale(1.15);
}

#mobile-sidebar .copy-icon:active {
    transform: scale(.85);
}

@media (prefers-reduced-motion: reduce) {
    #mobile-sidebar *,
    #mobile-sidebar *::before,
    #mobile-sidebar *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* =====================================================================
   Curriculum switcher in the phone drawer (التحصيلي / القدرات / +).
   home-dashboard.css stacks it in a column of outlined pills at phone
   widths; here it is one segmented bar: the tracks share the width, "+"
   is a small square at the end, the current track is filled green.
   ===================================================================== */
@media (max-width: 991px) {
    #mobile-sidebar .sidebar-content .navbar-curriculum-switcher {
        flex-direction: row !important;
        align-items: stretch;
        gap: 4px !important;
        margin: 4px 0 6px;
        padding: 4px !important;
        border: 1px solid var(--ss-line);
        border-radius: 14px !important;
        background: var(--ss-hover) !important;
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn-wrapper {
        flex: 1 1 0;
        min-width: 0 !important;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 8px !important;
        border: 0 !important;
        border-radius: 10px !important;
        background: transparent;
        transition: background-color .2s, box-shadow .2s, transform .15s !important;
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn-wrapper:not(.active):hover {
        background: var(--ss-card) !important;
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn-wrapper:active {
        transform: scale(.96);
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--ss-text) !important;
        font-size: 14px;
        font-weight: 500;
        line-height: 1.3;
        white-space: nowrap;
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn-wrapper.active {
        background: #165D31 !important;
        box-shadow: 0 2px 6px -2px rgba(22, 93, 49, .5);
        animation: ss-pop .35s var(--ss-spring);
    }

    #mobile-sidebar .sidebar-content .navbar-category-btn-wrapper.active .navbar-category-btn {
        color: #fff !important;
        font-weight: 600;
    }

    #mobile-sidebar .sidebar-content .category-soon {
        font-size: 11px;
        color: var(--ss-muted);
    }

    /* "+" (more curricula): a square at the end of the bar */
    #mobile-sidebar .sidebar-content .navbar-curriculum-more {
        flex: 0 0 44px;
        display: flex;
    }

    #mobile-sidebar .sidebar-content .navbar-category-more-btn {
        flex: 1;
        min-width: 0 !important;
        padding: 0 !important;
        background: var(--ss-card) !important;
        border: 1px solid var(--ss-line) !important;
    }

    #mobile-sidebar .sidebar-content .navbar-category-more-btn .navbar-category-btn {
        color: var(--ss-muted) !important;
    }

    #mobile-sidebar .sidebar-content .navbar-curriculum-more:hover .navbar-category-btn,
    #mobile-sidebar .sidebar-content .navbar-curriculum-more.show .navbar-category-btn {
        color: var(--ss-green) !important;
    }

    #mobile-sidebar .sidebar-content .navbar-category-more-btn svg {
        transition: transform .3s var(--ss-spring);
    }

    #mobile-sidebar .sidebar-content .navbar-curriculum-more.show .navbar-category-more-btn svg {
        transform: rotate(45deg);
    }
}

/* Web: register / login already sit in the top bar, so the sidebar copies go (phones keep them in the drawer) */
@media (min-width: 992px) {
    #mobile-sidebar .drawer-auth-actions { display: none !important; }
}
