/* ================================
   二维码解码器 - 自定义样式
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --danger: #DC2626;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  z-index: 1000;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.show { transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ── Page ── */
.page { max-width: 960px; margin: 0 auto; padding: 0 32px; }

/* ── Mode Bar ── */
.mode-bar {
  display: flex; gap: 6px; padding-bottom: 16px;
}
.mode-btn {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn:hover {
  border-color: rgba(79,70,229,0.25);
  color: var(--primary);
  background: var(--primary-light);
}
.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Mode Panel ── */
.mode-panel { display: none; padding-bottom: 16px; }
.mode-panel.active { display: block; }

/* ── Upload Zone ── */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 56px 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,70,229,0.06);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.08);
}

.upload-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}
.upload-zone:hover .upload-icon { color: var(--primary); }

.upload-text {
  font-size: 16px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.upload-input {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Paste Zone ── */
.paste-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 56px 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}
.paste-zone:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.08);
}

.paste-hint { margin-top: 8px; }

/* ── Camera ── */
.camera-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.video-wrapper {
  position: relative;
  width: 100%;
  max-height: 400px;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}

#cameraVideo {
  width: 100%;
  display: none;
}

.camera-placeholder {
  color: #666;
  text-align: center;
  padding: 60px 20px;
}

.camera-controls {
  display: flex; gap: 10px; justify-content: center;
  padding: 16px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.btn-scan {
  padding: 10px 24px;
  background: var(--primary);
  border: none;
  border-radius: 100px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: white; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-scan:hover { background: var(--primary-hover); }
.btn-scan.stop { background: var(--danger); }
.btn-scan.stop:hover { background: #B91C1C; }

/* ── Image Preview ── */
.preview-section { padding-bottom: 16px; }

.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.panel-title {
  font-size: 14px; font-weight: 700;
  color: var(--text);
}
.panel-actions {
  display: flex; align-items: center; gap: 8px;
}

.btn-action {
  padding: 6px 10px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.15s ease;
  display: flex; align-items: center;
  font-family: inherit;
}
.btn-action:hover {
  background: var(--primary-light);
  border-color: rgba(79,70,229,0.25);
  color: var(--primary);
}

.img-preview-body {
  padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-alt);
}
.img-preview-body canvas {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
}

/* ── Result ── */
.result-section { padding-bottom: 32px; }

.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.result-body {
  padding: 18px;
}

.result-text {
  padding: 16px;
  background: #F0FDF4;
  border: 1px solid rgba(5,150,105,0.2);
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 14px; line-height: 1.7;
  color: var(--text);
  word-break: break-all;
}

.result-text .url-link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.result-json {
  padding: 16px;
  background: #1e1e1e;
  border-radius: var(--radius);
  font-family: 'SF Mono', monospace;
  font-size: 13px; line-height: 1.6;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-error {
  text-align: center;
  color: var(--danger);
  padding: 16px;
  background: #FEF2F2;
  border-radius: var(--radius);
  font-size: 14px;
}

/* ── Decoded type badge ── */
.type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px; font-weight: 600;
  margin-bottom: 10px;
}
.type-url { background: #DBEAFE; color: #1E40AF; }
.type-text { background: var(--bg-alt); color: var(--text-secondary); }
.type-json { background: #FEF3C7; color: #92400E; }

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

::selection { background: rgba(79, 70, 229, 0.2); color: #1E293B; }

/* ── Guide Section (accordion) ── */
.guide-section {
  margin-top: 16px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover {
  background: var(--bg-alt);
}
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list {
  padding: 0 20px 20px;
}
.guide-list.hidden {
  display: none;
}
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child {
  border-top: 1px solid var(--border);
}
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.guide-item-body kbd {
  padding: 1px 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .page { padding: 0 16px; }

  .mode-bar {
    flex-wrap: wrap; gap: 4px;
  }
  .mode-btn {
    padding: 6px 14px; font-size: 12px;
  }
  .camera-controls {
    flex-direction: column;
  }
}
