/* ══════════════════════════════════════════════════════════════
   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 {
    background: var(--sf-nav-hover);
}

.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;
}

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

/* ── 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: var(--sf-nav-active);
}

/* ── 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);
}

/* ── 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;
}

/* ── 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 */
    }
}
