/**
 * Incremental header migration: search, user avatar, notifications.
 * Scoped to the legacy header; no full nav-v2 replacement.
 */

body.logged {
    margin-top: 0;
}

/* Desktop quick strip is replaced by the header controls. Keep the original
   bottom navigation on phones, where footpanel has a different layout. */
body.logged #footpanel {
    display: none;
}

@media (max-width: 767px) {
    body.logged #footpanel {
        display: block !important;
    }
}

#header {
    overflow: visible;
}

/* ===== Toolbar search ===== */
#toolbar .mfc-hdr-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 8px;
    z-index: 40;
}

#toolbar .mfc-hdr-search form {
    display: flex;
    align-items: center;
    height: 26px;
    background: #fff;
    border: 1px solid rgba(30, 60, 100, 0.16);
    border-radius: 999px;
    overflow: hidden;
    transition: border-color 0.18s, box-shadow 0.18s;
}

#toolbar .mfc-hdr-search form:focus-within {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
}

#toolbar .mfc-hdr-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

#toolbar .mfc-hdr-search input[type="search"] {
    width: 176px;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 0 4px 0 11px;
    font-size: 11px;
    color: #1c2a3a;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

#toolbar .mfc-hdr-search input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

#toolbar .mfc-hdr-search-submit {
    width: 28px;
    height: 100%;
    border: 0;
    background: transparent;
    color: #47627f;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

#toolbar .mfc-hdr-search-submit:hover {
    color: #1a6fc4;
    background: rgba(74, 144, 226, 0.08);
}

#toolbar .mfc-hdr-search-submit svg {
    width: 15px;
    height: 15px;
}

.mfc-hdr-search-results {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    max-height: min(420px, 62vh);
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(20, 45, 75, 0.12);
    border-radius: 10px;
    box-shadow: 0 14px 38px rgba(20, 45, 75, 0.18);
    padding: 5px;
    box-sizing: border-box;
}

.mfc-hdr-search-results[hidden] {
    display: none !important;
}

.mfc-hdr-search-results .search_display_box {
    padding: 7px 8px;
    border-radius: 7px;
    line-height: 1.35;
}

.mfc-hdr-search-results .search_display_box:hover {
    background: #f2f7ff;
}

.mfc-hdr-search-results .search_display_box a {
    color: #1d2f43;
    text-decoration: none;
    display: block;
    min-height: 32px;
}

.mfc-hdr-search-results .search_display_box img {
    border-radius: 50%;
    object-fit: cover;
}

.mfc-hdr-search-empty,
.mfc-hdr-search-loading {
    padding: 12px 10px;
    font-size: 11px;
    color: #6b7c8f;
    text-align: center;
}

.mfc-hdr-search-more {
    display: block;
    text-align: center;
    padding: 8px 6px 4px;
    margin-top: 3px;
    border-top: 1px solid rgba(20, 45, 75, 0.08);
    color: #1a6fc4;
    font-size: 11px;
    text-decoration: none;
}

/* ===== Avatar / friends / notifications ===== */
.header-main-row {
    gap: 24px;
    flex-wrap: nowrap;
}

#menu {
    flex: 1 1 0;
    min-width: 0;
}

.mfc-hdr-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex: 0 0 auto;
    z-index: 30;
}

.mfc-hdr-icon,
.mfc-hdr-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(30, 75, 125, 0.13);
    background: #fff;
    color: #36516c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
    text-decoration: none;
    flex: 0 0 auto;
    transition: background 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.mfc-hdr-icon:hover,
.mfc-hdr-avatar:hover,
.mfc-hdr-icon:focus-visible,
.mfc-hdr-avatar:focus-visible {
    background: #eef5ff;
    border-color: rgba(30, 110, 190, 0.32);
    box-shadow: 0 3px 10px rgba(30, 90, 160, 0.12);
    outline: none;
}

.mfc-hdr-icon svg {
    width: 18px;
    height: 18px;
}

.mfc-hdr-avatar {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 2px solid #dbe9f8;
    background: #fff;
}

.mfc-hdr-avatar > img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.mfc-hdr-caret {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #dbe9f8;
    color: #43627f;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mfc-hdr-caret svg {
    width: 10px;
    height: 10px;
}

.mfc-hdr-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e5484d;
    color: #fff;
    border: 2px solid #eef5fc;
    font-size: 9px;
    line-height: 13px;
    font-weight: 700;
    text-align: center;
    box-sizing: border-box;
    pointer-events: none;
}

/* ===== Dropdown panels ===== */
.mfc-hdr-pop {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: 312px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border: 1px solid rgba(20, 45, 75, 0.12);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(20, 45, 75, 0.2);
    overflow: hidden;
    z-index: 95;
    box-sizing: border-box;
}

.mfc-hdr-pop[hidden] {
    display: none !important;
}

.mfc-hdr-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(20, 45, 75, 0.08);
    background: #fbfdff;
}

.mfc-hdr-pop-head > div {
    min-width: 0;
}

.mfc-hdr-pop-head b {
    display: block;
    font-size: 13px;
    color: #1d2f43;
}

.mfc-hdr-pop-head small {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    color: #718499;
}

.mfc-hdr-pop-head a {
    color: #1a6fc4;
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
}

.mfc-hdr-notif-list {
    max-height: min(430px, 58vh);
    overflow-y: auto;
    padding: 5px 0;
}

.mfc-hdr-notif-group {
    padding: 8px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #73859a;
}

.mfc-hdr-notif-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    text-decoration: none;
    color: #1d2f43;
}

.mfc-hdr-notif-item:hover {
    background: #f2f7ff;
}

.mfc-hdr-notif-item > img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.mfc-hdr-notif-item > span {
    min-width: 0;
}

.mfc-hdr-notif-item b,
.mfc-hdr-notif-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mfc-hdr-notif-item b {
    font-size: 12px;
    line-height: 1.3;
}

.mfc-hdr-notif-item small {
    margin-top: 1px;
    font-size: 10px;
    color: #718499;
}

.mfc-hdr-notif-empty {
    padding: 8px 14px 10px;
    font-size: 11px;
    color: #8494a6;
}

.mfc-hdr-pop-foot {
    display: block;
    padding: 10px 14px;
    border-top: 1px solid rgba(20, 45, 75, 0.08);
    background: #fbfdff;
    color: #1a6fc4;
    font-size: 11px;
    text-decoration: none;
    text-align: center;
}

.mfc-hdr-pop-foot:hover {
    background: #f2f7ff;
}

.mfc-hdr-profile {
    width: 286px;
}

.mfc-hdr-profile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid rgba(20, 45, 75, 0.08);
    background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
}

.mfc-hdr-profile-head > img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dbe9f8;
}

.mfc-hdr-profile-head > div {
    min-width: 0;
}

.mfc-hdr-profile-head b,
.mfc-hdr-profile-head small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mfc-hdr-profile-head b {
    font-size: 13px;
    color: #1d2f43;
}

.mfc-hdr-profile-head small {
    margin-top: 2px;
    font-size: 10px;
    color: #718499;
}

.mfc-hdr-profile-links {
    max-height: min(430px, 54vh);
    overflow-y: auto;
    padding: 5px 0;
}

.mfc-hdr-profile-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 14px;
    color: #25384c;
    text-decoration: none;
    font-size: 12px;
    line-height: 1.3;
}

.mfc-hdr-profile-link:hover,
.mfc-hdr-profile-link:focus-visible {
    background: #f2f7ff;
    color: #145ca8;
    outline: none;
}

.mfc-hdr-profile-link svg {
    width: 16px;
    height: 16px;
    color: #5d7893;
    flex: 0 0 auto;
}

.mfc-hdr-profile-link > span {
    flex: 1 1 auto;
    min-width: 0;
}

.mfc-hdr-link-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #eaf2fc;
    color: #1a6fc4;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}

.mfc-hdr-logout {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-top: 1px solid rgba(20, 45, 75, 0.08);
    background: #fff;
    color: #b4232a;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.mfc-hdr-logout:hover {
    background: #fff5f5;
}

.mfc-hdr-logout svg {
    width: 16px;
    height: 16px;
}

body.mfc-hdr-pop-open #mfc-notify-container {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 1279px) {
    #top_message {
        display: none;
    }
}

@media (max-width: 767px) {
    #header {
        overflow: visible;
    }

    .header-main-row {
        gap: 6px;
        flex-wrap: wrap;
    }

    #logo {
        order: 0;
    }

    .mfc-hdr-user {
        order: 2;
        gap: 2px;
        margin-left: auto;
    }

    .header-mobile-toggle {
        order: 3;
        margin-left: 2px;
    }

    #menu {
        order: 4;
        box-sizing: border-box;
    }

    .mfc-hdr-icon {
        width: 32px;
        height: 32px;
    }

    .mfc-hdr-icon svg {
        width: 16px;
        height: 16px;
    }

    .mfc-hdr-avatar {
        width: 36px;
        height: 36px;
    }

    .mfc-hdr-caret {
        display: none;
    }

    .mfc-hdr-badge {
        top: -2px;
        right: -2px;
        min-width: 16px;
        height: 16px;
        line-height: 12px;
        font-size: 8px;
    }

    .mfc-hdr-pop {
        right: -2px;
        width: 300px;
    }

    .mfc-hdr-profile {
        width: 284px;
    }

    #toolbar .mfc-hdr-search {
        margin-right: 4px;
    }

    #toolbar .mfc-hdr-search input[type="search"] {
        width: 142px;
    }

    #toolbar .mfc-hdr-search-results {
        right: 0;
        width: min(320px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 480px) {
    #toolbar .right {
        display: flex;
        width: 100%;
        justify-content: flex-end;
        gap: 4px;
    }

    #toolbar .mfc-hdr-search input[type="search"] {
        width: 124px;
    }

    #toolbar .mfc-hdr-search form {
        height: 25px;
    }

    .mfc-hdr-user {
        gap: 1px;
    }

    .mfc-hdr-icon {
        width: 30px;
        height: 30px;
    }

    .mfc-hdr-avatar {
        width: 34px;
        height: 34px;
    }
}

/* ===== Notification feed ===== */
#mfc-hdr-notif {
    width: 348px;
}

.mfc-hdr-notif-readall {
    border: 0;
    background: transparent;
    color: #1a6fc4;
    font-size: 10px;
    line-height: 1.2;
    cursor: pointer;
    padding: 3px 0;
    white-space: nowrap;
}

.mfc-hdr-notif-readall:disabled {
    opacity: 0.5;
    cursor: default;
}

.mfc-hdr-notif-filters {
    display: flex;
    gap: 4px;
    padding: 7px 9px;
    flex-wrap: wrap;
    overflow: visible;
    border-bottom: 1px solid rgba(20, 45, 75, 0.08);
    background: #fbfdff;
}

.mfc-hdr-notif-filters::-webkit-scrollbar {
    display: none;
}

.mfc-hdr-notif-filters button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    border: 1px solid rgba(20, 45, 75, 0.12);
    border-radius: 999px;
    background: #fff;
    color: #526a82;
    font-size: 9px;
    line-height: 1.2;
    padding: 4px 7px;
    cursor: pointer;
}

.mfc-hdr-notif-filters button span {
    color: #8b9aac;
    font-size: 8px;
}

.mfc-hdr-notif-filters button.is-active {
    border-color: #b9d4ee;
    background: #eaf4ff;
    color: #145ca8;
}

.mfc-hdr-notif-filters button.is-active span {
    color: #1a6fc4;
}

.mfc-hdr-notif-list {
    max-height: min(440px, 58vh);
    overflow-y: auto;
    padding: 4px 0;
}

.mfc-hdr-notif-item {
    position: relative;
    align-items: flex-start;
    padding: 9px 32px 9px 14px;
    cursor: pointer;
    outline: none;
}

.mfc-hdr-notif-item[hidden] {
    display: none !important;
}

.mfc-hdr-notif-item:focus-visible {
    background: #eef6ff;
    box-shadow: inset 0 0 0 2px #b9d4ee;
}

.mfc-hdr-notif-ava {
    position: relative;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
}

.mfc-hdr-notif-ava > img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.mfc-hdr-notif-kind {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #dbe9f8;
    color: #3d6f9e;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(20, 45, 75, 0.12);
}

.mfc-hdr-notif-kind svg {
    width: 10px;
    height: 10px;
}

.mfc-kind-gift {
    color: #c76b18;
}

.mfc-kind-rating {
    color: #b8860b;
}

.mfc-kind-comment {
    color: #2b7a78;
}

.mfc-kind-message {
    color: #1a6fc4;
}

.mfc-hdr-notif-body {
    min-width: 0;
    flex: 1 1 auto;
}

.mfc-hdr-notif-body b,
.mfc-hdr-notif-body small,
.mfc-hdr-notif-body em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mfc-hdr-notif-body b {
    font-size: 12px;
    line-height: 1.35;
    color: #1d2f43;
}

.mfc-hdr-notif-body small {
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.35;
    color: #687b8f;
}

.mfc-hdr-notif-body em {
    margin-top: 3px;
    font-size: 9px;
    font-style: normal;
    line-height: 1.2;
    color: #95a3b3;
}

.mfc-hdr-notif-dot {
    position: absolute;
    left: 4px;
    top: 19px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #1a6fc4;
    opacity: 0;
}

.mfc-hdr-notif-item.is-unread .mfc-hdr-notif-dot {
    opacity: 1;
}

.mfc-hdr-notif-item.is-read {
    opacity: 0.76;
}

.mfc-hdr-notif-dismiss {
    position: absolute;
    top: 6px;
    right: 5px;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #9aa8b7;
    font-size: 16px;
    line-height: 18px;
    padding: 0;
    cursor: pointer;
    opacity: 0;
}

.mfc-hdr-notif-item:hover .mfc-hdr-notif-dismiss,
.mfc-hdr-notif-dismiss:focus-visible {
    opacity: 1;
}

.mfc-hdr-notif-dismiss:hover {
    background: #f0f4f8;
    color: #b4232a;
}

.mfc-hdr-notif .mfc-hdr-pop-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
}

.mfc-hdr-notif .mfc-hdr-pop-foot a {
    color: #1a6fc4;
    font-size: 10px;
    text-decoration: none;
}

.mfc-hdr-notif .mfc-hdr-pop-foot a:hover {
    text-decoration: underline;
}

.mfc-hdr-notif-filter-empty {
    padding: 12px 14px !important;
    text-align: center;
}

@media (max-width: 767px) {
    #mfc-hdr-notif {
        width: min(348px, calc(100vw - 16px));
    }

    .mfc-hdr-notif-dismiss {
        opacity: 1;
    }
}

@media (max-width: 767px) {
    /* The notification panel is anchored to the avatar, which sits near the
       right edge on phones. Use the viewport as the anchor so the panel is
       never clipped on the left and keeps a consistent 8px gutter. */
    #mfc-hdr-notif {
        position: fixed;
        left: 8px;
        right: 8px;
        top: 132px;
        bottom: calc(59px + 8px);
        width: auto;
        max-width: none;
        max-height: none;
        display: flex;
        flex-direction: column;
    }

    #mfc-hdr-notif[hidden] {
        display: none !important;
    }

    #mfc-hdr-notif .mfc-hdr-notif-list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }
}

/* The mini messenger launcher is fixed above the page; while a header
   dropdown is open it must not cover the notification/profile panel. */
body.mfc-hdr-pop-open .mfc-mini {
    display: none !important;
}

/* Keep the mobile sidebar tab from peeking out under an open header panel. */
body.mfc-hdr-pop-open #sidebar-mobile-toggle {
	display: none !important;
}
