/**
 * NobarTV AI Search — Search Widget
 * Design: Inline bar · Netral putih/abu · Modern 2026
 * Version: 1.5.0 — FIXED mobile overflow
 */

.nbt-widget {
    --nw-accent:      #3b6ef8;
    --nw-accent-dark: #2451d4;
    --nw-accent-glow: rgba(59,110,248,.16);
    --nw-text:        #1a1f36;
    --nw-muted:       #94a3b8;
    --nw-border:      #e2e8f0;
    --nw-surface:     #f8fafc;
    --nw-pill-bg:     #f1f5f9;
    --nw-pill-hover:  #e2e8f0;
    --nw-pill-text:   #475569;
    --nw-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    --nw-ease:        .18s cubic-bezier(.4,0,.2,1);

    font-family: var(--nw-font);
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0 0 24px;
    margin: 0 auto;
    /* FIX: ensure widget doesn't overflow its container */
    max-width: 100%;
    width: 100%;
    overflow: visible;
    box-sizing: border-box;
}

/* ── Inline bar ───────────────────────────────────────────────────────────── */
.nbt-widget__search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid var(--nw-border);
    border-radius: 50px;
    padding: 5px 5px 5px 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: border-color var(--nw-ease), box-shadow var(--nw-ease);
    margin-bottom: 10px;
    /* FIX: prevent overflow */
    min-width: 0;
    /* v4.22.1: overflow:hidden SEBELUMNYA memotong popup dropdown bahasa
       (.nbt-lang-dd__list) yang posisinya absolute di luar tinggi baris ini —
       hasilnya cuma nongol ~2px sliver. Dropdown & input sudah sama-sama
       dijaga tidak melebar horizontal lewat flex + min-width:0, jadi
       overflow:hidden di sini tidak lagi diperlukan. */
    overflow: visible;
    position: relative; /* anchor untuk dropdown autocomplete */
}

.nbt-widget__search-row:focus-within {
    border-color: var(--nw-accent);
    box-shadow: 0 0 0 3px var(--nw-accent-glow), 0 2px 12px rgba(0,0,0,.06);
}

/* ── Logo ─────────────────────────────────────────────────────────────────── */
.nbt-widget__logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.nbt-widget__logo-img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: contain;
    display: block;
}

.nbt-widget__logo-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--nw-text);
    white-space: nowrap;
    /* FIX: limit width on narrow sidebars */
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nbt-widget__logo::after {
    content: '';
    display: block;
    width: 1px;
    height: 18px;
    background: var(--nw-border);
    margin-left: 8px;
}

/* ── Search box ────────────────────────────────────────────────────────────── */
.nbt-widget__search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    background: transparent;
    border: none;
    padding: 0;
}

.nbt-widget__search-icon {
    color: var(--nw-muted);
    flex-shrink: 0;
    margin-right: 6px;
    transition: color var(--nw-ease);
}

.nbt-widget__search-row:focus-within .nbt-widget__search-icon {
    color: var(--nw-accent);
}

.nbt-widget__input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px; /* FIX: 16px prevents iOS zoom */
    font-family: var(--nw-font);
    color: var(--nw-text);
    font-weight: 500;
    padding: 6px 0;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

.nbt-widget__input::placeholder {
    color: var(--nw-muted);
    font-weight: 400;
    font-size: 14px;
}

/* ── Dropdown bahasa (icon bendera kompak) — override konteks widget ──────
   Struktur & popup datang dari assets/css/lang-select.css (di-enqueue
   bersamaan); di sini hanya menyesuaikan ukuran/warna tombol trigger supaya
   menyatu dengan search box widget shortcode. */
.nbt-widget__search-box .nbt-lang-dd { margin-right: 6px; }
.nbt-widget__search-box .nbt-lang-dd__btn {
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,.045);
    color: var(--nw-text);
}
.nbt-widget__search-box .nbt-lang-dd__btn:hover,
.nbt-widget__search-box .nbt-lang-dd.is-open .nbt-lang-dd__btn { background: rgba(0,0,0,.09); }

/* ── Autocomplete dropdown ─────────────────────────────────────────────────
   Anchor: .nbt-widget__search-row (position:relative, lihat di atas). */
.nbt-widget__autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid var(--nw-border);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,.14), 0 4px 10px rgba(0,0,0,.06);
    z-index: 5;
    max-height: 260px;
    overflow-y: auto;
    text-align: left;
}
.nbt-widget__autocomplete.is-open { display: block; }

.nbt-widget__autocomplete-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--nw-surface);
    transition: background var(--nw-ease);
    min-height: 40px;
}
.nbt-widget__autocomplete-item:last-child { border-bottom: none; }
.nbt-widget__autocomplete-item:hover,
.nbt-widget__autocomplete-item.is-active { background: var(--nw-surface); }

.nbt-widget__autocomplete-type {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--nw-muted);
    flex-shrink: 0; white-space: nowrap;
}
.nbt-widget__autocomplete-label {
    font-size: 14px; font-weight: 500;
    color: var(--nw-text);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nbt-widget__autocomplete-hits {
    font-size: 11px; font-weight: 600;
    color: var(--nw-muted);
    flex-shrink: 0;
}


.nbt-widget__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--nw-accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background var(--nw-ease), transform var(--nw-ease), box-shadow var(--nw-ease);
    box-shadow: 0 2px 8px rgba(59,110,248,.3);
    -webkit-tap-highlight-color: transparent;
    /* FIX: proper touch target */
    min-width: 36px;
    min-height: 36px;
}

.nbt-widget__btn:hover {
    background: var(--nw-accent-dark);
    transform: translateX(1px);
    box-shadow: 0 3px 12px rgba(59,110,248,.4);
}

.nbt-widget__btn:active { transform: scale(.93); }

/* ── Mode pencarian (Berita / Bola / Prediksi) ────────────────────────────── */
.nbt-widget__mode {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 4px;
    margin-bottom: 10px;
}

.nbt-widget__mode-option {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--nw-muted);
    user-select: none;
    white-space: nowrap;
    transition: color var(--nw-ease);
}

.nbt-widget__mode-option input[type="radio"] {
    accent-color: var(--nw-accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.nbt-widget__mode-option:has(input:checked) { color: var(--nw-text); }

/* ── Recent keywords ─────────────────────────────────────────────────────── */
.nbt-widget__recents {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px 2px;
    width: 100%;
    /* FIX: prevent overflow */
    overflow: hidden;
    box-sizing: border-box;
}

.nbt-widget__recents-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--nw-muted);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 4px;
}

.nbt-widget__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.nbt-widget__pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    background: var(--nw-pill-bg);
    color: var(--nw-pill-text);
    border: 1px solid var(--nw-border);
    border-radius: 50px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 400;
    text-decoration: none;
    transition: background var(--nw-ease), color var(--nw-ease), transform var(--nw-ease);
    white-space: nowrap;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    /* FIX: touch target */
    min-height: 28px;
}

.nbt-widget__pill:hover {
    background: var(--nw-pill-hover);
    color: var(--nw-text);
    text-decoration: none;
    transform: translateY(-1px);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .nbt-widget__input { font-size: 16px; } /* always 16px to prevent iOS zoom */
    .nbt-widget__search-box .nbt-lang-dd__btn { width: 27px; height: 27px; }
    .nbt-widget__search-box .nbt-lang-dd__flag { width: 17px; height: 12px; }
    .nbt-widget__logo-img { width: 26px; height: 26px; }
    .nbt-widget__logo-text { font-size: 12px; }
    .nbt-widget__mode { gap: 12px; }
    .nbt-widget__mode-option { font-size: 12px; }

    /* On mobile: label full row, pills below */
    .nbt-widget__recents-label {
        width: 100%;
        margin-bottom: 2px;
    }

    .nbt-widget__pills {
        width: 100%;
        flex: unset;
    }

    .nbt-widget__pill {
        font-size: 11px;
        padding: 3px 9px;
    }
}
