/**
 * Intent-aware header search (Sell / Buy) — desktop bar + mobile bar.
 * Dropdown is deliberately lightweight/navigational, not a product listing:
 * no prices, small thumbnails, tight rows.
 */

/* ============================================================
   Desktop search bar (sits in the main nav row)
   ============================================================ */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 340px;
    flex: 1 1 260px;
}

.header-search-field {
    display: flex;
    align-items: stretch;
    width: 100%;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.header-search-field:focus-within {
    border-color: #0474B4;
    box-shadow: 0 0 0 3px rgba(4, 116, 180, 0.14);
}

.header-search-intent {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: #f4f6f8;
    border-right: 1px solid #e5e8eb;
    flex-shrink: 0;
}

.header-search-intent button {
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #667085;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}

.header-search-intent button:hover {
    color: #0474B4;
}

.header-search-intent button.active {
    /* Sell = pink, matching the homepage hero's "Sell Your Device" button. */
    background: #c10077;
    color: #fff;
}

.header-search-intent button.active.buy-active {
    /* Buy = blue, matching the homepage hero's "Buy Refurbished" button. */
    background: #0474B4;
}

.header-search-intent button:focus-visible,
.header-search-result-link:focus-visible,
.header-search-view-all:focus-visible {
    outline: 2px solid #0474B4;
    outline-offset: 2px;
}

.header-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 0 12px;
    height: 42px;
    font-size: 14px;
    color: #333;
    background: transparent;
    font-family: inherit;
}

.header-search-input::placeholder {
    color: #98a2b3;
}

.header-search-submit {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    color: #667085;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-search-submit:hover {
    color: #0474B4;
}

/* ============================================================
   Results dropdown — lightweight & navigational, no prices
   ============================================================ */
.header-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #eaecef;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.10);
    z-index: 1200;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px 0;
}

.header-search-dropdown[hidden] {
    display: none;
}

.header-search-dropdown-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #98a2b3;
    padding: 7px 12px 4px;
}

.header-search-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-search-result-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    text-decoration: none !important;
    color: inherit;
    min-height: 40px;
}

.header-search-dropdown li.selected .header-search-result-link,
.header-search-result-link:hover,
.header-search-result-link:focus-visible {
    background: #f6f9fb;
}

.header-search-result-thumb {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    background: #f4f6f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    color: #98a2b3;
    font-size: 14px;
}

.header-search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-search-result-text {
    min-width: 0;
    flex: 1;
}

.header-search-result-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1d2939;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search-result-meta {
    display: block;
    font-size: 11.5px;
    color: #98a2b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search-dropdown-state {
    padding: 16px 12px;
    text-align: center;
    font-size: 13px;
    color: #98a2b3;
}

.header-search-dropdown-state.is-error {
    color: #c10077;
}

.header-search-dropdown-state a {
    color: #0474B4;
    font-weight: 600;
    text-decoration: underline;
}

.header-search-view-all {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px 12px;
    font-size: 12.5px;
    font-weight: 700;
    color: #0474B4;
    background: transparent;
    border: none;
    border-top: 1px solid #f0f2f4;
    text-decoration: none !important;
    cursor: pointer;
}

.header-search-view-all:hover {
    background: #f6f9fb;
}

@media (max-width: 1279px) {
    .header-search {
        display: none;
    }
}

/* ============================================================
   Mobile: static, slim search bar below the header
   ============================================================ */
.header-search-mobile-bar {
    display: none;
}

@media (max-width: 1279px) {
    .header-search-mobile-bar {
        display: block;
        padding: 8px 16px;
        background: #fff;
        position: static; /* normal document flow — must scroll away, not stick */
    }

    .header-search-mobile-bar .header-search {
        max-width: none;
        width: 100%;
        display: flex;
    }

    .header-search-mobile-bar .header-search-input,
    .header-search-mobile-bar .header-search-submit {
        height: 34px;
    }

    .header-search-mobile-bar .header-search-dropdown {
        max-height: min(60vh, 360px);
    }

    /* Tighten the header row itself to feel premium/compact on mobile —
       .container-fluid's default 24px side padding is shared site-wide, so
       override narrowly here rather than touching that global class. */
    .header-main > .container-fluid {
        padding-left: 16px;
        padding-right: 12px;
    }
}
