/* Shared header component styles */

body.has-fixed-header {
    padding-top: var(--site-header-offset, 88px);
}

/* Header */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 0.75rem;
    /* iOS safe-area: push content below Dynamic Island / notch */
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    padding-left:  calc(0.75rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(143, 113, 228, 0.16);
    border-radius: 0 0 24px 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 40px rgba(126, 92, 197, 0.1);
}

#header.scrolled {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(143, 113, 228, 0.22);
}

#header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-right {
    display: flex;
    gap: 1rem;
}

.burger {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.burger span {
    width: 24px;
    height: 2px;
    background: #2b2145;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.burger:hover span {
    background: #7C4CFF;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #F7F7FB;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo svg {
    width: 32px;
    height: 32px;
    fill: #7C4CFF;
}

/* Profile Button */
.profile-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    min-height: 44px; /* touch target */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #F7F7FB;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 200px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.profile-button:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #7C4CFF;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #7C4CFF;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
    text-align: left;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #F7F7FB;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-balance {
    font-size: 0.8rem;
    color: #9AE6B4;
    font-weight: 500;
}

.profile-arrow {
    font-size: 0.8rem;
    color: #71658f;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-dropdown.active .profile-arrow {
    transform: rotate(180deg);
}

/* Profile Menu */
.profile-menu {
    position: fixed;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(143, 113, 228, 0.16);
    border-radius: 12px;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999;
    backdrop-filter: blur(10px);
    box-shadow: 0 16px 36px rgba(126, 92, 197, 0.08);
}

.profile-dropdown.active .profile-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #F7F7FB;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(143, 113, 228, 0.1);
}

.profile-menu-item:first-child {
    border-radius: 12px 12px 0 0;
}

.profile-menu-item:last-child {
    border-bottom: none;
    border-radius: 0 0 12px 12px;
}

.profile-menu-item:hover {
    background: rgba(124, 76, 255, 0.1);
    color: #7C4CFF;
}

@media (max-width: 768px) {
    #header {
        padding: 0.5rem;
        border-radius: 0 0 22px 22px;
    }

    #header .container {
        padding: 0 0.65rem;
    }

    #header nav {
        min-height: 62px;
    }

    .nav-left {
        gap: 0.65rem;
    }

    .burger {
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .burger span {
        width: 21px;
        height: 2px;
    }

    .logo {
        font-size: 2rem;
        gap: 0.55rem;
    }

    .logo svg {
        width: 30px;
        height: 30px;
    }

    .nav-right {
        gap: 0.5rem;
    }

    .nav-right .btn {
        display: inline-flex;
    }

    .nav-right #sign-in-btn {
        display: none;
    }

    .nav-right #join-btn {
        min-width: 90px;
        padding: 0.5rem 0.8rem;
    }

    .profile-button {
        min-width: auto;
        padding: 0.35rem 0.55rem;
        border-radius: 18px;
        gap: 0.45rem;
    }

    .profile-avatar {
        width: 34px;
        height: 34px;
    }

    .profile-info {
        display: none;
    }

    .profile-arrow {
        display: inline-block;
        font-size: 0.72rem;
    }
}

/* ── Header Search (always visible) ─────────────────────────────────────── */
.header-search {
    position: relative;
    flex: 1;
    max-width: 400px;
    margin: 0 1rem;
}

@media (max-width: 900px) {
    #header {
        padding: 0.55rem;
        border-radius: 0 0 20px 20px;
    }

    #header nav {
        gap: 0.5rem;
    }

    .header-search {
        display: none;
    }

    .nav-left {
        min-width: 0;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.35rem;
    }

    .logo svg {
        width: 28px;
        height: 28px;
    }

    .nav-right {
        gap: 0.45rem;
        margin-left: auto;
        flex-shrink: 0;
    }

    .nav-right .btn {
        display: inline-flex;
        min-height: 40px;
        padding: 0.55rem 0.9rem;
        border-radius: 12px;
        font-size: 1rem;
    }
}

.header-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(143, 113, 228, 0.16);
    border-radius: 12px;
    padding: 0 0.75rem;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.header-search-box:focus-within {
    border-color: rgba(124, 76, 255, 0.6);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.header-search-icon {
    width: 16px;
    height: 16px;
    color: rgba(113, 101, 143, 0.6);
    flex-shrink: 0;
}

.header-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #2b2145;
    font-size: 0.875rem;
    padding: 0.55rem 0;
    min-width: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.header-search-input::placeholder { color: rgba(113, 101, 143, 0.6); }
.header-search-input::-webkit-search-cancel-button { display: none; }

.header-search-clear {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(139, 92, 246, 0.08);
    color: rgba(113, 101, 143, 0.8);
    font-size: 0.7rem;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: background 0.15s;
}
.header-search-clear:hover { background: rgba(255, 59, 48, 0.7); color: #fff; }

/* Dropdown results — fixed so it escapes header stacking context */
.header-search-dropdown {
    position: fixed;
    top: 70px;   /* updated by JS to exact header bottom */
    left: 0;
    width: 320px;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(143, 113, 228, 0.18);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 22px 46px rgba(111, 92, 170, 0.15);
    backdrop-filter: blur(16px);
    z-index: 99999;
    display: none;
}
.header-search-dropdown.active { display: block; }

.hsd-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    text-decoration: none;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(143, 113, 228, 0.08);
}
.hsd-item:last-child { border-bottom: none; }
.hsd-item:hover { background: rgba(139, 92, 246, 0.08); }

.hsd-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.hsd-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.hsd-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.96);
}
.hsd-dot.online  { background: #34C759; }
.hsd-dot.busy    { background: #FF9500; }
.hsd-dot.offline { background: #8E8E93; }

.hsd-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.hsd-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #2b2145;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hsd-title {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hsd-price {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(124, 76, 255, 0.9);
    white-space: nowrap;
    flex-shrink: 0;
}
.hsd-empty {
    padding: 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.85rem;
}
.hsd-loading {
    display: flex;
    justify-content: center;
    padding: 1rem;
}
.hsd-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(124, 76, 255, 0.25);
    border-top-color: #7C4CFF;
    border-radius: 50%;
    animation: hsd-spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes hsd-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
    .header-search {
        flex: 1;
        min-width: 80px;
        max-width: none;
        margin: 0 0.3rem;
    }

    .header-search-input {
        font-size: 0.8rem;
    }

    /* On mobile dropdown is positioned by JS, just set a reasonable width */
    .header-search-dropdown {
        width: calc(100vw - 2rem) !important;
    }

    .logo {
        font-size: 1.05rem !important;
    }

    .logo svg {
        width: 22px !important;
        height: 22px !important;
    }

    .nav-right #join-btn {
        min-width: 84px;
        font-size: 0.95rem;
        padding: 0.45rem 0.7rem;
    }
}

/* Reduce logo on small tablets so search/auth get room */
@media (max-width: 768px) and (min-width: 641px) {
    .logo {
        font-size: 1.2rem !important;
        gap: 0.4rem;
    }
    .logo svg {
        width: 24px !important;
        height: 24px !important;
    }
}

/* On very small screens hide logo text entirely — SVG stays visible */
@media (max-width: 400px) {
    .logo {
        font-size: 0 !important;   /* hides text node, SVG unaffected */
        gap: 0 !important;
    }
    .logo svg {
        width: 28px !important;
        height: 28px !important;
    }
}

body #header .profile-button {
    background: rgba(255, 255, 255, 0.86);
    border-color: rgba(143, 113, 228, 0.16);
    color: #2b2145;
}

body #header .logo,
body #header .logo:visited {
    color: #2b2145;
}

body #header .profile-name {
    color: #2b2145;
}

body .profile-menu {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(143, 113, 228, 0.16);
    box-shadow: 0 16px 36px rgba(126, 92, 197, 0.08);
}

body .profile-menu-item,
body .profile-menu-item:visited {
    color: #2b2145;
}

body .profile-menu-item:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #7c4cff;
}

body #header .nav-right .btn {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(143, 113, 228, 0.16);
    color: #2b2145;
    box-shadow: 0 10px 24px rgba(126, 92, 197, 0.08);
}

body #header .nav-right .btn:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

body #header .nav-right .btn.btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 14px 28px rgba(139, 92, 246, 0.24);
}

body #header .nav-right .btn.btn-primary:hover {
    background: linear-gradient(135deg, #7c4dff 0%, #9747ff 100%);
    color: #fff;
}

body #header .hsd-title,
body #header .hsd-empty {
    color: #71658f;
}

body #header .hsd-price {
    color: #8b5cf6;
}
