/* ---- GENERAL LAYOUT ---- */

* {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f7f7f7;
    color: #222;
    max-width: 1400px;
    margin: 0 auto;
}

/* ---- TRAINER NAV ---- */

.trainer-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.nav-back {
    color: #4A73FF;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

.nav-back:hover {
    text-decoration: underline;
}

.nav-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
}

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

main > h1 {
    grid-column: 1 / -1;
}

.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.left-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

section {
    background: white;
    padding: 20px 25px;
    margin: 0;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s ease;
}

section > div:not(.status-message):not(.keyboard-shortcuts):not(#musicalItems) {
    margin-bottom: 20px;
}

section > div:last-child {
    margin-bottom: 0;
}

section:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #444;
    font-size: 1.4em;
    border-bottom: 2px solid #4A73FF;
    padding-bottom: 10px;
}

h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #555;
    font-size: 1.1em;
}

section strong {
    display: block;
    margin-bottom: 8px;
}

/* ---- FORM ELEMENTS ---- */

label {
    display: block;
    margin: 2px 0;
    font-weight: 500;
}

label input[type="checkbox"] {
    margin-right: 6px;
}

select,
input[type="number"],
input[type="text"] {
    padding: 6px;
    margin: 5px 0;
    font-size: 14px;
}

input[type="range"] {
    width: 100%;
    max-width: 300px;
    margin: 5px 0;
    cursor: pointer;
}

label:has(input[type="number"]),
label:has(input[type="range"]),
label:has(select) {
    margin: 12px 0;
}

/* ---- CHECKBOX GROUPS ---- */

.checkbox-group {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    background: #fafafa;
    border-radius: 6px;
}

.checkbox-group label {
    display: block;
    font-size: 14px;
    padding: 2px 0;
}

/* ---- BUTTONS ---- */

button {
    padding: 10px 20px;
    margin: 5px 8px 5px 0;
    background: #4A73FF;
    border: none;
    color: white;
    font-size: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 500;
}

button:hover {
    background: #3659d4;
}

button.secondary {
    background: #6c6c6c;
}

button.secondary:hover {
    background: #4a4a4a;
}

button:focus,
input:focus,
select:focus {
    outline: 3px solid #4A73FF;
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- FLEX LAYOUTS ---- */

.flex-row {
    display: flex;
    align-items: center;
    gap: 20px;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.small-note {
    font-size: 12px;
    color: #555;
}

/* ---- CONTROLS ROW ---- */

.controls-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.controls-row button {
    margin: 0;
}

/* ---- STATUS MESSAGE ---- */

.status-message {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: opacity 0.3s ease;
    margin-left: 10px;
}

.status-message.playing {
    background-color: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}

.status-message.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.status-message:empty {
    display: none;
}

/* ---- SEQUENCE DISPLAY ---- */

.sequence-display {
    margin-top: 20px;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 6px;
    border: 1px solid #b3d9ff;
}

.sequence-display summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    padding: 5px;
    user-select: none;
    color: #1976d2;
}

.sequence-display summary:hover {
    color: #4A73FF;
}

.notes-content {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.note-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 4px 0;
    gap: 20px;
}

.note-content {
    flex: 0 0 auto;
}

.note-descriptor {
    flex: 1 1 auto;
    text-align: right;
    color: #666;
    font-style: italic;
    font-size: 13px;
}

/* ---- KEYBOARD SHORTCUTS ---- */

.keyboard-shortcuts {
    margin-top: 20px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.keyboard-shortcuts summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    padding: 5px;
    user-select: none;
}

.keyboard-shortcuts summary:hover {
    color: #4A73FF;
}

.keyboard-shortcuts ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
    list-style: none;
}

.keyboard-shortcuts li {
    padding: 4px 0;
    font-size: 14px;
}

/* ---- MUSICAL ITEMS GRID ---- */

#musicalItems {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

#musicalItems > div {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

#musicalItems h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1em;
    color: #4A73FF;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

#musicalItems label {
    margin: 2px 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

#musicalItems label:hover {
    color: #4A73FF;
}

/* ---- CHORD INVERSIONS ---- */

.chord-item {
    margin-bottom: 12px;
}

.chord-main {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
}

.inversion-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: 24px;
    margin-top: 4px;
}

.inversion-options label {
    font-size: 12px;
    font-weight: normal;
    color: #666;
    margin: 0;
    white-space: nowrap;
}

.inversion-options label:hover {
    color: #4A73FF;
}

.inversion-checkbox {
    margin-right: 3px;
}

/* ---- RESPONSIVE DESIGN ---- */

@media (max-width: 1024px) {
    .section-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    section {
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    #musicalItems {
        grid-template-columns: 1fr;
    }

    button {
        width: 100%;
        margin: 5px 0;
    }
}

/* ---- PIANO KEYBOARD ---- */

#piano-container {
    margin-top: 20px;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.piano-keyboard {
    --white-key-width: 24px;
    --white-key-height: 120px;
    --black-key-width: 14px;
    --black-key-height: 75px;

    position: relative;
    display: flex;
    height: var(--white-key-height);
    width: calc(var(--white-key-count) * var(--white-key-width));
    margin: 0 auto;
}

.piano-key {
    cursor: pointer;
    transition: background 0.05s ease;
}

.white-key {
    width: var(--white-key-width);
    height: var(--white-key-height);
    background: linear-gradient(to bottom, #f8f8f8 0%, #fff 10%, #f0f0f0 100%);
    border: 1px solid #bbb;
    border-radius: 0 0 4px 4px;
    flex-shrink: 0;
    position: relative;
}

.key-label {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: bold;
    color: #333;
    pointer-events: none;
    user-select: none;
}

.white-key:hover {
    background: linear-gradient(to bottom, #f0f0f0 0%, #f8f8f8 10%, #e8e8e8 100%);
}

.white-key.active {
    background: linear-gradient(to bottom, #ddd 0%, #e5e5e5 10%, #d0d0d0 100%);
}

.black-key {
    position: absolute;
    width: var(--black-key-width);
    height: var(--black-key-height);
    background: linear-gradient(to bottom, #333 0%, #1a1a1a 100%);
    border-radius: 0 0 3px 3px;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.black-key:hover {
    background: linear-gradient(to bottom, #444 0%, #2a2a2a 100%);
}

.black-key.active {
    background: linear-gradient(to bottom, #555 0%, #3a3a3a 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Responsive piano sizing */
@media (max-width: 768px) {
    .piano-keyboard {
        --white-key-width: 18px;
        --white-key-height: 90px;
        --black-key-width: 11px;
        --black-key-height: 55px;
    }
}

@media (min-width: 1200px) {
    .piano-keyboard {
        --white-key-width: 28px;
        --white-key-height: 140px;
        --black-key-width: 16px;
        --black-key-height: 85px;
    }
}
