/**
 * PWA Sheet Music Player v2.0 — Stile
 * Engine: OSMD + WebAudioFont
 * Colori: #1A3A5C / #F5820A / DM Sans
 */

.pwa-smp-wrapper {
    --pwa-blue:   #1A3A5C;
    --pwa-orange: #F5820A;
    --pwa-bg:     #f0f4f8;
    --pwa-bg-dark:#e4eaf1;
    --pwa-border: #cdd5e0;
    --pwa-text:   #1A3A5C;
    --pwa-muted:  #6b7f96;
    --pwa-radius: 8px;

    position:      relative;
    border:        1.5px solid var(--pwa-border);
    border-radius: var(--pwa-radius);
    background:    #fff;
    box-shadow:    0 2px 12px rgba(26,58,92,.12);
    overflow:      hidden;
    font-family:   'DM Sans', sans-serif;
    color:         var(--pwa-text);
}

/* ── Toolbar blu superiore ──────────────────────────────────────────────── */
.pwa-smp-toolbar {
    display:     flex;
    align-items: center;
    flex-wrap:   wrap;
    gap:         10px 18px;
    padding:     10px 14px;
    background:  var(--pwa-blue);
}

/* ── Toolbar grigia secondaria ──────────────────────────────────────────── */
.pwa-smp-toolbar--secondary {
    background:    var(--pwa-bg);
    border-bottom: 1.5px solid var(--pwa-border);
    padding:       8px 14px;
}

/* ── Labels ─────────────────────────────────────────────────────────────── */
.pwa-smp-label {
    font-size:   12px;
    font-weight: 600;
    color:       var(--pwa-muted);
    white-space: nowrap;
}

/* Label bianchi SOLO nella toolbar blu */
.pwa-smp-toolbar:not(.pwa-smp-toolbar--secondary) .pwa-smp-label {
    color: rgba(255,255,255,.8);
}

/* Label neri espliciti nella toolbar secondaria */
.pwa-smp-toolbar--secondary .pwa-smp-label {
    color: var(--pwa-text);
}

/* ── Bottoni ─────────────────────────────────────────────────────────────── */
.pwa-smp-btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    width:           36px;
    height:          36px;
    border:          none;
    border-radius:   6px;
    background:      rgba(255,255,255,.15);
    color:           #fff;
    cursor:          pointer;
    transition:      background .15s, transform .1s;
    font-size:       15px;
    padding:         0;
    flex-shrink:     0;
}
.pwa-smp-btn svg { width: 20px; height: 20px; }
.pwa-smp-btn:hover:not(:disabled) { background: var(--pwa-orange); transform: translateY(-1px); }
.pwa-smp-btn:disabled { opacity: .4; cursor: not-allowed; }

.pwa-smp-toolbar--secondary .pwa-smp-btn {
    background: var(--pwa-bg-dark);
    color:      var(--pwa-blue);
    width: 26px; height: 26px;
}
.pwa-smp-toolbar--secondary .pwa-smp-btn:hover:not(:disabled) {
    background: var(--pwa-orange); color: #fff;
}

/* ── Controlli play ──────────────────────────────────────────────────────── */
.pwa-smp-controls { display: flex; align-items: center; gap: 6px; }

/* ── BPM ─────────────────────────────────────────────────────────────────── */
.pwa-smp-bpm-group { display: flex; align-items: center; gap: 6px; }

.pwa-smp-bpm-slider {
    -webkit-appearance: none;
    width: 110px; height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,.3);
    outline: none; cursor: pointer;
}
.pwa-smp-bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--pwa-orange);
    cursor: pointer;
}

.pwa-smp-bpm-input {
    width: 52px; padding: 4px 6px;
    border: 1.5px solid rgba(255,255,255,.3);
    border-radius: 5px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 13px; font-weight: 700;
    font-family: 'DM Sans', sans-serif;
    text-align: center; outline: none;
}
.pwa-smp-bpm-input:focus { border-color: var(--pwa-orange); }

/* ── Zoom ────────────────────────────────────────────────────────────────── */
.pwa-smp-zoom-group { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pwa-smp-zoom-val   { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.9); min-width: 36px; text-align: center; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.pwa-smp-toggle-label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.pwa-smp-toggle-label input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }

.pwa-smp-toggle-track {
    display: inline-block;
    width: 34px; height: 18px;
    border-radius: 20px;
    background: var(--pwa-border);
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.pwa-smp-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: left .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
input:checked + .pwa-smp-toggle-track { background: var(--pwa-orange); }
input:checked + .pwa-smp-toggle-track::after { left: 18px; }

/* ── Metro group ─────────────────────────────────────────────────────────── */
.pwa-smp-metro-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pwa-smp-countin-select {
    border: 1.5px solid var(--pwa-border);
    border-radius: 5px;
    background: #fff;
    color: var(--pwa-blue);
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    padding: 3px 7px;
    outline: none; cursor: pointer;
}
.pwa-smp-countin-select:focus { border-color: var(--pwa-orange); }

/* ── Mixer ───────────────────────────────────────────────────────────────── */
.pwa-smp-mixer { display: flex; align-items: center; gap: 5px; }

input[type=range].pwa-smp-vol-piano,
input[type=range].pwa-smp-vol-metro {
    -webkit-appearance: none;
    width: 80px; height: 4px;
    border-radius: 4px;
    background: var(--pwa-border);
    outline: none; cursor: pointer;
}
input[type=range].pwa-smp-vol-piano::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--pwa-blue); cursor: pointer;
}
input[type=range].pwa-smp-vol-metro::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--pwa-orange); cursor: pointer;
}



/* ── Progress bar ────────────────────────────────────────────────────────── */
.pwa-smp-progress-wrap {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     6px 14px;
    background:  var(--pwa-bg);
    border-bottom: 1px solid var(--pwa-border);
}

.pwa-smp-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--pwa-border);
    border-radius: 6px;
    position: relative;
    cursor: pointer;
}
.pwa-smp-progress-fill {
    height: 100%;
    background: var(--pwa-orange);
    border-radius: 6px;
    width: 0%;
    transition: width .1s linear;
}
.pwa-smp-progress-thumb {
    position: absolute;
    top: 50%; left: 0%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--pwa-blue);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    transition: left .1s linear;
}
.pwa-smp-time-display {
    font-size: 11px;
    font-weight: 600;
    color: var(--pwa-muted);
    white-space: nowrap;
    min-width: 72px;
    text-align: right;
}

/* ── Score wrapper ───────────────────────────────────────────────────────── */
.pwa-smp-score-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    min-height: 200px;
    padding:    16px 12px;
}

/* OSMD SVG */
.pwa-smp-osmd-container svg {
    display: block;
    margin:  0 auto;
}

/* Cursore OSMD — evidenzia la nota corrente */
.pwa-smp-osmd-container .osmd-cursor {
    background: rgba(245,130,10,.25) !important;
    border-left: 2px solid var(--pwa-orange) !important;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */
.pwa-smp-loading {
    position:   absolute;
    inset:      0;
    display:    flex;
    flex-direction: column;
    align-items:center;
    justify-content:center;
    gap:        12px;
    background: rgba(240,244,248,.93);
    z-index:    10;
    font-size:  14px;
    color:      var(--pwa-muted);
    font-weight:500;
}

.pwa-smp-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--pwa-border);
    border-top: 3px solid var(--pwa-orange);
    border-radius: 50%;
    animation: pwa-spin .8s linear infinite;
}
@keyframes pwa-spin { to { transform: rotate(360deg); } }

/* ── Errore ──────────────────────────────────────────────────────────────── */
.pwa-smp-error {
    padding: 16px 20px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: var(--pwa-radius);
    font-size: 13px;
    margin: 12px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .pwa-smp-toolbar       { gap: 8px 10px; padding: 8px 10px; }
    .pwa-smp-toolbar--secondary { padding: 6px 10px; }
    .pwa-smp-bpm-slider    { width: 80px; }
    .pwa-smp-zoom-group    { margin-left: 0; }
    input[type=range].pwa-smp-vol-piano,
    input[type=range].pwa-smp-vol-metro { width: 55px; }
}


/* ── v2.7.0: tastiera pianoforte ── */
.pwa-smp-keyboard-wrap {
    width: 100%;
    padding: 10px 12px 8px;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    box-sizing: border-box;
    overflow: hidden;
}
.pwa-smp-keyboard {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15));
}

/* Pulsante tastiera attivo */
.pwa-smp-btn--keyboard {
    margin-left: 8px;
}
.pwa-smp-btn--active {
    background: rgba(255,255,255,0.25) !important;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.5);
}

/* ── v2.7.3: fullscreen ── */
.pwa-smp-btn--fullscreen {
    margin-left: 6px;
}

/* Modalità fullscreen: il wrapper occupa tutto lo schermo */
.pwa-smp-wrapper:-webkit-full-screen,
.pwa-smp-wrapper:-moz-full-screen,
.pwa-smp-wrapper:fullscreen,
.pwa-smp--fullscreen {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* In fullscreen lo score-wrap si espande per riempire lo spazio disponibile */
.pwa-smp-wrapper:-webkit-full-screen .pwa-smp-score-wrap,
.pwa-smp-wrapper:-moz-full-screen .pwa-smp-score-wrap,
.pwa-smp-wrapper:fullscreen .pwa-smp-score-wrap,
.pwa-smp--fullscreen .pwa-smp-score-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Tastiera in fullscreen rimane proporzionata */
.pwa-smp-wrapper:-webkit-full-screen .pwa-smp-keyboard-wrap,
.pwa-smp-wrapper:-moz-full-screen .pwa-smp-keyboard-wrap,
.pwa-smp-wrapper:fullscreen .pwa-smp-keyboard-wrap,
.pwa-smp--fullscreen .pwa-smp-keyboard-wrap {
    flex-shrink: 0;
}

/* ── v2.8.0: menu selezione file multi-brano ── */
.pwa-smp-file-select-wrap {
    padding: 8px 12px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}
.pwa-smp-file-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    color: #1a3a5c;
    cursor: pointer;
    font-family: inherit;
}
.pwa-smp-file-select:focus {
    outline: 2px solid #1a3a5c;
    outline-offset: 1px;
}
