/* =============================================================
   TOWN SEARCH — autocomplete widget for header
   Uses BestBuilders design tokens from site.css
   Two placements: compact utility bar + wider mega-menu
   ============================================================= */

/* ── Shared — base field + results ─────────────────────────── */
.town-search {
    position: relative;
}

.town-search-form {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.town-search-input {
    width: 100%;
    font-family: var(--font-body);
    color: var(--text-dark);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 9px 34px 9px 34px;
    font-size: 13px;
    line-height: 1.2;
    transition: border-color 0.15s, background 0.15s;
}

.town-search-input::placeholder {
    color: var(--text-muted);
}

.town-search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--white);
}

.town-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.town-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.town-search-clear:hover {
    background: var(--surface);
    color: var(--text-dark);
}

.town-search.is-active .town-search-clear {
    display: inline-flex;
}

/* Results dropdown */
.town-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 950;
    display: none;
}

.town-search.is-open .town-search-results {
    display: block;
}

.town-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: inherit;
}

.town-result:last-child {
    border-bottom: none;
}

.town-result:hover,
.town-result.is-active {
    background: var(--surface);
}

.town-result-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
}

.town-result-name mark {
    background: var(--accent-light);
    color: var(--text-dark);
    padding: 0 1px;
    border-radius: 2px;
}

.town-result-region {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

.town-result-empty {
    padding: 14px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Variant A — compact utility bar ───────────────────────── */
.town-search--bar {
    max-width: 220px;
    min-width: 180px;
}

.town-search--bar .town-search-input {
    height: 26px;
    padding: 3px 28px 3px 28px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border-radius: 4px;
}

.town-search--bar .town-search-input::placeholder {
    color: rgba(255,255,255,0.55);
}

.town-search--bar .town-search-input:focus {
    background: var(--white);
    color: var(--text-dark);
    border-color: var(--accent);
}

.town-search--bar .town-search-input:focus::placeholder {
    color: var(--text-muted);
}

.town-search--bar .town-search-icon {
    width: 12px;
    height: 12px;
    left: 8px;
    color: rgba(255,255,255,0.55);
}

.town-search--bar .town-search-input:focus ~ .town-search-icon {
    color: var(--text-muted);
}

.town-search--bar .town-search-clear {
    right: 4px;
    width: 18px;
    height: 18px;
    font-size: 12px;
}

.town-search--bar .town-search-results {
    min-width: 260px;
    right: auto;
    left: 0;
}

@media (max-width: 640px) {
    .town-search--bar {
        display: none; /* Utility bar itself is hidden on mobile already */
    }
}

/* ── Variant B — mega menu (Top Towns column) ──────────────── */
.town-search--mega {
    margin-bottom: 14px;
}

.town-search--mega .town-search-input {
    height: 38px;
    font-size: 13px;
    padding: 10px 34px 10px 34px;
}

.town-search--mega .town-search-icon {
    width: 15px;
    height: 15px;
}

.town-search--mega .town-search-results {
    /* Sits inside an already-elevated mega panel; keep shadow lighter */
    box-shadow: var(--shadow-sm);
}
