/* Home page specific styles */
.camera-container {
    width: 90%; /* Changed from 23% to be more responsive */
    max-width: 1200px; /* Changed from 50% to a more reasonable max size */
    margin: 48px auto;
    text-align: center;
    padding: 0 16px; /* Added padding for mobile */
}

.permission-note {
    margin-top: 12px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(42, 82, 152, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    display: none;
}

/* Camera Grid */
.camera-grid {
    margin-top: 32px;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Reduced minmax from 300px to 250px */
    gap: 16px;
}

.camera-grid video {
    width: 100%;
    border-radius: 8px;
    background: rgba(0,0,0,0.1);
    aspect-ratio: 16/9;
    object-fit: cover;
}

.camera-wrapper {
    position: relative;
    width: 100%;
}

.camera-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 1;
}

.camera-message {
    width: 100%;
    padding: 24px;
    text-align: center;
    color: #666;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
}

/* Sound Testing Section */
.sound-container {
    width: 90%;
    max-width: 1200px;
    margin: 48px auto;
    text-align: center;
}

.sound-grid {
    display: none;
    margin-top: 32px;
    background: rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.freq-control {
    margin: 24px 0;
    text-align: left;
}

.freq-control label {
    color: white;
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.freq-control input[type="range"] {
    width: 100%;
    margin: 8px 0;    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
}

.freq-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.freq-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.speaker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.speaker-btn {
    padding: 24px;
    font-size: 1.1rem;
    font-family: 'Montserrat', Arial, sans-serif;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.speaker-btn.left {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.1) 0%, rgba(46, 204, 113, 0.2) 100%);
    border-color: rgba(46, 204, 113, 0.3);
}

.speaker-btn.right {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(52, 152, 219, 0.2) 100%);
    border-color: rgba(52, 152, 219, 0.3);
}

/* Microphone and Keyboard Side-by-Side Layout */
.mic-keyboard-wrapper {
    width: 90%; /* Changed back to 90% for desktop */
    max-width: 1400px;
    margin: 12px auto;
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 24px;
    align-items: start;
    box-sizing: border-box;
}

/* New container for stacking keyboard and mouse vertically */
.keyboard-mouse-stack {
    display: grid;
    grid-template-rows: auto auto;
    gap: 16px;
    width: 100%;
}

/* Adjust individual container styles */
.mic-keyboard-wrapper .microphone-container,
.mic-keyboard-wrapper .keyboard-container {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.spectrogram-canvas {
    width: 100%;
    height: 200px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Responsive design for smaller screens */
@media (max-width: 1200px) {
    .mic-keyboard-wrapper {
        width: 95%; /* Slightly wider on medium screens */
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Additional mobile optimizations */
@media screen and (max-width: 768px) {
    .mic-keyboard-wrapper {
        width: 100%;
        margin: 8px auto;
        padding: 0 8px;
    }

    .mouse-grid {
        padding: 12px;
    }

    .mouse-visualization {
        grid-template-columns: 1fr;
        height: auto;
    }

    .movement-graph,
    .delta-display {
        height: 300px;
    }

    /* Ensure all interactive elements are properly contained */
    .mic-grid,
    .keyboard-grid,
    .mouse-grid {
        max-width: 100%;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Microphone Testing Section */
.microphone-container {
    width: 90%;
    max-width: 1200px;
    margin: 48px auto;
    text-align: center;
}

.mic-grid {
    display: none;
    margin-top: 32px;
    background: rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.mic-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.recording-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}

.record-btn, .play-btn, .reset-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: 'Montserrat', Arial, sans-serif;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.record-btn {
    background: #e74c3c;
    color: white;
}

.record-btn:hover {
    background: #c0392b;
}

.play-btn {
    background: #27ae60;
    color: white;
}

.play-btn:hover:not(:disabled) {
    background: #219a52;
}

.reset-btn {
    background: #95a5a6;
    color: white;
}

.reset-btn:hover:not(:disabled) {
    background: #7f8c8d;
}

.record-btn:disabled, .play-btn:disabled, .reset-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

.mic-device-select {
    padding: 8px 16px;
    font-size: 1rem;
    font-family: 'Montserrat', Arial, sans-serif;
    background: rgba(42, 82, 152, 0.6);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    max-width: 400px;
    transition: background-color 0.2s, border-color 0.2s;
}

.mic-device-select:hover {
    background: rgba(42, 82, 152, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.mic-device-select option {
    background: #2a5298;
    color: white;
    padding: 8px;
}

.device-select {
    margin-bottom: 24px;
    text-align: left;
}

.device-select label {
    color: white;
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.audio-device-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 1rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(42, 82, 152, 0.6);
    color: white;
    font-family: 'Montserrat', Arial, sans-serif;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.audio-device-select:hover {
    background: rgba(42, 82, 152, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.audio-device-select option {
    background: #2a5298;
    color: white;
    padding: 8px;
}

.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.visualization-label {
    color: white;
    font-size: 0.9rem;
    text-align: left;
    margin-bottom: -8px;
    opacity: 0.8;
}

.waveform-canvas {
    width: 100%;
    height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Media query for mobile devices */
@media screen and (max-width: 768px) {
    .camera-container {
        width: 100%;
        margin: 24px auto;
        padding: 0 8px;
    }

    .camera-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 12px;
    }

    .mic-keyboard-wrapper {
        flex-direction: column;
        gap: 24px;
    }

    .keyboard-mouse-stack {
        width: 100%;
    }

    .keyboard-container,
    .microphone-container,
    .sound-container {
        width: 100%;
        margin: 24px auto;
        padding: 0 8px;
    }

    .keyboard-grid,
    .mic-grid {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* High-priority CSS for mouse test section */
#mouseTestContainer {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.mouse-visualization, .click-test-section {
    margin: 20px !important; /* Added margin */
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
}
