/* ═══════════════════════════════════════════
   TTS READER — Floating narration player
   ═══════════════════════════════════════════ */

.tts-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    background: rgba(15, 15, 30, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 107, 107, 0.25);
    padding: 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
}

.tts-bar.tts-open {
    transform: translateY(0);
}

.tts-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    flex-wrap: nowrap;
}

.tts-chapter-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255, 107, 107, 0.85);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    flex-shrink: 0;
}

.tts-progress-wrap {
    flex: 1;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.tts-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.tts-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

.tts-progress-info {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.35);
    white-space: nowrap;
}

.tts-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.tts-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.65);
    transition: background 0.15s, color 0.15s, transform 0.1s;
    font-size: 1rem;
    padding: 0;
    flex-shrink: 0;
}

.tts-btn:hover {
    background: rgba(255, 107, 107, 0.15);
    color: #fff;
}

.tts-btn:active {
    transform: scale(0.9);
}

.tts-btn-play {
    width: 40px;
    height: 40px;
    background: #ff6b6b;
    color: #fff;
    font-size: 1.15rem;
}

.tts-btn-play:hover {
    background: #ff8585;
    color: #fff;
}

.tts-speed-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.tts-speed-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    width: 2.2rem;
    text-align: center;
    font-weight: 600;
}

.tts-speed-btn {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tts-speed-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #fff;
    border-color: rgba(255, 107, 107, 0.4);
}

.tts-btn-play:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

.tts-btn-close {
    opacity: 0.45;
    font-size: 0.9rem;
}

.tts-btn-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

/* ── Trigger floating pill ── */
/* Fica no canto esquerdo de propósito: o music player ocupa o canto
   direito (z-index 9998/9999) e não deve disputar espaço/empilhamento
   com o narrador. */
.tts-trigger-btn {
    position: fixed;
    bottom: 1.25rem;
    left: 1rem;
    z-index: 1100;
    background: rgba(15, 15, 30, 0.92);
    border: 1px solid rgba(255, 107, 107, 0.4);
    border-radius: 40px;
    padding: 0.45rem 0.85rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    backdrop-filter: blur(12px);
    transition: background 0.2s, border-color 0.2s, transform 0.15s, bottom 0.3s;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

.tts-trigger-btn:hover {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.7);
    transform: translateY(-2px);
}

.tts-trigger-btn.tts-active {
    background: rgba(255, 107, 107, 0.18);
    border-color: #ff6b6b;
    color: #ff8585;
}

.tts-trigger-btn.tts-unavailable {
    opacity: 0.55;
}

/* ── Mobile ── */
@media (max-width: 600px) {
    .tts-bar-inner {
        padding: 0.55rem 0.65rem;
        gap: 0.4rem;
    }

    .tts-chapter-label {
        max-width: 80px;
        font-size: 0.6rem;
    }

    .tts-btn {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .tts-btn-play {
        width: 36px;
        height: 36px;
    }

    .tts-speed-group {
        display: none;
    }

    .tts-trigger-btn {
        left: 0.65rem;
        padding: 0.4rem 0.7rem;
        font-size: 0.7rem;
    }
}

body.tts-bar-open .trilha-content {
    padding-bottom: 5rem;
    transition: padding-bottom 0.3s ease;
}

/* ── Empurra o music player para cima quando a barra do narrador está aberta ──
   A barra do narrador ocupa toda a largura no rodapé (~4.5rem de altura);
   sem isso, o botão/painel do music player (z-index 9998/9999) fica por
   cima da barra do narrador (z-index 1200) nesse mesmo espaço. */
body.tts-bar-open .music-player-v2 {
    bottom: calc(20px + 4.5rem);
    transition: bottom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 768px) {
    body.tts-bar-open .music-player-v2 {
        bottom: calc(15px + 4rem);
    }
}

@media (max-width: 480px) {
    body.tts-bar-open .music-player-v2 {
        bottom: calc(10px + 3.75rem);
    }
}
