/* CSS Custom Properties */
:root {
    --bg-color: #0f0f0f;
    --card-bg: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #5a9fd4;
    --border: #2a2a2a;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 2rem 1rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

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

/* Card Sections */
.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Control Bar */
.control-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn:hover {
    background: #252525;
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #3a7bc8;
    border-color: #3a7bc8;
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
    border-color: var(--text-secondary);
    width: 100%;
    margin-top: 1rem;
}

.btn-secondary:hover {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

/* Slider Container */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.slider-container label {
    flex: 1;
    min-width: 150px;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider-container input[type="range"] {
    flex: 2;
    min-width: 150px;
}

.value-display {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
}

/* Custom Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #333333;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #3a7bc8;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #3a7bc8;
}

/* Frequency Bands Grid */
.bands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
}

/* Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.preset-btn {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    text-align: center;
}

.preset-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.preset-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Noise Type Selector */
.noise-type-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: -0.5rem;
}

.noise-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.noise-type-btn {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.noise-type-btn:hover {
    border-color: var(--accent);
    background: #252525;
}

.noise-type-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.noise-desc {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Custom Preset Button */
.custom-preset-btn {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    text-align: left;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-preset-btn:hover {
    background: var(--accent);
    color: white;
}

.custom-preset-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.delete-custom-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.delete-custom-btn:hover {
    background: rgba(231, 76, 60, 0.1);
}

.custom-preset-btn:hover .delete-custom-btn {
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Timer Inputs */
.timer-inputs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.timer-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timer-input-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.timer-input-group select {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #252525;
    color: var(--text-primary);
    cursor: pointer;
}

.timer-input-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Timer Display */
.timer-display {
    font-size: 3rem;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1.5rem;
    font-variant-numeric: tabular-nums;
}

/* Timer Controls */
.timer-controls {
    display: flex;
    gap: 0.75rem;
}

.timer-controls .btn {
    flex: 1;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

    .control-bar {
        flex-direction: column;
    }

    .control-bar .btn {
        width: 100%;
    }

    .bands-grid {
        grid-template-columns: 1fr;
    }

    .presets-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .slider-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .slider-container label {
        min-width: auto;
    }

    .value-display {
        text-align: left;
    }

    .timer-display {
        font-size: 2.5rem;
    }

    .timer-inputs {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .presets-grid {
        grid-template-columns: 1fr;
    }

    .timer-controls {
        flex-direction: column;
    }
}
