/* ═══════════════════════════════════════════════════════════════
   layout.css — page structure, header, transport, sidebar
   ═══════════════════════════════════════════════════════════════ */

/* ── APP SHELL ───────────────────────────────────────────────── */
body {
  display: grid;
  grid-template-rows: 52px 52px 1fr 28px;
  grid-template-columns: 1fr;
  height: 100vh;
}

/* ── HEADER ──────────────────────────────────────────────────── */
#app-header {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  fill: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-version {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 2px 6px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
}

.header-file {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

#file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#file-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Hue control */
.hue-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.hue-control input[type="range"] {
  width: 90px;
  background: linear-gradient(to right,
    hsl(0,80%,58%), hsl(30,80%,58%), hsl(60,80%,58%),
    hsl(120,80%,58%), hsl(180,80%,58%), hsl(210,80%,58%),
    hsl(270,80%,58%), hsl(300,80%,58%), hsl(330,80%,58%), hsl(360,80%,58%)
  );
  height: 5px;
  border-radius: 3px;
}

/* ── TRANSPORT BAR ───────────────────────────────────────────── */
#transport-bar {
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
}

.transport-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.transport-group:last-child { border-right: none; }

.transport-right { margin-left: auto; }

.time-display {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  padding: 0 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  letter-spacing: 0.03em;
}

.time-sep { color: var(--text-muted); }

.zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#zoom-slider { width: 90px; }

/* ── MAIN AREA ───────────────────────────────────────────────── */
#main-layout {
  grid-row: 3;
  display: grid;
  grid-template-columns: 1fr 260px;
  overflow: hidden;
}

/* ── WAVEFORM SECTION ────────────────────────────────────────── */
#waveform-section {
  display: grid;
  grid-template-rows: 1fr 12px;
  grid-template-columns: 36px 1fr;
  overflow: hidden;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
}

#channel-labels {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.ch-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
}
.ch-label:last-child { border-bottom: none; }

#waveform-wrap {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  overflow: hidden;
}

#canvas-waveform,
#canvas-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

#canvas-overlay { pointer-events: none; }

#scroll-track {
  grid-column: 1 / -1;
  grid-row: 2;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  position: relative;
  cursor: pointer;
}

#scroll-thumb {
  position: absolute;
  top: 2px;
  height: calc(100% - 4px);
  min-width: 20px;
  background: var(--accent);
  border-radius: 3px;
  opacity: 0.5;
  cursor: grab;
  transition: opacity var(--t-fast);
}

#scroll-thumb:hover { opacity: 0.8; }
#scroll-thumb:active { cursor: grabbing; opacity: 1; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
#sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-surface);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title i { font-size: 13px; color: var(--accent); }

.panel-title-toggle {
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
}

.panel-title-toggle:hover { color: var(--text-secondary); }

.keys-arrow { margin-left: auto; transition: transform var(--t-med); }
.keys-body.collapsed + * { display: none; }
#panel-keys.open .keys-arrow { transform: rotate(180deg); }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-muted); }
.info-row span:last-child {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
}

.keys-body { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.keys-body.hidden { display: none; }

.key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  font-size: 11px;
}
.key-row span { color: var(--text-secondary); }

/* ── STATUS BAR ──────────────────────────────────────────────── */
#status-bar {
  grid-row: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

#progress-wrap {
  width: 160px;
  height: 4px;
  background: var(--bg-active);
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 2px;
  transition: width 80ms linear;
}

#progress-wrap.hidden { display: none; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hi);
}

.btn:active { transform: scale(0.97); }

.btn-accent {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent); }

.btn-export {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
  font-size: 12px;
}
.btn-export:hover { background: var(--accent-faint); }
.btn-export:disabled { opacity: 0.4; cursor: default; }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-mid);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.icon-btn.active {
  background: var(--accent-faint);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── DROP OVERLAY ────────────────────────────────────────────── */
.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-base);
  z-index: 10;
  transition: opacity var(--t-med);
}

.drop-overlay:not(.active) { display: none; }

.drop-icon {
  font-size: 52px;
  color: var(--accent);
  opacity: 0.5;
}

.drop-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.drop-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.drop-btn { margin-top: 8px; }

body.drag-over .drop-overlay.active {
  background: var(--accent-faint);
  border: 2px dashed var(--accent);
}

/* ── TOAST ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease forwards;
  white-space: nowrap;
}

.toast.removing { animation: toast-out 200ms ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}
