/* Shared top-header controls and dropdowns for app/public shells. */
#page-header .crm-header-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

#page-header .crm-header-action {
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .3rem .55rem;
    color: #dbeafe !important;
    background: rgba(15, 28, 48, .9) !important;
    border: 1px solid rgba(148, 163, 184, .22) !important;
    border-radius: 11px !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .12);
    transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

#page-header .crm-header-action:hover,
#page-header .crm-header-action:focus,
#page-header .dropdown.show > .crm-header-action {
    color: #fff !important;
    background: #172a46 !important;
    border-color: rgba(var(--crm-primary-rgb, 79, 70, 229), .55) !important;
    transform: translateY(-1px);
    outline: none;
}

#page-header .crm-header-action:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--crm-primary-rgb, 79, 70, 229), .24);
}

#page-header .crm-header-menu {
    direction: rtl;
    text-align: right;
    min-width: 248px;
    width: max-content;
    max-width: min(360px, calc(100vw - 16px));
    padding: 0 !important;
    overflow: hidden;
    color: #e2e8f0 !important;
    background: #0f1c30 !important;
    border: 1px solid rgba(148, 163, 184, .2) !important;
    border-radius: 16px !important;
    box-shadow: 0 18px 52px rgba(2, 6, 23, .42) !important;
    z-index: 1085;
}

/* Bootstrap's physical right:0 for dropdown-menu-end is not RTL-aware. */
html[dir="rtl"] #page-header .dropdown-menu-end[data-bs-popper],
html[dir="rtl"] #page-header .dropdown-menu-end.show {
    top: calc(100% + .45rem) !important;
    right: auto !important;
    left: 0 !important;
    margin: 0 !important;
    transform: none !important;
}

#page-header .crm-header-menu-head,
#page-header .crm-header-menu > .dropdown-header,
#page-header .crm-header-menu > .drop-head,
#page-header .crm-header-menu > .bg-body-light {
    margin: 0;
    padding: .78rem .9rem !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--crm-primary-dark, #3730a3), var(--crm-primary, #4f46e5)) !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, .1) !important;
}

#page-header .crm-header-menu .dropdown-item,
#page-header .crm-header-menu .drop-item,
#page-header .crm-header-menu .gsm-dd-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    width: auto;
    margin: .2rem .4rem;
    padding: .55rem .68rem;
    color: #b8c5d8 !important;
    background: transparent !important;
    border: 0;
    border-radius: 10px;
    font-size: .78rem;
    text-align: right;
    white-space: normal;
    transition: background-color .14s ease, color .14s ease;
}

#page-header .crm-header-menu .dropdown-item:hover,
#page-header .crm-header-menu .dropdown-item:focus,
#page-header .crm-header-menu .drop-item:hover,
#page-header .crm-header-menu .gsm-dd-item:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, .075) !important;
    outline: none;
}

#page-header .crm-header-menu .dropdown-divider,
#page-header .crm-header-menu .gsm-dd-divider {
    margin: .3rem .5rem;
    border-color: rgba(148, 163, 184, .14);
    background: rgba(148, 163, 184, .14);
}

#page-header .crm-header-menu .text-muted,
#page-header .crm-header-menu .gsm-chat-empty,
#page-header .crm-header-menu .dropdown-item.text-muted {
    color: #8190a6 !important;
}

#page-header .crm-header-menu .drop-footer {
    padding: .45rem;
    border-top: 1px solid rgba(148, 163, 184, .12);
    text-align: center;
}

#page-header .crm-header-menu .drop-footer a {
    color: #93c5fd !important;
    font-size: .76rem;
    text-decoration: none;
}

#page-header .crm-header-menu .badge {
    box-shadow: none;
}

@media (max-width: 575.98px) {
    #page-header .crm-header-actions {
        gap: .3rem;
    }

    #page-header .crm-header-action {
        min-width: 34px;
        min-height: 34px;
        padding: .25rem .45rem;
    }

    html[dir="rtl"] #page-header .crm-header-menu.dropdown-menu-end.show {
        position: fixed !important;
        top: 54px !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: calc(100dvh - 66px);
        overflow-y: auto;
        transform: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #page-header .crm-header-action {
        transition: none;
    }
}
