/* Speech TTS Plugin Styles - Compact player */
.speech-tts-wrapper {
    margin: 16px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    color: #111827;
    max-width: 100%;
}

.speech-tts-player-shell {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.speech-tts-screen {
    position: relative;
    min-height: 300px;
    max-height: 300px;
    padding: 12px 12px 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(90deg, #eff6ff, #f9fafb);
}

/* Thanh trạng thái nằm phía trên khung player */
.speech-tts-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 2px;
}

/* Cột sóng trạng thái (Sẵn sàng / Đang phát / Đang tải) */
.speech-tts-live-badge {
    display: inline-flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    position: relative;
}

.speech-tts-live-bar {
    width: 3px;
    border-radius: 2px;
    background: #22c55e;
    opacity: 0.5;
    animation: speech-tts-wave 1s infinite ease-in-out;
}

.speech-tts-live-bar:nth-child(1) { height: 4px; animation-delay: 0s; }
.speech-tts-live-bar:nth-child(2) { height: 8px; animation-delay: 0.1s; }
.speech-tts-live-bar:nth-child(3) { height: 14px; animation-delay: 0.2s; }
.speech-tts-live-bar:nth-child(4) { height: 10px; animation-delay: 0.3s; }
.speech-tts-live-bar:nth-child(5) { height: 6px; animation-delay: 0.4s; }

.speech-tts-live-badge.is-loading .speech-tts-live-bar {
    background: #3b82f6;
    opacity: 0.7;
}

.speech-tts-live-badge.is-active .speech-tts-live-bar {
    background: #ef4444;
    opacity: 0.9;
}

.speech-tts-live-badge.is-paused .speech-tts-live-bar {
    background: #9ca3af;
    opacity: 0.6;
    animation-play-state: paused;
}

/* Text ẩn cho trạng thái (phục vụ screen reader) */
.speech-tts-sr-only,
.speech-tts-live-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.speech-tts-progress-label {
    font-size: 11px;
    font-weight: 600;
    color: #111827;
}

.speech-tts-subtitle {
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 500;
    color: #111827;
    text-align: left;
    text-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 2px;
    height: 100%;
    width: 100%;
    padding: 28px 8px 8px 6px;
    box-sizing: border-box;
    overflow: hidden;
}

.speech-tts-subtitle-line {
    display: block;
    width: 100%;
    margin: 2px 0;
    max-width: 100%;
    word-break: break-word;
    overflow: hidden;
}

.speech-tts-subtitle-empty {
    opacity: 0.35;
}

.speech-tts-subtitle-word {
    color: rgba(241, 245, 249, 0.9);
}

.speech-tts-subtitle-active {
    color: #f472b6;
    text-shadow: 0 4px 12px rgba(244, 114, 182, 0.6);
}

.speech-tts-subtitle-placeholder {
    color: #6b7280;
    font-weight: 500;
}

.speech-tts-progress {
    height: 4px;
    background: #e5e7eb;
    overflow: hidden;
}

.speech-tts-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #22d3ee 50%, #f97316 100%);
    transition: width 0.18s linear;
}

/* Compact control row and buttons */
.speech-tts-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    padding: 6px 8px;
    background: #f3f4f6;
    border-radius: 0 0 6px 6px;
}

.speech-tts-card {
    background: transparent;
    border-radius: 0;
    padding: 0;
    border: 0;
    backdrop-filter: none;
}

.speech-tts-voice-control {
    min-width: 130px;
}

.speech-tts-slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speech-tts-speed-control,
.speech-tts-pitch-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.speech-tts-voice-control label,
.speech-tts-speed-control label,
.speech-tts-pitch-control label {
    font-weight: 600;
    font-size: 11px;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.speech-tts-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.8);
    background: #f9fafb;
    color: #111827;
    font-size: 13px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.speech-tts-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Ẩn slider, dùng stepper +/- thay thế */
.speech-tts-range {
    display: none;
}

/* Stepper +/- cho tốc độ và độ cao */
.speech-tts-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(148, 163, 184, 0.9);
    border-radius: 4px;
    overflow: hidden;
}

.speech-tts-stepper-btn {
    width: 28px;
    height: 26px;
    border: none;
    background: #f9fafb;
    color: #111827;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.speech-tts-stepper-btn:hover {
    background: #e5e7eb;
}

.speech-tts-stepper-value {
    min-width: 40px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    border-left: 1px solid rgba(148, 163, 184, 0.8);
    border-right: 1px solid rgba(148, 163, 184, 0.8);
    background: #ffffff;
}

.speech-tts-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 6px 2px;
}

.speech-tts-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    width: auto;
    height: auto;
    font-size: 18px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.speech-tts-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.speech-tts-btn-primary {
    background: #22c55e;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
}

.speech-tts-btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.speech-tts-btn-danger {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

.speech-tts-btn:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

.speech-tts-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.speech-tts-spinner {
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: speech-tts-spin 0.8s linear infinite;
}

@keyframes speech-tts-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes speech-tts-pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

@keyframes speech-tts-wave {
    0%, 100% { transform: scaleY(0.6); }
    50% { transform: scaleY(1.4); }
}

/* Highlight words inside chapter content */
.speech-tts-word-inline {
    display: inline;
    padding: 1px 2px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.speech-tts-word-inline.highlight {
    background: rgba(99, 102, 241, 0.18);
    color: #4f46e5;
    font-weight: 600;
}

.speech-tts-word-inline.read {
    color: rgba(100, 116, 139, 0.7);
}

/* Notifications */
.speech-tts-notification {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    font-size: 12px;
    pointer-events: none;
    opacity: 0.96;
    transition: opacity 0.25s ease;
}

.speech-tts-notification-warning {
    border-color: rgba(251, 191, 36, 0.6);
    background: rgba(120, 53, 15, 0.95);
    color: #fde68a;
}

.speech-tts-notification-info {
    border-color: rgba(59, 130, 246, 0.6);
    background: rgba(37, 99, 235, 0.95);
    color: #e0f2fe;
}

/* Responsive */
@media (max-width: 768px) {
    .speech-tts-wrapper {
        padding: 10px;
    }

    .speech-tts-screen {
        padding: 10px 8px 6px;
        min-height: 70px;
    }

    .speech-tts-control-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .speech-tts-slider-group {
        width: 100%;
        justify-content: space-between;
    }

    .speech-tts-buttons {
        justify-content: flex-start;
    }
}
