/* WaveSynthesis CSS - Vanilla CSS with Premium Modern Dark / Neon / Glassmorphism Aesthetic */

:root {
    --bg-color: #080b11;
    --card-bg: rgba(17, 24, 39, 0.65);
    --card-border: rgba(255, 255, 255, 0.07);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Neon Accents */
    --accent-color: #6366f1; /* Indigo */
    --accent-glow: rgba(99, 102, 241, 0.4);
    --original-color: #00ffcc; /* Neon Mint */
    --original-glow: rgba(0, 255, 204, 0.3);
    --synth-color: #ff007f; /* Neon Magenta */
    --synth-glow: rgba(255, 0, 127, 0.3);
    --cyan-accent: #00e5ff;
    
    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background glowing effect */
.glow-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(236, 72, 153, 0.05) 50%, transparent 100%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

/* Header */
header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--original-color), var(--synth-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: wave-motion 2s ease-in-out infinite alternate;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(to right, #ffffff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.75rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(99, 102, 241, 0.05);
}

/* Layout Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: auto auto;
    gap: 1.75rem;
}

/* Panels */
#control-panel {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    height: fit-content;
}

.main-display {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 400px;
}

.components-panel {
    grid-column: 2;
    grid-row: 2;
}

h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.control-group {
    display: flex;
    flex-direction: column;
}

/* Buttons and Inputs */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.85rem 1.25rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #4f46e5);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
    filter: brightness(1.1);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.btn-danger.recording {
    background: #111827;
    border: 2px solid #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    animation: pulse 1.5s infinite alternate;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.record-dot {
    width: 10px;
    height: 10px;
    background-color: white;
    border-radius: 50%;
    display: inline-block;
}

.btn-danger.recording .record-dot {
    background-color: #ef4444;
    animation: flash 1s infinite;
}

/* Select Styling */
.input-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.8rem;
    color: var(--text-secondary);
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

select {
    appearance: none;
    width: 100%;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Audio Play Control Section */
.play-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.volume-control label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 30px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    appearance: none;
}

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

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

/* Recording count status */
.status-text {
    font-size: 0.85rem;
    color: #ef4444;
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

/* Learning tips box */
.instruction-box {
    background: rgba(99, 102, 241, 0.08);
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    border-radius: 0 12px 12px 0;
    font-size: 0.85rem;
}

.instruction-box h4 {
    color: #a5b4fc;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.instruction-box ul {
    margin-left: 1.25rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--text-secondary);
}

/* Main graph display tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--cyan-accent);
    background: rgba(0, 229, 255, 0.08);
    box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.05);
}

/* Canvases */
.canvas-container {
    position: relative;
    width: 100%;
    height: 350px;
    background: rgba(9, 11, 18, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.legend {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 1rem;
    background: rgba(8, 11, 17, 0.8);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.legend-item.original {
    color: var(--original-color);
}

.legend-item.synthesized {
    color: var(--synth-color);
}

.legend-item .color-box {
    width: 12px;
    height: 4px;
    border-radius: 2px;
    display: inline-block;
}

.legend-item.original .color-box {
    background-color: var(--original-color);
    box-shadow: 0 0 6px var(--original-glow);
}

.legend-item.synthesized .color-box {
    background-color: var(--synth-color);
    box-shadow: 0 0 6px var(--synth-glow);
}

/* Components list panel */
.components-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.components-header h2 {
    border: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.batch-actions {
    display: flex;
    gap: 1rem;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-text:hover {
    color: var(--cyan-accent);
    background: rgba(0, 229, 255, 0.05);
}

.components-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Component Row Items */
.component-item {
    display: grid;
    grid-template-columns: 50px 100px 100px 1fr 60px;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.component-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.component-item.active-harmonic {
    border-left: 3px solid var(--synth-color);
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-container label {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2; /* Ensure input is on top to receive clicks reliably */
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 24px;
    width: 24px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    pointer-events: none; /* Let clicks pass through to the input */
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--synth-color);
    background-color: rgba(255, 255, 255, 0.1);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--synth-color);
    border-color: var(--synth-color);
    box-shadow: 0 0 10px var(--synth-glow);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 8px;
    top: 3px;
    width: 5px;
    height: 11px;
    border: solid white;
    border-width: 0 3px 3px 0; /* Thick check mark border */
    transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

/* Frequency & Amplitude details */
.comp-freq {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.comp-amp {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.comp-amp span {
    color: var(--cyan-accent);
    font-weight: 600;
}

/* Miniature waveform canvas container */
.comp-canvas-container {
    height: 40px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

/* Solo / preview sound button */
.btn-solo {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-solo:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 0 6px var(--accent-glow);
}

.btn-solo.playing {
    background: var(--original-color);
    border-color: var(--original-color);
    color: #080b11;
    font-weight: 600;
    box-shadow: 0 0 8px var(--original-glow);
}

/* Empty list styling */
.empty-components-message {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: 0.95rem;
    border: 2px dashed rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

/* Custom Scrollbar for Component List */
.components-list::-webkit-scrollbar {
    width: 6px;
}

.components-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.components-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.components-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    max-width: 1400px;
    margin: 0 auto;
}

/* Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    }
    100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    }
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes wave-motion {
    0% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(-3px) scaleY(1.15); }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 0 1rem 2rem;
    }
    
    #control-panel {
        grid-column: 1;
        grid-row: 1;
    }
    
    .main-display {
        grid-column: 1;
        grid-row: 2;
    }
    
    .components-panel {
        grid-column: 1;
        grid-row: 3;
    }
}

@media (max-width: 640px) {
    header {
        padding: 1.5rem 1rem 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .component-item {
        grid-template-columns: 40px 1fr 40px;
        gap: 0.5rem;
    }
    
    .comp-amp, .comp-canvas-container {
        display: none; /* Hide non-essentials on very small screens */
    }
}
