/* RadioStation - Huvudstilar */

:root {
  --bg-dark: #0f1117;
  --bg-panel: #1a1d27;
  --bg-hover: #252836;
  --bg-active: #2d3148;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --text: #e8e8f0;
  --text-muted: #8b8fa3;
  --border: #2d3148;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Dashboard ── */
.dashboard {
  background: linear-gradient(135deg, #1a1d27 0%, #12141c 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 24px;
  align-items: center;
  box-shadow: var(--shadow);
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 2rem;
}

.dashboard-brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.dashboard-now-playing {
  min-width: 0;
}

.now-playing-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-light);
  margin-bottom: 2px;
}

.now-playing-title {
  font-size: 1.4rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-artist {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dashboard-clocks {
  display: flex;
  gap: 20px;
}

.clock-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-panel);
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-width: 110px;
}

.clock-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.clock-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-light);
}

.dashboard-progress {
  min-width: 200px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-panel);
  border-radius: 3px;
  position: relative;
  overflow: visible;
  margin-bottom: 4px;
}

.progress-bar.seekable {
  cursor: pointer;
  height: 10px;
}

.progress-bar.seekable:hover .progress-fill {
  filter: brightness(1.15);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s linear;
}

.cue-marker,
.intro-marker,
.segue-marker {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  transform: translateX(-50%);
  pointer-events: none;
}

.cue-marker { background: #74b9ff; }
.intro-marker { background: var(--warning); }
.segue-marker { background: #e17055; }

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.intro-countdown {
  color: var(--warning);
  font-weight: 600;
}

.dashboard-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Knappar ── */
.btn {
  border: none;
  cursor: pointer;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-control {
  width: 44px;
  height: 44px;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 1.2rem;
}

.btn-control:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-play {
  width: 52px;
  height: 52px;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 1.4rem;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-play:hover {
  background: var(--accent-light);
}

.btn-play.playing {
  background: var(--success);
  border-color: var(--success);
}

.btn-secondary {
  padding: 8px 14px;
  background: var(--bg-panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-icon {
  width: 28px;
  height: 28px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

/* ── Huvudinnehåll ── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.panel:last-child {
  border-right: none;
}

.panel-header {
  padding: 14px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-dark);
  padding: 3px 10px;
  border-radius: 20px;
}

.panel-tools {
  display: flex;
  gap: 8px;
}

.search-input,
.filter-select {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.search-input {
  width: 200px;
}

.search-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Track-listor ── */
.track-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.track-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: grab;
  transition: background 0.15s;
  border: 1px solid transparent;
  user-select: none;
}

.track-item:hover {
  background: var(--bg-hover);
}

.track-item.playing {
  background: var(--bg-active);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.track-item.ui-sortable-helper {
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  cursor: grabbing;
}

.track-item.ui-sortable-placeholder {
  visibility: visible !important;
  background: var(--accent-glow);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  height: 48px;
}

.track-icon {
  font-size: 1.3rem;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.track-duration {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.track-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.track-item:hover .track-actions {
  opacity: 1;
}

/* ── Drag-and-drop ── */
.panel-playlist {
  position: relative;
}

.panel-playlist .track-list {
  min-height: 100px;
}

.panel-playlist.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

.drop-indicator {
  position: absolute;
  height: 3px;
  background: var(--accent-light);
  box-shadow: 0 0 10px var(--accent-glow);
  border-radius: 2px;
  z-index: 20;
  pointer-events: none;
}

.drop-indicator[hidden] {
  display: none;
}

.track-item {
  position: relative;
  overflow: hidden;
}

.track-item.dragging {
  opacity: 0.45;
}

.track-item.active-track {
  border-color: var(--accent);
}

.track-row-progress {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}

.track-row-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(108, 92, 231, 0.18), rgba(162, 155, 254, 0.12));
  transition: width 0.2s linear;
}

.track-item .track-icon,
.track-item .track-info,
.track-item .track-duration,
.track-item .track-actions {
  position: relative;
  z-index: 1;
}

/* Kontextmeny */
.context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20000;
  min-width: 200px;
  overflow: hidden;
}

.context-menu[hidden] { display: none; }

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.context-menu button:hover {
  background: var(--bg-hover);
}

/* Mix-dialog */
.mix-dialog { width: min(480px, 92vw); }

.mix-dialog-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.mix-form { display: flex; flex-direction: column; gap: 12px; }

.mix-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.mix-field input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.mix-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.mix-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.mix-field.readonly span {
  font-size: 1rem;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}

.mix-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 4px;
}

.btn-primary {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary:hover { background: var(--accent-light); }

.btn-primary:disabled { opacity: 0.5; cursor: wait; }

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Responsivt ── */
@media (max-width: 1100px) {
  .dashboard {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .dashboard-progress {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* ── Skanningsdialog ── */
.scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.scan-overlay[hidden] {
  display: none;
}

.scan-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(520px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.scan-dialog h3 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.scan-status {
  color: var(--accent-light);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.scan-file {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-progress-bar {
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  width: 0%;
  transition: width 0.2s ease;
}

.scan-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.scan-log {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 16px;
  font-size: 0.78rem;
  font-family: 'Consolas', 'Courier New', monospace;
}

.scan-log li {
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.scan-log li:last-child {
  border-bottom: none;
}

.scan-log-ok { color: var(--success); }
.scan-log-skip { color: var(--text-muted); }
.scan-log-error { color: var(--danger); }
.scan-log-info { color: var(--accent-light); }

.scan-actions {
  display: flex;
  justify-content: flex-end;
}
