/**
 * Enhanced SesoLibre TTS Player Styles
 * Enhanced version with featured image support and CSS customization
 */

.tts-enhanced-sesolibre-player {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background-color, #f8f9fa);
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    margin: 20px 0;
    overflow: visible;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    color: var(--text-color, #333333);
}

.tts-enhanced-sesolibre-player:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* Compact Layout */
.tts-enhanced-compact-controls {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 12px;
}

.tts-featured-image-compact {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tts-featured-image-compact img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.tts-enhanced-sesolibre-player:hover .tts-featured-image-compact img {
    transform: scale(1.05);
}

.tts-main-controls-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.tts-progress-area {
    flex: 1;
    min-width: 0;
}

.tts-article-title-above {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color, #333);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}

.tts-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.tts-volume-controls-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Play/Pause Button */
.tts-play-pause {
    background: var(--play-icon-color, #007cba);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.tts-play-pause:hover {
    background: var(--pause-icon-color, #005a87);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.4);
}

.tts-play-pause:active {
    transform: scale(0.95);
}

.tts-play-pause svg {
    width: 20px;
    height: 20px;
}

.tts-play-pause.playing .play-icon {
    display: none;
}

.tts-play-pause.playing .pause-icon {
    display: block !important;
}

/* Progress Container */
.tts-progress-container {
    flex: 1;
    min-width: 0;
}

.tts-phase-indicators {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.phase-label {
    color: #adb5bd;
    transition: color 0.2s ease;
}

.phase-label.active {
    color: var(--progress-color, #007cba);
}

/* Progress Bar */
.tts-progress {
    position: relative;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
}

.tts-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--progress-color, #007cba), #17a2b8);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s ease;
    position: relative;
}

.tts-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.tts-progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--progress-color, #007cba);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease;
    left: 0%;
}

.tts-progress:hover .tts-progress-handle {
    opacity: 1;
}

/* Time Display */
.tts-time-display {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 80px;
}

.tts-separator {
    opacity: 0.5;
}

/* Volume Controls Compact */
.tts-volume-control-compact {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tts-volume-control-compact .volume-icon {
    width: 16px;
    height: 16px;
    color: #6c757d;
    flex-shrink: 0;
}

.tts-volume-slider-compact {
    width: 60px;
    height: 3px;
    background: #e9ecef;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.tts-volume-slider-compact::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--progress-color, #007cba);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.tts-volume-slider-compact::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 124, 186, 0.4);
}

.tts-volume-slider-compact::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--progress-color, #007cba);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Speed Control Compact */
.tts-speed-control-compact {
    position: relative;
}

.tts-speed-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tts-speed-btn:hover {
    background: #f8f9fa;
    color: var(--progress-color, #007cba);
}

.tts-speed-btn svg {
    width: 16px;
    height: 16px;
}

.tts-speed-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    margin-top: 4px;
    min-width: 60px;
}

.tts-speed-menu button {
    display: block;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: center;
}

.tts-speed-menu button:hover {
    background: #f8f9fa;
}

.tts-speed-menu button.active {
    background: var(--progress-color, #007cba);
    color: white;
}

.tts-speed-menu button:first-child {
    border-radius: 6px 6px 0 0;
}

.tts-speed-menu button:last-child {
    border-radius: 0 0 6px 6px;
}

/* Compact Info Bar */
.tts-compact-info-bar {
    padding: 8px 12px;
    border-top: 1px solid #e9ecef;
    background: rgba(248, 249, 250, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #6c757d;
    overflow: hidden;
}

.tts-info-compact {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.tts-info-separator {
    color: #adb5bd;
    font-weight: normal;
}

.tts-download-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--progress-color, #007cba);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.tts-download-compact:hover {
    opacity: 0.8;
}

.tts-download-compact svg {
    width: 12px;
    height: 12px;
}

/* Status Container */
.tts-status-container {
    position: relative;
    min-height: 20px;
}

.tts-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(248, 249, 250, 0.95);
    font-size: 12px;
    color: #6c757d;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid var(--progress-color, #007cba);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.tts-error-container {
    padding: 12px 16px;
    background: #fff2f2;
    color: #d63384;
    font-size: 12px;
    border-top: 1px solid #f5c6cb;
    display: none;
}

.tts-error-container.show {
    display: block;
}

/* Custom Audio Notice */
.tts-custom-audio-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
    margin: 8px 0 0 0;
    padding: 8px 12px;
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 6px;
    font-style: italic;
}

.tts-custom-audio-notice svg {
    width: 14px;
    height: 14px;
    color: #0066cc;
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tts-enhanced-compact-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .tts-volume-controls-compact {
        order: 3;
        width: 100%;
        justify-content: center;
        gap: 16px;
        padding-top: 8px;
        border-top: 1px solid #e9ecef;
    }
    
    .tts-volume-control-compact .volume-icon {
        width: 14px;
        height: 14px;
    }
    
    .tts-volume-slider-compact {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .tts-enhanced-sesolibre-player {
        margin: 12px 0;
        border-radius: 8px;
    }
    
    .tts-enhanced-compact-controls {
        padding: 10px;
        gap: 6px;
    }
    
    .tts-featured-image-compact {
        width: 40px;
        height: 40px;
    }
    
    .tts-play-pause {
        width: 40px;
        height: 40px;
    }
    
    .tts-play-pause svg {
        width: 16px;
        height: 16px;
    }
    
    .tts-phase-indicators {
        font-size: 9px;
        gap: 4px;
    }
    
    .tts-compact-info-bar {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .tts-volume-control-compact .volume-icon {
        width: 12px;
        height: 12px;
    }
    
    .tts-volume-slider-compact {
        width: 60px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .tts-enhanced-sesolibre-player {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .tts-enhanced-header {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-bottom-color: #4a5568;
    }
    
    .tts-article-title {
        color: #f7fafc;
    }
    
    .tts-branding,
    .tts-branding-only {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-bottom-color: #4a5568;
        color: #a0aec0;
    }
    
    .tts-progress {
        background: #4a5568;
    }
    
    .tts-volume-controls {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .tts-volume-slider {
        background: #4a5568;
    }
    
    .tts-enhanced-info-bar {
        background: #1a202c;
        border-top-color: #4a5568;
    }
    
    .tts-info-item {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .info-value {
        color: #f7fafc;
    }
    
    .tts-loading {
        background: rgba(26, 32, 44, 0.95);
        color: #a0aec0;
    }
    
    .loading-spinner {
        border-color: #4a5568;
        border-top-color: var(--progress-color, #007cba);
    }
    
    .tts-custom-audio-notice {
        background: #1a365d;
        border-color: #2c5282;
        color: #bee3f8;
    }
    
    .tts-custom-audio-notice svg {
        color: #63b3ed;
    }
}