/* ══════════════════════════════════════════════════════════════════════
   Sync Fleet Audio — Dark DJ Theme
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-input: #22222e;
  --border: #2a2a3a;
  --border-focus: #6c5ce7;
  --text-primary: #eeeef0;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00e676;
  --success-dim: rgba(0, 230, 118, 0.15);
  --warning: #ffab00;
  --warning-dim: rgba(255, 171, 0, 0.15);
  --danger: #ff5252;
  --danger-dim: rgba(255, 82, 82, 0.15);
  --info: #40c4ff;
  --info-dim: rgba(64, 196, 255, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

.app-header {
  text-align: center;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.app-header .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 1rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-success {
  background: var(--success);
  color: #000;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.1rem;
  width: 100%;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Inputs ──────────────────────────────────────────────────────────── */
.input,
.select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--border-focus);
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.input-group .input {
  flex: 1;
}

/* ── PIN Screen ──────────────────────────────────────────────────────── */
.pin-screen,
.setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  gap: 20px;
  text-align: center;
}

.pin-screen .lock-icon,
.setup-screen .setup-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.pin-input {
  width: 180px;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 12px;
  padding: 14px;
}

/* ── Progress Bar ────────────────────────────────────────────────────── */
.progress-container {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-bar.uploading {
  background: linear-gradient(90deg, var(--warning), var(--accent));
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

/* ── Large Progress (Receiver Download) ──────────────────────────────── */
.progress-large {
  height: 16px;
  border-radius: 8px;
  margin: 12px 0;
}

.progress-large .progress-bar {
  border-radius: 8px;
}

.ready-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ── Transport Controls ──────────────────────────────────────────────── */
.transport-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.transport-controls .btn-play {
  grid-column: 1 / -1;
}

.seek-controls {
  margin-top: 12px;
}

.seek-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  margin: 8px 0;
}

.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.seek-bar::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.seek-time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.jump-time-group {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.jump-time-group .input {
  flex: 1;
  font-variant-numeric: tabular-nums;
}

/* ── Schedule Controls ───────────────────────────────────────────────── */
.schedule-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.schedule-controls .btn {
  flex: 1;
  min-width: 80px;
}

.schedule-time-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.schedule-time-input .input {
  flex: 1;
}

/* ── Track List ──────────────────────────────────────────────────────── */
.track-list {
  list-style: none;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color var(--transition);
}

.track-item:hover {
  border-color: var(--accent);
}

.track-item.active {
  border-color: var(--success);
  background: var(--success-dim);
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-name {
  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);
}

.track-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Fleet Dashboard ─────────────────────────────────────────────────── */
.fleet-list {
  list-style: none;
}

.fleet-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.fleet-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.fleet-status {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
}

.fleet-details {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

.status-playing {
  color: var(--success);
}

.status-paused {
  color: var(--warning);
}

.status-stopped {
  color: var(--text-muted);
}

.status-ready {
  color: var(--success);
}

.status-downloading {
  color: var(--info);
}

/* ── Receiver — Main Play Button ─────────────────────────────────────── */
.receiver-main-btn {
  width: 100%;
  padding: 20px;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: var(--radius);
  margin: 16px 0;
}

/* ── Receiver — Status Display ───────────────────────────────────────── */
.sync-status {
  text-align: center;
  padding: 20px;
}

.sync-status .big-status {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.sync-status .sync-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.now-playing {
  text-align: center;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing strong {
  color: var(--text-primary);
}

/* ── Calibration Drawer ──────────────────────────────────────────────── */
.calibration-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 12px;
}

.calibration-drawer {
  display: none;
  padding: 16px;
  margin-top: 8px;
}

.calibration-drawer.open {
  display: block;
}

.calibration-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  margin: 12px 0;
}

.calibration-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--warning);
  border-radius: 50%;
  cursor: pointer;
}

.calibration-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--warning);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.calibration-value {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--warning);
  font-variant-numeric: tabular-nums;
}

.calibration-label {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Connection Indicator ────────────────────────────────────────────── */
.connection-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1000;
  transition: background var(--transition);
}

.connection-bar.connected {
  background: var(--success);
}

.connection-bar.disconnected {
  background: var(--danger);
  animation: pulse-bar 1s infinite;
}

@keyframes pulse-bar {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* ── Upload Area ─────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 12px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
}

.upload-area .upload-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.upload-area .upload-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.upload-area input[type="file"] {
  display: none;
}

/* ── Empty States ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Countdown Overlay ───────────────────────────────────────────────── */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.countdown-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.countdown-number {
  font-size: 8rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 60px var(--accent-glow);
  animation: countPulse 1s ease infinite;
}

@keyframes countPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

/* ── Clear Cache Button ──────────────────────────────────────────────── */
.clear-cache-wrapper {
  margin-top: 20px;
  text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .app-container {
    padding: 10px;
  }

  .transport-controls {
    grid-template-columns: 1fr;
  }

  .btn-lg {
    padding: 14px 20px;
    font-size: 1rem;
  }
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.8rem;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-danger {
  color: var(--danger);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gap-8 {
  gap: 8px;
}