/* ═══════════════════════════════════════════════════════════════
   SpectroSampler — Premium Dark Theme
   DAW-inspired design with glassmorphism, gradients, micro-animations
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Core palette */
    --bg-deepest: #07070e;
    --bg-deep: #0c0c18;
    --bg-surface: #111122;
    --bg-panel: #141428;
    --bg-elevated: #1a1a36;
    --bg-hover: #222244;

    /* Accent colors */
    --accent-primary: #7c4dff;
    --accent-secondary: #00e5ff;
    --accent-tertiary: #ff4081;
    --accent-warm: #ffab40;
    --accent-green: #00ff88;

    /* Text */
    --text-primary: #e8e8f0;
    --text-secondary: #9898b4;
    --text-dim: #5a5a78;

    /* Borders & Glow */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(124, 77, 255, 0.3);
    --glow-primary: rgba(124, 77, 255, 0.15);
    --glow-secondary: rgba(0, 229, 255, 0.1);

    /* Sizing */
    --panel-width: 260px;
    --transport-height: 52px;
    --toolbar-height: 44px;
    --status-height: 28px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-normal: 200ms ease;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-deepest);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.25);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 77, 255, 0.45);
}

/* ── Transport Bar ─────────────────────────────────────────── */
#transport-bar {
    height: var(--transport-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: linear-gradient(180deg, #16162e, #0e0e1e);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    z-index: 100;
    position: relative;
}

.transport-left,
.transport-center,
.transport-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.5px;
    user-select: none;
}

.logo-icon {
    font-size: 20px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {

    0%,
    100% {
        opacity: 0.9;
        filter: brightness(1);
    }

    50% {
        opacity: 1;
        filter: brightness(1.3);
    }
}

.logo-text {
    color: var(--text-primary);
}

.logo-accent {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.transport-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    min-width: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.transport-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-accent);
    box-shadow: 0 0 8px var(--glow-primary);
}

.transport-btn.active {
    background: rgba(124, 77, 255, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    box-shadow: 0 0 12px var(--glow-primary);
}

.transport-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Volume control */
.volume-control {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    border-left: 1px solid var(--border-subtle);
    margin-left: 4px;
}

.volume-icon {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: opacity var(--transition-fast);
}

.volume-icon:hover {
    opacity: 0.7;
}

.volume-control input[type="range"] {
    width: 70px;
}

.volume-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
}

.play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent-primary), #5c2dbf);
    border: 2px solid rgba(124, 77, 255, 0.5);
    box-shadow: 0 0 20px var(--glow-primary);
}

.play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 28px rgba(124, 77, 255, 0.4);
}

.play-btn.active {
    background: linear-gradient(135deg, var(--accent-secondary), #00b0cc);
    border-color: rgba(0, 229, 255, 0.5);
    box-shadow: 0 0 28px var(--glow-secondary);
}

.resynth-btn {
    background: linear-gradient(135deg, #1a3a1a, #0a2a0a);
    border-color: rgba(0, 255, 136, 0.2);
    font-size: 12px;
    padding: 0 12px;
}

.resynth-btn:hover {
    border-color: var(--accent-green);
    box-shadow: 0 0 16px rgba(0, 255, 136, 0.15);
}

.time-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    padding: 0 8px;
    min-width: 160px;
}

.file-name {
    color: var(--text-dim);
    font-size: 12px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── App Body Layout ───────────────────────────────────────── */
#app-body {
    display: flex;
    height: calc(100vh - var(--transport-height) - var(--status-height));
}

/* ── Panels ────────────────────────────────────────────────── */
.panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#right-panel {
    border-right: none;
    border-left: 1px solid var(--border-subtle);
}

.panel-section {
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-title::before {
    content: '';
    width: 3px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* ── Parameter Controls ────────────────────────────────────── */
.param-group {
    margin-bottom: 8px;
}

.param-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.param-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--accent-secondary);
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: border-color var(--transition-fast);
}

.param-val:hover {
    border-bottom-color: var(--accent-secondary);
}

.param-val-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--accent-secondary);
    background: var(--bg-deep);
    border: 1px solid var(--accent-primary);
    border-radius: 3px;
    padding: 0 4px;
    width: 60px;
    outline: none;
    box-shadow: 0 0 6px var(--glow-primary);
}

/* Range slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-deep);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-deepest);
    box-shadow: 0 0 8px var(--glow-primary);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 14px rgba(124, 77, 255, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-deepest);
    box-shadow: 0 0 8px var(--glow-primary);
    cursor: pointer;
}

/* Select */
.param-select,
.effect-select {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-deep);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.param-select:hover,
.effect-select:hover {
    border-color: var(--border-accent);
}

.param-select:focus,
.effect-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--glow-primary);
}

/* Buttons */
.small-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.small-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.small-btn.accent {
    background: rgba(124, 77, 255, 0.15);
    border-color: rgba(124, 77, 255, 0.3);
    color: var(--accent-primary);
}

.small-btn.accent:hover {
    background: rgba(124, 77, 255, 0.25);
    box-shadow: 0 0 10px var(--glow-primary);
}

/* ── Add Effect Row ────────────────────────────────────────── */
.add-effect-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.add-effect-row .effect-select {
    flex: 1;
}

/* ── Center Area ───────────────────────────────────────────── */
#center-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Toolbar ───────────────────────────────────────────────── */
#toolbar {
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    padding: 0 8px;
    background: linear-gradient(180deg, var(--bg-surface), var(--bg-deep));
    border-bottom: 1px solid var(--border-subtle);
    gap: 4px;
    overflow-x: auto;
}

.tool-group {
    display: flex;
    gap: 2px;
}

.tool-divider {
    width: 1px;
    height: 28px;
    background: var(--border-subtle);
    margin: 0 6px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 1px;
}

.tool-icon {
    font-size: 14px;
    line-height: 1;
}

.tool-label {
    font-size: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.tool-btn.active {
    background: rgba(124, 77, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    box-shadow: inset 0 0 12px var(--glow-primary);
}

.tool-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-params {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-subtle);
}

.tool-params label {
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
}

.tool-params input[type="range"] {
    width: 80px;
}

/* ── Main View (Canvases) ──────────────────────────────────── */
#main-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-deepest);
    overflow: hidden;
}

#main-view.drag-over {
    outline: 2px dashed var(--accent-primary);
    outline-offset: -4px;
}

#main-view.drag-over::after {
    content: '🎵 Drop WAV here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: var(--accent-primary);
    background: rgba(124, 77, 255, 0.1);
    padding: 20px 40px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--accent-primary);
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.canvas-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

.canvas-container.waveform {
    flex: 0 0 100px;
    min-height: 100px;
    border-top: 1px solid var(--border-subtle);
}

.canvas-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* ── List Containers (Regions, Layers) ─────────────────────── */
.list-container {
    max-height: 400px;
    overflow-y: auto;
}

.empty-hint {
    color: var(--text-dim);
    font-size: 11px;
    font-style: italic;
    padding: 8px;
    text-align: center;
}

/* ── Region Items ──────────────────────────────────────────── */
.region-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 11px;
}

.region-item:hover {
    background: var(--bg-hover);
}

.region-item.selected {
    background: rgba(0, 229, 255, 0.08);
    outline: 1px solid rgba(0, 229, 255, 0.2);
}

.region-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.region-name {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.region-time {
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
}

.region-play-btn,
.region-retrigger-btn,
.region-remove-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.region-play-btn:hover {
    color: var(--accent-green);
}

.region-retrigger-btn:hover {
    color: var(--accent-secondary);
}

.region-retrigger-btn.active {
    color: var(--accent-secondary);
    background: rgba(0, 229, 255, 0.15);
}

.region-remove-btn:hover {
    color: var(--accent-tertiary);
}

/* ── Effect Layer Items ────────────────────────────────────── */
.layer-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    margin-bottom: 4px;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    overflow: hidden;
}

.layer-item:hover {
    border-color: var(--border-accent);
}

.layer-item.bypassed {
    opacity: 0.4;
}

.layer-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
}

.layer-expand-btn {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.layer-expand-btn:hover {
    color: var(--accent-secondary);
    background: rgba(0, 229, 255, 0.1);
}

.layer-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.layer-name {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 8px;
    background: rgba(255, 171, 64, 0.2);
    color: var(--accent-warm);
    font-weight: 600;
}

.layer-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.layer-mix-label {
    font-size: 9px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.layer-mix {
    width: 50px !important;
}

.layer-bypass-btn,
.layer-remove-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.layer-bypass-btn:hover {
    color: var(--accent-primary);
}

.layer-bypass-btn.active {
    color: var(--accent-tertiary);
    background: rgba(255, 64, 129, 0.15);
}

.layer-remove-btn:hover {
    color: var(--accent-tertiary);
}

/* ── Per-Layer Parameter Panel ─────────────────────────────── */
.layer-params {
    padding: 4px 10px 8px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-subtle);
    animation: slide-in 150ms ease;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.param-row:last-child {
    margin-bottom: 0;
}

.param-row .param-label {
    flex: 0 0 90px;
    font-size: 10px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.param-row .param-slider {
    flex: 1;
    height: 3px;
}

.param-row .param-val {
    flex: 0 0 36px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--accent-secondary);
}

.param-row .param-select {
    flex: 1;
    padding: 3px 6px;
    font-size: 10px;
    background: var(--bg-deep);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
}

.param-row .param-select:hover {
    border-color: var(--border-accent);
}

.param-row .param-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--glow-primary);
}

/* ── Status Bar ────────────────────────────────────────────── */
#status-bar {
    height: var(--status-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--bg-deep);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-dim);
}

#status-pos {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-secondary);
}

/* ── Glassmorphism accent elements ─────────────────────────── */
#transport-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(124, 77, 255, 0.3),
            rgba(0, 229, 255, 0.2),
            transparent);
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.layer-item {
    animation: slide-in 200ms ease;
}

.region-item {
    animation: slide-in 150ms ease;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
    :root {
        --panel-width: 220px;
    }
}

@media (max-width: 900px) {
    #left-panel {
        display: none;
    }

    :root {
        --panel-width: 200px;
    }
}

@media (max-width: 700px) {
    #right-panel {
        display: none;
    }

    .transport-left .file-name {
        display: none;
    }
}

/* ── Modal Dialog ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 200ms ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6), 0 0 24px var(--glow-primary);
    padding: 20px 24px;
    min-width: 380px;
    max-width: 480px;
    width: 90vw;
    animation: slide-in 250ms ease;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-preview {
    flex: 0 0 auto;
    text-align: center;
}

.modal-preview canvas {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-deepest);
    display: block;
    margin-bottom: 4px;
}

.modal-info {
    font-size: 10px;
    color: var(--text-dim);
}

.modal-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-field label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}