/* QRBeam — Dark Theme Stylesheet */

:root {
  --bg: #0f1115;
  --bg-card: #1a1d25;
  --bg-input: #252830;
  --border: #2d3039;
  --text: #e1e4eb;
  --text-muted: #8b8fa3;
  --accent: #4da6ff;
  --accent-hover: #6bb8ff;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --amber: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}
.header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.header h1 span { color: var(--accent); }
.header p {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* ---- Cards ---- */
.container {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  width: 100%;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
}
.card-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.card-link .icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}
.card-link h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.card-link p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #2d323d; }
.btn-danger {
  background: var(--danger);
  color: #000;
}
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success {
  background: var(--success);
  color: #000;
}
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-large {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
}

/* ---- Form controls ---- */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: rgba(77, 166, 255, 0.04);
}
.file-drop .drop-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}
.file-drop .drop-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.file-drop .drop-filename {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
}

.settings-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.settings-row > div {
  flex: 1;
  min-width: 120px;
}
.settings-row .value-label {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* ---- QR display ---- */
.qr-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  background: #000;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.qr-stage canvas {
  display: block;
  max-width: 90%;
  max-height: 90%;
  image-rendering: pixelated;
}
.qr-stage .corner-guide {
  position: absolute;
  width: 24px; height: 24px;
  border-color: rgba(255,255,255,0.15);
  border-style: solid;
  pointer-events: none;
}
.qr-stage .corner-guide.tl { top: 8px; left: 8px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.qr-stage .corner-guide.tr { top: 8px; right: 8px; border-width: 2px 2px 0 0; border-radius: 0 4px 0 0; }
.qr-stage .corner-guide.bl { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; border-radius: 0 0 0 4px; }
.qr-stage .corner-guide.br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }

/* ---- Stats bar ---- */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stats-bar .stat-value {
  color: var(--text);
  font-weight: 600;
}
.stats-bar .stat-accent { color: var(--accent); }
.stats-bar .stat-success { color: var(--success); }
.stats-bar .stat-warning { color: var(--warning); }

/* ---- Progress grid ---- */
.progress-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 1rem 0;
  max-height: 180px;
  overflow-y: auto;
}
.progress-grid .cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #2d3039;
  flex-shrink: 0;
  transition: background 0.15s;
}
.progress-grid .cell.received { background: var(--success); }
.progress-grid .cell.recovered { background: var(--amber); }
.progress-grid .cell.current { background: var(--accent); }

/* ---- Camera viewfinder ---- */
.viewfinder-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.viewfinder-wrap video {
  display: block;
  width: 100%;
  border-radius: var(--radius);
}
.scan-reticle {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 75%;
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
}
.scan-reticle::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  animation: scanLine 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent);
}
@keyframes scanLine {
  0%, 100% { top: 0%; }
  50% { top: 100%; }
}

/* ---- Utilities ---- */
.flex-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  max-width: 360px;
  animation: slideIn 0.25s ease-out;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .card { padding: 1.25rem; }
  .header h1 { font-size: 1.5rem; }
  .stats-bar { gap: 0.75rem; font-size: 0.75rem; }
}
