/*
 * nav.css — Navigation styles for all nav variants.
 *
 * Covers: site-header (public pages only), admin-sidebar (admin, superadmin
 * and resident portals — all use the same left-sidebar shell), and the
 * mobile hamburger toggle.
 */

/* ============================================================
   Shared site header (public and resident top bar)
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    max-width: var(--max-width);
    margin-inline: auto;
    padding: var(--space-sm) var(--space-md);
    min-height: 60px;
}

.site-header__logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}

/* Push nav links to the far right */
.site-header__inner > nav { margin-left: auto; }

/* ============================================================
   Public nav links
   ============================================================ */
.nav-public {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ============================================================
   Shared nav link styles
   ============================================================ */
.nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav__link:hover {
    background: var(--color-surface-alt);
    color: var(--color-primary);
}

.nav__link:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

.nav__link--active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
}

.nav__link--logout {
    color: var(--color-danger);
}

.nav__link--logout:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.nav__divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--space-sm) 0;
}

.nav__section-label {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

/* ============================================================
   Mobile hamburger toggle
   ============================================================ */
.nav-toggle {
    display: none;
    background: none;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-left: auto;
    color: var(--color-text);
}

.nav-toggle__bar {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
    opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   Admin sidebar — desktop
   ============================================================ */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 90;
}

.admin-sidebar--super {
    border-right-color: var(--color-primary);
}

.admin-sidebar--resident {
    border-right-color: var(--color-accent);
}

.admin-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    min-height: 64px;
}

.admin-sidebar__logo {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-primary);
    text-decoration: none;
}

.admin-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-sm) var(--space-xs);
}

.admin-nav .nav__link {
    border-radius: var(--radius-md);
    padding: 0.625rem var(--space-sm);
    font-size: 0.9375rem;
}

/* Spacing between the leading icon and the link label in the sidebar */
.admin-nav .nav__link .nav__icon {
    margin-right: 0.5rem;
    width: 1.1em;
    text-align: center;
    opacity: 0.85;
}
.admin-nav .nav__link--active .nav__icon { opacity: 1; }

.admin-sidebar__footer {
    padding: var(--space-md);
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.admin-sidebar__user {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Main content shifts right when sidebar is visible */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-layout__content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ============================================================
   Responsive — mobile nav
   ============================================================ */
@media (max-width: 767px) {
    /* Hamburger is visible on mobile */
    .nav-toggle { display: flex; }

    /* All sidebars (admin, superadmin, resident) become a slide-in drawer */
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-layout__content {
        margin-left: 0;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 89;
    }

    .sidebar-overlay.is-active { display: block; }
}

@media (max-width: 480px) {
    .site-header__logo { font-size: 1rem; }
}
