/* ============================================
   UNIFIED NAVIGATION
   Desktop: inline links in header
   Mobile: hamburger + slide-out panel
   ============================================ */

/* --- Page Loading Overlay (unified across all pages) --- */
.page-loading {
    position: fixed;
    inset: 0;
    background: var(--bg-primary, #0a0f1a);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.page-loading.fade-out {
    opacity: 0;
    pointer-events: none;
}

.page-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, #2d3a4f);
    border-top-color: var(--accent-primary, #3b82f6);
    border-radius: 50%;
    animation: navSpin 0.8s linear infinite;
}

@keyframes navSpin {
    to { transform: rotate(360deg); }
}

/* --- Nav container: sits at very top of page, full width --- */
#mainNav {
    margin: 0;
    width: 100%;
}

/* --- Site Header Bar --- */
.site-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary, #111827);
    border-bottom: 1px solid var(--border-color, #2d3a4f);
    z-index: 100;
    position: relative;
}

.site-header-brand {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Desktop Inline Navigation --- */
.desktop-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    margin-left: 8px;
}

.desktop-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 400;
    border-radius: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.desktop-nav-item:hover {
    background: var(--bg-tertiary, #1e2a3a);
    color: var(--text-primary, #f0f4f8);
}

.desktop-nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-primary, #3b82f6);
    font-weight: 500;
}

.desktop-nav-item .nav-item-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.desktop-nav-item:hover .nav-item-icon,
.desktop-nav-item.active .nav-item-icon {
    opacity: 1;
}

.desktop-nav-separator {
    width: 1px;
    height: 20px;
    background: var(--border-color, #2d3a4f);
    margin: 0 6px;
    flex-shrink: 0;
}

/* --- Right side of header --- */
.site-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

/* --- User Avatar in Header --- */
.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--border-color, #2d3a4f);
    transition: border-color 0.2s;
}

.header-avatar:hover {
    border-color: var(--accent-primary, #3b82f6);
}

/* --- Avatar Dropdown --- */
.header-avatar-wrapper {
    position: relative;
}

.header-avatar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border-color, #2d3a4f);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    overflow: hidden;
}

.header-avatar-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.avatar-dropdown-user {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.avatar-dropdown-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary, #f0f4f8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-dropdown-email {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-dropdown-divider {
    height: 1px;
    background: var(--border-color, #2d3a4f);
}

.avatar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
}

.avatar-dropdown-item:hover {
    background: var(--bg-tertiary, #1e2a3a);
    color: var(--text-primary, #f0f4f8);
}

.avatar-dropdown-logout {
    color: #ef4444;
}

.avatar-dropdown-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.avatar-dropdown-logout .nav-logout-icon {
    width: 16px;
    height: 16px;
}

/* --- Hamburger Button (mobile only) --- */
.hamburger-btn {
    display: none; /* Hidden on desktop */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 8px;
    background: var(--bg-tertiary, #1e2a3a);
    border: 1px solid var(--border-color, #2d3a4f);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.hamburger-btn:hover {
    background: var(--accent-primary, #3b82f6);
    border-color: var(--accent-primary, #3b82f6);
}

.hamburger-btn:hover .hamburger-line {
    background: white;
}

.hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-secondary, #94a3b8);
    border-radius: 1px;
    transition: background 0.2s;
}

/* --- Overlay Backdrop --- */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nav-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* --- Slide-out Panel (mobile only) --- */
.nav-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-secondary, #111827);
    border-left: 1px solid var(--border-color, #2d3a4f);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-panel.open {
    transform: translateX(0);
}

/* Panel header */
.nav-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #2d3a4f);
    flex-shrink: 0;
}

.nav-panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted, #64748b);
}

.nav-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary, #1e2a3a);
    border: 1px solid var(--border-color, #2d3a4f);
    border-radius: 6px;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.nav-close-btn:hover {
    background: var(--accent-primary, #3b82f6);
    border-color: var(--accent-primary, #3b82f6);
    color: white;
}

/* Navigation items (inside panel) */
.nav-items {
    padding: 12px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 400;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-tertiary, #1e2a3a);
    color: var(--text-primary, #f0f4f8);
}

.nav-item.active {
    color: var(--accent-primary, #3b82f6);
    border-left-color: var(--accent-primary, #3b82f6);
    background: rgba(59, 130, 246, 0.08);
    font-weight: 500;
}

.nav-item .nav-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon {
    opacity: 1;
}

.nav-separator {
    height: 1px;
    background: var(--border-color, #2d3a4f);
    margin: 8px 20px;
}

/* Panel footer (user info + logout) */
.nav-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #2d3a4f);
    flex-shrink: 0;
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.nav-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.nav-user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nav-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary, #f0f4f8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user-email {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    color: #ef4444;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.nav-logout-icon {
    width: 18px;
    height: 18px;
}

/* ============================================
   RESPONSIVE: Mobile <= 768px
   ============================================ */
@media (max-width: 768px) {
    .site-header {
        padding: 0 16px;
        height: 50px;
    }

    .site-header-brand {
        font-size: 1rem;
    }

    /* Hide desktop inline nav, show hamburger */
    .desktop-nav {
        display: none;
    }

    .hamburger-btn {
        display: flex;
    }

    .nav-panel {
        width: 100%;
        max-width: 100vw;
    }

    /* On dashboard (body.no-scroll): fix nav header above the municipality selector */
    body.no-scroll .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 150;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .site-header {
        padding: 0 12px;
    }
}
