/* ══════════════════════════════════════════════════════════════
   Student First — Navigation System (PBI 20406)
   BEM naming: sf-nav / sf-nav__element / sf-nav--modifier
   ══════════════════════════════════════════════════════════════ */

/* ── Root tokens ─────────────────────────────────────────────── */
:root {
    --sf-nav-main-expanded: 144px;
    --sf-nav-main-collapsed: 40px;
    --sf-nav-student-width: 120px;
    --sf-nav-width: 144px; /* dynamic — set by JS */

    --sf-nav-bg: #475569;
    --sf-nav-bg-dark: #334155;
    --sf-nav-text: rgba(255,255,255,0.85);
    --sf-nav-text-muted: rgba(255,255,255,0.6);
    --sf-nav-text-active: #ffffff;
    --sf-nav-hover: rgba(255,255,255,0.08);
    --sf-nav-active: rgba(255,255,255,0.13);
    --sf-nav-border-active: #ffffff;
    --sf-nav-shadow: 2px 0 12px rgba(0,0,0,0.18);

    --sf-nav-student-bg: #e2e8f0;
    --sf-nav-student-text: #334155;
    --sf-nav-student-text-muted: #64748b;
    --sf-nav-student-border-active: #475569;
}

/* ── Outer nav container ─────────────────────────────────────── */
.sf-nav {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: row;
    z-index: 20; /* --sf-z-main-menu */
    transition: width 200ms ease;
}

/* ── Main panel ──────────────────────────────────────────────── */
.sf-nav__main {
    width: var(--sf-nav-main-expanded);
    background: var(--sf-nav-bg);
    color: var(--sf-nav-text);
    display: flex;
    flex-direction: column;
    box-shadow: var(--sf-nav-shadow);
    overflow: hidden;
    transition: width 200ms ease;
}

.sf-nav--collapsed .sf-nav__main {
    width: var(--sf-nav-main-collapsed);
}

/* ── Logo header ─────────────────────────────────────────────── */
.sf-nav__header {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    flex-shrink: 0;
}

.sf-nav__header-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.sf-nav__header-text {
    font: 700 13px/1 'DM Sans', sans-serif;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
}

.sf-nav--collapsed .sf-nav__header-text {
    display: none;
}

.sf-nav--collapsed .sf-nav__header {
    justify-content: center;
    padding: 10px 0;
}

/* ── Section label ───────────────────────────────────────────── */
.sf-nav__section-label {
    font: 600 9px/1 'DM Sans', sans-serif;
    color: var(--sf-nav-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 8px 8px 2px;
    flex-shrink: 0;
}

.sf-nav--collapsed .sf-nav__section-label {
    display: none;
}

/* ── Scrollable items region ─────────────────────────────────── */
.sf-nav__items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0;
}

/* Thin scrollbar */
.sf-nav__items::-webkit-scrollbar { width: 3px; }
.sf-nav__items::-webkit-scrollbar-track { background: transparent; }
.sf-nav__items::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* ── Parent item (button) ────────────────────────────────────── */
.sf-nav__parent {
    display: flex;
    align-items: center;
    width: calc(100% - 6px);
    margin: 1px 3px;
    min-height: 28px;
    padding: 6px 4px 6px 6px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-text);
    font: 400 12px/1.3 'DM Sans', sans-serif;
    cursor: pointer;
    gap: 5px;
    text-align: left;
    transition: background-color 100ms;
}

.sf-nav__parent:hover,
.sf-nav__parent:focus {
    background: var(--sf-nav-hover);
    color: var(--sf-nav-text);
    text-decoration: none;
}

.sf-nav__parent[aria-expanded="true"] {
    background: var(--sf-nav-active);
    color: var(--sf-nav-text-active);
    font-weight: 500;
}

.sf-nav__parent:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #e2e8f0;
}

/* ── Parent icon ─────────────────────────────────────────────── */
.sf-nav__icon {
    width: 12px;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
    /* Don't set color here — let icon color classes (.blue-icon etc.) apply */
}

/* ── Parent label ────────────────────────────────────────────── */
.sf-nav__label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sf-nav--collapsed .sf-nav__label {
    display: none;
}

/* ── Chevron ─────────────────────────────────────────────────── */
.sf-nav__chevron {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.sf-nav__parent[aria-expanded="true"] .sf-nav__chevron {
    transform: rotate(90deg);
}

.sf-nav--collapsed .sf-nav__chevron {
    display: none;
}

/* ── Children container ──────────────────────────────────────── */
.sf-nav__children {
    padding: 0;
    margin: 0;
    list-style: none;
}

/* ── Child item (link) ───────────────────────────────────────── */
.sf-nav__child {
    display: block;
    width: calc(100% - 6px);
    margin: 1px 3px;
    min-height: 24px;
    padding: 5px 4px 5px 18px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-text);
    font: 400 11px/1.35 'DM Sans', sans-serif;
    text-decoration: none;
    cursor: pointer;
    word-break: break-word;
    white-space: normal;
    transition: background-color 100ms;
    border-left: 3px solid transparent;
}

.sf-nav__child:hover {
    background: var(--sf-nav-hover);
    color: var(--sf-nav-text);
    text-decoration: none;
}

.sf-nav__child--active,
.sf-nav__child--active:hover {
    background: var(--sf-nav-active);
    color: var(--sf-nav-text-active);
    font-weight: 500;
    border-left-color: var(--sf-nav-border-active);
}

.sf-nav__child:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #e2e8f0;
}

/* ── Collapsed icon-only buttons ─────────────────────────────── */
.sf-nav--collapsed .sf-nav__parent {
    justify-content: center;
    padding: 8px 0;
    min-height: 32px;
}

/* Flyout header — only visible in collapsed mode flyout */
.sf-nav__flyout-header {
    display: none;
}

/* Collapsed mode: parent treeitem is anchor for absolute-positioned flyout */
.sf-nav--collapsed .sf-nav__treeitem {
    position: relative;
}

/* Allow flyout to escape clipping containers in collapsed mode */
.sf-nav--collapsed .sf-nav__main,
.sf-nav--collapsed .sf-nav__items {
    overflow: visible;
}

/* Children render as a hidden flyout, positioned to the right of the icon */
.sf-nav--collapsed .sf-nav__children {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    background: var(--sf-nav-bg-dark);
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 4px 16px rgba(0,0,0,0.3);
    padding: 6px;
    z-index: 100;
}

/* Show flyout on hover or keyboard focus */
.sf-nav--collapsed .sf-nav__treeitem:hover > .sf-nav__children,
.sf-nav--collapsed .sf-nav__treeitem:focus-within > .sf-nav__children {
    display: block;
}

/* Always show flyout for the stuck (clicked) parent */
.sf-nav--collapsed .sf-nav__treeitem--stuck > .sf-nav__children {
    display: block;
}

/* When one parent is stuck, suppress hover flyouts on other parents */
.sf-nav--collapsed .sf-nav__items--has-stuck
    .sf-nav__treeitem:not(.sf-nav__treeitem--stuck):hover > .sf-nav__children {
    display: none;
}

/* Raise collapsed nav above the top-row (z:40) and Telerik-based inner navs
   (e.g., the Settings ConfigurationNavigator cards/splitter) so flyouts aren't clipped */
.sf-nav--collapsed {
    z-index: 500;
}

/* Label-only flyout (direct-nav parents with no children) */
.sf-nav--collapsed .sf-nav__children--label-only {
    min-width: auto;
}

.sf-nav--collapsed .sf-nav__children--label-only .sf-nav__flyout-header {
    border-bottom: none;
    margin-bottom: 0;
    padding: 8px 14px;
    white-space: nowrap;
}

/* Flyout header — title bar with parent name (collapsed mode only) */
.sf-nav--collapsed .sf-nav__flyout-header {
    display: block;
    padding: 6px 10px 8px;
    margin-bottom: 4px;
    font: 600 12px/1.3 'DM Sans', sans-serif;
    color: var(--sf-nav-text-active);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Tighten child link styling inside the flyout for readability */
.sf-nav--collapsed .sf-nav__children .sf-nav__child {
    padding-left: 12px;
}

/* ── Footer ──────────────────────────────────────────────────── */
.sf-nav__footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 4px;
}

.sf-nav__footer-link {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-text);
    font: 400 11px/1 'DM Sans', sans-serif;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
}

.sf-nav__footer-link:hover {
    background: var(--sf-nav-hover);
    color: var(--sf-nav-text);
    text-decoration: none;
}

.sf-nav__footer-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 2px 4px;
}

.sf-nav__footer-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.sf-nav__footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    min-height: 28px;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-text);
    font: 400 10px/1 'DM Sans', sans-serif;
    cursor: pointer;
}

.sf-nav__footer-btn:hover {
    background: var(--sf-nav-hover);
}

.sf-nav__footer-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #e2e8f0;
}

.sf-nav__footer-btn--active {
    background: rgba(255,255,255,0.25);
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}

.sf-nav__footer-btn--active:hover {
    background: rgba(255,255,255,0.30);
}

/* ── Icon color classes (from MenuService icon assignments) ─── */
.sf-nav .green-icon { color: lightgreen !important; }
.sf-nav .blue-icon { color: #2eb5f0 !important; }
.sf-nav .purple-icon { color: #975aed !important; }
.sf-nav .orange-icon { color: #e68230 !important; }
.sf-nav .cyan-icon { color: #0ee2e6 !important; }
.sf-nav .yellow-icon { color: #ced10d !important; }
.sf-nav .lime-icon { color: #99b551 !important; }
.sf-nav .white-icon { color: silver !important; }
.sf-nav .red-icon { color: #e13929 !important; }

/* Collapsed footer: stack vertically */
.sf-nav--collapsed .sf-nav__footer-link span {
    display: none;
}

.sf-nav--collapsed .sf-nav__footer-actions {
    flex-direction: column;
}

.sf-nav--collapsed .sf-nav__footer-btn span {
    display: none;
}

/* ── Student panel ───────────────────────────────────────────── */
.sf-nav__student {
    width: var(--sf-nav-student-width);
    background: var(--sf-nav-student-bg);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
}

.sf-nav__student-header {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.sf-nav__student-name {
    font: 700 12px/1.3 'DM Sans', sans-serif;
    color: var(--sf-nav-student-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sf-nav__student-id {
    font: 400 10px/1.3 'DM Sans', sans-serif;
    color: var(--sf-nav-student-text-muted);
}

.sf-nav__student-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}

/* Student nav parent items */
.sf-nav__student-parent {
    display: flex;
    align-items: center;
    width: calc(100% - 12px);
    margin: 1px 6px;
    min-height: 24px;
    padding: 6px 6px 6px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-student-text);
    font: 400 11px/1.3 'DM Sans', sans-serif;
    cursor: pointer;
    gap: 4px;
    text-align: left;
}

.sf-nav__student-parent:hover {
    background: rgba(0,0,0,0.04);
}

.sf-nav__student-parent[aria-expanded="true"] {
    font-weight: 600;
}

/* Student nav child items */
.sf-nav__student-child {
    display: block;
    width: calc(100% - 12px);
    margin: 1px 6px;
    min-height: 20px;
    padding: 5px 6px 5px 18px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-student-text);
    font: 400 10px/1.35 'DM Sans', sans-serif;
    text-decoration: none;
    cursor: pointer;
    word-break: break-word;
    white-space: normal;
    border-left: 3px solid transparent;
}

.sf-nav__student-child:hover {
    background: rgba(0,0,0,0.04);
    color: var(--sf-nav-student-text);
    text-decoration: none;
}

.sf-nav__student-child--active,
.sf-nav__student-child--active:hover {
    font-weight: 600;
    border-left-color: var(--sf-nav-student-border-active);
    background: rgba(71,85,105,0.08);
}

/* Student nav search */
.sf-nav__student-search {
    padding: 6px 8px;
    flex-shrink: 0;
}

.sf-nav__student-search input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 4px;
    font: 400 10px/1.5 'DM Sans', sans-serif;
    background: #ffffff;
    outline: none;
}

.sf-nav__student-search input:focus {
    border-color: var(--sf-nav-student-border-active);
    box-shadow: 0 0 0 2px rgba(71,85,105,0.15);
}

/* Badge (holds count) */
.sf-nav__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font: 600 8px/1 'DM Sans', sans-serif;
    flex-shrink: 0;
}

/* Student nav chevron */
.sf-nav__student-chevron {
    font-size: 9px;
    color: var(--sf-nav-student-text-muted);
    transition: transform 200ms ease;
    flex-shrink: 0;
    margin-left: auto;
}

.sf-nav__student-parent[aria-expanded="true"] .sf-nav__student-chevron {
    transform: rotate(90deg);
}

/* ══════════════════════════════════════════════════════════════
   Subnav (SimpleNav, ConfigurationNavigator) — matches student
   submenu visual pattern: slate-bg pane, slate-tinted hover/active
   ══════════════════════════════════════════════════════════════ */

.sf-subnav {
    width: 240px;
    flex-shrink: 0;
    background-color: var(--sf-nav-student-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
    font-family: var(--sf-font-family);
}

.sf-subnav__search {
    padding: 6px 8px;
    flex-shrink: 0;
}

.sf-subnav__search input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    font: 400 10px/1.5 var(--sf-font-family);
    background: #ffffff;
    color: var(--sf-nav-student-text);
    outline: none;
}

.sf-subnav__search input:focus {
    border-color: var(--sf-nav-student-border-active);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

/* Group toggle button (category header) */
.sf-subnav__group {
    display: flex;
    align-items: center;
    width: calc(100% - 12px);
    margin: 2px 6px;
    min-height: 28px;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-student-text);
    font: 600 11px/1.3 var(--sf-font-family);
    cursor: pointer;
    gap: 6px;
    text-align: left;
    transition: background-color 100ms ease;
}

.sf-subnav__group:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--sf-nav-student-text);
}

.sf-subnav__group:focus-visible {
    outline: 2px solid var(--sf-nav-student-border-active);
    outline-offset: -2px;
}

.sf-subnav__group[aria-expanded="true"] {
    background: rgba(71, 85, 105, 0.08);
}

.sf-subnav__group-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sf-subnav__group-chevron {
    font-size: 9px;
    color: var(--sf-nav-student-text-muted);
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.sf-subnav__group[aria-expanded="true"] .sf-subnav__group-chevron {
    transform: rotate(90deg);
}

/* Group body (item list) */
.sf-subnav__group-body {
    margin: 0 6px 4px;
    padding: 0;
    list-style: none;
}

.sf-subnav__group-body li {
    list-style: none;
}

/* Item link (matches sf-nav__student-child) */
.sf-subnav__item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 1px 0;
    min-height: 24px;
    padding: 5px 6px 5px 18px;
    border-radius: 6px;
    background: none;
    color: var(--sf-nav-student-text);
    font: 400 11px/1.35 var(--sf-font-family);
    text-decoration: none;
    cursor: pointer;
    word-break: break-word;
    white-space: normal;
    border-left: 3px solid transparent;
    transition: background-color 100ms ease;
}

.sf-subnav__item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--sf-nav-student-text);
    text-decoration: none;
}

.sf-subnav__item.active,
.sf-subnav__item.active:hover {
    font-weight: 600;
    border-left-color: var(--sf-nav-student-border-active);
    background: rgba(71, 85, 105, 0.08);
    color: var(--sf-nav-student-text);
}

.sf-subnav__item-icon {
    width: 14px;
    text-align: center;
    flex-shrink: 0;
    font-size: 11px;
}

/* ── Skip-to-content link ────────────────────────────────────── */
.sf-skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--sf-nav-bg);
    color: #ffffff;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    font: 600 14px/1 'DM Sans', sans-serif;
}

.sf-skip-link:focus {
    top: 0;
    color: #ffffff;
}

/* ── Mobile backdrop ─────────────────────────────────────────── */
.sf-nav__backdrop {
    display: none;
}

@media (max-width: 767.98px) {
    .sf-nav--mobile-open .sf-nav__backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: -1;
    }
}

/* ── Hamburger button (mobile only) ──────────────────────────── */
.sf-hamburger {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--sf-nav-bg);
    font-size: 20px;
}

@media (max-width: 767.98px) {
    .sf-hamburger { display: block; }

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

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .sf-nav,
    .sf-nav__main,
    .sf-nav__chevron,
    .sf-nav__student-chevron {
        transition: none !important;
    }
}

/* ── Mobile overlay ──────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .sf-nav {
        display: none;
    }

    .sf-nav--mobile-open {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: rgba(0,0,0,0.5);
    }

    .sf-nav--mobile-open .sf-nav__main {
        width: 280px;
    }

    .sf-nav__parent,
    .sf-nav__child,
    .sf-nav__footer-link,
    .sf-nav__footer-btn {
        min-height: 44px; /* Touch target */
    }
}
