/* Capture & Detection screens */

/* ── Mode toggle ──────────────────────────────────────────────────────────── */
.mode-toggle-bar {
  display: flex;
  margin: 12px 16px 0;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.mode-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-toggle-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ── Single-card mode queue ───────────────────────────────────────────────── */
.single-mode-hint {
  font-size: 13px;
  color: var(--text-muted);
  padding: 10px 16px 4px;
  text-align: center;
}

.sc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 0;
}

.sc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.sc-faces {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sc-face {
  width: 80px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.sc-face img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.sc-face-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sc-front { background: var(--bg); }

.sc-back-btn {
  width: 80px; height: 56px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--accent);
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

.sc-back-btn:active { opacity: 0.7; }

.sc-back-btn.pulse {
  animation: sc-pulse 1.2s ease-in-out 3;
}

@keyframes sc-pulse {
  0%,100% { border-color: var(--border); background: var(--bg); }
  50%      { border-color: var(--accent); background: var(--accent-light); }
}

.sc-back-filled { background: var(--bg); }

.sc-remove {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.sc-remove:active { color: var(--danger); }

/* Session banner */
.session-banner {
  background: var(--accent-light);
  border-bottom: 1px solid #c8e6d8;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-banner .no-session {
  color: var(--text-muted);
  font-weight: 400;
}

/* Capture tabs */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Camera / Library input areas */
.capture-area {
  padding: 24px 16px;
}

.photo-input-btn {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
}

.photo-input-btn svg { color: var(--accent); opacity: 0.7; }
.photo-input-btn span { font-size: 15px; font-weight: 600; color: var(--accent); }
.photo-input-btn small { font-size: 13px; }

.photo-input-btn:active { opacity: 0.75; }

/* Photo queue */
.photo-queue {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.queue-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.queue-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.queue-thumb {
  position: relative;
  flex-shrink: 0;
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border);
}

.queue-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.queue-thumb-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Detection screen — new layout ──────────────────────────────────────────
 *
 *  .det-wrap
 *    .det-photo-nav       (only when > 1 photo)
 *    .det-img-wrap        photo + overlay canvas
 *    .det-carousel        card viewer / loading / empty states
 *    .det-footer          manual + confirm buttons
 */

.det-wrap {
  display: flex;
  flex-direction: column;
  background: #000;
  min-height: 100%;
}

/* ── Photo nav ─────────────────────────────────────────────────────────────── */
.det-photo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #111;
  border-bottom: 1px solid #222;
}

.det-label {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
}

.det-nav-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  opacity: 0.75;
  font-family: var(--font);
}
.det-nav-btn:disabled { opacity: 0.2; cursor: default; }

/* ── Photo + overlay ───────────────────────────────────────────────────────── */
.det-img-wrap {
  position: relative;
  flex-shrink: 0;
  background: #000;
  /* Limit photo to ~40% of viewport so there's room for the carousel */
  max-height: 42vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.det-img {
  width: 100%;
  display: block;
  max-height: 42vh;
  object-fit: contain;
}

.det-canvas {
  position: absolute;
  top: 0; left: 0;
  /* CSS 100%/100% scales the canvas pixel space to exactly match the img.
     canvas.width/height are set to naturalWidth/Height, so drawing coords
     are 1:1 with the image — no getBoundingClientRect needed. */
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ── Carousel ──────────────────────────────────────────────────────────────── */
.det-carousel {
  flex: 1;
  background: #111;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  border-top: 1px solid #222;
}

.det-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #888;
  font-size: 13px;
  padding: 24px;
}

/* Spinner on dark background */
.det-spinner {
  border-color: #333 !important;
  border-top-color: var(--accent) !important;
  width: 26px !important;
  height: 26px !important;
}

.det-card-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 4px;
}

/* Arrow nav row */
.det-card-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
  border-bottom: 1px solid #1e1e1e;
}

.det-card-arrow {
  background: none;
  border: 1px solid #333;
  color: #ccc;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: 6px;
  font-family: var(--font);
}
.det-card-arrow:disabled { opacity: 0.2; cursor: default; }
.det-card-arrow:active:not(:disabled) { background: #222; }

/* Crop preview */
.det-crop-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 6px;
  /* Touch target for swipe */
  touch-action: pan-y;
  overflow: hidden;
  min-height: 90px;
}

.det-crop-canvas {
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  display: block;
}

/* Confidence badge */
.det-conf-badge {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 16px 6px;
  min-height: 20px;
  letter-spacing: 0.2px;
}

/* Include / Skip buttons */
.det-card-btns {
  display: flex;
  gap: 8px;
  padding: 6px 16px 10px;
}

.det-skip-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid #333;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #666;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.det-skip-btn.active {
  border-color: #c0392b;
  color: #e74c3c;
  background: rgba(231,76,60,0.08);
}

.det-include-btn {
  flex: 2;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: #333;
  color: #666;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.det-include-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Empty / no-cards state */
.det-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.det-footer {
  background: #111;
  border-top: 1px solid #222;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.det-manual-btn {
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
}
.det-manual-btn:active { background: #1a1a1a; }

/* ── Legacy detection classes (kept for backwards compatibility) ─────────── */
.detection-container {
  position: relative;
  background: #000;
}

.detection-image-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}

.detection-image-wrap img {
  width: 100%;
  display: block;
}

.detection-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.detection-actions {
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.detection-card-list {
  padding: 12px 16px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detection-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  border: 2px solid var(--border);
}

.detection-card-item.accepted { border-color: var(--accent); }
.detection-card-item.rejected { border-color: var(--danger); opacity: 0.5; }

.detection-card-thumb {
  width: 56px; height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--border);
  flex-shrink: 0;
}

.detection-card-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex: 1;
}

.detection-toggle-btns {
  display: flex;
  gap: 6px;
}

.detection-toggle-btns button {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  font-family: var(--font);
}

.detection-toggle-btns button.accept { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.detection-toggle-btns button.reject { color: var(--danger); border-color: var(--danger); background: #fdf0ef; }
