/**
 * Web Spectrum Analyzer Styles
 * Dark theme optimized for audio visualization
 */

/* CSS Reset for analyzer container */
.spectrum-analyzer,
.spectrum-analyzer *,
.spectrum-analyzer *::before,
.spectrum-analyzer *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main container */
.spectrum-analyzer {
    --sa-bg-primary: #0a0a0a;
    --sa-bg-secondary: #141414;
    --sa-bg-tertiary: #1a1a1a;
    --sa-border-color: #2a2a2a;
    --sa-text-primary: #e0e0e0;
    --sa-text-secondary: #888;
    --sa-accent-primary: #00ff88;
    --sa-accent-secondary: #0088ff;
    --sa-accent-warning: #ffaa00;
    --sa-accent-danger: #ff4444;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    color: var(--sa-text-primary);
    background: var(--sa-bg-primary);
    border: 1px solid var(--sa-border-color);
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Controls bar */
.sa-controls {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: var(--sa-bg-secondary);
    border-bottom: 1px solid var(--sa-border-color);
    align-items: center;
}

.sa-control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sa-control-group label {
    font-size: 11px;
    color: var(--sa-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Input buttons */
.sa-input-buttons {
    display: flex;
    gap: 8px;
}

/* Buttons */
.sa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sa-text-primary);
    background: var(--sa-bg-tertiary);
    border: 1px solid var(--sa-border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sa-btn:hover {
    background: #252525;
    border-color: #3a3a3a;
}

.sa-btn:active {
    transform: scale(0.98);
}

.sa-btn.active {
    background: var(--sa-accent-primary);
    color: #000;
    border-color: var(--sa-accent-primary);
}

.sa-btn.active:hover {
    background: #00dd77;
}

.sa-icon {
    font-size: 16px;
}

/* Select dropdowns */
.sa-select {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--sa-text-primary);
    background: var(--sa-bg-tertiary);
    border: 1px solid var(--sa-border-color);
    border-radius: 6px;
    cursor: pointer;
    min-width: 140px;
}

.sa-select:hover {
    border-color: #3a3a3a;
}

.sa-select:focus {
    outline: none;
    border-color: var(--sa-accent-primary);
}

/* Sliders */
.sa-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: var(--sa-bg-tertiary);
    border-radius: 3px;
    cursor: pointer;
}

.sa-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--sa-accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.sa-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.sa-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--sa-accent-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Status indicator */
.sa-status {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    margin-left: auto;
}

.sa-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--sa-text-secondary);
}

.sa-status-indicator.sa-status-active {
    background: var(--sa-accent-primary);
    box-shadow: 0 0 10px var(--sa-accent-primary);
    animation: pulse 2s infinite;
}

.sa-status-indicator.sa-status-pending {
    background: var(--sa-accent-warning);
    animation: blink 1s infinite;
}

.sa-status-indicator.sa-status-error {
    background: var(--sa-accent-danger);
}

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

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

.sa-status-text {
    font-size: 12px;
    color: var(--sa-text-secondary);
}

/* Display area */
.sa-display {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    background: var(--sa-bg-primary);
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* Spectrum container (top 25%) */
.sa-spectrum-container {
    flex: 0 0 25%;
    position: relative;
    border-bottom: 1px solid var(--sa-accent-primary);
    box-shadow: 0 2px 10px rgba(0, 255, 136, 0.2);
    min-height: 0;
    overflow: hidden;
}

.sa-spectrum-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Waterfall container (bottom 75%) */
.sa-waterfall-container {
    flex: 1 1 0;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.sa-waterfall-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Frequency axis */
.sa-freq-axis {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
    pointer-events: none;
}

.sa-spectrum-axis {
    bottom: auto;
    top: 100%;
    background: transparent;
    z-index: 10;
}

.sa-freq-tick {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sa-freq-tick::before {
    content: '';
    width: 1px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
}

.sa-freq-label {
    font-size: 10px;
    color: var(--sa-text-secondary);
    white-space: nowrap;
    margin-top: 2px;
}

/* Audio controls */
.sa-audio-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--sa-bg-secondary);
    border-top: 1px solid var(--sa-border-color);
}

.sa-audio-time {
    font-size: 12px;
    font-family: monospace;
    color: var(--sa-text-secondary);
    min-width: 100px;
}

.sa-audio-controls .sa-slider {
    flex: 1;
    max-width: 300px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sa-controls {
        gap: 10px;
        padding: 10px;
    }

    .sa-control-group label {
        font-size: 10px;
    }

    .sa-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .sa-select {
        min-width: 100px;
        font-size: 12px;
    }

    .sa-slider {
        width: 80px;
    }

    .sa-freq-label {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .sa-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .sa-control-group {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .sa-status {
        margin-left: 0;
        justify-content: center;
    }

    .sa-input-buttons {
        flex: 1;
    }

    .sa-btn {
        flex: 1;
        justify-content: center;
    }
}

/* Fullscreen mode */
.spectrum-analyzer.sa-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    border-radius: 0;
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
    .spectrum-analyzer {
        --sa-border-color: #444;
        --sa-text-secondary: #aaa;
    }

    .sa-btn {
        border-width: 2px;
    }
}

/* Print styles - hide when printing */
@media print {
    .spectrum-analyzer {
        display: none !important;
    }
}

/* WordPress specific overrides */
.wpsa-container {
    width: 100%;
    max-width: 100%;
}

.wpsa-container .spectrum-analyzer {
    height: 100%;
}
