/* ===========================================
   FLOATING BUTTON
   =========================================== */

#tts-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4675EF;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(70, 117, 239, 0.4);
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9999;
}

    #tts-btn:hover {
        transform: scale(1.08);
        box-shadow: 0 6px 20px rgba(70, 117, 239, 0.5);
    }

    #tts-btn:focus-visible {
        outline: 3px solid #4675EF;
        outline-offset: 3px;
    }

    #tts-btn svg {
        width: 24px;
        height: 24px;
    }

/* Hide on mobile/tablet */
@media (max-width: 1280px) {
    #tts-btn {
        display: none;
    }
}

/* ===========================================
   SELECTION POPUP
   =========================================== */

#tts-popup {
    position: fixed;
    background: #333;
    color: #fff;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

    #tts-popup.visible {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    #tts-popup::after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        border: 8px solid transparent;
        border-top-color: #333;
    }

#tts-popup-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 14px;
    white-space: nowrap;
}

    #tts-popup-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    #tts-popup-btn:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 2px;
    }

    #tts-popup-btn svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

/* Hide on mobile/tablet */
@media (max-width: 1280px) {
    #tts-popup {
        display: none !important;
    }
}

/* ===========================================
   PLAYER CONTROLS
   =========================================== */

#tts-controls {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
}

    #tts-controls.visible {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        visibility: visible;
    }

    #tts-controls button {
        background: none;
        border: none;
        color: #fff;
        cursor: pointer;
        padding: 10px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s;
    }

        #tts-controls button:hover {
            background: rgba(255, 255, 255, 0.15);
        }

        #tts-controls button:focus-visible {
            outline: 2px solid #fff;
            outline-offset: 2px;
        }

    #tts-controls svg {
        width: 20px;
        height: 20px;
    }

/* Play/Pause icon toggle */
#tts-toggle .icon-play {
    display: none;
}

/* ===========================================
   SPEED CONTROL
   =========================================== */

#tts-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 13px;
}

#tts-speed-slider {
    width: 60px;
    height: 4px;
    cursor: pointer;
    accent-color: #4675EF;
}

#tts-speed-val {
    min-width: 28px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.tts-highlight {
    background: #FEF3A0;
    border-radius: 2px;
}

/* ===========================================
   RTL SUPPORT (Arabic)
   =========================================== */


[dir="rtl"] #tts-speed,
html[lang="ar"] #tts-speed {
    padding-left: 0;
    padding-right: 12px;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
}

/* ===========================================
   MOBILE ADJUSTMENTS
   =========================================== */

@media (max-width: 480px) {
    #tts-controls {
        padding: 8px 16px;
        gap: 8px;
        bottom: 16px;
    }

        #tts-controls button {
            padding: 8px;
        }

    #tts-speed-slider {
        width: 50px;
    }
}

/* ===========================================
   REDUCED MOTION
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    #tts-btn,
    #tts-popup,
    #tts-controls,
    #tts-controls button {
        transition: none;
    }

        #tts-btn:hover {
            transform: none;
        }
}

/* ===========================================
   PRINT
   =========================================== */

@media print {
    #tts-btn,
    #tts-popup,
    #tts-controls {
        display: none !important;
    }
}