/* ============================================ */
/* ПАНЕЛЬ ПЛЕЄРА TTS                            */
/* ============================================ */

.tts-player {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 1100;
    background-color: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-bottom: none;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 10px 18px;
    transition: transform 0.3s ease, opacity 0.3s ease, margin-bottom 0.2s ease;
    opacity: 0;
    pointer-events: none;

    /* Відступ від низу = реальна висота рекламного банера (встановлюється через JS) */
    margin-bottom: var(--tts-player-bottom-offset, 0px);
}

.tts-player.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.tts-player-inner {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ============ КНОПКИ ============ */

.tts-player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: var(--accent-primary, #8b5cf6);
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    padding: 0;
    flex-shrink: 0;
}

.tts-player-btn:hover {
    background-color: var(--accent-hover, #7c3aed);
    transform: scale(1.05);
}

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

.tts-player-btn .material-symbols-outlined {
    font-size: 26px;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Кнопка Stop — сіра, щоб візуально відрізняти від Play/Pause */
#ttsPlayerStop {
    background-color: var(--bg-secondary, #f1f5f9);
    color: var(--text-secondary, #475569);
    width: 40px;
    height: 40px;
}

#ttsPlayerStop:hover {
    background-color: var(--bg-tertiary, #e2e8f0);
    color: var(--text-primary, #1e293b);
}

#ttsPlayerStop .material-symbols-outlined {
    font-size: 22px;
}

/* ============ ГАЛОЧКА "ПЕРЕМОТУВАТИ ТЕКСТ" ============ */

.tts-player-follow {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    font-size: 13px;
    color: var(--text-secondary, #475569);
    white-space: nowrap;
}

.tts-player-follow:hover {
    background-color: var(--bg-secondary, #f1f5f9);
}

.tts-player-follow input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary, #8b5cf6);
    margin: 0;
    flex-shrink: 0;
}

.tts-player-follow .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-secondary, #475569);
    transition: color 0.2s ease;
}

.tts-player-follow input[type="checkbox"]:checked ~ .material-symbols-outlined {
    color: var(--accent-primary, #8b5cf6);
}

.tts-player-follow-label {
    font-weight: 500;
}

/* ============ ПІДСВІЧУВАННЯ ПОТОЧНОГО РЕЧЕННЯ ============ */

.sentence.tts-highlight,
.sentence-full.tts-highlight {
    background-color: rgba(139, 92, 246, 0.15);
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.sentence.tts-highlight .original,
.sentence.tts-highlight .translation,
.sentence-full.tts-highlight .original-full,
.sentence-full.tts-highlight .translation-full {
    transition: color 0.3s ease;
}

/* ============ ТЕМИ ============ */

/* Темна тема */
.theme-dark .tts-player {
    background-color: var(--bg-secondary, #1e293b);
    border-color: var(--border-color, #334155);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.theme-dark #ttsPlayerStop {
    background-color: var(--bg-tertiary, #334155);
    color: var(--text-secondary, #cbd5e1);
}

.theme-dark #ttsPlayerStop:hover {
    background-color: #475569;
    color: var(--text-primary, #f1f5f9);
}

.theme-dark .tts-player-follow {
    color: var(--text-secondary, #cbd5e1);
}

.theme-dark .tts-player-follow:hover {
    background-color: var(--bg-tertiary, #334155);
}

.theme-dark .tts-player-follow .material-symbols-outlined {
    color: var(--text-secondary, #cbd5e1);
}

.theme-dark .sentence.tts-highlight,
.theme-dark .sentence-full.tts-highlight {
    background-color: rgba(167, 139, 250, 0.2);
}

/* Сепія тема */
.theme-sepia .tts-player {
    background-color: var(--bg-primary, #fbf7f0);
    border-color: var(--border-color, #d9c8b4);
    box-shadow: 0 -4px 20px rgba(91, 70, 54, 0.2);
}

.theme-sepia .tts-player-btn {
    background-color: var(--accent-primary, #b45f3a);
    color: #ffffff;
}

.theme-sepia .tts-player-btn:hover {
    background-color: var(--accent-hover, #9e4f2f);
}

.theme-sepia #ttsPlayerStop {
    background-color: var(--bg-secondary, #f3ede3);
    color: var(--text-secondary, #7d6b5a);
}

.theme-sepia #ttsPlayerStop:hover {
    background-color: var(--bg-tertiary, #e8dccc);
    color: var(--text-primary, #5b4636);
}

.theme-sepia .tts-player-follow {
    color: var(--text-secondary, #7d6b5a);
}

.theme-sepia .tts-player-follow:hover {
    background-color: var(--bg-secondary, #f3ede3);
}

.theme-sepia .tts-player-follow input[type="checkbox"] {
    accent-color: var(--accent-primary, #b45f3a);
}

.theme-sepia .sentence.tts-highlight,
.theme-sepia .sentence-full.tts-highlight {
    background-color: rgba(180, 95, 58, 0.15);
}

/* ============ МОБІЛЬНА АДАПТАЦІЯ ============ */

@media (max-width: 768px) {
    .tts-player {
        left: 50%;
        transform: translateX(-50%) translateY(120%);
        width: calc(100% - 20px);
        max-width: 360px;
        padding: 8px 12px;
        border-radius: 14px;
        /* margin-bottom — через CSS-змінну */
    }

    .tts-player.open {
        transform: translateX(-50%) translateY(0);
    }

    .tts-player-inner {
        gap: 10px;
        justify-content: center;
    }

    .tts-player-btn {
        width: 40px;
        height: 40px;
    }

    .tts-player-btn .material-symbols-outlined {
        font-size: 22px;
    }

    #ttsPlayerStop {
        width: 36px;
        height: 36px;
    }

    #ttsPlayerStop .material-symbols-outlined {
        font-size: 20px;
    }

    .tts-player-follow-label {
        display: none;
    }

    .tts-player-follow {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .tts-player {
        width: calc(100% - 12px);
        padding: 6px 10px;
    }

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

    .tts-player-btn .material-symbols-outlined {
        font-size: 20px;
    }

    #ttsPlayerStop {
        width: 32px;
        height: 32px;
    }

    #ttsPlayerStop .material-symbols-outlined {
        font-size: 18px;
    }
}

/* ============ ДРУК ============ */

@media print {
    .tts-player {
        display: none !important;
    }

    .sentence.tts-highlight,
    .sentence-full.tts-highlight {
        background-color: transparent !important;
    }
}