/* Modern Dark Mode Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #e0e0e0;
    background-color: #121212;
    margin: 0;
    padding: 0;
    animation: fadeIn 0.4s ease-in;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 1.8rem;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Browser Compatibility Warning */
.browser-warning {
    background-color: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 12px;
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.browser-warning h3 {
    margin-bottom: 10px;
    color: #f39c12;
}

.browser-warning ul {
    margin-left: 20px;
    margin-bottom: 10px;
    color: #e0e0e0;
}

/* Control Panel */
.control-panel {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-panel button {
    padding: 10px 16px;
    background-color: #2c2c2c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    order: 0; /* Default order for all buttons in control panel */
}

.control-panel #testFirework {
    order: 3; /* Default order assuming it's after Start and Settings */
}

.control-panel #togglePanels {
    order: 4; /* Default order assuming it's last */
    background-color: #95a5a6 !important;
    color: #ffffff !important;
}

.control-panel button#togglePanels {
    background-color: #95a5a6 !important;
    color: #ffffff !important;
}

#togglePanels {
    background-color: #95a5a6 !important;
    color: #ffffff !important;
}

.control-panel #startMicrophone {
    order: 1; /* Default order */
}

.control-panel #toggleSettings {
    order: 2; /* Default order */
}

button .icon {
    font-size: 16px;
    line-height: 1;
}

button .text {
    font-size: 12px;
    line-height: 1;
}

button:hover {
    background-color: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background-color: #2a2a2a;
    color: #555555;
    cursor: not-allowed;
    box-shadow: none;
}

#startMicrophone {
    background-color: #2ecc71;
    color: #ffffff;
}

#startMicrophone:hover {
    background-color: #27ae60;
}

#stopMicrophone {
    background-color: #e74c3c;
    color: #ffffff;
}

#stopMicrophone:hover {
    background-color: #c0392b;
}

#testFirework {
    background-color: #9b59b6;
    color: #ffffff;
}

#testFirework:hover {
    background-color: #8e44ad;
}

#toggleSettings {
    background-color: #3498db;
    color: #ffffff;
}

#toggleSettings:hover {
    background-color: #2980b9;
}

/* Visualization Container */
.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 30px;
}

/* Audio Visualizer */
.audio-visualizer {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid #2c2c2c;
    transition: opacity 0.3s ease, border-color 0.3s ease;
}

.audio-visualizer.active {
    border-color: #2ecc71;
    box-shadow: 0 4px 20px rgba(46, 204, 113, 0.2);
}

.audio-visualizer.inactive {
    border-color: #e74c3c;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.2);
}

.audio-visualizer.mic-active {
    border-color: rgba(46, 204, 113, 0.5);
}

.audio-visualizer.mic-inactive {
    border-color: rgba(231, 76, 60, 0.5);
}

.volume-meter {
    height: 12px;
    background-color: rgba(44, 44, 44, 0.5);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.level-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2ecc71, #3498db);
    position: relative;
    transform-origin: left center;
}

.level-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8),
                0 0 5px rgba(255, 255, 255, 0.5);
}

#audioStatus {
    font-size: 16px;
    color: #a0a0a0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#audioStatus::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #e74c3c;
    transition: all 0.3s ease;
}

#audioStatus.active::before {
    background-color: #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

#audioStatus.inactive::before {
    background-color: #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

/* Animation Canvas - both layers */
#animationCanvas, #backgroundCanvas {
    width: 100%;
    height: 500px;
    background-color: #000000;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: block;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background-color: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    padding: 24px;
    border: 1px solid #2c2c2c;
    max-width: 400px;
    width: 90%;
}

.hidden {
    display: none;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: #ffffff;
    border-bottom: 1px solid #2c2c2c;
    padding-bottom: 8px;
}

.setting {
    margin-bottom: 18px;
}

.setting label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #e0e0e0;
}

.setting input[type="range"] {
    width: 100%;
    padding: 5px;
    background-color: #2c2c2c;
    border-radius: 10px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
}

.setting input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}

.setting input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}

.setting select {
    width: 100%;
    padding: 8px 12px;
    background-color: #2c2c2c;
    color: #e0e0e0;
    border: none;
    border-radius: 8px;
}

/* Settings panel buttons - removed in favor of simplified approach in settings-tabs.css */

/* Footer */
footer {
    margin-top: 40px;
    text-align: center;
}

.reference-guide {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    border: 1px solid #2c2c2c;
}

.reference-guide h3 {
    margin-bottom: 16px;
    color: #ffffff;
}

.reference-guide ul {
    list-style-type: none;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.reference-guide li {
    padding: 10px 0;
    border-bottom: 1px solid #2c2c2c;
}

.reference-guide li:last-child {
    border-bottom: none;
}

.reference-guide strong {
    color: #3498db;
}

/* Microphone Test */
.mic-test {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid #2c2c2c;
}

.mic-test p {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #a0a0a0;
    line-height: 1.5;
}

.mic-detection {
    padding: 10px 16px;
    border-radius: 8px;
    background-color: #2c2c2c;
    display: inline-block;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.mic-detection.detected-loud {
    background-color: #e74c3c;
    color: white;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.mic-detection.detected-sudden {
    background-color: #f39c12;
    color: white;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.mic-detection.detected-sustained {
    background-color: #2ecc71;
    color: white;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Responsive Design */
@media (min-width: 768px) {
    .visualization-container {
        flex-direction: row;
    }
    
    .audio-visualizer {
        flex: 1;
    }
    
    #animationCanvas, #backgroundCanvas {
        flex: 2;
        height: 500px;
    }
    
    .control-panel {
        justify-content: space-evenly;
    }

    /* Desktop: Reorder Test and Show/Hide buttons when Start and Settings are hidden */
    .control-panel:has(#startMicrophone.is-hidden):has(#toggleSettings.is-hidden):not(:has(#togglePanels.is-hidden)):not(:has(#testFirework.is-hidden)) {
        /* Assuming desktop always keeps them in a row, or specific adjustments might be needed if it becomes 2x1 */
        /* We just need to reorder if they are visible and others are not */
    }

    .control-panel:has(#startMicrophone.is-hidden):has(#toggleSettings.is-hidden):not(:has(#togglePanels.is-hidden)):not(:has(#testFirework.is-hidden)) #testFirework {
        order: 1; /* Test button first */
    }

    .control-panel:has(#startMicrophone.is-hidden):has(#toggleSettings.is-hidden):not(:has(#togglePanels.is-hidden)):not(:has(#testFirework.is-hidden)) #togglePanels {
        order: 2; /* Show/Hide button second */
    }
}

@media (max-width: 767px) {
    .control-panel {
        flex-wrap: wrap;
    }
    
    button {
        min-width: 45%;
    }
    
    #animationCanvas, #backgroundCanvas {
        height: 350px;
    }
}

/* Add a subtle animation to the entire app */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* General utility classes */
.is-hidden {
    display: none !important;
}

/* Desktop layout for buttons */
@media (min-width: 769px) {
    button {
        flex-direction: row;
        gap: 8px;
    }
    
    button .icon {
        font-size: 14px;
    }
    
    button .text {
        font-size: 14px;
    }
}

.control-panel #togglePanels:hover,
.control-panel button#togglePanels:hover,
#togglePanels:hover {
    background-color: #7f8c8d !important;
    color: #ffffff !important;
}