/**
 * NobarTV AI Search — Recent/Trending Search Widget
 * [nbt_recent_searches] + widget "NobarTV — Pencarian Terkini"
 *
 * v4.34.0 — FIX tampilan widget:
 *   1) Sebelumnya widget maksa kartu putih (background:#fff + border + shadow)
 *      sendiri, padahal di banyak lokasi widget sudah dibungkus kartu/area
 *      milik tema (yang bisa gelap, mis. sidebar hijau tua) → hasilnya kotak
 *      putih nyempil aneh, teksnya jadi susah kebaca / medium-kontras.
 *      FIX: hapus kartu sendiri, semua warna teks & border sekarang ikut
 *      `currentColor` (warisi warna teks kontainer/tema), jadi otomatis pas
 *      dipasang di area gelap teksnya ikut putih, di area terang teksnya
 *      ikut gelap — konsisten dengan widget lain di tema yang juga transparan.
 *   2) Sebelumnya widget punya width:100% tapi tinggi ikut stretch penuh
 *      container grid/flex (mis. kolom sidebar 4-kolom) → banyak area kosong
 *      besar di bawah list yang cuma berisi sedikit item.
 *      FIX: align-self/justify-self: start + height: fit-content supaya
 *      tinggi widget selalu pas-mengikuti isi, tidak ikut stretch.
 *   3) Dirapikan supaya lebih kompak: padding & gap dikecilkan, header lebih
 *      ramping, tidak makan banyak ruang vertikal.
 */

.nbt-rsw {
    --rsw-accent:      #3b6ef8;
    --rsw-accent-dark: #5b8bff;
    --rsw-accent-glow: rgba(59,110,248,.16);
    --rsw-gold:        #f5b301;
    --rsw-silver:      #b9c2cc;
    --rsw-bronze:      #d68f56;
    --rsw-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    --rsw-ease:        .18s cubic-bezier(.4,0,.2,1);
    /* Border/hover diturunkan dari currentColor supaya otomatis kontras
       di background apa pun (terang maupun gelap), tanpa warna abu-abu
       "mati" yang cuma cocok di satu jenis background. */
    --rsw-border:      color-mix(in srgb, currentColor 16%, transparent);
    --rsw-hover-bg:    color-mix(in srgb, currentColor 8%, transparent);
    --rsw-pill-bg:     color-mix(in srgb, currentColor 6%, transparent);
    --rsw-pill-hover:  color-mix(in srgb, currentColor 12%, transparent);
    --rsw-muted:       currentColor;

    font-family: var(--rsw-font);
    /* Ikut background/warna teks kontainer tempat widget dipasang — TIDAK
       maksa kartu putih sendiri lagi (lihat catatan v4.34.0 di atas). */
    background: transparent;
    color: inherit;
    border: none;
    border-radius: 12px;
    box-shadow: none;
    padding: 10px 0;
    max-width: 100%;
    width: 100%;
    height: fit-content;
    align-self: start;
    justify-self: start;
    box-sizing: border-box;
}

/* Kalau widget MEMANG mau dikasih kartu (opt-in lewat class tambahan
   .nbt-rsw--card dari tema/shortcode wrapper), baru dikasih permukaan. */
.nbt-rsw--card {
    background: color-mix(in srgb, currentColor 5%, transparent);
    border: 1px solid var(--rsw-border);
    padding: 12px 14px 14px;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.nbt-rsw__header {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
}

.nbt-rsw__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--rsw-accent-glow);
    color: var(--rsw-accent-dark);
    flex-shrink: 0;
}

.nbt-rsw__title {
    font-size: 13px;
    font-weight: 700;
    color: inherit;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nbt-rsw__live {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #22c55e;
    flex-shrink: 0;
}

.nbt-rsw__live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: nbtRswPulse 1.8s infinite;
}

@keyframes nbtRswPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
    70%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ── Body / transition saat live-refresh ─────────────────────────────── */
.nbt-rsw__body {
    transition: opacity .18s ease;
}

.nbt-rsw__empty {
    font-size: 12px;
    color: inherit;
    opacity: .6;
    margin: 0;
    padding: 2px;
}

/* ── Layout: pills (chip, wrap) ──────────────────────────────────────── */
.nbt-rsw--pills .nbt-rsw__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.nbt-rsw__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--rsw-pill-bg);
    color: inherit;
    border: 1px solid var(--rsw-border);
    border-radius: 50px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
    min-height: 26px;
    transition: background var(--rsw-ease), color var(--rsw-ease), transform var(--rsw-ease), border-color var(--rsw-ease);
}

.nbt-rsw__pill:hover {
    background: var(--rsw-pill-hover);
    color: var(--rsw-accent-dark);
    border-color: var(--rsw-accent-glow);
    transform: translateY(-1px);
    text-decoration: none;
}

.nbt-rsw__pill--top {
    border-color: var(--rsw-accent-glow);
    background: var(--rsw-accent-glow);
}

.nbt-rsw__pill .nbt-rsw__rank {
    font-size: 10px;
    font-weight: 800;
    color: var(--rsw-accent-dark);
}

.nbt-rsw__pill .nbt-rsw__hits {
    font-size: 10px;
    font-weight: 600;
    color: inherit;
    opacity: .55;
}

/* ── Layout: list (kompak, vertikal — cocok utk sidebar sempit) ──────── */
.nbt-rsw--list .nbt-rsw__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nbt-rsw__item { margin: 0; }

.nbt-rsw__row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background var(--rsw-ease);
    -webkit-tap-highlight-color: transparent;
}

.nbt-rsw__row:hover {
    background: var(--rsw-hover-bg);
    text-decoration: none;
}

.nbt-rsw__row .nbt-rsw__rank {
    flex-shrink: 0;
    width: 20px;
    font-size: 10px;
    font-weight: 800;
    color: inherit;
    opacity: .55;
}

/* Medali warna untuk top-3 trending di layout list */
.nbt-rsw--list .nbt-rsw__item:nth-child(1) .nbt-rsw__rank { color: var(--rsw-gold); opacity: 1; }
.nbt-rsw--list .nbt-rsw__item:nth-child(2) .nbt-rsw__rank { color: var(--rsw-silver); opacity: 1; }
.nbt-rsw--list .nbt-rsw__item:nth-child(3) .nbt-rsw__rank { color: var(--rsw-bronze); opacity: 1; }

.nbt-rsw__row .nbt-rsw__label {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nbt-rsw__row .nbt-rsw__hits {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    color: inherit;
    opacity: .55;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .nbt-rsw--card { padding: 10px 10px 12px; }
    .nbt-rsw__title { font-size: 12px; }
    .nbt-rsw__icon { width: 20px; height: 20px; }
    .nbt-rsw__pill { font-size: 11px; padding: 4px 9px; min-height: 25px; }
    .nbt-rsw__row .nbt-rsw__label { font-size: 12px; }
}

/* Widget sidebar tema WP biasanya sempit — pastikan tidak overflow, dan
   tidak ikut stretch tinggi kolom (lihat catatan #2 di atas). */
.widget .nbt-rsw,
aside .nbt-rsw {
    max-width: 100%;
    height: fit-content;
}

/* Fallback untuk browser tanpa dukungan color-mix() (sangat jarang di 2026,
   tapi jaga-jaga): border/hover pakai currentColor transparan tipis. */
@supports not (background: color-mix(in srgb, red 5%, transparent)) {
    .nbt-rsw {
        --rsw-border: currentColor;
        --rsw-hover-bg: transparent;
        --rsw-pill-bg: transparent;
        --rsw-pill-hover: transparent;
    }
    .nbt-rsw__pill,
    .nbt-rsw__row { border-color: currentColor; }
}
