/*
 * Samraworld Admin Header / Nav
 *
 * Two-bar layout:
 *   Top bar    — brand + user actions on the gradient #668295 → #4a6070 (admin gray-blue)
 *   Menubar    — original reddish #eb7d7d with sw_dropdown menus (hover-to-open on desktop)
 *
 * Variants:
 *   .site-header              — full header (top bar + menubar)
 *   .site-header--minimal     — brand + single action (Login), no menubar
 *   .site-header--mini        — brand only, smaller height
 */

@import url(https://fonts.googleapis.com/css?family=Rubik:400,500,600,700);

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    color: #fff;
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ======== Top bar (brand + actions) ======== */

.site-header__top {
    background: linear-gradient(135deg, #668295 0%, #4a6070 100%);
}

.site-header__top-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 60px;
}

/* ======== Brand ======== */

.site-header__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
    color: inherit !important;
    flex-shrink: 1;
    min-width: 0;
    line-height: 1;
}

.site-header__brand:hover {
    text-decoration: none !important;
}

.site-header__logo {
    height: 36px;
    width: auto;
    display: block;
    float: none !important;
    margin: 0 !important;
}

.site-header__brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

/* ======== Hamburger toggle (mobile only) ======== */

.site-header__menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    padding: 8px 12px;
    margin-left: auto;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.18s;
    line-height: 1;
}

.site-header__menu-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

.site-header__menu-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

.site-header__menu-toggle .close-icon { display: none; }
.site-header.is-nav-open .site-header__menu-toggle .hamburger-icon { display: none; }
.site-header.is-nav-open .site-header__menu-toggle .close-icon { display: inline; }

/* ======== Right-side actions ======== */

.site-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.header-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    text-decoration: none !important;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1rem;
    transition: background 0.18s;
    line-height: 1;
}

.header-action:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff !important;
    text-decoration: none !important;
}

.header-action__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ff5757;
    color: #fff;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid #5b7488;
}

.header-action__badge:empty {
    display: none;
}

.header-action--login {
    background: rgba(255, 255, 255, 0.16);
    padding: 8px 22px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.header-action--login:hover {
    background: rgba(255, 255, 255, 0.26);
}

.header-action--lang {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    margin-right: 4px;
}

.header-action--lang:hover {
    background: rgba(255, 255, 255, 0.16);
}

/* ======== Cross-subdomain switcher ========
   Compact pill in site-header__actions that opens a dropdown with the
   three subdomain destinations. Uses the existing [data-menu] machinery
   in sw_navbar.js — no new JS needed. */

.subdomain-switch {
    position: relative;
}

.subdomain-switch__btn {
    background: rgba(255, 255, 255, 0.14);
    border: 0;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    transition: background 0.15s ease;
    font-family: inherit;
}

.subdomain-switch__btn:hover,
.subdomain-switch__btn:focus-visible,
.subdomain-switch.is-open .subdomain-switch__btn {
    background: rgba(255, 255, 255, 0.26);
    outline: none;
}

.subdomain-switch__btn > i.fa-th-large {
    font-size: 0.85rem;
}

.subdomain-switch__chevron {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
    opacity: 0.85;
}

.subdomain-switch.is-open .subdomain-switch__chevron {
    transform: rotate(180deg);
}

.subdomain-switch__panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    padding: 6px;
    z-index: 1000;
}

.subdomain-switch.is-open .subdomain-switch__panel {
    display: block;
}

.subdomain-switch__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: #1f2937;
    font-size: 0.92rem;
    transition: background 0.12s ease;
}

.subdomain-switch__item:hover,
.subdomain-switch__item:focus-visible {
    background: #f3f6f9;
    text-decoration: none;
    color: #1f2937;
}

.subdomain-switch__item.is-current {
    font-weight: 600;
    cursor: default;
}

.subdomain-switch__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Subdomain brand colors */
.subdomain-switch__dot--admin    { background: #668295; }
.subdomain-switch__dot--teachers { background: #5134f1; }
.subdomain-switch__dot--students { background: #0e6630; }

.subdomain-switch__label {
    line-height: 1.3;
}

.subdomain-switch__check {
    color: var(--brand, #668295);
    font-size: 0.78rem;
}

.subdomain-switch__ext {
    color: #97a3ad;
    font-size: 0.72rem;
}

/* Mobile — hide the text label, keep just the icon + chevron. The label
   reappears inside the dropdown panel. */
@media (max-width: 700px) {
    .subdomain-switch__btn-label {
        display: none;
    }
    .subdomain-switch__btn {
        padding: 6px 10px;
    }
}

/* ======== User menu ======== */

.user-menu {
    position: relative;
}

.user-menu__btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 14px 4px 4px;
    border-radius: 24px;
    font-family: inherit;
    transition: background 0.18s;
    line-height: 1;
}

.user-menu__btn:hover,
.user-menu__btn:focus-visible,
.user-menu.is-open .user-menu__btn {
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.user-menu__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1;
    flex-shrink: 0;
}

.user-menu__name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu__chevron {
    font-size: 0.7rem;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

.user-menu.is-open .user-menu__chevron {
    transform: rotate(180deg);
}

.user-menu__panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
    padding: 6px 0;
    z-index: 50;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.user-menu.is-open .user-menu__panel {
    display: block;
    animation: site-header-fadeIn 0.16s ease;
}

@keyframes site-header-fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-menu__panel a,
.user-menu__panel a:link,
.user-menu__panel a:visited {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: #2c3e50 !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.user-menu__panel a:hover {
    background: #f4f7f9;
    color: #668295 !important;
}

.user-menu__panel i {
    width: 16px;
    text-align: center;
    color: #8a9ba8;
    transition: color 0.15s;
}

.user-menu__panel a:hover i {
    color: #668295;
}

/* ======== Menubar (original reddish bar with sw_dropdown menus) ======== */

.site-header__menubar {
    background-color: #eb7d7d;
}

.site-header__menubar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* sw_dropdown markup from getNavbarForUser_R() */

.site-header__menubar .sw_dropdown {
    position: relative;
    float: none;
    overflow: visible;
}

.site-header__menubar .sw_dropbtn {
    font-size: 14px;
    border: none;
    outline: none;
    color: #fff;
    padding: 12px 14px;
    background-color: transparent;
    font-family: inherit;
    margin: 0;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color 0.15s;
}

.site-header__menubar .sw_dropbtn:hover,
.site-header__menubar .sw_dropdown:hover .sw_dropbtn,
.site-header__menubar .sw_dropdown.is-open .sw_dropbtn {
    background-color: #d96b6b;
}

.site-header__menubar .sw_dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #f9f9f9;
    min-width: 180px;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
    z-index: 50;
    padding: 4px 0;
}

.site-header__menubar .sw_dropdown-content a,
.site-header__menubar .sw_dropdown-content a:link,
.site-header__menubar .sw_dropdown-content a:visited {
    float: none !important;
    color: #222 !important;
    padding: 10px 16px;
    text-decoration: none !important;
    display: block;
    text-align: left;
    font-size: 14px;
    background: transparent;
    border: none !important;
    width: auto !important;
    transition: background-color 0.12s;
}

.site-header__menubar .sw_dropdown-content a:hover {
    background-color: #ddd;
    color: #000 !important;
}

/* Hover-to-open on desktop (original behavior) */
@media (min-width: 901px) {
    .site-header__menubar .sw_dropdown:hover .sw_dropdown-content {
        display: block;
    }
}

/* Click-to-open also works (mobile, keyboard) */
.site-header__menubar .sw_dropdown.is-open > .sw_dropdown-content {
    display: block;
}

/* ======== Mobile drawer backdrop ======== */

.site-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
    pointer-events: none;
}

body.site-nav-locked {
    overflow: hidden;
}

body.site-nav-locked .site-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ======== Variants ======== */

.site-header--minimal .site-header__top-inner {
    min-height: 56px;
    justify-content: space-between;
}

.site-header--mini .site-header__top-inner {
    min-height: 44px;
    padding: 4px 16px;
}

.site-header--mini .site-header__logo {
    height: 26px;
}

.site-header--mini .site-header__brand-name {
    font-size: 0.95rem;
}

/* ======== Mobile (≤ 900px) ======== */

@media (max-width: 900px) {

    .site-header__top-inner {
        gap: 12px;
        min-height: 56px;
        padding: 0 14px;
    }

    .site-header__logo {
        height: 32px;
    }

    .site-header__brand-name {
        font-size: 0.85rem;
        line-height: 1.2;
    }

    .site-header__menu-toggle {
        display: inline-flex;
        align-items: center;
    }

    /* Menubar becomes the upper portion of the slide-in drawer */
    .site-header__menubar {
        position: fixed;
        top: 56px;
        right: 0;
        bottom: 0;
        width: 320px;
        max-width: 88vw;
        background: linear-gradient(160deg, #668295 0%, #4a6070 100%);
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 110;
        overflow-y: auto;
        padding-bottom: 260px;     /* reserve room for actions overlay below */
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.25);
        margin: 0;
    }

    .site-header.is-nav-open .site-header__menubar {
        transform: translateX(0);
    }

    /* Actions overlay the bottom of the drawer */
    .site-header__actions {
        position: fixed;
        right: 0;
        bottom: 0;
        width: 320px;
        max-width: 88vw;
        height: auto;
        max-height: 60vh;
        background: linear-gradient(160deg, #4a6070 0%, #3d505e 100%);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 111;
        overflow-y: auto;
        box-shadow: -8px -2px 20px rgba(0, 0, 0, 0.15);
        border-top: 1px solid rgba(255, 255, 255, 0.18);
    }

    .site-header.is-nav-open .site-header__actions {
        transform: translateX(0);
    }

    .header-action {
        justify-content: flex-start;
        padding: 12px 18px;
        font-size: 0.9rem;
        gap: 12px;
        border-radius: 0;
    }

    .header-action__badge {
        position: static;
        margin-left: auto;
        border: none;
    }

    .header-action--login {
        justify-content: center;
        margin: 12px 14px;
        border-radius: 6px;
    }

    .header-action--lang {
        margin: 0;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 0;
        padding: 14px 18px;
        font-size: 0.85rem;
    }

    .header-action--lang:hover {
        background: rgba(255, 255, 255, 0.08);
    }

    /* User menu in drawer: always-expanded, button is informational header */
    .user-menu {
        width: 100%;
    }

    .user-menu__btn {
        width: 100%;
        justify-content: flex-start;
        background: rgba(0, 0, 0, 0.12);
        border-radius: 0;
        padding: 14px 14px;
        gap: 12px;
        cursor: default;
    }

    .user-menu__btn:hover,
    .user-menu.is-open .user-menu__btn {
        background: rgba(0, 0, 0, 0.18);
    }

    .user-menu__name {
        max-width: none;
    }

    .user-menu__chevron {
        display: none;
    }

    .user-menu__panel,
    .user-menu.is-open .user-menu__panel {
        display: block;
        position: static;
        background: transparent;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0;
        animation: none;
    }

    .user-menu__panel a,
    .user-menu__panel a:link,
    .user-menu__panel a:visited {
        color: rgba(255, 255, 255, 0.92) !important;
        padding: 12px 18px;
    }

    .user-menu__panel a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff !important;
    }

    .user-menu__panel i {
        color: rgba(255, 255, 255, 0.7);
    }

    .user-menu__panel a:hover i {
        color: #fff;
    }

    /* Menubar inside the drawer: vertical accordion, brand-colored */
    .site-header__menubar-inner {
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        max-width: none;
    }

    .site-header__menubar .sw_dropdown {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .site-header__menubar .sw_dropbtn {
        width: 100%;
        text-align: left;
        padding: 14px 18px;
        font-size: 0.95rem;
        position: relative;
        background-color: transparent;
        color: #fff;
    }

    .site-header__menubar .sw_dropbtn:hover,
    .site-header__menubar .sw_dropdown.is-open .sw_dropbtn {
        background-color: rgba(255, 255, 255, 0.08);
    }

    .site-header__menubar .sw_dropbtn::after {
        content: "";
        position: absolute;
        right: 18px;
        top: 50%;
        width: 7px;
        height: 7px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: translateY(-70%) rotate(45deg);
        opacity: 0.85;
        transition: transform 0.18s;
    }

    .site-header__menubar .sw_dropdown.is-open .sw_dropbtn::after {
        transform: translateY(-30%) rotate(-135deg);
    }

    .site-header__menubar .sw_dropdown-content {
        position: static;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.18);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        min-width: 0;
        padding: 4px 0;
    }

    .site-header__menubar .sw_dropdown-content a,
    .site-header__menubar .sw_dropdown-content a:link,
    .site-header__menubar .sw_dropdown-content a:visited {
        padding: 10px 32px;
        font-size: 0.85rem;
        color: rgba(255, 255, 255, 0.88) !important;
    }

    .site-header__menubar .sw_dropdown-content a:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #fff !important;
    }

    /* Minimal variant on mobile: keep actions inline (no drawer) */
    .site-header--minimal .site-header__actions {
        position: static;
        flex-direction: row;
        background: transparent;
        padding: 0;
        transform: none;
        box-shadow: none;
        margin-left: auto;
        gap: 6px;
    }

    .site-header--minimal .site-header__menu-toggle { display: none; }

    .site-header--minimal .header-action--login {
        margin: 0;
    }

    .site-header--minimal .header-action--lang {
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 4px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .site-header__actions {
        width: 100vw;
        max-width: 100vw;
    }
    .site-header__brand-name {
        font-size: 0.78rem;
    }
}

/* ======== Bootstrap-style navbar used by guest pages (SW_HEAD_NONAV_*.shtml) ========
   Production used to rely on the body's green background showing through a
   transparent .navbar. Modernized pages override body to a neutral surface,
   so .navbar needs its own brand background. */
nav.navbar {
    background: linear-gradient(135deg, #668295 0%, #4a6070 100%);
}
