/* MusicBreeze Web - Global Styles */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* When app-container is used, body should not scroll (score layout handles it) */
body:has(.app-container) {
    overflow: hidden;
}

/* App layout - toolbar top, mixer bottom, score scrolls */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    flex-wrap: wrap;
    border-bottom: 1px solid;
    flex-shrink: 0;
    z-index: 10;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    opacity: 0.3;
}

.btn {
    padding: 6px 14px;
    border: 1px solid;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn.active {
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.4);
}

.btn-icon {
    padding: 6px 10px;
    border: 1px solid;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    min-width: 36px;
    text-align: center;
}

.btn-icon:hover {
    opacity: 0.85;
}

/* Score Container - scrollable middle area */
.score-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    position: relative;
    min-height: 0; /* important for flex scroll */
}

/* Horizontal scroll mode */
.score-container.horizontal-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 0;
}

.score-container.horizontal-scroll svg {
    display: inline-block;
}

.score-container svg {
    display: block;
}

/* Ensure inner containers fill height for horizontal/bar mode */
.score-container .score-svg-container {
    height: 100%;
}

/* File Upload */
.file-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    border: 3px dashed;
    border-radius: 16px;
    margin: 0 auto;
    max-width: 500px;
    padding: 28px;
    text-align: center;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.file-upload-zone:hover {
    border-color: #e94560;
}

.file-upload-zone.dragging {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.05);
    transform: scale(1.02);
}

.file-upload-zone .icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.file-upload-zone h2 {
    margin: 0 0 10px;
    font-weight: 600;
}

.file-upload-zone p {
    opacity: 0.6;
    margin: 0;
}

.file-input-label {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.file-input-label:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(233, 69, 96, 0.2);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Bottom Panel (Mixer) - sticky bottom */
.bottom-panel {
    border-top: 1px solid;
    padding: 12px 20px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
    z-index: 10;
    max-height: 140px;
    overflow-x: auto;
}

.mixer-channel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid;
}

.mixer-channel.muted {
    opacity: 0.4;
}

.mixer-channel .name {
    font-size: 12px;
    font-weight: 600;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.mixer-channel .volume-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
    outline: none;
}

.mixer-channel .mute-btn {
    padding: 2px 8px;
    border: 1px solid;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    background: transparent;
}

/* Score info header */
.score-header {
    text-align: center;
    padding: 16px 0;
}

.score-header h1 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 700;
}

.score-header .composer {
    font-size: 14px;
    font-style: italic;
    opacity: 0.7;
}

.score-header .info {
    font-size: 12px;
    opacity: 0.5;
    margin-top: 4px;
}

/* Loading */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-size: 18px;
    gap: 8px;
}

.progress-bar-container {
    width: 300px;
    height: 8px;
    border-radius: 4px;
    border: 1px solid;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.15);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Instrument select */
select.instrument-select {
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid;
    background: transparent;
    color: inherit;
    max-width: 80px;
}

/* Toggle switch */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.toggle {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
    border: none;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.toggle.on::after {
    transform: translateX(18px);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.4);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.6);
}

/* === Toolbar responsive === */
.toolbar-score-info {
    margin-left: auto;
}

@media (max-width: 768px) {
    .toolbar-score-info {
        display: none;
    }

    .toolbar {
        gap: 6px;
        padding: 6px 10px;
    }
}

/* === Library responsive layout === */
.lib-account-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.lib-layout {
    display: flex;
    gap: 20px;
}

.lib-sidebar {
    width: 220px;
    flex-shrink: 0;
}

.lib-sidebar-toggle {
    display: none;
}

.lib-content {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .lib-account-bar {
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .lib-layout {
        flex-direction: column;
        gap: 8px;
    }

    .lib-sidebar {
        width: 100%;
        display: none;
        max-height: 50vh;
        overflow-y: auto;
    }

    .lib-sidebar.open {
        display: block;
    }

    .lib-sidebar-toggle {
        display: block;
        width: 100%;
        text-align: center;
        padding: 10px;
        font-size: 15px;
        border-radius: 8px;
    }

    .lib-content {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .lib-sidebar-toggle {
        font-size: 14px;
        padding: 8px;
    }
}

/* Accessibility: visible focus indicators */
*:focus-visible {
    outline: 3px solid #e94560;
    outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.toggle:focus-visible {
    outline: 3px solid #e94560;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.3);
}

input[type="range"]:focus-visible {
    outline: 3px solid #e94560;
    outline-offset: 4px;
}

select:focus-visible {
    outline: 3px solid #e94560;
    outline-offset: 2px;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: 8px 16px;
    background: #e94560;
    color: white;
    z-index: 100;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
}
