/* Base Layout */
body, html { 
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%; 
    overflow: hidden; 
    font-family: sans-serif; 
}

#app-wrapper { 
    display: flex; 
    flex-direction: column; 
    width: 100%; 
    height: 100%; 
}

#app-container {
    position: relative; /* Important for the overlay */
    display: flex;
    width: 100%;
    flex-grow: 1;
    gap: 10px; /* Add a small gap between the iframes */
    padding-left: 5px; /* Add some padding to the sides */
    padding-right: 5px;
    box-sizing: border-box; /* Ensure padding is included in the width */
}

#touch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* Sits on top of the iframes */
    display: block; /* Visible by default for touch mode */
}

/* When keyboard mode is active, hide the overlay */
#app-container.keyboard-mode-active #touch-overlay {
    display: none;
}


iframe {
    border: none;
    width: 50%;
    height: 100%;
    /* The overlay now handles all pointer events, so iframes can be none */
    pointer-events: none;
}


/* Master Controls Bar */
.master-controls-bar {
    padding: 6px 12px;
    background: linear-gradient(to bottom, #f5f7fa, #e8edf2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #d1d9e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.controls-row {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap to the next line */
    justify-content: center;
    align-items: center;
    gap: 16px;
    width: 100%;
}

/* Sound controls row styling */
.sound-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.control-area {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 6px;
    padding: 2px;
    border: 1px solid #d1d9e6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

/* Different border styles for different control areas */
.key-control-area {
    border-left: 3px solid #4a6da7;
}

.scale-control-area {
    border-left: 3px solid #6a7a8c;
}

.keyboard-control-area {
    border-left: 3px solid #6a7a8c;
}

.arrow {
    cursor: pointer;
    user-select: none;
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
    color: #555;
    transition: background-color 0.2s;
}

.arrow:hover {
    background-color: #f0f0f0;
}

#key-name {
    font-weight: bold;
    padding: 4px 10px;
    text-align: center;
    min-width: 30px;
    color: #2c3e50;
    background-color: #edf2f7;
    border-radius: 4px;
    margin: 0 2px;
}

.sound-name {
    font-weight: bold;
    padding: 4px 10px;
    text-align: center;
    min-width: 70px;
    color: #2c3e50;
    background-color: #edf2f7;
    border-radius: 4px;
    margin: 0 2px;
}

#chord-sound-name {
    background-color: #e8f4fd; /* Subtle blue for chord */
    color: #2271b1;
}

#note-sound-name {
    background-color: #f0fdf4; /* Subtle green for note */
    color: #2e7d32;
}

#scale-select {
    font-size: 0.9em;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #ccd0d5;
    background-color: white;
    color: #2c3e50;
}

.control-box {
    padding: 6px 12px;
    background-color: #f5f7fa;
    color: #555;
    border: 1px solid #d1d9e6;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.2s;
    border-left: 3px solid #6a7a8c;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-box:hover {
    background-color: #e8edf2;
}

#name-toggle-btn.active {
    background-color: #34C759;
    color: white; /* This will make the SVG icon white */
    border-color: #28a745;
    border-left: 3px solid #28a745;
}

#keyboard-mode-toggle.active {
    background-color: #007AFF;
    color: white;
    border-color: #0062cc;
    border-left: 3px solid #0062cc;
}


#keyboard-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    background: #f5f7fa;
    border: 1px solid #d1d9e6;
    cursor: pointer;
    transition: background-color 0.2s;
}

#keyboard-icon-container:hover {
    background-color: #e8edf2;
}

#keyboard-icon {
    color: #555;
}

.label {
    font-size: 0.75em;
    color: #777;
    text-transform: uppercase;
    margin-right: 5px;
}

/* Sound section labels */
.sound-label {
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    padding: 0 5px;
    color: #555;
}

/* Sound control areas */
.chord-control-area {
    border-left: 3px solid #2271b1;
    margin-right: 10px;
}

.note-control-area {
    border-left: 3px solid #2e7d32;
    margin-left: 10px;
}

/* Buffer between sound controls */
.sound-buffer {
    width: 20px;
    height: 30px;
    display: inline-block;
    position: relative;
}

/* Divider line in the buffer */
.sound-buffer:after {
    content: "";
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 50%;
    width: 1px;
    background-color: #d1d9e6;
}

/* Modal and Keyboard Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#simulated-keyboard {
    padding: 10px;
    background-color: #444;
    border-radius: 5px;
    display: inline-block;
}

.key-row {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.key {
    border: 1px solid #333;
    background-color: #666;
    color: white;
    border-radius: 4px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    width: 40px;
    height: 40px;
    margin: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    cursor: pointer;
    transition: transform 0.1s ease-out, filter 0.1s ease-out, box-shadow 0.1s ease-out, background-color 0.1s ease-out;
}

.key.pressed {
    filter: brightness(1.6);
    transform: scale(1.15) translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 10;
}

.key.key-re.pressed {
    background-color: #ffae42; /* Lighter orange */
    filter: brightness(1.1); /* Less intense brightness */
}

.key.space { 
    width: 220px; 
}

.key.key-do { background-color: #FF3B30; }
.key.key-re { background-color: #FF9500; }
.key.key-mi { background-color: #FFCC00; }
.key.key-fa { background-color: #34C759; }
.key.key-so { background-color: #30c0c6; }
.key.key-la { background-color: #007AFF; }
.key.key-ti { background-color: #AF52DE; }
.key.key-chord { background-color: #5856d6; }
.key.key-accidental { background-color: #8E8E93; }

.key[data-key="5"],
.key[data-key="t"],
.key[data-key="g"],
.key[data-key="b"] {
    margin-right: 20px;
}

/* Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.toggle-label {
    margin: 0 10px;
    font-weight: bold;
    color: #555;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}
