/* core/css/site-header.css - the one site header (core/includes/site_header.html).
   Works on Bootstrap 5.3 alone (financial reports) and with the theme's style.css (everything else).
   Colors come from Bootstrap's theme variables only, so light and dark mode follow data-bs-theme. */

/* ===== Sticky: pure CSS, no scroll script, no fade-in delay ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background-color: rgba(var(--bs-body-bg-rgb, 255, 255, 255), .92);
    background-color: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--bs-border-color);
}

.site-header > .navbar {
    --bs-navbar-padding-y: .5rem;
    flex-wrap: nowrap;
}

.site-header > .navbar > .container {
    flex-wrap: wrap;
    gap: .25rem 0;
}

/* ===== Logo ===== */
.site-header .site-header-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0;
    margin-inline-end: 1rem;
    color: var(--bs-heading-color, var(--bs-body-color));
    min-width: 0;
}

.site-header .site-header-logo {
    height: 36px;
    width: auto;
}

.site-header .site-header-name {
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
}

/* theme helpers (style.css has them too; repeated so the header works without it) */
.site-header .dark-mode-item { display: none !important; }
[data-bs-theme=dark] .site-header .dark-mode-item { display: inline-block !important; }
[data-bs-theme=dark] .site-header .light-mode-item { display: none !important; }

/* ===== Actions (cart, bell, language, theme, profile/sign in, toggler) ===== */
.site-header-actions {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-inline-start: auto;
}

.site-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-width: 40px;
    height: 40px;
    padding: 0 .5rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 1.15rem;
    line-height: 1;
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.site-header-icon:hover,
.site-header-icon:focus-visible,
.site-header-icon[aria-expanded="true"] {
    background-color: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
}

.site-header-lang {
    font-size: .9rem;
    font-weight: 500;
}

.site-header-lang .bi { font-size: 1.1rem; }

.site-header-flag {
    flex: 0 0 auto;
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

/* Language menu: same look as the main-menu panels. #siteHeader outranks the theme's dropdown padding
   and Bootstrap's ".dropdown-menu-end[data-bs-popper]" offsets (the theme adds a negative end margin,
   so the menu hung past the toggle). Opens under the toggle, flush with its end edge, in LTR and RTL. */
#siteHeader .site-header-lang-menu {
    top: calc(100% + .35rem);
    inset-inline-end: 0;
    inset-inline-start: auto;
    min-width: 11rem;
    margin: 0;
    padding: .4rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .85rem;
    background: var(--bs-body-bg);
    box-shadow: 0 24px 48px -16px rgba(15, 23, 42, .22);
    text-align: start;
}

#siteHeader .site-header-lang-menu .dropdown-item {
    gap: .65rem !important;
    margin: 0;
    padding: .5rem .75rem;
    border-radius: .6rem;
    color: var(--bs-body-color);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

#siteHeader .site-header-lang-menu .dropdown-item:hover,
#siteHeader .site-header-lang-menu .dropdown-item:focus-visible {
    background: rgba(var(--bs-primary-rgb), .07);
    color: var(--bs-primary);
}

#siteHeader .site-header-lang-menu .dropdown-item.active {
    background: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
    font-weight: 600;
}

#siteHeader .site-header-lang-menu .dropdown-item .bi { color: var(--bs-primary); width: 20px; text-align: center; }

.site-header-signin {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    margin-inline-start: .25rem;
}

/* Cart badge */
.site-header .cart-badge {
    position: absolute;
    top: 0;
    inset-inline-end: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    line-height: 14px;
    text-align: center;
    color: #fff;
    background-color: var(--bs-primary);
    border: 2px solid var(--bs-body-bg);
    border-radius: 999px;
}

/* Notification bell (notifications/includes/notification_bell.html is an <li>) */
.site-header-bell > .nav-item {
    list-style: none;
    margin: 0 !important;
    position: relative;
}

.site-header-bell #notificationBell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 1.15rem;
}

.site-header-bell #notificationBell:hover,
.site-header-bell #notificationBell[aria-expanded="true"] {
    background-color: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
}

.site-header-bell .notif-badge {
    border-color: var(--bs-body-bg);
}

/* Profile avatar */
.site-header .avatar-img {
    object-fit: cover;
}

/* Dropdowns never wider than the phone screen */
.site-header .dropdown-menu {
    max-width: calc(100vw - 1.5rem);
}

.site-header .site-header-bell .dropdown-menu {
    width: 22rem;
}

/* Phones/small tablets: the bell sits mid-row, so a menu anchored to it spills off screen.
   Anchor it to the whole bar instead (.navbar is the positioned ancestor once the bell's
   <li> is static) and pin it to the bar's end edge, in LTR and RTL alike. */
@media (max-width: 767.98px) {
    .site-header-bell > .nav-item {
        position: static;
    }

    .site-header .site-header-bell .dropdown-menu {
        inset-inline-start: auto !important;
        inset-inline-end: .75rem !important;
        width: min(22rem, calc(100vw - 1.5rem));
        min-width: 0;
        max-width: none;
        margin: .25rem 0 0 !important; /* style.css adds margin-right: -25px on phones */
        /* never taller than the screen below the bar (two rows on the narrowest phones);
           only the list scrolls */
        max-height: calc(100vh - 8rem);
        max-height: calc(100dvh - 8rem);
    }

    .site-header .site-header-bell .dropdown-menu.show {
        display: flex;
        flex-direction: column;
    }

    .site-header .site-header-bell .dropdown-menu > .card {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .site-header .site-header-bell .notification-scroll-container {
        flex: 1 1 auto;
        min-height: 0;
    }
}

/* Menu toggler */
.site-header .site-header-toggler {
    border: 0;
    padding: 0;
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
    color: var(--bs-body-color);
    box-shadow: none;
}

/* ===== Account actions (sign in link, Start free / Dashboard button) ===== */
.site-header-signin-link {
    align-items: center;
    height: 40px;
    padding: 0 .6rem;
    font-weight: 500;
    color: var(--bs-body-color);
    text-decoration: none;
    white-space: nowrap;
}

.site-header-signin-link:hover { color: var(--bs-primary); }

.site-header .site-header-cta {
    align-items: center;
    gap: .4rem;
    margin: 0 0 0 0;
    margin-inline-start: .25rem;
    padding: .4rem .9rem;
    border-radius: .55rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ===== Main menu ===== */
.site-header .navbar-nav .nav-link {
    font-weight: 500;
    color: var(--bs-body-color);
}

.site-header .navbar-nav .nav-link:hover,
.site-header .navbar-nav .nav-link.active,
.site-header .navbar-nav .nav-link[aria-expanded="true"] {
    color: var(--bs-primary);
}

.site-header .site-nav .dropdown-toggle::after,
#siteHeader .site-nav .dropdown-toggle::after {   /* a small chevron instead of the caret (theme blanks it) */
    content: "\F282";                              /* bi-chevron-down */
    display: inline-block;
    font-family: bootstrap-icons !important;
    border: 0;
    vertical-align: -.1em;
    margin-inline-start: .3rem;
    font-size: .7em;
    transition: transform .2s ease;
}

#siteHeader .site-nav .dropdown-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

/* Panels */
.site-header .site-nav-panel {
    --sn-muted: color-mix(in srgb, var(--bs-body-color) 72%, var(--bs-body-bg));
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    background: var(--bs-body-bg);
    box-shadow: 0 24px 48px -16px rgba(15, 23, 42, .22);
}

.site-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .25rem;
}

.site-nav-card {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .7rem .75rem;
    border-radius: .75rem;
    color: var(--bs-body-color);
    text-decoration: none;
    transition: background-color .15s ease;
}

.site-nav-card:hover,
.site-nav-card:focus-visible { background: rgba(var(--bs-primary-rgb), .07); }

.site-nav-icon {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: .7rem;
    background: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
    font-size: 1.15rem;
}

.site-nav-card-body { display: grid; gap: .1rem; min-width: 0; }

.site-nav-card-title {
    margin: 0;
    font-weight: 600;
    color: var(--bs-heading-color, var(--bs-body-color));
}

.site-nav-card-text {
    margin: 0;
    font-size: .85rem;
    line-height: 1.45;
    color: var(--sn-muted);
}

.site-nav-label {
    margin: 0 0 .5rem;
    padding-inline: .75rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--sn-muted);
}

:lang(fa) .site-nav-label, :lang(ar) .site-nav-label { font-size: .85rem; letter-spacing: 0; }

.site-nav-list {
    display: grid;
    gap: .1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav-list-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.site-nav-list a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: .6rem;
    color: var(--bs-body-color);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.site-nav-list a .bi { color: var(--bs-primary); font-size: 1.05rem; }
.site-nav-list a:hover,
.site-nav-list a:focus-visible { background: rgba(var(--bs-primary-rgb), .07); color: var(--bs-primary); }

.site-nav-split {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 1rem;
}

.site-nav-feature {
    display: grid;
    align-content: start;
    justify-items: start;
    gap: .5rem;
    padding: 1rem;
    border-radius: .85rem;
    background: rgba(var(--bs-primary-rgb), .06);
}

.site-nav-panel-foot {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin-top: .75rem;
    padding: .75rem .75rem 0;
    border-top: 1px solid var(--bs-border-color);
}

.site-nav-panel-foot a {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-weight: 600;
    color: var(--bs-primary);
    text-decoration: none;
}

/* RTL: the arrow's glyph (::before) is mirrored by core/css/l10n.css; the element itself must never be flipped too. */
[dir=rtl] .site-nav-arrow { transform: none !important; }

.site-nav-mobile-actions { display: none; }

/* ----- xl and up: floating panels under the bar ----- */
@media (min-width: 1200px) {
    .site-header .navbar-nav .nav-link {
        padding-inline: .9rem;
    }

    /* The theme (style.css) shows navbar dropdowns on :hover via opacity/visibility and ignores Bootstrap's
       .show. These panels are click-driven only (one open at a time, Esc / outside click closes), so undo
       the theme's rules; #siteHeader outranks its ".navbar-expand-xl .navbar-nav .dropdown:hover > ..." */
    #siteHeader .site-nav-panel {
        display: none;
        visibility: visible;
        opacity: 1;
        position: absolute;
        top: calc(100% + .35rem);
        inset-inline-start: 0;
        min-width: 15rem;
        margin-top: 0;
        transition: none;
    }

    #siteHeader .site-nav-panel.show { display: block; }

    /* narrow panels (Explore, Resources) grow with their longest label; without this they stay at
       min-width and long labels (fa: "کارت‌های NFC و استندهای QR") run past the panel edge */
    #siteHeader .site-nav-panel:not(.site-nav-panel-wide) { width: max-content; }

    /* the theme also sets pointer-events:none on a pressed toggle, so mouseup lands on the <li> and
       Bootstrap never sees the click */
    #siteHeader .site-nav .dropdown > .dropdown-toggle:active { pointer-events: auto; }

    /* wide panels (Product, Solutions) are centred under the whole bar: their item is static, so .navbar is
       the positioned ancestor */
    #siteHeader .site-nav-item:has(> .site-nav-panel-wide) { position: static; }

    #siteHeader .site-nav-panel-wide {
        top: calc(100% - .25rem);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(46rem, calc(100vw - 2rem));
    }
}

/* Below xl: the menu drops down as a full-width panel under the bar */
@media (max-width: 1199.98px) {
    .site-header .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
        overflow-y: auto;
        background: var(--bs-body-bg);
        border-top: 1px solid var(--bs-border-color);
        border-bottom: 1px solid var(--bs-border-color);
        box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
        margin: 0;
        padding: 0;
        border-radius: 0;
    }

    .site-header .navbar-collapse .navbar-nav .nav-item {
        border-bottom: 1px solid var(--bs-border-color);
        padding: 0 1.5rem;
    }

    .site-header .navbar-collapse .nav-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: .85rem 0;
        font-size: 1.02rem;
    }

    /* the theme pins the toggle's chevron at right:25px (wrong side in RTL); let it flow at the row's end */
    #siteHeader .site-nav .dropdown-toggle::after { position: static; }

    /* panels fold out inside the list (#siteHeader: outrank the theme's grey mobile dropdown) */
    #siteHeader .site-nav-panel {
        position: static;
        margin: 0 0 .75rem;
        padding: .25rem 0 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    .site-nav-grid,
    .site-nav-split { grid-template-columns: minmax(0, 1fr); }
    .site-nav-card { padding: .55rem .25rem; }
    .site-nav-card-text { display: none; }      /* titles only on phones: shorter list */
    .site-nav-icon { width: 34px; height: 34px; font-size: 1rem; }
    .site-nav-list a { padding: .55rem .25rem; white-space: normal; }
    .site-nav-feature { margin-top: .25rem; }
    .site-nav-panel-foot { padding-inline: .25rem; }

    .site-nav-mobile-actions {
        display: flex;
        gap: .75rem;
        padding: 1rem 1.5rem 1.25rem;
    }

    .site-nav-mobile-actions .btn {
        flex: 1 1 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;
        margin: 0;
        font-weight: 600;
    }
}

@media (min-width: 576px) and (max-width: 1199.98px) {
    .site-nav-list-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
    .site-nav-list-2col { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .site-header .site-nav .dropdown-toggle::after, .site-nav-card { transition: none; }
}

/* Small phones: tighten so logo + all actions fit on one row */
@media (max-width: 575.98px) {
    .site-header .site-header-name { display: none; }
    .site-header-actions { gap: 0; }
    .site-header-icon, .site-header-bell #notificationBell { min-width: 36px; width: auto; height: 36px; padding: 0 .4rem; }
    .site-header .site-header-toggler { width: 36px; height: 36px; }
}

/* ===== App bar: second row under the site header (CRM, reports) ===== */
.app-subnav {
    position: relative;
    background-color: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.app-subnav .navbar-brand {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-heading-color, var(--bs-body-color));
}

.app-subnav .nav-link {
    color: var(--bs-body-color);
}

.app-subnav .nav-link:hover,
.app-subnav .nav-link.active {
    color: var(--bs-primary);
}
