/* Root variables for theme colors */
:root {
    --bg-darkest: #0a0b0e;
    --bg-darker: #12141c;
    --bg-card: rgba(26, 29, 41, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(138, 92, 246, 0.2);
    
    /* Neon Accents */
    --accent-primary: #8b5cf6; /* Violet */
    --accent-primary-glow: rgba(139, 92, 246, 0.6);
    --accent-secondary: #06b6d4; /* Cyan */
    --accent-secondary-glow: rgba(6, 182, 212, 0.6);
    --accent-success: #10b981; /* Green */
    --accent-danger: #ef4444; /* Red */
    --accent-danger-glow: rgba(239, 68, 68, 0.6);
    
    /* Text Colors */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Font sizes & styling */
    --font-primary: 'Inter', sans-serif;
    --font-header: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Gradients */
.glass-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

/* App Wrapper */
.app-container {
    width: 100%;
    max-width: 1200px;
    margin: 20px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- HEADER --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--accent-primary-glow));
    animation: rotateLogo 8s linear infinite;
}

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

.logo-text h1 {
    font-family: var(--font-header);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    line-height: 1;
}

.logo-text span {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 4px;
    color: var(--accent-secondary);
}

/* Bank Selector */
.bank-selector {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    gap: 12px;
}

.bank-label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.bank-buttons {
    display: flex;
    gap: 6px;
}

.bank-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-header);
    font-size: 16px;
    font-weight: 700;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bank-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.bank-btn.active {
    color: #fff;
    background: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-primary-glow);
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* Master controls in header */
.master-control {
    display: flex;
    align-items: center;
    gap: 24px;
}

.master-knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

/* Horizontal sliders customized */
input[type="range"].vertical-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background 0.3s;
}

input[type="range"].vertical-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary-glow);
    cursor: pointer;
    border: none;
    transition: transform 0.1s;
}

input[type="range"].vertical-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.mono-display {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-secondary);
}

/* --- WORKSPACE --- */
.app-workspace {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
}

@media(max-width: 900px) {
    .app-workspace {
        grid-template-columns: 1fr;
    }
}

/* --- PAD GRID SECTION --- */
.pad-grid-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pad-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 14px;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 20px;
}

/* Tactile Drum Pad */
.drum-pad {
    position: relative;
    background: linear-gradient(145deg, #1f222d, #161821);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    transition: all 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    overflow: hidden;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.drum-pad::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
    pointer-events: none;
}

/* Pad Glow (Reflects loaded/playing state) */
.pad-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    opacity: 0.15;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
}

/* Pad Status States */
.drum-pad.loaded .pad-glow {
    border-color: var(--pad-color, var(--accent-primary));
    background-color: var(--pad-color-glow, rgba(139, 92, 246, 0.4));
    box-shadow: inset 0 0 12px var(--pad-color-glow, rgba(139, 92, 246, 0.4));
    opacity: 0.35;
}

.drum-pad.loaded:active .pad-glow, .drum-pad.loaded.active .pad-glow {
    opacity: 0.9;
    background-color: var(--pad-color-glow, rgba(139, 92, 246, 0.4));
    box-shadow: inset 0 0 20px var(--pad-color, var(--accent-primary));
}

.drum-pad.selected {
    border-color: var(--accent-secondary);
    box-shadow: 
        0 0 12px var(--accent-secondary-glow),
        inset 0 0 8px rgba(6, 182, 212, 0.2);
}

.drum-pad:active, .drum-pad.active {
    transform: scale(0.96);
    background: #252836;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.4),
        inset 0 2px 8px rgba(0, 0, 0, 0.5),
        0 0 15px var(--pad-color-glow, rgba(139, 92, 246, 0.3));
}

/* Playback flash animation classes */
.drum-pad.hit {
    animation: padHit 0.15s ease-out;
}

@keyframes padHit {
    0% {
        background: var(--pad-color, #fff);
        box-shadow: 0 0 30px var(--pad-color, #fff);
    }
    100% {
        background: linear-gradient(145deg, #1f222d, #161821);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    }
}

/* Recording Pulse State */
.drum-pad.recording {
    background: linear-gradient(145deg, #2b1111, #1f0b0b);
    border-color: var(--accent-danger);
    animation: padRecordingPulse 1s ease-in-out infinite alternate;
}

@keyframes padRecordingPulse {
    0% {
        box-shadow: 0 0 8px var(--accent-danger-glow);
    }
    100% {
        box-shadow: 0 0 20px var(--accent-danger);
    }
}

/* Drag over states */
.drum-pad.dragover {
    border: 2px dashed var(--accent-secondary);
    background: rgba(6, 182, 212, 0.1);
    transform: scale(1.03);
}

/* Pad Labels */
.pad-key-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(0,0,0,0.4);
    padding: 1px 5px;
    border-radius: 4px;
    align-self: flex-start;
    border: 1px solid rgba(255,255,255,0.02);
    z-index: 1;
}

.drum-pad.loaded .pad-key-label {
    color: var(--pad-color, var(--accent-primary));
}

.pad-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 1;
    pointer-events: none;
}

.pad-number {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
}

.pad-sample-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.drum-pad.loaded .pad-sample-name {
    color: var(--text-primary);
}

/* Actions icon indicators */
.pad-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 1;
    align-items: center;
}

.mic-indicator {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.drum-pad:hover .mic-indicator {
    opacity: 1;
}

.recording-pulse {
    display: none;
    font-size: 8px;
    color: var(--accent-danger);
}

.drum-pad.recording .recording-pulse {
    display: block;
    animation: flash 0.5s ease infinite alternate;
}

.drum-pad.recording .mic-indicator {
    display: none;
}

@keyframes flash {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

/* Tips Panel */
.instructions-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
}

.instructions-panel p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.instructions-panel i {
    color: var(--accent-secondary);
    margin-right: 6px;
}

/* --- SIDEBAR PANEL --- */
.control-panel-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.card-header h3 {
    font-family: var(--font-header);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.card-header h3 i {
    color: var(--accent-primary);
    margin-right: 6px;
}

/* Visualizer Card details */
.recording-state-text {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
}

.recording-state-text.active {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.2);
    animation: flash 0.5s ease infinite alternate;
}

.visualizer-container {
    position: relative;
    height: 100px;
    background: #06070a;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.03);
}

#freq-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.recording-indicator-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 11, 14, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.recording-indicator-overlay.active {
    display: flex;
}

.pulse-mic-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 0 12px var(--accent-danger);
    animation: micIconPulse 1s ease-in-out infinite alternate;
}

@keyframes micIconPulse {
    0% { transform: scale(1); box-shadow: 0 0 10px var(--accent-danger-glow); }
    100% { transform: scale(1.15); box-shadow: 0 0 20px var(--accent-danger); }
}

.recording-indicator-overlay .timer {
    font-family: var(--font-mono);
    font-size: 16px;
    color: white;
    font-weight: 700;
}

.recording-indicator-overlay .helper-text {
    font-size: 9px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

/* Parameter Knobs / Controls Card */
.parameter-card {
    transition: opacity 0.3s;
}

.parameter-card.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.param-info-bar {
    background: rgba(0, 0, 0, 0.2);
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.sample-name-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--accent-secondary);
    font-family: var(--font-mono);
    transition: all 0.2s ease;
}

.sample-name-input[readonly] {
    color: var(--text-muted);
    cursor: not-allowed;
}

.sample-name-input:not([readonly]):focus {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    box-shadow: inset 0 0 5px rgba(6, 182, 212, 0.2);
}

.dials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px 0;
}

.dial-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dial-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 0.5px;
}

.dial-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide fallback sliders but keep accessible for accessibility/keys */
.radial-fallback {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}

/* Simulated Hardware Rotary Knob */
.knob-control {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #2a2e3d 0%, #161821 100%);
    border: 2px solid #2d3245;
    position: relative;
    box-shadow: 
        0 4px 6px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.05);
    cursor: grab;
    transition: border-color 0.2s;
}

.knob-control:active {
    cursor: grabbing;
    border-color: var(--accent-secondary);
}

.knob-pointer {
    position: absolute;
    width: 3px;
    height: 14px;
    background: var(--accent-secondary);
    border-radius: 1.5px;
    top: 4px;
    left: 21.5px; /* (50 - 2px_border*2)/2 - 3/2 = 23 - 1.5 = 21.5 */
    transform-origin: 1.5px 21px; /* Center of pointer rotation */
    transform: rotate(0deg);
    box-shadow: 0 0 6px var(--accent-secondary);
}

.param-actions {
    margin-top: 6px;
}

/* Buttons and Knobs styling */
.action-btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #6d28d9);
    border: none;
    color: white;
    font-family: var(--font-header);
    font-weight: 600;
    font-size: 13px;
    padding: 10px;
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(109, 40, 217, 0.45);
}

.action-btn-primary:active {
    transform: translateY(1px);
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-header);
    font-weight: 500;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.text-danger {
    color: var(--accent-danger);
}

.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Microphone Card details */
.mic-status-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.mic-status-badge.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.mic-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mic-card-body p {
    font-size: 12px;
    color: var(--text-secondary);
}

.mic-card-body ol {
    margin-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.mic-card-body ol strong {
    color: var(--text-secondary);
}

/* Toast Notification System */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.toast {
    background: rgba(18, 20, 28, 0.95);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
    color: var(--text-primary);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 250px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(100%) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.toast.success {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast.info {
    border-left-color: var(--accent-secondary);
}

/* --- COLOR SELECTOR FOR PAD --- */
.color-selector-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.color-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 2px 0;
}

.color-opt-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    position: relative;
    outline: none;
}

.color-opt-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px currentColor;
}

.color-opt-btn.active {
    border-color: #ffffff;
    transform: scale(1.15);
    box-shadow: 0 0 12px currentColor, 0 4px 8px rgba(0,0,0,0.5);
}
