/* ============================================================
   header.css — Blue Medical Theme
   Palette:
     Navy dark   : #061b45  (topbar)
     Navy main   : #0a2d6e  (header bg)
     Blue primary: #0d5db5
     Cyan accent : #29b6f6
     Red CTA     : #e53935
     Nav dark    : #082357
   ============================================================ */

/* ── Top bar ─────────────────────────────────────────────── */
.header-topbar {
    background: #061b45;
    padding: 6px 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-topbar a {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.header-topbar a:hover { color: #29b6f6; }

/* ── Main header ─────────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, #0a2d6e 0%, #0d5db5 100%);
    color: #fff;
    border-bottom: none;
    position: relative;
    z-index: 80;
    overflow: visible;
    transition: background 0.24s ease, box-shadow 0.24s ease, padding 0.24s ease;
}

/* Subtle glow behind search */
.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 600px 200px at 70% 50%, rgba(41, 182, 246, 0.12), transparent);
    pointer-events: none;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 88px;
    gap: 20px;
    position: relative;
    z-index: 1;
    transition: min-height 0.24s ease;
}

/* ── Logo ────────────────────────────────────────────────── */
.header-left .logo {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
    transition: gap 0.24s ease;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #f44336, #c62828);
    border-radius: 14px;
    font-size: 24px;
    color: #fff;
    flex: 0 0 52px;
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.4);
    position: relative;
    transition: width 0.24s ease, height 0.24s ease, font-size 0.24s ease, flex-basis 0.24s ease;
}

.logo-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    pointer-events: none;
}

.logo-text {
    line-height: 1.1;
    font-size: 20px;
    font-weight: 800;
    transition: font-size 0.24s ease;
}

.logo-text strong { display: block; color: #fff; }

.logo-text span {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── Search bar ──────────────────────────────────────────── */
.header-center {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.header-search {
    width: min(100%, 580px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s ease;
}

.site-header.is-search-visible .header-search,
.header-search.is-always-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.header-search__form { width: 100%; }

.header-search__inner {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(10, 45, 110, 0.22);
    padding: 5px 5px 5px 14px;
    gap: 0;
    min-height: 58px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.header-search__select-wrap {
    position: relative;
    flex: 0 0 auto;
    max-width: 140px;
}

.header-search__select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    padding: 8px 24px 8px 0;
    white-space: nowrap;
    font-family: inherit;
}

.header-search__select-arrow {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #9ca3af;
}

.header-search__divider {
    width: 1px;
    height: 22px;
    background: #e5e7eb;
    margin: 0 12px;
    flex: 0 0 1px;
}

.header-search__input-wrap {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #9ca3af;
}

.header-search__input-wrap.is-open .header-search__suggestions { display: block; }

.header-search__icon { flex: 0 0 auto; }

.header-search__input {
    width: 100%;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #111827;
    font-size: 14px;
    padding: 8px 0;
    font-family: inherit;
}

.header-search__input::placeholder { color: #9ca3af; }

.header-search__clear {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}

.header-search__clear:hover { color: #374151; background: #f3f4f6; }

.header-search__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #e53935;
    color: #fff;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
    font-family: inherit;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    transition: background 0.18s ease, transform 0.18s ease;
}

.header-search__button:hover {
    background: #c62828;
    transform: translateY(-1px);
}

/* Suggestions dropdown */
.header-search__suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: -44px;
    right: -44px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(10, 45, 110, 0.16);
    list-style: none;
    margin: 0;
    padding: 6px;
    z-index: 999;
    display: none;
    max-height: 360px;
    overflow: auto;
    border: 1px solid #c5d8f0;
}

.header-search__suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.12s ease;
    color: #374151;
}

.header-search__suggestion-item:hover { background: #e8f4fd; }

.header-search__suggestion-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #e8f4fd;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
}

.header-search__suggestion-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-search__suggestion-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
}

.header-search__suggestion-type {
    font-size: 12px;
    color: #0d5db5;
    background: #e8f4fd;
    padding: 2px 8px;
    border-radius: 20px;
    flex: 0 0 auto;
    font-weight: 600;
}

.header-search__suggestion-address {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Right actions ───────────────────────────────────────── */
.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: gap 0.24s ease;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.header-link:hover,
.header-link:focus {
    background: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}

/* Cộng đồng: cyan */
.header-link--community { color: #7dd3fc !important; }

/* Thêm cơ sở: solid red */
.header-link--request {
    background: #e53935;
    color: #fff !important;
    border: 1px solid #e53935;
    box-shadow: 0 4px 14px rgba(229, 57, 53, 0.35);
}

.header-link--request:hover {
    background: #c62828 !important;
    color: #fff !important;
    border-color: #c62828;
    box-shadow: 0 6px 18px rgba(229, 57, 53, 0.45);
    transform: translateY(-1px);
}

.header-link__text--mobile { display: none; }
.header-link__icon { line-height: 1; flex: 0 0 auto; }

/* Login button */
.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #29b6f6;
    color: #fff;
    padding: 11px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 18px rgba(41, 182, 246, 0.4);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.btn-login:hover {
    background: #0288d1;
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(41, 182, 246, 0.5);
    color: #fff;
}

/* ── User menu ───────────────────────────────────────────── */
.header-user-menu { position: relative; }

/* Fix: override global button style cho toggle */
.header-user-menu__toggle {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    min-height: auto !important;
    border-radius: 0 !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-family: inherit;
    transition: opacity 0.2s;
}

.header-user-menu__toggle:hover {
    background: transparent !important;
    color: #fff !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.85;
}

.header-user-menu__toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.header-user-menu__avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #29b6f6 0%, #0288d1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    flex: 0 0 52px;
    box-shadow: 0 2px 12px rgba(41, 182, 246, 0.35);
    transition: width 0.24s ease, height 0.24s ease, flex-basis 0.24s ease;
}

.header-user-menu__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.header-user-menu__name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    transition: font-size 0.24s ease;
}

.header-user-menu__dropdown {
    position: absolute;
    top: calc(100% + 16px);
    right: 0;
    width: 260px;
    background: #0a2d6e;
    border: 1px solid rgba(41, 182, 246, 0.2);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(10, 45, 110, 0.4);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s ease;
    z-index: 9999;
    pointer-events: none;
}

.header-user-menu.is-open { z-index: 10000; }

.header-user-menu__dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 28px;
    width: 12px;
    height: 12px;
    background: #0a2d6e;
    border-top: 1px solid rgba(41, 182, 246, 0.2);
    border-left: 1px solid rgba(41, 182, 246, 0.2);
    transform: rotate(45deg);
}

.header-user-menu.is-open .header-user-menu__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.header-user-menu__item {
    display: block;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
}

.header-user-menu__item:hover {
    background: rgba(41, 182, 246, 0.15);
    color: #29b6f6;
}

/* ── Sticky state ────────────────────────────────────────── */
.site-header.is-sticky {
    position: sticky;
    top: 0;
    box-shadow: 0 8px 32px rgba(10, 45, 110, 0.3);
    background: rgba(10, 45, 110, 0.97);
    backdrop-filter: blur(14px);
}

.site-header.is-sticky .header-inner { min-height: 64px; gap: 16px; }

.site-header.is-sticky .header-left .logo { gap: 10px; }

.site-header.is-sticky .logo-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 18px;
    border-radius: 10px;
}

.site-header.is-sticky .logo-text { font-size: 17px; }

.site-header.is-sticky .logo-text span { display: none; }

.site-header.is-sticky .header-link { font-size: 13px; }

.site-header.is-sticky .btn-login { padding: 9px 18px; font-size: 13px; }

.site-header.is-sticky .header-user-menu__avatar {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 20px;
}

.site-header.is-sticky .header-user-menu__name { font-size: 14px; }

.site-header.is-sticky .header-search__inner { min-height: 46px; }

.site-header.is-sticky .header-search__button {
    width: 38px;
    height: 38px;
    border-radius: 8px;
}

/* ── Responsive: tablet ──────────────────────────────────── */
@media (max-width: 1199px) {
    .header-right { gap: 4px; }
    .header-link { font-size: 13px; padding: 8px 10px; }
    .header-search { width: min(100%, 460px); }
    .header-search__suggestions { left: -16px; right: -16px; }
}

@media (max-width: 991px) {
    .header-inner {
        flex-wrap: wrap;
        align-items: center;
        padding-top: 10px;
        padding-bottom: 10px;
        gap: 0;
        min-height: auto;
    }

    .header-left { flex: 1 1 auto; min-width: 0; }

    .header-right { flex-shrink: 0; gap: 8px; width: auto; }

    .header-link { font-size: 12px; white-space: nowrap; }

    .header-user-menu__name { display: none; }

    .header-center {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        padding: 8px 0 10px;
    }

    .site-header.is-search-visible .header-search,
    .header-search {
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        width: 100%;
    }

    .site-header.is-sticky .header-inner { min-height: auto; }
    .header-search__inner { min-height: 46px; }
    .header-search__suggestions { left: 0; right: 0; }
}

/* ── Responsive: mobile ──────────────────────────────────── */
@media (max-width: 767px) {
    .header-inner { min-height: auto; }

    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
        border-radius: 10px;
        flex: 0 0 40px;
    }

    .logo-text { font-size: 15px; }
    .logo-text span { display: none; }

    .header-link__text--desktop { display: none !important; }
    .header-link__text--mobile { display: inline !important; }

    .header-link--community { max-width: 120px; }
    .header-link--request { max-width: 110px; }

    .header-user-menu__avatar {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
        font-size: 20px;
    }

    .header-user-menu__dropdown { width: 220px; }

    .header-user-menu__item { font-size: 14px; padding: 12px 16px; }

    .header-search__inner {
        border-radius: 999px;
        padding: 4px 4px 4px 12px;
        min-height: 44px;
    }

    .header-search__select { font-size: 12px; padding: 0 20px 0 0; max-width: 90px; }

    .header-search__button {
        width: 36px;
        height: 36px;
        min-height: 36px;
        border-radius: 50%;
    }

    .header-topbar { display: none; }
}

/* Ensure desktop text visibility */
@media (min-width: 768px) {
    .header-link__text--desktop { display: inline !important; }
    .header-link__text--mobile { display: none !important; }
}