/* BuscaOke — UI mobile-first, tema escuro (ambiente de videokê).
   Sem dependências externas: fonte do sistema, ícones SVG inline. */

:root {
    --bg: #0d0e14;
    --bg-glow: #13232e;
    --surface: #181b26;
    --surface-2: #20242f;
    --border: #2b3040;
    --border-hover: #3a405a;
    --text: #f2f3f8;
    --muted: #9aa0b5;
    --faint: #6b7186;
    --accent: #22d3ee;
    --accent-2: #fbbf24;
    --accent-glow: rgb(34 211 238 / 0.22);
    --gold: #fbbf24;
    --on-accent: #0d0e14;
    --select-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa0b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --shadow-card: none;
    --radius: 14px;
    --radius-pill: 999px;
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg-glow: #cffafe;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --accent: #0891b2;
    --accent-2: #d97706;
    --accent-glow: rgb(8 145 178 / 0.18);
    --on-accent: #ffffff;
    --gold: #b45309;
    --select-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --shadow-card: 0 1px 3px 0 rgb(15 23 42 / 0.06), 0 1px 2px -1px rgb(15 23 42 / 0.04);
    color-scheme: light;
}

* { box-sizing: border-box; }

/* O atributo hidden deve vencer qualquer display de classe. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1100px 480px at 50% -160px, var(--bg-glow) 0%, transparent 70%),
        var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    transition: background-color 0.25s ease, color 0.25s ease;
}

button { font: inherit; color: inherit; }

/* Transições suaves de tema */
.searchbar,
.card,
.recent-chip,
.filter-select,
.more-btn,
.empty,
.clear-btn {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

/* ---------- Topo ---------- */

.topbar {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brand-logo { font-size: 22px; align-self: center; }

.brand-name {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-accent {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Botão de alternar tema */
.theme-toggle {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: background-color 0.25s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
    transform: scale(1.06);
}

.theme-toggle:active {
    transform: scale(0.94);
}

.theme-toggle:focus-visible {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Ícone no tema escuro: mostra sol para mudar para claro */
.theme-icon-moon { display: none; }
.theme-icon-sun { display: block; }

/* Ícone no tema claro: mostra lua para mudar para escuro */
[data-theme="light"] .theme-icon-sun { display: none; }
[data-theme="light"] .theme-icon-moon { display: block; }

/* ---------- Busca ---------- */

.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px;
    flex: 1;
}

.searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 54px;
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.25s;
}

.searchbar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.icon-search {
    width: 22px;
    height: 22px;
    flex: none;
    color: var(--faint);
}

.searchbar input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 17px;
}

.searchbar input::placeholder { color: var(--faint); }
.searchbar input::-webkit-search-cancel-button { display: none; }

.clear-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-right: -6px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
}

.clear-btn:hover { color: var(--text); }
.clear-btn svg { width: 18px; height: 18px; }

/* Buscas recentes */

.recent {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.recent-label {
    width: 100%;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.recent-chip {
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
}

.recent-chip:hover { border-color: var(--accent); color: var(--text); }

.recent-clear {
    padding: 7px 10px;
    border: 0;
    background: transparent;
    color: var(--faint);
    font-size: 13px;
    cursor: pointer;
}

.recent-clear:hover { color: var(--accent-2); }

/* ---------- Filtro de idioma ---------- */

.filter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.filter-label {
    flex: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.filter-select {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 40px 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 15px center;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.25s, color 0.25s;
}

.filter-select:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Resultados ---------- */

.results-area { margin-top: 14px; }

.status {
    min-height: 22px;
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--muted);
}

.status.is-busy::after {
    content: "…";
    animation: dots 1.2s steps(4) infinite;
}

@keyframes dots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
}

.status .status-highlight { color: var(--gold); font-weight: 600; }

.results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    display: flex;
    gap: 12px;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.card-code {
    flex: none;
    display: grid;
    place-items: center;
    min-width: 64px;
    padding: 8px 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--on-accent);
    font-size: 19px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    align-self: flex-start;
}

.card-body { flex: 1; min-width: 0; }

.card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.card-artist {
    margin: 2px 0 0;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--accent-2);
    overflow-wrap: anywhere;
}

.card-inicio {
    margin: 5px 0 0;
    font-size: 13.5px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    margin: 7px 0 0;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 9px;
}

.card-letra {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--gold);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.card-letra:hover { border-color: var(--gold); }
.card-letra svg { width: 14px; height: 14px; }

mark {
    background: transparent;
    color: var(--gold);
    font-weight: 700;
    padding: 0;
}

/* Carregar mais */

.more-wrap { display: flex; justify-content: center; margin: 16px 0 8px; }

.more-btn {
    padding: 12px 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.more-btn:hover { border-color: var(--accent); }

/* ---------- Estados vazios ---------- */

.empty {
    padding: 34px 16px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.empty .empty-emoji { font-size: 30px; display: block; margin-bottom: 8px; }

.empty-hint {
    margin-top: 14px;
    font-size: 13px;
    color: var(--faint);
}

/* ---------- Rodapé ---------- */

.footer {
    padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 22px);
    text-align: center;
    color: var(--faint);
    font-size: 13px;
}

/* ---------- Telas maiores ---------- */

@media (min-width: 700px) {
    .topbar { padding-top: 26px; padding-bottom: 4px; }
    .brand-name { font-size: 26px; }
    .searchbar { height: 58px; }
    .filter-select { flex: 0 1 320px; }
    .card { padding: 15px 16px; }
    .card:hover { border-color: var(--border-hover); }
}
