/* =============================================================================
   Bíblia em Áudio — estilos da área pública
   Tema claro/escuro via [data-bs-theme]; variáveis CSS para fácil customização.
   ========================================================================== */

:root {
    --brand: #6c4cf1;
    --brand-2: #9d7bff;
    --radius: 14px;
    --player-h: 88px;
}

[data-bs-theme="dark"] {
    --bg: #0c0c12;
    --bg-elev: #15151f;
    --bg-elev-2: #1e1e2c;
    --text: #f2f2f7;
    --text-muted: #9a9ab0;
    --border: #25253a;
}

[data-bs-theme="light"] {
    --bg: #f6f6fb;
    --bg-elev: #ffffff;
    --bg-elev-2: #f0f0f7;
    --text: #1a1a2a;
    --text-muted: #6a6a80;
    --border: #e2e2ee;
}

* { box-sizing: border-box; }

body.app-body {
    background: var(--bg);
    color: var(--text);
    padding-bottom: calc(var(--player-h) + 1rem);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ----- Header ----- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.app-brand {
    display: flex; align-items: center; gap: .5rem;
    color: var(--text); font-weight: 700; font-size: 1.15rem;
}
.app-brand i { color: var(--brand-2); font-size: 1.4rem; }
.app-brand-logo { height: 34px; width: auto; display: block; }
.app-search { max-width: 460px; width: 100%; }
.app-search .input-group-text,
.app-search .form-control {
    background: var(--bg-elev); border-color: var(--border); color: var(--text);
}

.btn-icon {
    background: transparent; border: none; color: var(--text);
    width: 42px; height: 42px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.btn-icon:hover { background: var(--bg-elev-2); color: var(--text); }

/* ----- Seções ----- */
.section-title {
    font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.section-title i { color: var(--brand-2); }

/* ----- Hero ----- */
.hero {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-radius: var(--radius); padding: 2.5rem 2rem; color: #fff;
}
.hero-title { font-weight: 800; font-size: clamp(1.5rem, 4vw, 2.4rem); }
.hero-sub { opacity: .9; }

/* ----- Grids de livros ----- */
.livros-grid {
    display: grid; gap: .8rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.livro-card {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; text-decoration: none;
    color: var(--text); transition: transform .15s, border-color .15s;
    display: flex; flex-direction: column; gap: .25rem;
}
.livro-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.livro-card-abrev {
    width: 44px; height: 44px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-weight: 700; display: flex; align-items: center;
    justify-content: center; margin-bottom: .4rem;
}
.livro-card-nome { font-weight: 600; }
.livro-card-caps { color: var(--text-muted); font-size: .85rem; }

/* ----- Cards horizontais (rows) ----- */
.card-row {
    display: grid; gap: .8rem; grid-auto-flow: column;
    grid-auto-columns: minmax(160px, 1fr);
    overflow-x: auto; padding-bottom: .5rem;
}
.audio-card {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text);
    transition: transform .15s;
}
.audio-card:hover { transform: translateY(-3px); }
.audio-card-cover {
    aspect-ratio: 1; border-radius: 10px; margin-bottom: .6rem;
    background: var(--bg-elev-2); display: flex; align-items: center;
    justify-content: center; font-size: 2rem; color: var(--brand-2);
}
.audio-card-title { font-weight: 600; }
.audio-card-sub { color: var(--text-muted); font-size: .85rem; }

/* ----- Cabeçalho de livro ----- */
.livro-header { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.livro-header-cover {
    width: 120px; height: 120px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-size: 2rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.livro-header-title { font-weight: 800; margin: .25rem 0; }

/* ----- Grid de capítulos ----- */
.capitulos-grid {
    display: grid; gap: .6rem;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
}
.capitulo-chip {
    aspect-ratio: 1; border-radius: 12px; background: var(--bg-elev);
    border: 1px solid var(--border); text-decoration: none; color: var(--text);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .2rem; transition: transform .15s, border-color .15s;
}
.capitulo-chip:hover { transform: translateY(-2px); border-color: var(--brand); }
.capitulo-chip--vazio { opacity: .45; }
.capitulo-num { font-weight: 700; font-size: 1.1rem; }
.capitulo-ico { font-size: .9rem; color: var(--brand-2); }

/* ----- Cabeçalho de capítulo ----- */
.capitulo-header { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.capitulo-header-cover {
    width: 96px; height: 96px; border-radius: var(--radius);
    background: var(--bg-elev-2); display: flex; align-items: center;
    justify-content: center; font-size: 2.4rem; color: var(--brand-2);
}
.capitulo-header-title { font-weight: 800; }

/* ----- Lista de áudios/narradores ----- */
.lista-audios { display: flex; flex-direction: column; gap: .5rem; max-width: 560px; }
.audio-item {
    display: flex; align-items: center; gap: .8rem; text-align: left;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 12px; padding: .7rem 1rem; color: var(--text); cursor: pointer;
}
.audio-item:hover { border-color: var(--brand); }
.audio-item-ico {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; display: flex; align-items: center; justify-content: center;
}
.audio-item-info { display: flex; flex-direction: column; }
.audio-item-dur { color: var(--text-muted); font-size: .82rem; }

/* ----- Continuar ouvindo ----- */
.continuar-card {
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.2rem;
    display: flex; align-items: center; gap: 1rem;
}

/* =========================== PLAYER FIXO =========================== */
.player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
    background: var(--bg-elev); border-top: 1px solid var(--border);
    /* Respeita a barra de gestos do iPhone (notch / home indicator). */
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.player-bar {
    display: grid; align-items: center; gap: 1rem;
    grid-template-columns: 1fr auto 2fr auto;
    padding: .6rem 1rem; height: var(--player-h);
}
.player-info { display: flex; align-items: center; gap: .8rem; min-width: 0; cursor: pointer; }
.player-cover {
    width: 52px; height: 52px; border-radius: 10px; flex: 0 0 auto;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.player-meta { min-width: 0; }
.player-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--text-muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-controls { display: flex; align-items: center; gap: .25rem; }
.btn-play {
    background: var(--text); color: var(--bg); width: 48px; height: 48px;
}
.btn-play:hover { background: var(--text); color: var(--bg); opacity: .9; }
.player-progress { display: flex; align-items: center; gap: .6rem; }
.player-time { color: var(--text-muted); font-size: .78rem; font-variant-numeric: tabular-nums; min-width: 44px; }
.player-seek { flex: 1; accent-color: var(--brand); }
.player-extra { display: flex; align-items: center; gap: .25rem; }
.player-volume { display: flex; align-items: center; gap: .4rem; }
.player-volume input { width: 90px; accent-color: var(--brand); }
.player-active { color: var(--brand-2) !important; }

/* Ícone de carregamento (buffering) girando no botão play. */
.player-spin { display: inline-block; animation: player-spin 0.8s linear infinite; }
@keyframes player-spin { to { transform: rotate(360deg); } }

/* Player expandido */
.player-full {
    position: fixed; inset: 0; z-index: 1050;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.player-full-inner { max-width: 520px; width: 100%; padding: 2rem; text-align: center; }
.player-full-close { position: absolute; top: 1rem; left: 1rem; }
.player-full-cover {
    width: 220px; height: 220px; margin: 0 auto 1.5rem; border-radius: 20px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; font-size: 5rem; display: flex; align-items: center; justify-content: center;
}
.player-full-title { font-weight: 800; }
.player-full-sub { color: var(--text-muted); margin-bottom: 1.5rem; }
.player-playlist-list { text-align: left; max-height: 220px; overflow-y: auto; padding-left: 1.2rem; }
.player-playlist-list li { padding: .35rem 0; color: var(--text-muted); }
.player-playlist-list li.atual { color: var(--text); font-weight: 600; }

/* ----- Responsivo: player no smartphone ----- */
@media (max-width: 768px) {
    :root { --player-h: 78px; }
    /* Barra em 2 linhas: info+controles em cima, progresso embaixo. */
    .player-bar {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: .4rem .6rem;
        padding: .5rem .7rem;
    }
    .player-info { grid-column: 1; grid-row: 1; }
    .player-controls { grid-column: 2; grid-row: 1; gap: .1rem; }
    .player-progress { grid-column: 1 / -1; grid-row: 2; order: 3; }
    /* Extras (velocidade/sleep/volume) ficam no player expandido no mobile. */
    .player-extra { display: none; }
    /* Esconde shuffle/repeat na barra (disponíveis no player completo). */
    #pShuffle, #pRepeat { display: none; }
    .player-cover { width: 44px; height: 44px; }
    .btn-play { width: 44px; height: 44px; }
    .btn-icon { width: 40px; height: 40px; } /* alvo de toque adequado */
}

/* Player expandido: garante controles extras visíveis no mobile */
.player-full-controls {
    display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
    margin: 1rem 0;
}
.player-full-controls .form-range { width: 140px; }

.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--brand-2); }

/* Transição suave ao trocar conteúdo na navegação SPA */
.app-main { transition: opacity .12s ease; }
.app-main--loading { opacity: .45; pointer-events: none; }

/* ----- Compartilhamento ----- */
.share-buttons {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem;
}
.share-btn {
    display: flex; flex-direction: column; align-items: center; gap: .3rem;
    padding: .7rem .3rem; border-radius: 12px; text-decoration: none;
    color: var(--text); background: var(--bg-elev-2); font-size: .72rem;
    transition: transform .15s;
}
.share-btn:hover { transform: translateY(-2px); color: var(--brand-2); }
.share-btn i { font-size: 1.5rem; }
@media (max-width: 480px) {
    .share-buttons { grid-template-columns: repeat(3, 1fr); }
}
