/* 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;
    gap: 8px;
}

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

.header-btn {
    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;
    display: flex;
    align-items: center;
    justify-content: center;
}

#help-button { }

.views-button-wrapper {
    position: relative;
}


#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: 15px;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

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

.load-save-group {
    margin-right: 15px;
}

.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;
}

.dropdown-lock-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lock-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    color: #555;
    transition: color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    height: 38px;
}

.lock-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.lock-btn.locked {
    color: #e74c3c;
}

.lock-btn:hover {
    color: #333;
}

.lock-btn:disabled {
    color: #ddd;
    cursor: not-allowed;
}


.generation-controls, .load-save-controls, .instrument-toggle-controls {
    display: flex;
    gap: 5px;
}
.load-save-controls button {
    width: 40px;
    height: 38px;
    padding: 0;
}
.instrument-toggle-controls button {
    width: auto;
    min-width: 50px;
    height: 38px;
    padding: 0 12px;
    font-weight: bold;
}

.load-save-controls button svg {
    width: 18px;
    height: 18px;
}

#generate-random-btn {
    font-weight: bold;
    font-size: 20px;
    width: 40px;
    height: 38px;
    padding: 0;
    line-height: 1;
}


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

#chord-buttons 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: 10px;
}

#chord-buttons { }

#chord-buttons button {
    margin: 0;
    width: auto;
    min-width: 70px;
    padding: 5px 15px;
    height: 50px;
    display: inline-flex; 
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: none;
    border: 1px solid #ccc;
    line-height: 1.2;
}

.chord-name {
    font-weight: bold;
    font-size: 16px;
}

.roman-numeral {
    font-size: 12px;
    color: #555;
}

#chord-buttons button.active .roman-numeral {
    color: white;
}

#chord-buttons button:hover {
    border-color: #aaa;
}


/* Views Menu */
#views-menu {
    position: absolute;
    top: 100%;
    left: 0;
    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;
}


/* Progression Info & Chord Buttons */
#progression-info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-basis: 100%;
    margin-top: 10px;
}

#progression-text-display {
    text-align: center;
}

.progression-numerals {
    font-size: 32px;
    font-weight: bold;
    color: #2c3e50;
    line-height: 1;
}

.progression-name {
    font-size: 14px;
    font-style: italic;
    color: #7f8c8d;
    margin-top: 5px;
    min-height: 20px;
}

/* Help Container */
#help-container, #rules-description {
    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: 850px;
}

#rules-description.hidden {
    display: none;
}

#rules-description:not(.hidden) {
    display: block;
}


/* Fretboard & Shape Names */
.fretboard-container {
    position: relative;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 20px;
    padding-left: 55px;
    margin: 0 auto 10px auto;
    border-radius: 8px;
    width: fit-content;
}

#shape-name-container {
    position: absolute;
    top: 2px;
    left: 55px;
    right: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 10;
}

.shape-name {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-weight: bold;
    color: red;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 0 5px;
    border-radius: 3px;
    font-size: 14px;
}


#strings-and-frets {
    position: relative;
    border-left: 5px solid #333; /* The nut */
    height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 25px 0;
    box-sizing: border-box;
    z-index: 1; 
}

.string {
    position: absolute;
    background-color: #333;
    z-index: 1;
    cursor: pointer;
}
.string-name-label {
    position: absolute;
    left: -22px;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #555;
    cursor: pointer;
}


.string[data-string-number="1"] { height: 1.5px; } 
.string[data-string-number="2"] { height: 2px; }   
.string[data-string-number="3"] { height: 2.5px; } 
.string[data-string-number="4"] { height: 3px; }   
.string[data-string-number="5"] { height: 3.5px; } 
.string[data-string-number="6"] { height: 4px; }   

.fret {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #aaa;
    z-index: 0;
}

.note {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    z-index: 5; 
    transform: translate(-50%, -50%) translateX(6px);
    transition: background-color 0.3s, color 0.3s, opacity 0.3s;
}

#fret-number-row {
    position: relative;
    margin-top: 5px;
    height: 25px;
}

.fret-number {
    position: absolute;
    transform: translateX(-50%);
    font-size: 14px;
    color: #555;
    text-align: center;
}

/* --- Fretboard Inlay Markers --- */
.inlay-marker-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Place behind the strings */
    pointer-events: none;
}

.inlay-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    background-color: #e0e0e0;
    border: 1px solid #c7c7c7;
    border-radius: 50%;
    transform: translate(-50%, -50%); /* Center the dot on its position */
}


/* Legend and Action Buttons */
#legend-wrapper {
    text-align: center;
    margin-top: 15px;
    cursor: pointer;
}
.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    font-size: 14px;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 50%;
}


/* Suggested Scales */
#suggested-scales-container {
    margin-top: 20px;
    text-align: center;
}
#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;
}

/* Note Styling & Animations */
.note.scale-note {
    background-color: #ccc !important;
    color: #555 !important;
}
@keyframes pulse-level-1-animation {
    0% { transform: translate(-50%, -50%) translateX(6px) scale(1); box-shadow: 0 3px 6px rgba(0,0,0,0.3); }
    50% { transform: translate(-50%, -50%) translateX(6px) scale(1.2); box-shadow: 0 5px 15px rgba(0,0,0,0.4); }
    100% { transform: translate(-50%, -50%) translateX(6px) scale(1); box-shadow: 0 3px 6px rgba(0,0,0,0.3); }
}

@keyframes lefty-pulse-level-1-animation {
    0% { transform: translate(-50%, -50%) scaleX(-1) translateX(-6px) scale(1); box-shadow: 0 3px 6px rgba(0,0,0,0.3); }
    50% { transform: translate(-50%, -50%) scaleX(-1) translateX(-6px) scale(1.2); box-shadow: 0 5px 15px rgba(0,0,0,0.4); }
    100% { transform: translate(-50%, -50%) scaleX(-1) translateX(-6px) scale(1); box-shadow: 0 3px 6px rgba(0,0,0,0.3); }
}

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

.left-handed-view .note.flavor-note-level-1 {
    animation-name: lefty-pulse-level-1-animation;
}

/* Overlays & Left-Handed View */
#voicing-overlay-container, #note-overlay-container {
    position: absolute;
    top: 20px;
    left: 55px;
    right: 20px;
    height: 250px;
    pointer-events: none;
}
#voicing-overlay-container { z-index: 2; }
#note-overlay-container { z-index: 4; }

.voicing-shape {
    position: absolute;
    border-radius: 15px;
    top: 0;
    height: 100%;
}

.left-handed-view {
    padding-left: 20px;
    padding-right: 55px;
}

.left-handed-view #strings-and-frets,
.left-handed-view #fret-number-row,
.left-handed-view #shape-name-container,
.left-handed-view #voicing-overlay-container,
.left-handed-view #note-overlay-container {
    transform: scaleX(-1);
}

.left-handed-view #shape-name-container,
.left-handed-view #voicing-overlay-container,
.left-handed-view #note-overlay-container {
    left: 20px;
    right: 55px;
}

.left-handed-view .shape-name { transform: translateX(50%) scaleX(-1); }
.left-handed-view .note { transform: translate(-50%, -50%) scaleX(-1) translateX(-6px); }
.left-handed-view .string-name-label {
    transform: translate(50%, -50%) scaleX(-1);
    left: -35px;
}
.left-handed-view .fret-number { transform: translateX(50%) scaleX(-1); }

.greyscale-mode .note {
    background-color: #a5a5a5 !important;
    color: white !important;
}

/* Load/Save UI */
#flash-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-weight: bold;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

#flash-message.hidden {
    opacity: 0;
    pointer-events: none;
}

#load-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

#load-panel.hidden {
    display: none;
}

.load-panel-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#load-textarea {
    width: 100%;
    height: 100px;
    resize: vertical;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.load-panel-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.load-panel-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    font-weight: bold;
}
#confirm-load-btn {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* --- Keyboard Styling --- */
.keyboard-container {
    position: relative;
    background-color: #333;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 10px;
    margin: 0 auto 10px auto;
    border-radius: 8px;
    width: fit-content;
    height: 200px;
    white-space: nowrap;
}

.keyboard-container.hidden, #fretboard.hidden {
    display: none;
}

.key {
    position: relative;
    border: 1px solid #555;
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.white-key {
    width: 50px;
    height: 100%;
    background-color: #f9f9f9;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    display: inline-block;
    vertical-align: top;
}

.black-key {
    width: 30px;
    height: 60%;
    background-color: #222;
    position: absolute;
    top: 10px;
    z-index: 2;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
}

.key-note-text {
    font-weight: bold;
    font-size: 14px;
    z-index: 3;
    pointer-events: none;
    transition: color 0.2s ease-in-out;
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
}

.white-key .key-note-text { 
    color: #555; 
}
.black-key .key-note-text { 
    color: #ccc; 
}


/* Conditional hiding of guitar-specific view options */
.keyboard-mode .view-option-row[data-view-option="caged"],
.keyboard-mode .view-option-row[data-view-option="side"],
.keyboard-mode .view-option-row[data-view-option="tuning"],
.keyboard-mode .view-option-row[data-view-option="frets"] {
    display: none !important;
}

/* Greyscale mode for keyboard */
.greyscale-mode .key.highlighted {
    background-color: #a5a5a5 !important;
}
.greyscale-mode .key.highlighted .key-note-text {
    color: white !important;
}

/* Animation for flavor note text on keyboard */
@keyframes text-pulse-animation {
    0% {
        transform: scale(1);
        text-shadow: none;
    }
    50% {
        transform: scale(1.15);
        text-shadow: 0 0 8px rgba(231, 76, 60, 0.7);
    }
    100% {
        transform: scale(1);
        text-shadow: none;
    }
}

.flavor-note-text {
    animation: text-pulse-animation 2.5s infinite ease-in-out;
    display: inline-block;
}
