:root {
    --site-header-height: 72px;
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #000;
    border-bottom: 3px solid #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
    box-sizing: border-box;
}

.header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    min-height: 44px;
}

/* ─── Left: Home, My Products, Pricing, Admin ─────────────────── */
.nav-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-self: start;
}

/* ─── Center: company name / mega-menu ──────────────────────────── */
.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    min-width: 0;
    text-align: center;
}

.company-name--static {
    display: block;
    max-width: min(420px, 40vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.company-dropdown--center {
    max-width: min(480px, 50vw);
}

.company-dropdown--center .company-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ─── Right: Login / Logout ───────────────────────────────────── */
.nav-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

/* ─── Links ───────────────────────────────────────────────────── */
.nav-left a,
.nav-right a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    padding: 8px 14px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.nav-left a:hover,
.nav-right a:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.home,
.about,
.portal,
.products,
.login,
.logout,
.signup {
    font-weight: 700;
}

/* ─── Mobile-only top bar pieces (hidden on desktop) ──────────── */
.mobile-bar-title {
    display: none;
}

.nav-right--top {
    display: none;
}

/* ─── Hamburger (mobile only) ─────────────────────────────────── */
.nav-toggle {
    display: none;
}

/* ─── Company / Admin dropdowns ───────────────────────────────── */
.company-dropdown {
    position: relative;
}

.company-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 4px 8px 4px 4px;
    background: transparent;
    font: inherit;
    max-width: 100%;
}

.company-dropdown:hover .company-dropdown-trigger,
.company-dropdown.is-open .company-dropdown-trigger {
    background-color: rgba(255, 255, 255, 0.12);
}

.company-name {
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    padding: 6px 10px;
    border-radius: 6px;
}

.company-dropdown-chevron {
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.company-dropdown.is-open .company-dropdown-chevron {
    transform: rotate(180deg);
}

.company-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    padding-top: 8px;
    z-index: 1001;
    min-width: 220px;
}

.company-dropdown-menu--mega {
    min-width: min(720px, calc(100vw - 32px));
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    padding: 16px 18px 14px;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.company-dropdown-menu--compact {
    min-width: 240px;
    grid-template-columns: 1fr;
}

.company-dropdown--admin .company-dropdown-menu {
    left: 0;
    transform: none;
}

.company-dropdown-section {
    padding: 4px 10px 8px 0;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.company-dropdown-section:last-child {
    border-right: none;
    padding-right: 0;
}

.company-dropdown-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 10px 4px;
}

.company-dropdown .company-dropdown-item {
    display: block;
    padding: 9px 12px;
    margin-bottom: 2px;
    color: #0c2756;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.94rem;
    border-radius: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.company-dropdown .company-dropdown-item:hover {
    background-color: #f1f5f9;
    color: #051a3d;
}

.company-dropdown .company-dropdown-item.active {
    background-color: #e2e8f0;
    font-weight: 600;
    border-left: 3px solid #0c2756;
    padding-left: 9px;
    color: #051a3d;
}

/* Desktop: show menus on hover and when open */
@media (min-width: 769px) {
    .company-dropdown:hover .company-dropdown-menu,
    .company-dropdown.is-open .company-dropdown-menu {
        display: block;
    }

    .company-dropdown:hover .company-dropdown-menu--mega,
    .company-dropdown.is-open .company-dropdown-menu--mega {
        display: grid;
    }
}

/* ─── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --site-header-height: 56px;
    }

    .header-container {
        padding: 8px 12px;
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        align-items: center;
        gap: 0;
    }

    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        padding: 10px;
        margin: 0;
        border: none;
        border-radius: 6px;
        background: transparent;
        cursor: pointer;
        grid-column: 1;
        grid-row: 1;
    }

    .nav-toggle-bar {
        display: block;
        width: 22px;
        height: 2px;
        background: #fff;
        border-radius: 1px;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .site-header.is-open .nav-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .site-header.is-open .nav-toggle-bar:nth-child(2) {
        opacity: 0;
    }

    .site-header.is-open .nav-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .header-inner {
        grid-column: 1 / -1;
        grid-row: 2;
        display: none;
        grid-template-columns: 1fr;
        gap: 0;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: 10px;
        margin-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .site-header.is-open .header-inner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-bar-title {
        display: block;
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        min-width: 0;
        max-width: 100%;
        padding: 0 8px;
        text-align: center;
    }

    .mobile-bar-title .company-name {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 52vw;
        margin: 0 auto;
    }

    .nav-right--top {
        display: flex;
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        gap: 6px;
    }

    .nav-right--top a {
        color: #fff;
        text-decoration: none;
        font-weight: 700;
        font-size: 14px;
        padding: 6px 10px;
        border-radius: 6px;
        white-space: nowrap;
    }

    .header-inner .nav-right {
        display: none;
    }

    .nav-left {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding-bottom: 8px;
    }

    .nav-left a {
        width: 100%;
        box-sizing: border-box;
    }

    .nav-center {
        width: 100%;
        justify-content: flex-start;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-top: 4px;
    }

    .company-dropdown--center,
    .company-dropdown--admin {
        width: 100%;
        max-width: none;
    }

    .company-dropdown-trigger {
        width: 100%;
        justify-content: space-between;
        box-sizing: border-box;
        padding: 12px 8px;
    }

    .company-dropdown-menu {
        position: static;
        transform: none;
        left: auto;
        margin-top: 0;
        padding-top: 0;
        min-width: 0;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        border: none;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .company-dropdown.is-open .company-dropdown-menu,
    .company-dropdown.is-open .company-dropdown-menu--mega {
        display: grid;
    }

    .company-dropdown-menu--mega {
        grid-template-columns: 1fr;
    }

    .company-dropdown-section {
        padding: 4px 0 8px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .company-dropdown-section:last-child {
        border-bottom: none;
    }

}

body.nav-locked {
    overflow: hidden;
}
