/**
 * Text-to-Speech Controls Component - Minimal Professional Design
 * 
 * Modern, minimal design for audio settings that integrates
 * with the financial headlines interface
 */

/* TTS control container */
.tts-controls-container {
    background-color: var(--color-background-secondary);
    border-bottom: 1px solid var(--color-border-medium);
    padding: 0;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dark-mode .tts-controls-container {
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* TTS Toggle Button in header - more noticeable design */
.tts-header-toggle {
    position: relative;
    border-radius: 16px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-right: 5px;
    height: 32px;
}

.tts-header-toggle::after {
    content: 'Audio';
    font-size: 12px;
    font-weight: 600;
    margin-left: 5px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.tts-header-toggle svg {
    fill: var(--color-text-primary);
    transition: all 0.2s ease;
    width: 14px;
    height: 14px;
}

.dark-mode .tts-header-toggle {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tts-header-toggle.active {
    background-color: var(--color-brand-primary) !important;
    border-color: var(--color-brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tts-header-toggle:hover {
    background-color: rgba(252, 208, 10, 0.2);
    border-color: rgba(252, 208, 10, 0.3);
    transform: translateY(-1px);
}

.tts-header-toggle.active svg {
    fill: #000000;
}

/* Light mode hover colors */
.tts-header-toggle:hover svg,
.tts-header-toggle:hover::after {
    fill: #000000;
    color: #000000;
}

/* Add focus state to match hover styling */
.tts-header-toggle:focus::after,
.tts-header-toggle:focus-visible::after {
    color: #000000;
}

.dark-mode .tts-header-toggle svg {
    fill: #ffffff;
}

.dark-mode .tts-header-toggle.active {
    background-color: var(--color-brand-primary) !important;
    border-color: var(--color-brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark-mode .tts-header-toggle.active svg,
.dark-mode .tts-header-toggle.active::after {
    fill: #000000 !important;
    color: #000000 !important;
}

.dark-mode .tts-header-toggle:hover {
    background-color: rgba(252, 208, 10, 0.2);
}

/* Dark mode hover colors */
.dark-mode .tts-header-toggle:hover svg,
.dark-mode .tts-header-toggle:hover::after {
    color: #ffffff !important;
    fill: #ffffff !important;
    text-decoration: none;
}

/* Remove underlines on hover for audio button */
.tts-header-toggle,
.tts-header-toggle *,
.tts-header-toggle:hover,
.tts-header-toggle:hover * {
    text-decoration: none !important;
    border-bottom: none !important;
}

.tts-header-toggle::after,
.tts-header-toggle:hover::after {
    text-decoration: none !important;
    border-bottom: none !important;
}

/* Keep text white but no underline in dark mode */
.dark-mode .tts-header-toggle:hover,
.dark-mode .tts-header-toggle:hover::after {
    color: #ffffff !important;
    text-decoration: none !important;
    border-bottom: none !important;
}

/* Pulsing indicator for new headlines when audio is enabled */
@keyframes gentle-pulse {
    0% { box-shadow: 0 0 0 0 rgba(252, 208, 10, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(252, 208, 10, 0); }
    100% { box-shadow: 0 0 0 0 rgba(252, 208, 10, 0); }
}

.tts-header-toggle.has-new-headlines {
    animation: gentle-pulse 2s infinite;
}

/* Title - clean minimal design */
.tts-controls-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
}

.tts-controls-title::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fcd00a'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z'/%3E%3C/svg%3E");
    background-size: contain;
    margin-right: 8px;
}

.dark-mode .tts-controls-title {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Settings form */
.tts-settings-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 16px 24px;
    background-color: var(--color-background-secondary);
}

@media (min-width: 768px) {
    .tts-settings-form {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px 32px;
    }
}

/* Control groups */
.tts-control-group {
    margin-bottom: 0;
    padding-right: 8px;
}

/* Labels */
.tts-control-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--color-text-primary);
    letter-spacing: 0.02em;
    opacity: 0.8;
}

.dark-mode .tts-control-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Range inputs - refined modern styling */
.tts-range-input {
    width: 100%;
    margin-top: 8px;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    border-radius: 4px;
    background: var(--color-border-medium);
    outline: none;
}

.tts-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-brand-primary);
    cursor: pointer;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.tts-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.tts-range-input::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-brand-primary);
    cursor: pointer;
    border: none;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.tts-range-input::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Voice selector - sleek dropdown */
.tts-voice-selector {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--color-border-medium);
    background-color: var(--color-background-primary);
    color: var(--color-text-primary);
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5' viewBox='0 0 10 5'%3E%3Cpath fill='%23999' d='M0 0L5 5L10 0Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

.dark-mode .tts-voice-selector {
    color: #ffffff;
    background-color: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5' viewBox='0 0 10 5'%3E%3Cpath fill='%23ffffff' d='M0 0L5 5L10 0Z'/%3E%3C/svg%3E");
}

/* Fix dropdown options in dark mode */
.dark-mode .tts-voice-selector option,
.dark-mode .tts-voice-selector optgroup {
    background-color: #1e1e1e;
    color: #ffffff;
}

.tts-voice-selector:focus,
.tts-voice-selector:hover {
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 2px rgba(252, 208, 10, 0.15);
}

/* TTS toggle switch - modern minimal design */
.tts-toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.tts-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    margin: 0;
}

.tts-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tts-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.12);
    transition: .2s;
    border-radius: 22px;
}

.dark-mode .tts-toggle-slider {
    background-color: rgba(255, 255, 255, 0.15);
}

.tts-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.tts-toggle input:checked + .tts-toggle-slider {
    background-color: var(--color-brand-primary);
}

.tts-toggle input:focus + .tts-toggle-slider {
    box-shadow: 0 0 0 2px rgba(252, 208, 10, 0.2);
}

.tts-toggle input:checked + .tts-toggle-slider:before {
    transform: translateX(18px);
}

/* Status indicators - refined and minimal */
.tts-status-indicator {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0, 0, 0, 0.02);
}

.dark-mode .tts-status-indicator {
    color: rgba(255, 255, 255, 0.6);
    background-color: rgba(0, 0, 0, 0.15);
    border-top-color: rgba(255, 255, 255, 0.05);
}

.tts-status-indicator span {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Queue status - modern badge */
.tts-queue-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.tts-queue-count {
    background-color: var(--color-brand-primary);
    color: #000;
    border-radius: 12px;
    padding: 2px 8px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
    font-size: 10px;
    line-height: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Reading animation - more subtle pulse */
.tts-reading-animation {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--color-brand-primary);
    border-radius: 50%;
    margin-right: 6px;
    position: relative;
}

.tts-reading-animation:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-brand-primary);
    opacity: 0.6;
    border-radius: 50%;
    animation: ttsPulse 1.5s infinite ease-out;
}

@keyframes ttsPulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { opacity: 0.3; }
    100% { transform: scale(2); opacity: 0; }
}

/* Current text indicator - cleaner display */
.tts-current-text {
    margin: 0;
    padding: 12px 16px;
    background-color: rgba(252, 208, 10, 0.04);
    font-size: 12px;
    line-height: 1.4;
    color: var(--color-text-primary);
    border-left: 2px solid var(--color-brand-primary);
    display: none; /* Hidden by default, shown when active */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
    letter-spacing: 0.01em;
}

.dark-mode .tts-current-text {
    color: rgba(255, 255, 255, 0.9);
    background-color: rgba(252, 208, 10, 0.06);
}

.tts-current-text.active {
    display: block;
}

/* Value display for sliders - more professional */
.tts-value-display {
    font-size: 11px;
    color: var(--color-text-secondary);
    text-align: right;
    margin-left: 6px;
    font-weight: 500;
    opacity: 0.8;
    padding: 1px 4px;
    background: rgba(0,0,0,0.04);
    border-radius: 3px;
    letter-spacing: 0.01em;
}

.dark-mode .tts-value-display {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255,255,255,0.1);
}

/* TTS not supported message */
.tts-not-supported {
    background-color: rgba(248, 215, 218, 0.7);
    color: #721c24;
    padding: 10px 14px;
    border-radius: 4px;
    margin: 10px 16px;
    border-left: 3px solid #f5c6cb;
    font-size: 12px;
    line-height: 1.5;
}

.dark-mode .tts-not-supported {
    background-color: rgba(114, 28, 36, 0.2);
    color: #f8d7da;
    border-left-color: rgba(245, 198, 203, 0.5);
}

/* Responsive styling */
@media (max-width: 576px) {
    .tts-settings-form {
        padding: 12px 14px 16px;
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .tts-controls-title,
    .tts-status-indicator,
    .tts-current-text {
        padding: 10px 14px;
    }
}