/* General page and body styling */
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #f9f9f9;
    color: #333;
}

/* Header */
.header-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    gap: 15px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin: 0;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

#help-button {
    background: none;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: #555;
    padding: 0;
    line-height: 1;
}

#view-toggle-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: #555;
    padding: 0;
    line-height: 1;
}

#help-button:hover, #view-toggle-btn:hover {
    background-color: #e9e9e9;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    position: relative;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.control-group label {
    font-weight: bold;
    margin-bottom: 8px;
}

.control-group select, .control-group button {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#interval-select button {
     font-weight: bold;
}

.control-group button:hover, .control-group select:hover {
    background-color: #e9e9e9;
}

.control-group button.active, .view-btn.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.button-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.button-grid button {
    margin: 0;
    width: 50px; 
    display: inline-flex; 
    justify-content: center;
    align-items: center;
}

/* Views Menu */
#views-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    z-index: 100;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: fit-content;
    white-space: nowrap;
    border: 1px solid #ddd;
}

#views-menu.hidden {
    display: none;
}

.view-option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.view-option-row label {
    font-weight: bold;
    margin-right: 15px;
    margin-bottom: 0;
}

.view-option-row select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
}

.button-group {
    display: flex;
    gap: 5px;
}

.button-group button {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    cursor: pointer;
}


/* Help Container */
#help-container {
    display: none;
    background-color: #fff;
    padding: 20px;
    margin: 0 auto 30px auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-width: 900px;
}

#help-container p, #help-container ul {
    font-size: 14px;
    line-height: 1.6;
}

#help-container ul {
    padding-left: 20px;
}


/* --- Metronome --- */
.metronome-controls-main {
    display: flex;
    gap: 4px;
    align-items: center;
}
#metronome-play-btn, #metronome-settings-btn {
    width: 45px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    transition: background-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}
#metronome-play-btn svg {
    width: 100%;
    height: 100%;
    fill: #333;
}
#metronome-play-btn.downbeat-flash {
    background-color: #e74c3c88;
    box-shadow: 0 0 12px 2px #e74c3caa;
}
#metronome-play-btn.beat-flash {
    background-color: #3498db88;
    box-shadow: 0 0 12px 2px #3498dbaa;
}

/* --- Metronome Panel --- */
@keyframes pulse-animation {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

#metronome-panel {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin: -10px auto 20px auto;
    width: fit-content;
    overflow: hidden;
    border: 1px solid #eee;
    transition: all 0.3s ease-in-out;
}
#metronome-panel.hidden { display: none; }

.metronome-panel-content {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 40px;
    flex-wrap: wrap;
}

.metro-display-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#metronome-panel #time-signature-select {
    width: 130px;
    margin-bottom: 2px;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
}

#metronome-button {
    width: 130px;
    height: 130px;
    border: 4px solid #eee;
    border-radius: 50%;
    background-color: #f9f9f9;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 0 1px #ccc, inset 0 3px 8px rgba(0,0,0,0.05);
    transition: background-color 0.1s;
}
#metronome-button.downbeat-flash {
    animation: pulse-animation 0.15s ease-out;
    background-color: #e74c3c30;
}
#metronome-button.beat-flash {
    animation: pulse-animation 0.15s ease-out;
    background-color: #3498db20;
}

#bpm-display {
    font-size: 2.8em;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.bpm-label {
    font-size: 0.9em;
    color: #555;
}

#beat-counter-display {
    font-size: 0.9em;
    min-height: 18px;
    color: #777;
}

.beat-indicators {
    display: flex;
    justify-content: center;
    height: 10px;
    gap: 8px;
}
.beat-dot {
    width: 10px;
    height: 10px;
    background-color: #ddd;
    border-radius: 50%;
    transition: all 0.1s;
}
.beat-dot.active { background-color: #3498db; }
.beat-dot.downbeat { background-color: #e74c3c; }


.metro-controls-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 280px;
}
.tempo-group-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sub-controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.metro-controls-section .metro-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.metro-controls-section label {
    font-size: 0.8em;
    font-weight: bold;
    color: #555;
    margin-bottom: 0;
}
.metro-controls-section select, 
.metro-controls-section input,
.metro-controls-section button {
    width: 100%;
    box-sizing: border-box;
}
.metro-controls-section select {
    padding: 6px;
}
.metro-controls-section button {
    padding: 6px;
}

.sound-octave-container {
    flex-direction: row !important;
    align-items: flex-end;
    gap: 20px !important;
    width: 100%;
    justify-content: center;
}
.sound-control-wrapper, .octave-control-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.sound-control-wrapper select {
    width: 140px;
}

.metro-button-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}
.metro-button-group button {
    width: 28px;
    height: 28px;
    font-size: 1em;
    flex-shrink: 0;
    padding: 0;
}
.metro-button-group span {
    font-size: 1em;
    width: 20px;
    text-align: center;
}
#metronome-panel input[type="range"] {
    height: 6px;
    margin: 0;
}
#metronome-panel input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
}

/* --- Keyboard --- */

/* -- Keyboard with no border
#keyboard-container {
    display: flex;
    justify-content: center;
    margin: 30px auto 20px auto;
    background-color: transparent;
    padding: 0;
    border-radius: 8px;
    box-shadow: none;
    width: fit-content;
}
*/

/* --- Keyboard with border --- */

#keyboard-container {
    display: flex;
    justify-content: center;
    margin: 30px auto 20px auto;
    background-color: #222;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    width: fit-content;
}

.key {
    position: relative;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.key.white {
    width: 50px;
    height: 220px;
    background-color: #f9f9f9;
    z-index: 1;
}

.key.black {
    width: 30px;
    height: 140px;
    background-color: #333;
    margin: 0 -15px;
    z-index: 2;
}

.key .note-label {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
    color: #333;
}

.key.black .note-label {
    color: #fff;
}

.key.active {
    background-color: var(--note-bg-color, #ccc);
}

.key.active .note-label {
    color: var(--note-text-color, #fff);
}

.greyscale-mode .key.active {
    background-color: #a5a5a5 !important;
}

.greyscale-mode .key.active .note-label {
    color: white !important;
}

/* Legend and Action Buttons */
#legend-wrapper { text-align: center; margin-top: 20px; cursor: pointer; }
.legend {
    display: flex; justify-content: center; flex-wrap: wrap;
    margin-bottom: 20px; font-size: 14px; gap: 20px;
}
.legend-item { display: flex; align-items: center; }
.legend-color { width: 20px; height: 20px; border-radius: 50%; margin-right: 8px; }

/* --- Audio Controls --- */
#audio-controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

#audio-controls-container.hidden {
    display: none;
}

#listen-btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    cursor: pointer;
    font-weight: bold;
}

#listen-btn:hover {
    background-color: #e0e0e0;
}

/* Suggested Scales */
#suggested-scales-container { margin-top: 30px; text-align: center; }
#suggested-scales-container h2 { margin-bottom: 10px; }
#suggested-scales-container ul {
    list-style-type: none; padding: 0; display: flex;
    flex-wrap: wrap; justify-content: center; gap: 10px;
}
#suggested-scales-container li {
    background-color: #fff; padding: 8px 15px; border-radius: 20px;
    border: 1px solid #ddd; font-weight: bold; font-size: 14px;
    cursor: pointer; transition: all 0.2s ease-in-out;
}
#suggested-scales-container li:hover { background-color: #e9e9e9; }
#suggested-scales-container li.active {
    background-color: #3498db; color: white; border-color: #3498db;
}

/* --- Animations for Flavor Notes --- */
@keyframes pulse-level-1-animation {
    0% { box-shadow: 0 0 8px rgba(192, 57, 43, 0.0); }
    50% { box-shadow: 0 0 15px 5px rgba(192, 57, 43, 0.6); }
    100% { box-shadow: 0 0 8px rgba(192, 57, 43, 0.0); }
}
@keyframes pulse-level-2-animation {
    0% { box-shadow: 0 0 8px rgba(192, 57, 43, 0.0); }
    50% { box-shadow: 0 0 12px 3px rgba(192, 57, 43, 0.4); }
    100% { box-shadow: 0 0 8px rgba(192, 57, 43, 0.0); }
}

@keyframes flash-text-animation {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.key.flavor-note-level-1 { 
    animation: pulse-level-1-animation 2.5s infinite ease-in-out; 
}
.key.flavor-note-level-2 { 
    animation: pulse-level-2-animation 3.0s infinite ease-in-out; 
}

.key.flavor-note-level-1 .note-label {
    animation: flash-text-animation 2.5s infinite ease-in-out;
}
.key.flavor-note-level-2 .note-label {
    animation: flash-text-animation 3.0s infinite ease-in-out;
}