/* assets/css/style.css */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    /* --- COLOR PALETTE (PREMIUM DARK) --- */
    --bg-app: #09090b;
    /* Deepest Black */
    --bg-panel: #121214;
    /* Dark Grey for Panels */
    --bg-surface: #18181b;
    /* Slightly lighter for cards/inputs */
    --bg-active: #27272a;
    /* Hover states */

    --border-light: #27272a;
    --border-dark: #000000;

    --primary: #22c55e;
    /* Neon Green - Success/Active */
    --primary-dim: rgba(34, 197, 94, 0.1);
    --secondary: #3b82f6;
    /* Blue - Selection */
    --accent: #f59e0b;
    /* Amber - Solo */
    --danger: #ef4444;
    /* Red - Mute/Record */

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-tertiary: #52525b;

    /* --- DIMENSIONS --- */
    --header-height: 80px;
    --setlist-height: 100px;
    --mixer-height: 380px;
    --fader-height: 220px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    /* App-like feel */
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
    font-size: 13px;
    display: flex;
    flex-direction: column;
}

/* --- LAYOUT GRID --- */
.app-layout {
    display: grid;
    grid-template-rows: var(--header-height) var(--setlist-height) 1fr var(--mixer-height);
    height: 100%;
    width: 100%;
}

/* --- 1. TOP BAR --- */
.top-bar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    align-items: center;
    padding: 0 24px;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.left-section,
.right-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.center-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.right-section {
    justify-content: flex-end;
}

/* Song Info */
.song-info {
    display: flex;
    flex-direction: column;
}

.song-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.song-artist {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Transport Display */
.transport-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.time-total {
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.time-sep {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Transport Controls */
.transport-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.btn-control {
    background: #27272a;
    border: none;
    border-radius: 6px;
    /* Squircle */
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-control:hover {
    background: #3f3f46;
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-control:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-control.sm {
    width: 36px;
    height: 32px;
}

.btn-control.md {
    width: 44px;
    height: 36px;
}

.btn-control.lg {
    width: 60px;
    height: 44px;
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 15px var(--primary-dim);
}

.btn-control.lg:hover {
    background: #4ade80;
    /* Brighter Green */
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.btn-control.active {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* BPM & Actions */
.bpm-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.bpm-box:hover {
    border-color: var(--text-secondary);
}

.bpm-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-tertiary);
}

.bpm-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.btn-action {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-action:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
}

.btn-action.icon-only {
    padding: 8px;
}

/* --- 2. SETLIST RAIL --- */
.setlist-rail {
    background: #0d0d0e;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
    overflow-x: auto;
}

.setlist-rail::-webkit-scrollbar {
    height: 4px;
}

.setlist-rail::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

.song-card {
    background: var(--bg-panel);
    border: 1px solid #27272a;
    border-radius: 6px;
    min-width: 140px;
    max-width: 180px;
    height: 70px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.song-card:hover {
    background: #202022;
    transform: translateY(-2px);
}

.song-card.active {
    background: linear-gradient(135deg, #18181b 0%, #101012 100%);
    border: 1px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.song-card.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
    border-radius: 6px 0 0 6px;
}

.add-song-btn-rail {
    width: 50px;
    height: 70px;
    border: 1px dashed #333;
    background: transparent;
    color: #444;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.add-song-btn-rail:hover {
    border-color: #666;
    color: #888;
}

/* --- 3. WORKSPACE (WAVEFORM) --- */
.workspace {
    position: relative;
    background: #050505;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.timeline-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    /* Javascript controls position */
    left: 0;
    z-index: 10;
}

.playhead::after {
    /* Triangle Cap */
    content: '';
    position: absolute;
    top: 0;
    left: -5px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid #fff;
}

/* --- 4. MIXER PANEL --- */
.mixer-panel {
    background: var(--bg-panel);
    border-top: 1px solid #333;
    display: flex;
    height: var(--mixer-height);
    padding: 16px 0 16px 16px;
    gap: 16px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    z-index: 30;
}

.mixer-scroll-area {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    /* For scrollbar */
    padding-right: 16px;
}

.mixer-scroll-area::-webkit-scrollbar {
    height: 8px;
    background: #000;
}

.mixer-scroll-area::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.master-section {
    width: 110px;
    /* Fixed width */
    border-left: 1px solid #333;
    background: #0e0e10;
    display: flex;
    justify-content: center;
    padding-bottom: 8px;
    box-shadow: -10px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* CHANNEL STRIP */
.channel-strip {
    width: 70px;
    background: #1c1c1f;
    border: 1px solid #27272a;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    padding: 8px 4px;
    flex-shrink: 0;
    position: relative;
    transition: background 0.1s;
}

.channel-strip:hover {
    background: #222226;
    border-color: #3f3f46;
}

.channel-strip.master {
    width: 90px;
    background: #18181b;
    border: 1px solid #333;
    height: 100%;
}

/* Strip Header */
.strip-header {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.strip-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Buttons Area */
.strip-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px;
}

.btn-mute,
.btn-solo {
    width: 32px;
    height: 24px;
    font-size: 9px;
    font-weight: 800;
    border: 1px solid #333;
    border-radius: 2px;
    background: #27272a;
    color: #71717a;
    cursor: pointer;
    transition: 0.1s;
}

.btn-mute:hover,
.btn-solo:hover {
    color: #eee;
    background: #333;
}

.btn-mute.active {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.btn-solo.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Fader Track */
.fader-track {
    flex: 1;
    position: relative;
    background: #121212;
    border-radius: 4px;
    margin: 0 10px 8px 10px;
    border: 1px solid #000;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
}

/* The Line in the middle */
.fader-track::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #222;
    z-index: 0;
}

/* Vertical Input Range Hack */
.fader-input {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    position: absolute;
    /* Center and rotate */
    width: 200px;
    /* Use a fixed large width to become height */
    height: 40px;
    /* Hitbox width */
    transform-origin: center;
    transform: rotate(-90deg);
    top: 50%;
    left: 50%;
    margin-left: -100px;
    /* Half width */
    margin-top: -20px;
    /* Half height */
    cursor: grab;
    z-index: 10;
}

.fader-input:active {
    cursor: grabbing;
}

.fader-input:focus {
    outline: none;
}

/* Track (Invisible) */
.fader-input::-webkit-slider-runnable-track {
    width: 100%;
    height: 40px;
    background: transparent;
}

/* Thumb (The Fader Cap) */
.fader-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 38px;
    /* Width visually */
    width: 60px;
    /* Height visually */
    background: linear-gradient(to right, #3f3f46, #27272a);
    border: 1px solid #000;
    border-radius: 3px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin-top: 0;
    /* Center */
}

/* Value Display */
.strip-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: #555;
    text-align: center;
    margin-bottom: 4px;
}

/* --- OVERLAY --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    :root {
        --header-height: 120px;
        --mixer-height: 300px;
    }

    .top-bar {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 10px;
        gap: 10px;
    }

    .left-section,
    .right-section,
    .center-section {
        justify-content: center;
        width: 100%;
    }

    .transport-controls button {
        padding: 12px;
    }

    .app-layout {
        grid-template-rows: var(--header-height) var(--setlist-height) 1fr var(--mixer-height);
    }
}