/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-color: #0f0f1a;
    --surface-color: #1a1a2e;
    --surface-hover: #252540;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --border-color: #2a2a40;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --gradient-start: #6366f1;
    --gradient-end: #ec4899;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Upload Section */
.upload-section {
    margin-bottom: 1.5rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface-color);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.upload-subtext {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: 8px;
    margin-top: 1rem;
}

.file-name {
    color: var(--success-color);
    font-weight: 500;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Player Section */
.player-section {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.player-section audio {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-control {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-control:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.time-display {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.9rem;
    margin-left: auto;
}

/* Visualization Section */
.visualization-section {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: var(--background-color);
    border-radius: 8px;
    overflow: hidden;
}

#spectrumCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.frequency-labels,
.amplitude-labels {
    position: absolute;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-family: monospace;
    pointer-events: none;
}

.frequency-labels {
    bottom: 4px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
}

.amplitude-labels {
    top: 10px;
    left: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: calc(100% - 30px);
}

.visualization-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.info-item {
    display: flex;
    gap: 0.5rem;
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    color: var(--primary-color);
    font-weight: 600;
    font-family: monospace;
}

/* Controls Section */
.controls-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.control-group {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.control-group h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-row label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 100px;
}

.control-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

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

.control-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.control-row select {
    flex: 1;
    padding: 0.5rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.control-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.range-value {
    min-width: 60px;
    text-align: right;
    color: var(--primary-color);
    font-family: monospace;
    font-size: 0.85rem;
}

.checkbox-row {
    justify-content: flex-start;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    min-width: auto;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .canvas-container {
        height: 250px;
    }

    .visualization-info {
        flex-direction: column;
        gap: 0.75rem;
    }

    .controls-section {
        grid-template-columns: 1fr;
    }

    .control-row {
        flex-wrap: wrap;
    }

    .control-row label {
        min-width: 100%;
        margin-bottom: 0.25rem;
    }

    .control-row input[type="range"] {
        flex: 1;
    }

    .playback-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .time-display {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .canvas-container {
        height: 200px;
    }

    .btn-control {
        width: 40px;
        height: 40px;
    }

    .btn-control svg {
        width: 20px;
        height: 20px;
    }
}

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

.analyzing {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}
