/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color System */
    --accent-cyan: #00FFFF;
    --accent-pink: #FF00FF;
    --bg-base: #000000;
    --bg-surface-1: #0A0A0A;
    --bg-surface-2: #141414;
    --text-primary: #E4E4E7;
    --text-secondary: #A1A1AA;
    --text-accent: #00FFFF;
    --success: #00FF7F;
    --warning: #FFD700;
    --error: #FF4136;
    
    /* Spacing (8px Grid) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;
    
    /* Typography */
    --font-heading: 'Teko', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    
    /* Glow Effects */
    --glow-md: 0 0 12px 2px rgba(0, 255, 255, 0.4);
    --glow-lg: 0 0 24px 4px rgba(0, 255, 255, 0.5);
}

body {
    font-family: var(--font-mono);
    background: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
    user-select: none;
}

/* Main Container */
.main-container {
    min-height: 100vh;
    padding: var(--space-md);
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--bg-surface-2);
    margin-bottom: var(--space-lg);
}

.app-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 32px;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.ai-status {
    display: flex;
    align-items: center;
}

.ai-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--success);
}

.ai-indicator.active {
    animation: pulse 2s infinite ease-in-out;
    box-shadow: var(--glow-md);
}

/* DJ Interface */
.dj-interface {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

/* Deck Styles */
.deck {
    background: var(--bg-surface-1);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.deck-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.deck-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: 0.5px;
}

#deckA .deck-title {
    color: var(--accent-cyan);
}

#deckB .deck-title {
    color: var(--accent-pink);
}

.bpm-display {
    text-align: right;
}

.bpm-label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.bpm-value {
    font-size: 16px;
    font-weight: 500;
}

/* Waveform */
.waveform-container {
    position: relative;
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: 100%;
    height: 120px;
}

#waveformA {
    background: linear-gradient(90deg, 
        var(--accent-cyan) 0%, 
        var(--accent-cyan) 50%, 
        var(--text-secondary) 50%, 
        var(--text-secondary) 100%);
}

#waveformB {
    background: linear-gradient(90deg, 
        var(--accent-pink) 0%, 
        var(--accent-pink) 50%, 
        var(--text-secondary) 50%, 
        var(--text-secondary) 100%);
}

.playhead {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--text-accent);
    transition: left 0.1s linear;
}

/* Track Info */
.track-info {
    text-align: center;
}

.track-title {
    font-size: 16px;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}

.track-duration {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Transition Countdown */
.transition-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-xs) 0;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(0, 255, 127, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    animation: countdown-pulse 1s ease-in-out infinite alternate;
}

.countdown-label {
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.countdown-timer {
    font-size: 14px;
    color: var(--success);
    font-weight: 600;
    font-family: var(--font-heading);
    text-shadow: 0 0 4px rgba(0, 255, 127, 0.5);
}

@keyframes countdown-pulse {
    0% {
        opacity: 0.8;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Transport Controls */
.transport-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

.control-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: var(--bg-surface-2);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.control-btn:hover {
    background: var(--bg-surface-1);
    color: var(--text-accent);
}

.control-btn:active,
.control-btn.playing {
    background: var(--accent-cyan);
    color: var(--bg-base);
    box-shadow: var(--glow-md);
}

.play-btn .pause-icon {
    display: none;
}

.control-btn.playing .play-icon {
    display: none;
}

.control-btn.playing .pause-icon {
    display: block;
}

/* EQ Controls */
.eq-controls {
    display: flex;
    justify-content: space-around;
    margin-top: var(--space-md);
}

.eq-knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

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

.eq-slider {
    writing-mode: bt-lr; /* IE */
    -webkit-appearance: slider-vertical; /* WebKit */
    width: 8px;
    height: 100px;
    background: var(--bg-surface-2);
    outline: none;
    border-radius: var(--radius-sm);
}

.eq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-cyan);
    border-radius: 50%;
    cursor: pointer;
}

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

/* Mixer */
.mixer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-surface-1);
    border-radius: var(--radius-md);
    min-width: 250px;
}

.channel-faders {
    display: flex;
    gap: var(--space-xl);
    align-items: center;
}

.channel-fader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.fader-track {
    width: 8px;
    height: 160px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    position: relative;
    cursor: pointer;
}

.fader-handle {
    width: 24px;
    height: 8px;
    background: var(--bg-surface-1);
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-sm);
    position: absolute;
    left: -8px;
    transition: top 0.1s ease-out;
    cursor: grab;
}

.fader-handle:active {
    cursor: grabbing;
}

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

/* Crossfader */
.crossfader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.crossfader-label {
    font-family: var(--font-heading);
    font-size: 14px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.crossfader-track {
    width: 200px;
    height: 48px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    position: relative;
    cursor: pointer;
}

.crossfader-handle {
    width: 24px;
    height: 32px;
    background: var(--bg-surface-1);
    border-top: 3px solid var(--accent-cyan);
    border-radius: var(--radius-sm);
    position: absolute;
    top: 8px;
    left: 88px;
    transition: left 0.15s linear;
    cursor: grab;
    box-shadow: var(--glow-md);
}

.crossfader-handle:active {
    cursor: grabbing;
}

.crossfader-indicators {
    display: flex;
    justify-content: space-between;
    width: 200px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* AI Sync Status */
.ai-mixer-status {
    margin-top: var(--space-md);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.sync-status.active {
    color: var(--success);
    animation: pulse 2s infinite ease-in-out;
}

/* File Browser */
.file-browser {
    background: var(--bg-surface-1);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.browser-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.file-controls {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* Playlist Info */
.playlist-info {
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.playlist-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#playlistCount {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-accent);
}

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

.file-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--text-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease-out;
}

.file-btn:hover {
    background: var(--bg-surface-1);
    color: var(--text-accent);
    border-color: var(--text-accent);
}

.file-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
}

.file-placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--space-xl);
}

.support-text {
    font-size: 12px;
    margin-top: var(--space-sm);
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
    cursor: pointer;
    transition: background 0.2s ease-out;
}

.file-item:hover {
    background: var(--bg-surface-2);
}

.file-item.selected {
    background: rgba(0, 255, 255, 0.1);
    border-left: 2px solid var(--accent-cyan);
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

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

.file-actions {
    display: flex;
    gap: var(--space-xs);
}

.load-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-cyan);
    color: var(--bg-base);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease-out;
}

.load-btn.deck-a:hover {
    background: var(--accent-cyan);
}

.load-btn.deck-b {
    background: var(--accent-pink);
    color: var(--bg-base);
}

.load-btn.deck-b:hover {
    background: var(--accent-pink);
}

.load-btn:hover {
    box-shadow: var(--glow-md);
}

.load-btn.playlist {
    background: var(--success);
    color: var(--bg-base);
}

.load-btn.playlist:hover {
    background: var(--success);
}

/* AI Hint Text */
.ai-hint {
    font-size: 12px;
    color: var(--text-accent);
    margin-top: var(--space-xs);
    font-style: italic;
}

/* Animations */
@keyframes pulse {
    0%, 100% { 
        opacity: 1; 
    }
    50% { 
        opacity: 0.7; 
    }
}

@keyframes glow {
    0%, 100% { 
        box-shadow: var(--glow-md); 
    }
    50% { 
        box-shadow: var(--glow-lg); 
    }
}

/* Responsive Design */
@media (max-width: 1280px) {
    .dj-interface {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .deck {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .mixer {
        order: -1;
        min-width: auto;
    }
    
    .channel-faders {
        flex-direction: column;
        gap: var(--space-md);
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: var(--space-sm);
    }
    
    .app-title {
        font-size: 24px;
    }
    
    .deck-title {
        font-size: 16px;
    }
    
    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 14px;
    }
    
    .eq-slider {
        height: 80px;
    }
    
    .crossfader-track {
        width: 150px;
    }
    
    .crossfader-indicators {
        width: 150px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .ai-indicator.active,
    .sync-status.active {
        animation: none;
    }
}

/* Custom Scrollbar */
.file-list::-webkit-scrollbar {
    width: 8px;
}

.file-list::-webkit-scrollbar-track {
    background: var(--bg-base);
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
}

.file-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --bg-base: #000000;
        --bg-surface-1: #1a1a1a;
        --bg-surface-2: #333333;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --accent-cyan: #00ffff;
        --accent-pink: #ff00ff;
    }
}