/* Site header — authenticated toolbar (loads via asset('css/site-header.css')) */

.header .site-header-actions,
.portal-root .site-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.65rem;
    margin-inline-start: auto;
    flex-shrink: 0;
}

/* Override legacy: .toggle, .dropdown-menu { width: 100% } */
.header .site-header-actions .toggle,
.header .site-header-actions .dropdown-menu,
.portal-root .site-header-actions .toggle,
.portal-root .site-header-actions .dropdown-menu {
    width: auto !important;
}

.site-header-actions__lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 0.55rem;
    border-radius: 10px;
    border: 1px solid #d9e3de;
    background: #fff;
    color: #374151 !important;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-decoration: none !important;
    line-height: 1;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.site-header-actions__lang:hover {
    border-color: #1b8354;
    color: #1b8354 !important;
    background: #f4fbf7;
}

.site-header-actions__tools {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem;
    border-radius: 12px;
    background: #f6faf8;
    border: 1px solid #e3ebe6;
}

.site-header-actions__icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #64748b !important;
    text-decoration: none !important;
    transition: background 0.2s, color 0.2s;
}

.site-header-actions__icon:hover {
    background: #fff;
    color: #1b8354 !important;
    box-shadow: 0 1px 4px rgba(27, 131, 84, 0.1);
}

.site-header-actions__icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.site-header-actions__icon i {
    font-size: 1rem;
}

.site-header-actions__badge {
    position: absolute;
    top: 0.05rem;
    inset-inline-end: 0.05rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.22rem;
    border-radius: 999px;
    background: #1b8354;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 800;
    line-height: 1rem;
    text-align: center;
    pointer-events: none;
}

.site-header-actions__login {
    padding: 0.48rem 1.1rem !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    white-space: nowrap;
}

/* Profile chip */
.site-header-actions__user {
    position: relative;
}

.site-header-actions__profile {
    display: inline-flex !important;
    align-items: center;
    gap: 0.65rem;
    padding: 0.28rem 0.7rem 0.28rem 0.32rem;
    border: 1px solid #d9e3de;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(19, 95, 61, 0.08);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-width: 15rem;
    line-height: 1.2;
}

.site-header-actions__profile:hover,
.site-header-actions__user.is-active .site-header-actions__profile {
    border-color: rgba(27, 131, 84, 0.45);
    box-shadow: 0 4px 14px rgba(27, 131, 84, 0.12);
}

.site-header-actions__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #1b8354, #135f3d);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 800;
    flex-shrink: 0;
}

.site-header-actions__avatar--lg {
    width: 2.65rem;
    height: 2.65rem;
    font-size: 0.86rem;
}

.site-header-actions__profile-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    text-align: start;
}

.site-header-actions__name {
    display: block;
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a2e28;
}

.site-header-actions__role {
    display: block;
    font-size: 0.67rem;
    font-weight: 600;
    color: #1b8354;
}

.site-header-actions__chevron {
    font-size: 0.6rem;
    color: #9ca3af;
    margin-inline-end: 0.1rem;
    transition: transform 0.2s, color 0.2s;
}

.site-header-actions__user.is-active .site-header-actions__chevron {
    transform: rotate(180deg);
    color: #1b8354;
}

/* Dropdown */
.site-header-actions__menu {
    position: absolute !important;
    top: calc(100% + 0.5rem) !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    min-width: 16rem !important;
    padding: 0.45rem !important;
    margin: 0 !important;
    border: 1px solid #e3ebe6 !important;
    border-radius: 14px !important;
    background: #fff !important;
    box-shadow: 0 16px 40px rgba(15, 45, 35, 0.14) !important;
    z-index: 1050;
}

.site-header-actions__menu-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.65rem 0.7rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid #eef2f0;
}

.site-header-actions__menu-head strong {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    color: #1a2e28;
    line-height: 1.3;
}

.site-header-actions__menu-head span {
    display: block;
    font-size: 0.71rem;
    color: #6b7280;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-header-actions__menu-item {
    display: flex !important;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.65rem !important;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155 !important;
    text-decoration: none !important;
    transition: background 0.15s;
}

.site-header-actions__menu-item i {
    width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(27, 131, 84, 0.08);
    color: #1b8354;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.site-header-actions__menu-item:hover {
    background: rgba(27, 131, 84, 0.08) !important;
    color: #135f3d !important;
}

.site-header-actions__menu-divider {
    height: 1px;
    background: #eef2f0;
    margin: 0.3rem 0.2rem;
}

.site-header-actions__menu-item--logout {
    color: #dc2626 !important;
}

.site-header-actions__menu-item--logout i {
    background: #fef2f2;
    color: #dc2626;
}

.site-header-actions__menu-item--logout:hover {
    background: #fef2f2 !important;
}

/* Public sticky header — keep appearance stable; stay fixed so main-wrapper offset stays correct */
.header.fixed,
.header.site-header--auth.fixed,
.header.profile-header.fixed,
.header.new-header {
    z-index: 1030;
}

.header.new-header,
.header.profile-header,
.header.site-header--auth,
.header.new-header.fixed,
.header.profile-header.fixed,
.header.site-header--auth.fixed {
    position: fixed;
    top: 0;
    inset-inline: 0;
    width: 100%;
    background: #fff !important;
    border-bottom: 1px solid #eceff1;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.header.new-header .header-nav,
.header.profile-header .header-nav,
.header.site-header--auth .header-nav {
    min-height: 0;
    padding-block: 0.35rem;
}

.header.new-header .logo img,
.header.profile-header .logo img,
.header.site-header--auth .logo img,
.header.new-header.fixed .logo img,
.header.profile-header.fixed .logo img,
.header.site-header--auth.fixed .logo img {
    filter: none !important;
}

.header.new-header .main-nav li a,
.header.profile-header .main-nav li a,
.header.site-header--auth .main-nav li a,
.header.new-header.fixed .main-nav li a,
.header.profile-header.fixed .main-nav li a,
.header.site-header--auth.fixed .main-nav li a {
    color: #515151 !important;
}

.header-nav {
    gap: 0.75rem;
}

/* Ensure page content offset matches measured header height */
.main-wrapper:has(> .header.new-header),
.main-wrapper:has(> .header.profile-header) {
    margin-top: var(--header-height, 85px);
}

/* Mobile: keep hamburger + logo as one aligned group */
@media (max-width: 991.98px) {
    .header .header-nav {
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding-block: 0.35rem;
        min-height: 0;
    }

    .header .navbar-header {
        display: inline-flex !important;
        align-items: center;
        justify-content: flex-start;
        gap: 0.55rem;
        flex: 0 1 auto;
        min-width: 0;
        max-width: calc(100% - 9.5rem);
    }

    .header #mobile_btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        margin: 0 !important;
        padding: 0;
        flex: 0 0 2.5rem;
        border-radius: 10px;
        line-height: 1;
        color: var(--primary, #1b8354);
    }

    .header #mobile_btn:hover,
    .header #mobile_btn:focus-visible {
        background: color-mix(in oklab, var(--primary, #1b8354) 10%, #fff);
    }

    .header .bar-icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
        width: 1.35rem;
        height: 1.05rem;
        gap: 0.28rem;
        float: none;
    }

    .header .bar-icon span,
    .header.fixed .bar-icon span,
    .header.new-header .bar-icon span,
    .header.profile-header .bar-icon span {
        float: none !important;
        display: block;
        width: 100% !important;
        height: 2px !important;
        margin: 0 !important;
        border-radius: 999px;
        background-color: var(--primary, #1b8354) !important;
    }

    .header .navbar-brand.logo {
        display: inline-flex !important;
        align-items: center;
        margin: 0 !important;
        padding: 0;
        min-width: 0;
        max-width: 100%;
    }

    .header .navbar-brand.logo img,
    .header .navbar-brand.logo .platform-logo--primary {
        max-height: 52px !important;
        max-width: min(160px, 42vw) !important;
    }

    .header .navbar-brand.logo-small {
        display: none !important;
    }

    .site-header-actions__profile-text,
    .site-header-actions__chevron {
        display: none !important;
    }

    .site-header-actions__profile {
        padding: 0.2rem !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* القائمة الجوال — فتح القوائم الفرعية */
    .main-nav li.has-submenu > ul.submenu {
        display: none !important;
    }

    .main-nav li.has-submenu.active > ul.submenu {
        display: block !important;
    }

    .main-nav li.has-submenu > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .main-nav li.has-submenu > a .fa-chevron-down {
        font-size: 0.72rem;
        opacity: 0.75;
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    .main-nav li.has-submenu.active > a {
        color: var(--primary, #1b8354) !important;
    }

    .main-nav li.has-submenu.active > a .fa-chevron-down {
        transform: rotate(180deg);
    }
}

@media (max-width: 767.98px) {
    .site-header-actions {
        gap: 0.35rem;
    }

    .site-header-actions__tools {
        padding: 0.12rem;
    }

    .site-header-actions__icon {
        width: 2.1rem;
        height: 2.1rem;
    }

    .site-header-actions__lang {
        min-width: 2.1rem;
        height: 2.1rem;
        font-size: 0.65rem;
    }
}

@media (max-width: 520px) {
    .site-header-actions__lang {
        display: none;
    }
}

/* Platform logos — preserve aspect ratio and override legacy fixed heights */
.navbar-brand.logo,
.menu-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
    max-width: none;
}

img.platform-logo {
    display: block;
    width: auto !important;
    height: auto !important;
    max-width: none;
    object-fit: contain;
    object-position: center;
}

img.platform-logo--primary {
    max-height: 64px;
    max-width: 220px;
}

img.platform-logo--secondary {
    max-height: 63px !important;
    max-width: 80px !important;
    height: auto !important;
    margin-inline-start: -12px;
}

html[dir="ltr"] img.platform-logo--secondary {
    margin-inline-start: 0;
}

img.platform-logo--footer {
    max-height: 100px;
    max-width: 280px;
}

img.platform-logo--vision {
    max-height: 100px;
    max-width: 200px;
}

img.platform-logo--favicon {
    max-height: 32px;
    max-width: 32px;
}

.admin-sidebar__logo-link img.platform-logo--primary {
    max-height: 56px;
    max-width: 200px;
}

@media (min-width: 992px) and (max-width: 1680px) {
    img.platform-logo--secondary {
        max-height: 55px !important;
        max-width: 70px !important;
    }
}

@media (max-width: 566.98px) {
    img.platform-logo--primary {
        max-height: 60px;
    }
}

@media (max-width: 575.98px) {
    .header .navbar-header {
        max-width: calc(100% - 8.25rem);
        gap: 0.4rem;
    }

    .header #mobile_btn {
        width: 2.35rem;
        height: 2.35rem;
        flex-basis: 2.35rem;
    }

    .header .navbar-brand.logo img,
    .header .navbar-brand.logo .platform-logo--primary {
        max-height: 46px !important;
        max-width: min(140px, 38vw) !important;
    }

    .header .header-nav {
        min-height: 0;
        padding-block: 0.3rem;
    }
}

.footer-logos img.platform-logo {
    width: auto !important;
    height: auto !important;
    max-height: 90px;
    max-width: min(100%, 280px);
    object-fit: contain;
}

.footer-logos,
.row.footer-logos {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center;
    gap: 0.75rem 1rem;
}

.row.footer-logos > [class*="col"],
.footer-logos__item {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
}
