/* AudioWave.app Styles */

:root {
    --bg-dark: #0a0a0f;
    --bg-panel: rgba(15, 15, 25, 0.85);
    --accent: #00ffcc;
    --accent-dim: #00ccaa;
    --text: #e0e0e8;
    --text-dim: #a0a0a8;
    --border: rgba(0, 255, 204, 0.2);
    --shadow: rgba(0, 255, 204, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    position: fixed;
    -webkit-font-smoothing: antialiased;
}

/* Canvas */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#visualizer-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(135deg, #0a0a0f 0%, #15151f 100%);
}

/* UI Overlay */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Top Bar */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(180deg, var(--bg-panel) 0%, transparent 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: all;
    transition: opacity 0.3s ease;
}

body.hide-ui #top-bar {
    opacity: 0;
    pointer-events: none;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent);
}

/* Audio Source Buttons */
.audio-source-buttons {
    display: flex;
    gap: 8px;
}

.source-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.source-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

/* Radio Panel */
.radio-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 380px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    pointer-events: all;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 20;
}

.radio-panel.visible {
    display: block;
}

body.hide-ui .radio-panel {
    display: none;
}

.radio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.radio-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.radio-close {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.radio-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

/* Location Selectors */
.location-selectors {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selector-group label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 600;
}

.styled-select {
    position: relative;
}

.styled-select select {
    width: 100%;
    padding: 10px 36px 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s ease;
}

.styled-select select:hover {
    border-color: var(--accent-dim);
}

.styled-select select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--shadow);
}

.styled-select select option {
    background: #1a1a2e;
    color: var(--text);
    padding: 8px;
}

.styled-select::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--accent);
    pointer-events: none;
}

.genre-row {
    display: flex;
    gap: 12px;
}

.genre-row .selector-group {
    flex: 1;
}

/* Station Info */
.station-info {
    text-align: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 16px;
    min-height: 60px;
}

#station-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#station-genre {
    font-size: 11px;
    color: var(--accent-dim);
}

/* Radio Controls */
.radio-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.radio-nav-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.radio-nav-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.radio-play-btn {
    width: 60px;
    height: 60px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: var(--bg-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 0 20px var(--shadow);
}

.radio-play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px var(--accent);
}

.radio-play-btn.playing {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    border: 2px solid var(--accent);
}

/* Radio Volume */
.radio-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    margin-bottom: 16px;
}

.radio-volume svg {
    color: var(--text-dim);
    flex-shrink: 0;
}

#radio-volume {
    flex: 1;
}

/* Station List */
.station-list-section {
    margin-bottom: 16px;
}

.station-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.station-list-header span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.refresh-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

.refresh-btn.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.station-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.station-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.station-item:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--border);
}

.station-item.active {
    background: rgba(0, 255, 204, 0.15);
    border-color: var(--accent);
}

.station-item-name {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.station-item-freq {
    font-size: 10px;
    color: var(--accent-dim);
    flex-shrink: 0;
}

.loading-message,
.error-message,
.no-stations {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
}

.error-message {
    color: #ff6b6b;
}

/* Custom URL */
.custom-url-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.control-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
    font-weight: 600;
}

.custom-url-input {
    display: flex;
    gap: 8px;
}

.custom-url-input input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.custom-url-input input:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-url-input button {
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: var(--bg-dark);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-url-input button:hover {
    box-shadow: 0 0 15px var(--shadow);
}

/* Control Panel */
#control-panel {
    position: absolute;
    left: 20px;
    bottom: 80px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 320px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    pointer-events: all;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

body.hide-ui #control-panel {
    width: 44px;
    height: 44px;
    padding: 0;
    grid-template-columns: 1fr;
    gap: 0;
    overflow: visible;
    cursor: pointer;
    border-radius: 8px;
}

body.hide-ui #control-panel > *:not(.panel-icon) {
    display: none;
}

.panel-icon {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
}

body.hide-ui .panel-icon {
    display: flex;
}

body.hide-ui #control-panel:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--accent);
    transform: scale(1.05);
}

.control-section {
    margin-bottom: 0;
}

.control-section.full-width,
.control-section.patterns {
    grid-column: 1 / -1;
}

/* Pattern Grid */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.pattern-btn {
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.pattern-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--border);
    color: var(--text);
}

.pattern-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
    font-weight: 600;
}

/* Sliders */
.slider-container {
    margin-bottom: 10px;
}

.slider-container:last-child {
    margin-bottom: 0;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.slider-label {
    font-size: 10px;
    color: var(--text);
}

.slider-value {
    font-size: 10px;
    color: var(--accent);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px var(--shadow);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--accent);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px var(--shadow);
}

/* Color Mode */
.color-mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.color-mode-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-mode-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--border);
}

.color-mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
    font-weight: 600;
}

/* Status Bar */
#status-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-dim);
    pointer-events: all;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.hide-ui #status-bar {
    opacity: 0;
    pointer-events: none;
}

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

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

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

/* Bottom Buttons */
#fullscreen-toggle,
#help-toggle {
    position: absolute;
    bottom: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: all;
    color: var(--text-dim);
}

#fullscreen-toggle {
    right: 20px;
}

#help-toggle {
    right: 74px;
}

body.hide-ui #fullscreen-toggle,
body.hide-ui #help-toggle {
    opacity: 0;
    pointer-events: none;
}

#fullscreen-toggle:hover,
#help-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--shadow);
}

/* Help Overlay */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.help-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.help-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    position: relative;
}

.help-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

.help-content h2 {
    color: var(--accent);
    font-size: 20px;
    margin-bottom: 20px;
}

.help-section {
    margin-bottom: 24px;
}

.help-section h3 {
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.help-section p {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.help-section p strong {
    color: var(--accent);
}

.shortcut-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.shortcut kbd {
    background: rgba(0, 255, 204, 0.1);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    min-width: 28px;
    text-align: center;
}

/* Presets */
.presets-section {
    margin-top: 8px;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.preset-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--border);
}

.preset-btn.has-preset {
    border-color: var(--accent-dim);
    color: var(--accent);
}

.preset-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

.hide-ui-btn {
    grid-column: 1 / -1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hide-ui-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #top-bar {
        padding: 15px;
    }

    .logo {
        font-size: 14px;
    }

    .audio-source-buttons {
        gap: 4px;
    }

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

    .radio-panel {
        top: 60px;
        width: calc(100% - 24px);
        padding: 16px;
    }

    #control-panel {
        left: 50%;
        bottom: 70px;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        max-width: 360px;
        padding: 16px;
        max-height: calc(100vh - 160px);
    }

    body.hide-ui #control-panel {
        transform: translateX(-50%) translateY(20px);
    }

    .pattern-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .pattern-btn {
        padding: 8px 4px;
        font-size: 8px;
    }

    #status-bar {
        bottom: 15px;
        padding: 8px 16px;
        font-size: 10px;
    }

    #fullscreen-toggle {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }

    #help-toggle {
        bottom: 15px;
        right: 65px;
        width: 40px;
        height: 40px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    #control-panel {
        width: calc(100% - 16px);
        padding: 12px;
        gap: 12px;
    }

    .pattern-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .control-section {
        grid-column: 1 / -1;
    }

    .genre-row {
        flex-direction: column;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .pattern-btn,
    .color-mode-btn,
    .source-btn,
    .hide-ui-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Reduced motion accessibility support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .refresh-btn.loading {
        animation: none;
    }

    .status-indicator.active {
        animation: none;
    }

    .radio-play-btn:hover,
    body.hide-ui #control-panel:hover {
        transform: none;
    }
}
