/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --primary:   #667eea;
  --safe:      #22c55e;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f172a;
    --surface: #1e293b;
    --border:  #334155;
    --text:    #e2e8f0;
    --muted:   #94a3b8;
  }
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.app-header {
  background: #1e293b;
  color: white;
  padding: 0 16px;
  height: 56px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: white;
}

.logo svg { color: #818cf8; }

/* Strict mode toggle */
.strict-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.strict-toggle input { display: none; }

.strict-label {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  transition: color 0.2s;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid #334155;
  transition: all 0.2s;
}

.strict-toggle input:checked + .strict-label {
  color: white;
  background: #7c3aed;
  border-color: #7c3aed;
}

/* ── Main ────────────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Drop Zone ───────────────────────────────────────────────────────── */
.upload-section { display: flex; flex-direction: column; gap: 16px; }

.drop-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(102,126,234,0.04);
}

.drop-icon { color: #94a3b8; margin-bottom: 12px; }
.drop-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.drop-sub   { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

.drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover { opacity: 0.88; }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { opacity: 0.8; }

.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }

/* ── Camera ──────────────────────────────────────────────────────────── */
.camera-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  width: 60%;
  aspect-ratio: 1;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  animation: scan-pulse 2s ease-in-out infinite;
}

@keyframes scan-pulse {
  0%,100% { border-color: rgba(255,255,255,0.8); }
  50%      { border-color: #818cf8; }
}

.camera-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

/* ── Results ─────────────────────────────────────────────────────────── */
.results-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 120px;
}

.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.results-list { display: flex; flex-direction: column; }

/* ── Result Card ─────────────────────────────────────────────────────── */
.result-card {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.result-card:last-child { border-bottom: none; }
.result-card:hover { background: rgba(102,126,234,0.03); }

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.result-type {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px;
  border-radius: 20px;
  color: white;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.risk-meter {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  margin-bottom: 10px;
  overflow: hidden;
}

.risk-meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.result-data {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  word-break: break-all;
  margin-bottom: 10px;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Accordion */
.result-accordion-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.result-accordion-body {
  overflow: hidden;
  transition: max-height 0.25s ease;
  max-height: 0;
}

.result-accordion-body.open { max-height: 500px; }

.reasons-list, .rec-list {
  margin: 6px 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
}

.reasons-list li { margin-bottom: 4px; }
.rec-list li     { margin-bottom: 4px; color: #0f766e; }

.rec-heading {
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  margin-top: 8px;
}

/* Actions */
.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ── Spinner ─────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.scanning-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--muted);
  font-size: 14px;
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-main { padding: 16px 12px 32px; gap: 16px; }
  .drop-zone { padding: 28px 16px; }
  .drop-title { font-size: 15px; }
}

/* ── URLScan.io result section ───────────────────────────────────────── */
.urlscan-result {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--border);
}

.urlscan-header {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.urlscan-header::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23667eea'%3E%3Cpath d='M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.urlscan-detail {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.urlscan-link {
  font-size: 11px;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.urlscan-pending {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  animation: pulse-opacity 1.5s ease-in-out infinite;
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
