/* ═══════════════════════════════════════════════════════════
   TEETH AI SCANNER — Full Modal
   ═══════════════════════════════════════════════════════════ */

/* ── Trigger banner ─────────────────────────────────────────── */
#scanBanner {
  background: linear-gradient(135deg, #1f7a6e 0%, #2A9D8F 60%, #e9c46a 100%);
  color: #fff;
  text-align: center;
  padding: 12px 20px;
  font-size: .92rem;
  font-weight: 600;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  height: 48px;
}
#scanBanner span { opacity: .9; font-weight: 400; }
.scan-banner-btn {
  background: #fff;
  color: #1f7a6e;
  border: none;
  border-radius: 99px;
  padding: 7px 20px;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: transform .15s;
  font-family: inherit;
}
.scan-banner-btn:hover { transform: scale(1.05); }

/* ── Overlay ────────────────────────────────────────────────── */
#teethScanModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(10,20,18,.92);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}
#teethScanModal.open { display: flex; align-items: center; justify-content: center; }

.scan-modal-box {
  background: #fff;
  border-radius: 24px;
  width: min(700px, 95vw);
  max-height: 95vh;
  overflow-y: auto;
  position: relative;
  animation: scanIn .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes scanIn { from { opacity:0; transform:scale(.9) translateY(20px); } to { opacity:1; transform:scale(1) translateY(0); } }

.scan-modal-close {
  position: absolute;
  top: 16px; right: 18px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
  color: #374151;
  transition: background .2s;
}
.scan-modal-close:hover { background: #e5e7eb; }

/* ── Screens ────────────────────────────────────────────────── */
.scan-screen { display: none; padding: 36px 32px 40px; }
.scan-screen.active { display: block; }

/* Screen 0 — Welcome */
.scan-welcome { text-align: center; }
.scan-welcome .scan-hero-icon { font-size: 4rem; margin-bottom: 16px; }
.scan-welcome h2 { font-size: 1.7rem; margin-bottom: 10px; color: #1a1a2e; font-family: 'Playfair Display', serif; }
.scan-welcome p { color: #6b7280; margin-bottom: 28px; line-height: 1.6; max-width: 460px; margin-inline: auto; }
.scan-disclaimer {
  background: #fef9ec;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: .8rem;
  color: #92400e;
  margin-bottom: 24px;
  line-height: 1.5;
}
.scan-start-btn {
  background: #2A9D8F;
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
  display: inline-flex; align-items: center; gap: 8px;
}
.scan-start-btn:hover { background: #1f7a6e; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(42,157,143,.3); }

/* Screen 1 — Instructions + Camera */
.scan-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  align-items: start;
}

.scan-instructions h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: #1a1a2e; }
.scan-steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.scan-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid #f3f4f6;
  transition: border-color .2s;
}
.scan-step.active-step { border-color: #2A9D8F; background: #f0fafa; }
.scan-step-num {
  width: 28px; height: 28px;
  background: #e5e7eb;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
  flex-shrink: 0;
  color: #374151;
}
.scan-step.active-step .scan-step-num { background: #2A9D8F; color: #fff; }
.scan-step-text { font-size: .85rem; color: #4b5563; line-height: 1.4; }
.scan-step-text strong { color: #1a1a2e; display: block; margin-bottom: 2px; }

/* Camera area */
.scan-camera-area { display: flex; flex-direction: column; gap: 12px; }

#scanVideo {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 16px;
  background: #111;
  object-fit: cover;
  border: 3px solid #2A9D8F;
}
.scan-overlay-guide {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
}
.scan-guide-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.scan-guide-inner {
  width: 70%; height: 35%;
  border: 2px dashed rgba(255,255,255,.6);
  border-radius: 40px;
  position: relative;
}
.scan-guide-inner::after {
  content: "Open wide & show teeth";
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: rgba(255,255,255,.85);
  font-size: .72rem;
  font-weight: 600;
  background: rgba(0,0,0,.4);
  padding: 3px 10px;
  border-radius: 99px;
}

.scan-cam-status {
  text-align: center;
  font-size: .8rem;
  color: #6b7280;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.scan-cam-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; animation: blink 1.5s infinite; }

.scan-capture-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #2A9D8F;
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px #2A9D8F;
  cursor: pointer;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  transition: transform .15s;
}
.scan-capture-btn:hover { transform: scale(1.08); }
.scan-capture-btn:active { transform: scale(.95); }

/* Camera error */
.cam-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: #dc2626;
  font-size: .88rem;
}

/* Screen 2 — Analysing */
.scan-analysing { text-align: center; padding: 60px 32px; }
#capturedPreview {
  width: 200px; height: 150px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 24px;
  border: 3px solid #2A9D8F;
}
.scan-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(42,157,143,.2);
  border-top-color: #2A9D8F;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-analysis-steps { list-style: none; text-align: left; display: inline-flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.scan-analysis-step { font-size: .85rem; color: #6b7280; display: flex; gap: 8px; align-items: center; }
.scan-analysis-step.done { color: #16a34a; }
.scan-analysis-step.done::before { content: "✓"; font-weight: 700; }
.scan-analysis-step:not(.done)::before { content: "○"; opacity: .4; }

/* Screen 3 — Report */
.scan-report h2 { font-size: 1.4rem; margin-bottom: 6px; font-family: 'Playfair Display', serif; }
.scan-report-sub { color: #6b7280; font-size: .88rem; margin-bottom: 24px; }

.report-overall {
  background: linear-gradient(135deg, #f0fafa, #fff);
  border: 1.5px solid rgba(42,157,143,.2);
  border-radius: 16px;
  padding: 20px;
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.report-score-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
  flex-shrink: 0;
  border: 4px solid;
}
.report-score-label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.report-overall-text h4 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.report-overall-text p { font-size: .83rem; color: #6b7280; line-height: 1.5; }

.report-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.report-metric {
  background: #f9fafb;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid #f3f4f6;
}
.report-metric-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.report-metric-name { font-size: .82rem; font-weight: 600; color: #374151; }
.report-metric-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 99px;
}
.badge-good  { background: #dcfce7; color: #15803d; }
.badge-fair  { background: #fef9c3; color: #a16207; }
.badge-poor  { background: #fee2e2; color: #b91c1c; }
.report-bar { height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.report-bar-fill { height: 100%; border-radius: 99px; transition: width 1s ease; }
.report-metric-note { font-size: .75rem; color: #6b7280; margin-top: 6px; line-height: 1.4; }

.report-findings {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 22px;
}
.report-findings h4 { font-size: .88rem; font-weight: 700; margin-bottom: 10px; color: #92400e; }
.report-findings ul { display: flex; flex-direction: column; gap: 6px; }
.report-findings li { font-size: .83rem; color: #78350f; padding-left: 18px; position: relative; line-height: 1.4; }
.report-findings li::before { content: "⚠"; position: absolute; left: 0; }

.report-cta-box { background: linear-gradient(135deg, #2A9D8F, #1f7a6e); border-radius: 16px; padding: 24px; text-align: center; }
.report-cta-box h4 { color: #fff; font-size: 1rem; margin-bottom: 6px; }
.report-cta-box p { color: rgba(255,255,255,.8); font-size: .83rem; margin-bottom: 18px; }
.report-cta-box .wa-cta {
  display: inline-flex; align-items: center; gap: 10px;
  background: #25D366;
  color: #fff;
  padding: 13px 28px;
  border-radius: 99px;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  transition: all .2s;
  box-shadow: 0 4px 16px rgba(37,211,102,.3);
}
.report-cta-box .wa-cta:hover { background: #1ebe5d; transform: translateY(-2px); }
.report-rescan { margin-top: 12px; font-size: .8rem; color: rgba(255,255,255,.7); }
.report-rescan button { background: none; border: none; color: rgba(255,255,255,.85); cursor: pointer; text-decoration: underline; font-family: inherit; font-size: inherit; }

/* Hidden canvas */
#scanCanvas { display: none; }

/* ── Mobile banner ──────────────────────────────────────────── */
@media (max-width: 600px) {
  #scanBanner { font-size: .78rem; gap: 8px; padding: 10px 12px; height: auto; min-height: 48px; }
  #navbar { top: 56px; }
}

@media (max-width: 600px) {
  .scan-screen { padding: 24px 18px 32px; }
  .scan-layout { grid-template-columns: 1fr; }
  .scan-instructions { order: 2; }
  .scan-camera-area { order: 1; }
  .report-metrics { grid-template-columns: 1fr; }
  .report-overall { flex-direction: column; text-align: center; }
}
