/**
* Main CSS - Core styles for Piano Trainer modular architecture
* Compatible with app-styles.css from chordbuddy
*/

/* Reset and base styles - compatible with app-styles.css */
* {
    box-sizing: border-box;
}

:root {
    --transport-topbar-height: 60px;
    --transport-progress-height: 45px;
    --keyboard-height: 150px;
    --statusbar-height: 40px;
    --mixer-reserved: 0px;
    --mixer-reserved-left: 0px;
    --mixer-reserved-right: 0px;
}

/* CSS Variable Overrides removed - managed by JS/ResizeObserver for accuracy */
/* @media (max-width: 1400px) { ... } removed */

html,
body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Override app-styles.css body to work with our layout */
body {
    margin: 0;
    padding: 0;
    background: #000;
    /* Dark theme base color */
    color: #fff;
    font-family: system-ui, -apple-system, sans-serif;
    /* System default font stack */
    overflow: hidden;
    padding-top: calc(var(--transport-topbar-height, 30px) + var(--transport-progress-height, 45px));
    padding-bottom: var(--statusbar-height, 28px);
    /* Account for fixed TopBar component height */
}

input,
textarea,
[contenteditable="true"],
.allow-text-selection {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Audio unlock overlay */
.audio-unlock-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 120px;
    z-index: 5000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
}

.audio-unlock-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.audio-unlock-overlay.hidden {
    display: none;
}

.audio-unlock-card {
    pointer-events: auto;
    background: rgba(10, 10, 10, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 18px 22px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(18px);
}

.audio-unlock-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.audio-unlock-copy {
    margin: 0;
    font-size: 13px;
    opacity: 0.8;
}

.audio-unlock-button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    padding: 10px 28px;
    font-size: 15px;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.audio-unlock-button:hover {
    background: var(--accent-hover);
    transform: translateY(var(--lift-1));
    box-shadow: 0 6px 18px rgba(56, 145, 255, 0.4);
}

.audio-unlock-button:disabled {
    opacity: 0.6;
    cursor: wait;
    box-shadow: none;
}

/* Modular canvas components - each component owns its own canvas */
.pianoroll-canvas {
    position: fixed;
    bottom: var(--statusbar-height, 28px);
    left: 0;
    width: 100vw;
    height: var(--keyboard-height, 150px);
    z-index: 10;
    /* Above waterfall (5) for user interaction */
    pointer-events: auto;
}

.waterfall-canvas {
    position: fixed;
    top: calc(var(--transport-topbar-height, 30px) + var(--transport-progress-height, 45px));
    /* Below transport bar */
    left: 0;
    width: 100vw;
    height: calc(100vh - (var(--transport-topbar-height, 30px) + var(--transport-progress-height, 45px)) - var(--keyboard-height, 150px) - var(--statusbar-height, 28px));
    z-index: 5;
    pointer-events: none;
}

/* Hide the old grid-based containers - components use fixed positioning */
#waterfall-container,
#pianoroll-container {
    display: none !important;
}

/* Component-specific overrides for compatibility */

/* TrackMixer component positioning - handled by component itself */
/* #track-mixer.track-mixer-container handled by component itself */

/* Hide removed info panels - override app-styles.css */
#info,
#audioInfo {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   CONTROL PANELS & BUTTONS (ported from app-styles.css)
   ═══════════════════════════════════════════════════════════════ */

#controls {
    position: absolute;
    top: calc(var(--transport-topbar-height, 30px) + var(--transport-progress-height, 45px) + 10px);
    /* Below transport bar + margin */
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/*
 * Legacy button fallback — scoped to the debug HUD only.
 * Removed the global `button { … }` rule (was polluting every <button>
 * across the app and forcing every primitive to fight specificity).
 * DebugHUD has two unstyled <button> elements that previously inherited
 * the global rule; this preserves their appearance without leaking.
 */
#debug-hud button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    margin: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-lg);
    transition: all 0.2s;
}

#debug-hud button:hover {
    background: var(--accent-hover);
    transform: translateY(var(--lift-1));
    box-shadow: 0 2px 8px rgba(56, 145, 255, 0.3);
}

/* MIDI editor toolbar styles relocated to components/midi-editor.css. */

body.cb-playing .playhead,
body.cb-transport-active .playhead,
body.cb-progress-interacting .playhead {
    box-shadow: none !important;
}

/*
 * Removed: .file-label, .control-btn — verified zero consumers across
 * src/ and index.html, leftover from an older skin.
 *
 * Removed: input[type="range"] { width: 100% } — this unscoped global
 * was forcing inline style="width:Npx" on every range input that wanted
 * a non-100% width (notably the MIDI editor zoom-x/zoom-y). Width is now
 * controlled via --range-width on the parent group; .ui-slider reads it.
 *
 * Removed: .slider-container — orphaned helper, no consumers.
 */

.info-row {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    font-size: 14px;
}

.info-label {
    opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════
   DRAG OVERLAY (ported from app-styles.css)
   ═══════════════════════════════════════════════════════════════ */

.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(56, 145, 255, 0.9);
    color: white;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
}

.drag-overlay.active {
    display: flex;
}

.drag-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL STYLES (ported from app-styles.css)
   ═══════════════════════════════════════════════════════════════ */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #1e1e1e;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #444;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #fff;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.close-modal:hover {
    color: #fff;
}

.song-list {
    display: grid;
    gap: 10px;
}

.song-item {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #444;
}

.song-item:hover {
    background: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.song-item h3 {
    margin: 0 0 5px 0;
    color: #fff;
    font-size: 16px;
}

.song-item p {
    margin: 0;
    color: #ccc;
    font-size: 14px;
    opacity: 0.8;
}

/* Ensure compatibility with existing component styles */
/* Components handle their own styling: .top-bar-container, .track-mixer-container, .waterfall-container, .pianoroll-container */

/* Additional styles for new UI elements not covered by app-styles.css */
#midiDeviceCount,
#midi-device-list {
    color: #fff;
}

.midi-device {
    background: #444;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 4px 0;
    font-size: 13px;
    color: #fff;
}

.midi-device-status__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.midi-device-status__count {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 2px 8px;
    font-weight: 600;
}

.midi-device-status__list {
    max-height: 180px;
    overflow-y: auto;
}

.midi-device__meta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

.midi-device--empty {
    opacity: 0.7;
    font-style: italic;
}

/* Performance stats styling - consistent with design system */
/* #performance-stats styled by component or inherited */

/* Responsive adjustments - simplified for fixed layout */
@media (max-width: 900px) {
    body {
        padding-top: 120px;
        /* Adjust for smaller navigation */
    }

    #canvas {
        height: calc(100vh - 120px);
        top: 120px;
    }
}
