/* ============================================================
   HEADER / NAVIGATION STYLES
   Extracted from components/header.php so a CSS typo can't fatal
   the every-page PHP header. Loaded after css/styles.css.
   ============================================================ */
        * { box-sizing: border-box; }


    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #ffffff;
        border-bottom: 1px solid #e2e6ed;
        box-shadow: 0 1px 4px rgba(26,45,90,0.08), 0 4px 16px rgba(26,45,90,0.06);
    }

    .site-header .container {
        max-width: 1280px;
        margin: 0 auto;
        padding: 0 1.5rem;
    }

    .header-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 68px;
        gap: 1rem;
    }

    /* ---- LOGO ---- */
    .logo a {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        text-decoration: none;
        white-space: nowrap;
    }
    .logo img {
        height: 44px;
        width: auto;
        object-fit: contain;
    }
    .logo-text {
        display: flex;
        flex-direction: column;
        line-height: 1.1;
    }
    .logo-name {
        font-size: 1.05rem;
        font-weight: 800;
        color: #1a2d5a;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
    .logo-tagline {
        font-size: 0.6rem;
        font-weight: 500;
        color: #8a9ab5;
        letter-spacing: 0.12em;
        text-transform: uppercase;
    }

    /* ---- DESKTOP NAV ---- */
    .main-nav { display: flex; align-items: center; }

    .nav-menu {
        display: flex;
        align-items: center;
        gap: 0.1rem;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .nav-menu > li { position: relative; }

    .nav-menu > li > a {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.45rem 0.8rem;
        color: #374151;
        text-decoration: none;
        font-size: 0.875rem;
        font-weight: 500;
        border-radius: 6px;
        white-space: nowrap;
        transition: color 0.15s, background 0.15s;
    }
    .nav-menu > li > a:hover {
        color: #1a2d5a;
        background: #f0f3f9;
    }

    /* ---- DROPDOWN ARROW (desktop only) ---- */
    .has-dropdown > a::after {
        content: '';
        display: inline-block;
        width: 0; height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 4px solid #8a9ab5;
        margin-left: 3px;
        transition: transform 0.2s;
    }
    .has-dropdown:hover > a::after,
    .has-dropdown:focus-within > a::after,
    .has-dropdown.open > a::after {
        transform: rotate(180deg);
    }

    /* ---- DESKTOP DROPDOWN ---- */
    .dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        min-width: 200px;
        background: #ffffff;
        border: 1px solid #e2e6ed;
        border-radius: 10px;
        box-shadow: 0 4px 6px rgba(26,45,90,0.05), 0 12px 32px rgba(26,45,90,0.12);
        list-style: none;
        margin: 0;
        padding: 0.4rem 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-6px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
        z-index: 2000;
    }
    .has-dropdown:hover > .dropdown,
    .has-dropdown:focus-within > .dropdown {
        opacity: 1; visibility: visible; transform: translateY(0);
    }
    .has-dropdown.open > .dropdown {
        opacity: 1; visibility: visible; transform: translateY(0);
    }
    .dropdown li a {
        display: block;
        padding: 0.6rem 1.1rem;
        color: #374151;
        text-decoration: none;
        font-size: 0.8125rem;
        font-weight: 500;
        white-space: nowrap;
        transition: color 0.12s, background 0.12s;
    }
    .dropdown li a:hover {
        color: #1a2d5a;
        background: #f0f3f9;
    }
    .has-dropdown:last-child .dropdown,
    .has-dropdown.align-right .dropdown {
        left: auto; right: 0;
    }

    /* ---- ROLE BADGE ---- */
    .role-badge {
        display: inline-block;
        background: #eef1f8;
        color: #1a2d5a;
        padding: 2px 7px;
        border-radius: 4px;
        font-size: 0.6rem;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        border: 1px solid #c8d0e0;
    }

    /* ---- DASHBOARD & PORTAL LINKS ---- */
    .nav-menu .dashboard-link > a {
        background: #1a2d5a;
        color: #ffffff;
        font-weight: 600;
        border-radius: 6px;
        padding: 0.45rem 1rem;
    }
    .nav-menu .dashboard-link > a:hover {
        background: #243d7a;
        color: #ffffff;
    }
    .nav-menu .portal-link > a {
        border: 1.5px solid #1a2d5a;
        color: #1a2d5a;
        font-weight: 600;
    }
    .nav-menu .portal-link > a:hover {
        background: #1a2d5a;
        color: #ffffff;
    }
    .nav-menu .login-link > a {
        color: #1a2d5a;
        font-weight: 600;
    }

    /* ---- HAMBURGER ---- */
    .mobile-menu-toggle {
        display: none;
        align-items: center;
        justify-content: center;
        color: #1a2d5a;
        background: none;
        border: 1.5px solid #e2e6ed;
        cursor: pointer;
        padding: 9px;
        border-radius: 7px;
        width: 44px;
        height: 44px;
        transition: background 0.15s, border-color 0.15s;
    }
    .mobile-menu-toggle:hover {
        background: #f0f3f9;
        border-color: #c8d0e0;
    }
    /* Universal 3-line (hamburger) icon, swaps to an X when open */
    .mobile-menu-toggle .mmt-icon { display: block; width: 24px; height: 24px; color: #1a2d5a; }
    .mobile-menu-toggle .mmt-close { display: none; }
    .mobile-menu-toggle.open .mmt-open  { display: none; }
    .mobile-menu-toggle.open .mmt-close { display: block; }

    /* ---- FLASH MESSAGES ---- */
    .flash-messages {
        max-width: 1280px;
        margin: 0.75rem auto;
        padding: 0 1.5rem;
    }
    .alert {
        padding: 0.75rem 1.1rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
        font-size: 0.875rem;
        font-weight: 500;
    }
    .alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
    .alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
    .alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

    /* ============================================================
       MOBILE — clean dropdown panel below header
       FIX: was full-screen slide-in, now drops cleanly from header
       ============================================================ */
    @media (max-width: 900px) {

        .mobile-menu-toggle { display: flex; }

        /* Nav drops full viewport width */
        .nav-menu {
            position: fixed;
            top: 68px;
            left: 0;
            right: 0;
            flex-direction: column;
            align-items: stretch;
            gap: 0;
            background: #ffffff;
            border-top: 2px solid #1a2d5a;
            border-bottom: 1px solid #e2e6ed;
            box-shadow: 0 8px 24px rgba(26,45,90,0.12);
            padding: 0.5rem 0;
            overflow-y: auto;
            max-height: calc(100vh - 68px);
            /* Hidden state */
            opacity: 0;
            visibility: hidden;
            transform: translateY(-8px);
            transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
            z-index: 999;
        }

        /* Open state — drops into view */
        .nav-menu.mobile-open {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        /* Top-level links */
        .nav-menu > li > a {
            padding: 1rem 1.5rem;
            border-radius: 0;
            font-size: 1rem;
            font-weight: 600;
            color: #1a2d5a;
            border-bottom: 1px solid #f0f3f9;
            min-height: 56px;
            display: flex;
            align-items: center;
        }
        .nav-menu > li > a:hover { background: #f0f3f9; }

        /* Dashboard & portal — centered pills */
        .nav-menu .dashboard-link > a {
            margin: 0.5rem 1rem;
            border-radius: 8px;
            min-height: 48px;
            justify-content: center;
        }
        .nav-menu .portal-link > a {
            margin: 0 1rem;
            border-radius: 8px;
            justify-content: center;
            min-height: 48px;
        }

        /* Hide desktop arrow, show +/− indicator */
        .has-dropdown > a::after { display: none; }
        .has-dropdown > a {
            position: relative;
            justify-content: space-between;
        }
        .has-dropdown > a::before {
            content: '+';
            font-size: 1.3rem;
            font-weight: 300;
            color: #8a9ab5;
            margin-left: auto;
            padding-left: 1rem;
            line-height: 1;
        }
        .has-dropdown.open > a::before {
            content: '−';
            color: #1a2d5a;
        }

        /* Sub-dropdown — hidden by default, shown when JS adds .open */
        .has-dropdown > .dropdown {
            position: static !important;
            opacity: 1 !important;
            visibility: visible !important;
            transform: none !important;
            transition: none !important;
            box-shadow: none !important;
            border: none !important;
            border-radius: 0 !important;
            background: #f0f4fb;
            border-left: 3px solid #1a2d5a !important;
            margin: 0 !important;
            padding: 0.25rem 0 !important;
            display: none !important;
            width: 100% !important;
        }
        .has-dropdown.open > .dropdown {
            display: block !important;
        }
        /* Make sure dropdown links are fully visible */
        .has-dropdown > .dropdown li {
            display: block !important;
            width: 100% !important;
            border-bottom: 1px solid #e2e6ed;
        }
        .has-dropdown > .dropdown li:last-child { border-bottom: none; }
        .has-dropdown > .dropdown li a {
            display: block !important;
            padding: 1rem 1.5rem !important;
            font-size: 0.9375rem !important;
            font-weight: 500 !important;
            color: #1a2d5a !important;
            min-height: 52px !important;
            width: 100% !important;
            visibility: visible !important;
            opacity: 1 !important;
        }
        .has-dropdown > .dropdown li a:hover {
            background: #e2e8f4 !important;
        }

        .dropdown li { border-bottom: 1px solid #e8edf5; }
        .dropdown li:last-child { border-bottom: none; }
        .dropdown li a {
            padding: 1rem 1.5rem;
            font-size: 0.9375rem;
            font-weight: 500;
            color: #374151;
            min-height: 52px;
            display: flex;
            align-items: center;
        }
        .dropdown li a:hover { background: #eef1f8; color: #1a2d5a; }
    }

    @media (max-width: 400px) {
        .logo-tagline { display: none; }
        .logo-name { font-size: 0.9rem; }
    }

/* Mobile density pass (1.6.1): tighter top bar on phones. */
@media (max-width: 640px) {
    .site-header .container { padding: 0 1rem; }
    .header-content { height: 56px; }
    .logo img { height: 34px; }
    .logo-name { font-size: 0.9rem; }
    .logo-tagline { font-size: 0.52rem; letter-spacing: 0.14em; }
    .nav-menu { top: 56px; max-height: calc(100vh - 56px); }
}

/* ============================================================
   1.7.2 — Mobile nav tightened & cleaned (UniFi-style).
   Fixes: labels left-aligned (the +/− pseudo-element used to
   flex-push them right), compact 46px rows, chevron on the
   right, no duplicate role badge, tidy submenus.
   ============================================================ */
@media (max-width: 900px) {

    /* Rows: compact, uniform, label on the LEFT. */
    .nav-menu > li > a {
        padding: 0.45rem 1.25rem;
        min-height: 42px;
        font-size: 0.9rem;
        font-weight: 600;
        justify-content: flex-start;
        border-bottom: 1px solid #eef1f6;
    }

    /* Kill the old +/− that hijacked the flex row. */
    .has-dropdown > a::before { content: none !important; }

    /* Chevron on the right instead — rotates when open. */
    .has-dropdown > a::after {
        content: '' !important;
        display: block !important;
        width: 8px; height: 8px;
        border-right: 2px solid #8a9ab5;
        border-bottom: 2px solid #8a9ab5;
        transform: rotate(45deg);
        margin-left: auto;
        margin-top: -4px;
        transition: transform 0.18s;
        border-top: none; border-left: none;
    }
    .has-dropdown.open > a::after {
        transform: rotate(-135deg);
        margin-top: 4px;
        border-color: #1a2d5a;
    }

    /* The role badge duplicates the username on phones — hide it. */
    .nav-menu .role-badge { display: none; }

    /* Dashboard pill: compact. */
    .nav-menu .dashboard-link > a {
        margin: 0.5rem 1.25rem;
        min-height: 44px;
        border-radius: 10px;
        font-size: 0.9375rem;
        justify-content: center;
        border-bottom: none;
    }

    /* Submenus: quiet indented panel, tight rows. */
    .has-dropdown > .dropdown {
        background: #f7f9fc;
        border-left: 2px solid #c9a227 !important;
        padding: 0.15rem 0 !important;
    }
    .has-dropdown > .dropdown li { border-bottom: 1px solid #edf0f5; }
    .has-dropdown > .dropdown li a {
        padding: 0.45rem 1.5rem !important;
        min-height: 38px !important;
        font-size: 0.86rem !important;
        font-weight: 500 !important;
        color: #33415c !important;
    }

    /* Menu sheet: crisp edge, soft shadow. */
    .nav-menu {
        border-top: 1px solid #e2e6ed;
        box-shadow: 0 14px 34px rgba(26,45,90,0.14);
        padding: 0.25rem 0 0.5rem;
    }
}
