/**
 * Frontend TTS Audio Player Styles
 */

.wp-tts-audio-player {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 20px 5px 20px;
    margin: 2px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: relative;
}

.wp-tts-player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.wp-tts-player-header {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    gap: 8px;
}

.wp-tts-icon {
    font-size: 18px;
    margin-right: 4px;
}

/* Speed Control */
.wp-tts-speed-control {
    position: relative;
    flex-shrink: 0;
}

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

.wp-tts-speed-btn:hover {
    background: #005a87;
}

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

.wp-tts-speed-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 4px;
    min-width: 80px;
}

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

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

.wp-tts-speed-menu button.active {
    background: #007cba;
    color: white;
}

.wp-tts-headphones {
    margin-right: 6px;
}

.wp-tts-label {
    font-weight: 600;
    color: #333;
    flex-grow: 1;
    font-size: 14px;
}

.wp-tts-provider {
    background: #007cba;
    color: white;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wp-tts-player-controls {
    margin: 2px 0;
}

.wp-tts-audio-element {
    width: 100%;
    height: 30px;
    outline: none;
    border-radius: 4px;
}

.wp-tts-audio-element:focus {
    box-shadow: 0 0 0 2px #007cba;
}

.wp-tts-player-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.wp-tts-download-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    padding: 2px 4px;
    border-radius: 3px;
}

.wp-tts-download-link:hover {
    color: #005a87;
    text-decoration: none;
    background: rgba(0, 124, 186, 0.1);
}

.wp-tts-download-link .dashicons {
    font-size: 14px;
    width: 14px;
    height: 10px;
}

.wp-tts-generated-date {
    font-style: italic;
    opacity: 0.8;
}

/* Loading state */
.wp-tts-loading .wp-tts-audio-element {
    opacity: 0.6;
    pointer-events: none;
}

.wp-tts-loading::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #007cba;
    border-top-color: transparent;
    border-radius: 50%;
    animation: wp-tts-spin 1s linear infinite;
}

@keyframes wp-tts-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error state */
.wp-tts-error {
    border-color: #d63638;
    background: #ffebee;
}

.wp-tts-error .wp-tts-player-header {
    color: #d63638;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .wp-tts-audio-player {
        padding: 8px;
        margin: 6px 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    
    /* Hide all metadata and extra elements on mobile - show only audio player */
    .wp-tts-player-meta,
    .wp-tts-icon,
    .wp-tts-label,
    .wp-tts-provider,
    .wp-tts-generated-date,
    .wp-tts-download {
        display: none !important;
    }
    
    .wp-tts-player-controls {
        margin: 0;
    }
    
    .wp-tts-audio-element {
        width: 100%;
        height: 35px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .wp-tts-audio-player {
        background: #2c2c2c;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .wp-tts-label {
        color: #e0e0e0;
    }
    
    .wp-tts-player-meta {
        color: #b0b0b0;
    }
    
    .wp-tts-download-link {
        color: #4fc3f7;
    }
    
    .wp-tts-download-link:hover {
        color: #29b6f6;
        background: rgba(79, 195, 247, 0.1);
    }
    
    .wp-tts-error {
        border-color: #f28b82;
        background: #3c1b1b;
    }
    
    .wp-tts-error .wp-tts-player-header {
        color: #f28b82;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .wp-tts-audio-player {
        border-width: 2px;
        border-color: #000;
    }
    
    .wp-tts-provider {
        background: #000;
        color: #fff;
    }
    
    .wp-tts-download-link {
        color: #0000ee;
        text-decoration: underline;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .wp-tts-download-link {
        transition: none;
    }
    
    @keyframes wp-tts-spin {
        to {
            transform: none;
        }
    }
}

/* Accessibility improvements */
.wp-tts-audio-player:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.wp-tts-audio-element:focus {
    outline: 2px solid #007cba;
    outline-offset: 1px;
}

/* Print styles */
@media print {
    .wp-tts-audio-player {
        display: none;
    }
}

/* WordPress admin bar adjustments */
.admin-bar .wp-tts-audio-player {
    /* Add any specific styles needed when admin bar is present */
}

/* Integration with common themes */
.wp-tts-audio-player {
    clear: both;
}

/* Ensure proper spacing in different content contexts */
.single .wp-tts-audio-player,
.page .wp-tts-audio-player {
    margin-top: 12px;
    margin-bottom: 6px;
    margin-left: 5%;
    margin-right: 5%;
}
