/* ═══════════════════════════════════════════════════════
   TTS Reader — ITALYHUB v1.0
   Player flottante Text-to-Speech per presentazione
   Zero dipendenze · Web Speech API nativa
   ═══════════════════════════════════════════════════════ */

/* ── FAB "Ascolta" ── */
.tts-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tts-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.6);
}

.tts-fab.tts-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.6);
}

/* ── Tooltip FAB ── */
.tts-fab-tip {
    position: fixed;
    bottom: 44px;
    right: 94px;
    z-index: 9998;
    background: rgba(15, 15, 30, 0.94);
    color: #e2e8f0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.tts-fab-tip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(15, 15, 30, 0.94);
}

.tts-fab:hover + .tts-fab-tip {
    opacity: 1;
    transform: translateX(0);
}

/* ── Player pannello ── */
.tts-player {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    width: 370px;
    max-width: calc(100vw - 40px);
    background: rgba(15, 15, 30, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 18px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55),
                0 0 0 1px rgba(99, 102, 241, 0.08);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #e2e8f0;
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
}

.tts-player.tts-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* ── Header ── */
.tts-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tts-hdr-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tts-hdr-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.tts-hdr-txt {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tts-hdr-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.tts-hdr-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ── Info sezione corrente ── */
.tts-sec {
    padding: 10px 16px 6px;
}

.tts-sec-lbl {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    margin-bottom: 3px;
}

.tts-sec-name {
    font-size: 13px;
    font-weight: 500;
    color: #c4b5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Onde audio animate ── */
.tts-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 14px;
    flex-shrink: 0;
}

.tts-wave-bar {
    width: 3px;
    height: 3px;
    background: #a78bfa;
    border-radius: 2px;
    animation: ttsWave 0.7s ease-in-out infinite;
}

.tts-wave-bar:nth-child(1) { animation-delay: 0s; }
.tts-wave-bar:nth-child(2) { animation-delay: 0.12s; }
.tts-wave-bar:nth-child(3) { animation-delay: 0.24s; }
.tts-wave-bar:nth-child(4) { animation-delay: 0.36s; }

.tts-wave.tts-stopped .tts-wave-bar {
    animation-play-state: paused;
    height: 3px;
}

@keyframes ttsWave {
    0%, 100% { height: 3px; }
    50% { height: 13px; }
}

/* ── Barra progresso ── */
.tts-prog-wrap {
    padding: 0 16px;
    margin: 6px 0 2px;
}

.tts-prog-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    transition: height 0.15s ease;
}

.tts-prog-track:hover {
    height: 6px;
}

.tts-prog-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    border-radius: 2px;
    width: 0%;
    transition: width 0.35s ease;
}

.tts-prog-nums {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #64748b;
    padding: 3px 0 0;
}

/* ── Controlli centrali ── */
.tts-ctrls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px 6px;
}

.tts-btn {
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease,
                transform 0.1s ease,
                color 0.15s ease;
    line-height: 1;
}

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

.tts-btn-sm {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    font-size: 16px;
}

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

.tts-btn-play {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 22px;
    border-radius: 50%;
    box-shadow: 0 2px 14px rgba(99, 102, 241, 0.4);
}

.tts-btn-play:hover {
    box-shadow: 0 4px 22px rgba(99, 102, 241, 0.55);
    transform: scale(1.06);
}

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

/* ── Velocità ── */
.tts-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 14px;
    justify-content: center;
}

.tts-speed-lbl {
    font-size: 11px;
    color: #64748b;
    min-width: 48px;
    text-align: right;
}

.tts-speed-range {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.tts-speed-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #8b5cf6;
    cursor: pointer;
    border: 2px solid #c4b5fd;
}

.tts-speed-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #8b5cf6;
    cursor: pointer;
    border: 2px solid #c4b5fd;
}

.tts-speed-val {
    font-size: 12px;
    font-weight: 600;
    color: #c4b5fd;
    min-width: 36px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .tts-player {
        bottom: 12px;
        right: 12px;
        width: calc(100vw - 24px);
        border-radius: 14px;
    }

    .tts-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .tts-fab-tip {
        display: none;
    }
}
