/* Modern app navigation */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.85rem clamp(1rem, 2.5vw, 3rem);
    box-sizing: border-box;
    position: relative;
}

.site-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-family: "Raleway", sans-serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-logo span {
    color: #f87171;
}

.site-nav-wrap {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    min-width: 0;
}

.app-nav {
    position: relative;
    width: 100%;
}

.app-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-left: auto;
    min-height: 2.15rem;
    height: auto;
    padding: 0.55rem 0.85rem;
    border: 1px solid rgba(248, 250, 252, 0.2);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.app-nav-toggle:hover,
.app-nav-toggle:focus {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(248, 250, 252, 0.35);
    color: #fff;
}

.app-nav-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-nav-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.app-nav-link,
.app-nav-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: auto;
    min-height: 2.35rem;
    margin: 0;
    padding: 0.6rem 0.95rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease, color 0.15s ease;
}

button.app-nav-trigger,
button.app-nav-toggle,
button.app-nav-sub-trigger {
    -webkit-appearance: none;
    appearance: none;
}

.app-nav-link:hover,
.app-nav-link:focus,
.app-nav-trigger:hover,
.app-nav-trigger:focus {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.app-nav-item.is-open > .app-nav-trigger,
.app-nav-item.is-open > .app-nav-link {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.app-nav-icon {
    font-size: 0.95rem;
    opacity: 0.85;
    width: 1rem;
    text-align: center;
}

.app-nav-chevron {
    font-size: 0.75rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.app-nav-item.is-open > .app-nav-trigger .app-nav-chevron,
.app-nav-item.is-open > .app-nav-sub-trigger .app-nav-chevron {
    transform: rotate(180deg);
}

.app-nav-dropdown,
.app-nav-sub-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 13rem;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    z-index: 10;
}

.app-nav-item.is-open > .app-nav-dropdown {
    display: block;
}

.app-nav-dropdown a,
.app-nav-sub-dropdown a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 0.4rem;
    color: #334155;
    font-size: 1.05rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-nav-dropdown a:hover,
.app-nav-dropdown a:focus,
.app-nav-sub-dropdown a:hover,
.app-nav-sub-dropdown a:focus {
    background: #f1f5f9;
    color: #0f172a;
}

.app-nav-item--sub {
    position: relative;
}

.app-nav-sub-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: 0.4rem;
    background: transparent;
    color: #475569;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.app-nav-sub-trigger:hover,
.app-nav-sub-trigger:focus {
    background: #f1f5f9;
    color: #0f172a;
}

.app-nav-item--sub.is-open > .app-nav-sub-dropdown {
    display: block;
    position: static;
    margin-top: 0.25rem;
    padding: 0.25rem 0 0.25rem 0.75rem;
    border: none;
    border-left: 2px solid #e2e8f0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.app-nav-item--logout {
    margin-left: 0.25rem;
}

.app-nav-link--logout {
    color: #fca5a5;
}

.app-nav-link--logout:hover,
.app-nav-link--logout:focus {
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
}

/* Desktop: hover opens dropdowns */
@media (min-width: 1024px) {
    /* Invisible bridge so hover is not lost between trigger and dropdown */
    .app-nav-item--dropdown::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 0.5rem;
    }

    .app-nav-dropdown {
        top: calc(100% + 0.35rem);
    }

    .app-nav-item--dropdown:hover > .app-nav-dropdown {
        display: block;
    }

    /* Bridge for nested sub-menus (e.g. Education admin) */
    .app-nav-item--sub::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 100%;
        width: 0.5rem;
    }

    .app-nav-item--sub:hover > .app-nav-sub-dropdown,
    .app-nav-dropdown .app-nav-item--sub:hover > .app-nav-sub-dropdown {
        display: block;
        position: absolute;
        top: 0;
        left: calc(100% + 0.35rem);
        min-width: 12rem;
        margin-top: 0;
        margin-left: 0;
        padding: 0.35rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.65rem;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
        background: #fff;
    }
}

/* Mobile */
@media (max-width: 1023px) {
    .site-logo {
        flex: 1 1 auto;
        min-width: 0;
    }

    .site-nav-wrap {
        flex: 0 0 auto;
        width: auto;
    }

    .app-nav-toggle {
        display: inline-flex;
    }

    .app-nav-menu {
        display: none;
        position: absolute;
        top: calc(100% + 0.35rem);
        left: clamp(1rem, 2.5vw, 3rem);
        right: clamp(1rem, 2.5vw, 3rem);
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: 0.75rem;
        background: #1e293b;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 0.75rem;
        box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
        max-height: calc(100vh - 5rem);
        overflow-y: auto;
    }

    .app-nav-menu.is-open {
        display: flex;
    }

    .app-nav-link,
    .app-nav-trigger {
        width: 100%;
        justify-content: flex-start;
        padding: 0.7rem 0.85rem;
    }

    .app-nav-dropdown,
    .app-nav-sub-dropdown {
        position: static;
        min-width: 0;
        margin: 0.15rem 0 0.35rem;
        padding: 0.25rem;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.95);
    }

    .app-nav-item--logout {
        margin-left: 0;
        margin-top: 0.35rem;
        padding-top: 0.35rem;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .app-nav-item--sub.is-open > .app-nav-sub-dropdown {
        border-left-color: #cbd5e1;
    }
}

@media (max-width: 640px) {
    .site-logo {
        font-size: 1.25rem;
    }
}
