/* ============================================
   MENU.CSS — GloseMester Navigasjonssystem v3.0
   AppHeader + TabBar (elev) + Sidebar (lærer)
   ============================================ */

:root {
    --nav-tab-height: 72px;
    --nav-tab-safe: env(safe-area-inset-bottom, 0px);
    --header-height: 56px;
    --sidebar-width: 280px;
}

/* ============================================
   APP HEADER — toppbar for elev/student
   ============================================ */

#app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    z-index: 1500;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(124, 58, 237, 0.08);
}

body.has-header #app {
    padding-top: var(--header-height);
}

/* Tilbake-knapp */
.app-header-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(124, 58, 237, 0.07);
    color: var(--purple-600, #7C3AED);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.app-header-back:hover {
    background: rgba(124, 58, 237, 0.14);
    transform: translateX(-2px);
}

/* Tittel */
.app-header-title {
    flex: 1;
    min-width: 0;
}
.app-header-title h1 {
    font-family: var(--font-heading, 'Outfit', system-ui);
    font-size: 16px;
    font-weight: 700;
    color: var(--purple-900, hsl(258,90%,20%));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
}
.app-header-breadcrumb {
    font-size: 11px;
    color: var(--text-muted, #9CA3AF);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* Rolle-chip */
.app-header-role {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}
.app-header-role.elev {
    background: rgba(124, 58, 237, 0.08);
    color: var(--purple-600, #7C3AED);
    border: 1px solid rgba(124, 58, 237, 0.18);
}
.app-header-role.laerer {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
    border: 1px solid rgba(245, 158, 11, 0.22);
}

/* Avatar-knapp */
.app-header-profile {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(124, 58, 237, 0.18);
    background: rgba(124, 58, 237, 0.07);
    color: var(--purple-600, #7C3AED);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
    position: relative;
}
.app-header-profile:hover {
    background: rgba(124, 58, 237, 0.13);
    border-color: rgba(124, 58, 237, 0.32);
}

/* Dropdown */
.app-header-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 190px;
    background: white;
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.14);
    overflow: hidden;
    z-index: 2000;
    animation: ddIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes ddIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.app-header-dd-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    font-family: var(--font-body, 'Inter', system-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1F2937);
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}
.app-header-dd-item:hover { background: rgba(124, 58, 237, 0.05); }
.app-header-dd-item.danger { color: #EF4444; }
.app-header-dd-item.danger:hover { background: rgba(239, 68, 68, 0.05); }
.app-header-dd-divider { height: 1px; background: rgba(124, 58, 237, 0.07); margin: 3px 0; }

/* ============================================
   BOTTOM TAB BAR — elev + øving
   ============================================ */

#tab-bar {
    position: fixed;
    bottom: calc(16px + var(--nav-tab-safe));
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 999px;
    padding: 6px 8px;
    box-shadow: 0 8px 40px rgba(124, 58, 237, 0.16), 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(255, 255, 255, 0.55);
    gap: 2px;
    pointer-events: auto;
    animation: tabBarIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tabBarIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s;
    color: var(--purple-400, #a78bfa);
    min-width: 60px;
    position: relative;
}
.tab-btn svg {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: block;
}
.tab-btn-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1;
}
.tab-btn.active {
    background: var(--purple-600, #7C3AED);
    color: white;
}
.tab-btn.active svg { transform: scale(1.1); }
.tab-btn.active .tab-btn-label { font-weight: 700; }
.tab-btn:not(.active):hover {
    background: rgba(124, 58, 237, 0.08);
    color: var(--purple-700, #6D28D9);
}
.tab-btn.tab-danger { color: #F87171; }
.tab-btn.tab-danger:hover { background: rgba(239,68,68,0.07); color: #EF4444; }

/* Varselbadge */
.tab-badge {
    position: absolute;
    top: 4px; right: 6px;
    min-width: 15px; height: 15px;
    background: #EF4444;
    color: white;
    font-size: 9px; font-weight: 800;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
    border: 2px solid white;
    pointer-events: none;
}

body.has-tabbar #app {
    padding-bottom: calc(var(--nav-tab-height) + var(--nav-tab-safe) + 8px);
}

/* ============================================
   TEACHER TOPBAR (mobil)
   ============================================ */

#teacher-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(16, 30, 56, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.t-topbar-hamburger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #F1F5F9;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    font-size: 13px; font-weight: 600;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}
.t-topbar-hamburger:hover { background: rgba(255,255,255,0.1); }
.t-topbar-hamburger svg { flex-shrink: 0; }

.t-topbar-logo {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 18px; font-weight: 900;
    color: #F59E0B;
    letter-spacing: -0.02em;
    pointer-events: none;
}

.t-topbar-home {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.22);
    color: #F59E0B;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    font-size: 13px; font-weight: 600;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.t-topbar-home:hover { background: rgba(245, 158, 11, 0.18); }

@media (min-width: 1024px) {
    .t-topbar-hamburger { display: none !important; }
    .t-topbar-logo { display: none !important; }
    #teacher-topbar { left: var(--sidebar-width); }
}

/* ============================================
   SIDEBAR FORBEDRINGER (SVG + rolle-veksler)
   ============================================ */

/* SVG-ikoner i sidebar */
.drawer-item svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.65;
    transition: opacity 0.15s;
}
.drawer-item.active svg,
body.teacher-mode .drawer-item.active svg { opacity: 1; }
.drawer-item:hover svg { opacity: 0.85; }

/* Rolle-veksler nederst i sidebar */
.t-role-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: 10px;
    color: #a78bfa;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.15s;
    text-align: left;
}
.t-role-switch:hover { background: rgba(124, 58, 237, 0.14); }
.t-role-switch svg { opacity: 0.8; flex-shrink: 0; }

/* ============================================
   LAYOUT-JUSTERINGER
   ============================================ */

/* Lærer-modus: toppbar tar plass */
body.teacher-mode #app {
    padding-top: var(--header-height);
}

@media (max-width: 768px) {
    body.teacher-mode .teacher-content {
        padding: 24px 16px calc(24px + var(--nav-tab-safe));
    }
}
