/**
 * Shared header.phtml structural baseline.
 *
 * Loaded by ThemesFacade alongside tokens.css for every theme — provides
 * positioning, flex layout, dropdown behavior, avatar sizing, and mobile
 * breakpoints for the markup in src/dashboard/templates/header.phtml.
 *
 * Theme-specific colours / backgrounds / borders are applied by per-theme
 * files in static/css/themes/{ident}.css. Defaults consume var() from
 * tokens.css so colours resolve consistently without explicit overrides.
 *
 * Loading order (see ThemesFacade::onPrepareUserThemes):
 *   1. tokens.css        — variable contract
 *   2. header.css        — this file, shared structural baseline
 *   3. themes/{ident}.css — per-theme palette + tweaks
 */

/* ============ Header layout containers ============ */

/* Override submodule default's `#header { display:block; margin:0 220px 0 0;
   padding:0 13px 0 0; background:#242424 }`. Shared header.phtml has two
   top-level children — #hide-menu (logo/menu toggle/left panel) and
   .header-right-panel (avatar dropdown / right actions) — that need to sit
   on opposite edges. Background is themed via --header-bg. */
#header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    padding: 0;
    margin: 0;
    background: var(--header-bg);
}

/* Submodule pins `#header > :first-child { width: 220px }` for the legacy
   default DOM where that child was a single 220px-wide #logo-group. Shared
   header.phtml splits that slot into hide-menu-button + #logo + the project
   selector, so we let it grow with content here. */
#header > #hide-menu {
    display: inline-flex;
    height: 100%;
    width: auto;
}

#header > #hide-menu > .header-left-panel {
    display: inline-flex;
}

#header > .header-right-panel {
    display: inline-flex;
}

/* ============ Hide-menu button (SVG sidebar icon) ============ */

/* Cross-theme reset for the submodule's admin-template button skin lives
   in static/css/reset.css — see that file for the .btn-header /
   .hidden-menu selectors. This file keeps only the layout geometry. */

#header > #hide-menu > .hide-menu-button > a {
    min-width: 64px;
    margin: unset !important;
    height: 100% !important;
    font-size: 24px;
    padding: unset !important;
}

#header > #hide-menu > .hide-menu-button > a > img {
    padding-top: 8px;
}

#header > #hide-menu > .hide-menu-button > a:hover {
    border: unset;
}

#header > #hide-menu > .hide-menu-button > a:active {
    background: unset;
}

/* Font-awesome bell icon override */
#hide-menu i.fa.fa-bell-o::before {
    content: "\f0a2";
}

/* ============ Profile dropdown layout ============ */

.header-right-panel > .profile-info {
    height: 100%;
    vertical-align: middle;
    text-align: center;
    display: inline-flex;
    align-items: center;
}

.header-right-panel > .profile-info > a {
    text-align: left;
    display: inline-flex;
    align-items: center;
}

.profile-info > .dropdown:hover .dropdown-menu {
    display: block;
}

.profile-info > .dropdown .dropdown-menu {
    margin-top: 0;
}

.header-right-panel > .profile-info > .profile-info-dropdown {
    margin-right: 5px;
    margin-left: 5px;
    font-size: 12px;
    color: var(--header-fg);
}

.header-right-panel > .profile-info > .profile-info-dropdown > a {
    color: var(--header-fg);
    display: flex;
    text-decoration-line: none;
}

.header-right-panel > .profile-info > .profile-info-dropdown > a:hover {
    cursor: pointer;
}

.profile-info-dropdown > ul.dropdown-menu > li > a {
    line-height: 25px;
}

/* User-name display next to avatar */
.header-right-panel div.profile-info-user-name {
    color: var(--header-fg);
    font-family: var(--font-family);
    font-style: normal;
    font-weight: bold;
    font-size: var(--font-size-base);
    line-height: 19px;
    margin-top: 10px;
}

/* Avatar sizing */
.avatar-s {
    height: 4rem;
    width: 4rem;
}

/* Ajax-dropdown position inside header */
.header-right-panel .ajax-dropdown {
    left: unset;
    right: 40%;
}

/* Notifications bell + dropdown: anchor the panel to the bell so it always
   stays centred under it, regardless of logo width or other header layout.
   `.notifications-anchor` (notifications.phtml) wraps both the bell and the
   panel; the panel is then positioned relative to that wrapper, not #header.
   Scoped to the desktop header (>= 980px, where the bell is shown). Below that
   the bell is hidden and the legacy mobile `.ajax-dropdown` rules position the
   panel relative to #header — so the anchor stays static there, untouched. */
@media (min-width: 980px) {
    .notifications-anchor {
        position: relative;
        display: inline-block;
    }

    .notifications-anchor .ajax-dropdown {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

/* Below 980px the bell (`#notifications-btn`) is hidden, but its wrapper
   (`.header-btn` inside `.notifications-anchor`) still reserves width and pushes
   the workspace selector right. Hide the whole anchor so it occupies no space. */
@media (max-width: 979px) {
    .notifications-anchor {
        display: none;
    }

    /* Hide the sidebar-toggle button on mobile for every theme — at <=979px the
       sidebar is off-canvas and the mobile header is decluttered to the menu
       label + workspace selector only. */
    #header > #hide-menu > .hide-menu-button {
        display: none;
    }
}

/* At <=820px the workspace selector switches to a full-width block (themes set
   `display:block`) and the hidden notifications anchor no longer separates it
   from the menu button, so its desktop 14px left margin (default + overwatch
   carry `div.project-context { margin-left:14px !important }`) reads as an
   oversized left indent. Zero it for every theme — `#header` outranks the
   per-theme base rule, and modern/victory have no such margin so this is a
   no-op there. Kept separate from the 979px block above: between 821-979px the
   selector is still in its desktop inline layout and should keep the margin. */
@media (max-width: 820px) {
    #header div.project-context {
        margin-left: 0 !important;
    }
}

/* Legacy sidebar sign-out link hidden — dropdown now owns Logout */
li > #menu-item-sign-out-link {
    display: none;
}

/* Standalone #logout (pre-login fallback when no user) */
#logout {
    display: unset;
}

#logout a {
    font-size: var(--font-size-base);
    line-height: 25px;
}

/* ============ Logo ============ */
/* Submodule's `#logo { display:inline-block; margin-top:13px; margin-left:9px }`
   only centres the bitmap when paired with the legacy default header DOM.
   Shared header.phtml puts #logo inside the flex hide-menu, so use a flex
   slot here. The slot is fixed size (predictable header layout) and the
   image scales to fill it via max-width/max-height + object-fit:contain —
   any aspect ratio fits without distortion. */
#header #logo {
    display: flex;
    box-sizing: border-box;
    flex: 0 0 175px;
    height: 49px;
    padding: 4px 8px;
    margin: 0;
    justify-content: center;
    align-items: center;
}

/* The shared header DOM nests #logo inside #hide-menu, so the submodule's
   hide-menu-button rule — `#hide-menu > :first-child > a, .btn-header a { width:
   40px !important; height: 39px !important }` (active at 768-880px) — also matches
   the logo link and collapses the logo to a 40px button. Force the logo link to
   fill its slot instead; `#header #logo a` (two IDs) + !important outranks the
   submodule rule. Scoped to the logo link only, so the real hide-menu button is
   untouched. */
#header #logo a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    height: 100% !important;
}

/* Clamp the image into the padded slot and let intrinsic aspect lead — works
   for any image format with intrinsic w/h (PNG/JPG/SVG with width+height).
   max-height is pinned in pixels because `max-height: 100%` resolves to the
   parent flex item's full height including padding, which would let tall
   logos overflow the padded area. Keep in sync with #header height − 2×y-padding.
   object-fit: contain guarantees the bitmap never stretches if the box ratio
   differs from the logo's intrinsic ratio. */
#header #logo img {
    max-width: 100%;
    max-height: 41px;
    width: auto;
    height: auto;
    padding: 0;
    object-fit: contain;
}

/* ============ Mobile breakpoints ============ */

@media only screen and (min-width: 320px) and (max-width: 589px) {
    div.project-context {
        width: 160px;
    }
}

@media only screen and (min-width: 588px) and (max-width: 992px) {
    div.project-context {
        display: block !important;
        width: 250px;
    }

    div.header-btn #notifications-btn {
        margin-left: 5px;
        margin-top: 8px !important;
    }

    div.project-context .dropdown-menu {
        min-height: 150px;
    }
}

@media (max-width: 767px) {
    .profile-info-dropdown > ul.dropdown-menu {
        margin: unset;
    }

    #hide-menu > :first-child > a,
    .btn-header a {
        width: auto !important;
        line-height: 22px !important;
    }
}

@media (max-width: 720px) {
    /* Match the base `#header #logo` specificity (0,2,0) so this win on
       source order — `div#logo` (0,1,1) would lose to the base rule. */
    #header #logo {
        display: none;
    }

    #notifications-btn {
        margin-left: 5px !important;
        margin-top: 8px !important;
    }
}

@media (max-width: 479px) {
    .profile-info-user-name {
        display: none;
    }
}

@media only screen and (min-width: 320px) and (max-width: 479px) {
    #header > #hide-menu > #logo {
        margin-top: 5px !important;
    }

    #header > #hide-menu > .hide-menu-button > a > img.sidebar-icon {
        padding-top: 5px;
    }

    .header-right-panel .ajax-dropdown {
        right: 7%;
    }
}
