/* ════════════════════════════════════════════════════════════
   Haorgrix — Design System
   Dark + glassmorphism + Inter
════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:          hsl(224, 22%, 7%);
  --bg-2:        hsl(224, 20%, 10%);
  --surface:     hsl(224, 18%, 13%);
  --surface-2:   hsl(224, 16%, 17%);
  --border:      hsla(220, 30%, 60%, 0.10);
  --border-h:    hsla(220, 30%, 60%, 0.20);

  --accent:      hsl(217, 91%, 62%);
  --accent-dim:  hsla(217, 91%, 62%, 0.15);
  --violet:      hsl(258, 80%, 68%);
  --green:       hsl(142, 72%, 46%);
  --green-dim:   hsla(142, 72%, 46%, 0.15);
  --amber:       hsl(38, 95%, 54%);
  --amber-dim:   hsla(38, 95%, 54%, 0.15);
  --red:         hsl(0, 82%, 61%);
  --red-dim:     hsla(0, 82%, 61%, 0.15);
  --muted:       hsl(220, 14%, 48%);

  --text:        hsl(220, 20%, 95%);
  --text-2:      hsl(220, 14%, 70%);
  --text-3:      hsl(220, 12%, 45%);

  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   18px;
  --shadow:      0 4px 32px hsla(217, 91%, 30%, 0.18);
  --transition:  0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
}

/* ── Utility ─────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  background: hsla(224, 22%, 7%, 0.80);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { flex-shrink: 0; }
.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #4a94ba, #82caeb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-badges { display: flex; gap: 8px; align-items: center; }
.badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-h);
  background: var(--surface);
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.badge-free { border-color: hsla(142,72%,46%,0.3); color: var(--green); background: var(--green-dim); }

/* ── Main layout ────────────────────────────────────────── */
.main {
  max-width: 1020px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ── Steps ──────────────────────────────────────────────── */
.step { display: none; }
.step.active { display: block; animation: fadeUp 0.35s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Step hero ───────────────────────────────────────────── */
.step-hero {
  text-align: center;
  margin-bottom: 40px;
}
.step-hero h1, .step-hero h2 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, #f1f5f9 40%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.step-sub {
  margin-top: 12px;
  font-size: 1rem;
  color: var(--text-2);
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.step-sub strong { color: var(--text); }

/* ── Drop zone ───────────────────────────────────────────── */
.drop-zone {
  position: relative;
  border: 1.5px dashed var(--border-h);
  border-radius: var(--radius-lg);
  padding: 64px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface);
  overflow: hidden;
}
.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}
.drop-zone-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(ellipse at 50% 0%, hsla(217,91%,62%,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.drop-icon {
  color: var(--accent);
  margin-bottom: 20px;
  transition: transform var(--transition);
}
.drop-zone:hover .drop-icon,
.drop-zone.dragging .drop-icon { transform: translateY(-4px); }

.drop-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  flex-wrap: wrap;
}
.drop-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-3);
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color var(--transition);
}
.link-btn:hover { text-decoration-color: var(--accent); }

/* ── How it works ─────────────────────────────────────────── */
.how-it-works {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
  flex-wrap: wrap;
}
.hiw-step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  flex: 1;
  min-width: 160px;
  max-width: 220px;
}
.hiw-step div { display: flex; flex-direction: column; gap: 2px; }
.hiw-step strong { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.hiw-step span { font-size: 0.74rem; color: var(--text-3); }
.hiw-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid hsla(217,91%,62%,0.25);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.hiw-arrow { color: var(--text-3); font-size: 1.2rem; flex-shrink: 0; }

.sample-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--transition);
}
.sample-link:hover { color: var(--accent); }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

/* ── Mapping grid ─────────────────────────────────────────── */
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.mapping-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mapping-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mapping-field select {
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.mapping-field select:focus {
  outline: none;
  border-color: var(--accent);
}
.mapping-required label::after { content: ' *'; color: var(--accent); }

/* ── Preview section ─────────────────────────────────────── */
.preview-section { margin-top: 4px; }
.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.section-label span { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── Action bar ──────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.file-meta { font-size: 0.82rem; color: var(--text-3); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 20px;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  box-shadow: 0 2px 16px hsla(217,91%,62%,0.30);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 24px hsla(217,91%,62%,0.45);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid hsla(142,72%,46%,0.25);
}
.btn-success:hover:not(:disabled) { background: hsla(142,72%,46%,0.22); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--border-h); color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

/* ── Stats bar ───────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat {
  flex: 1;
  min-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition);
}
.stat-val {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  transition: color var(--transition);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
}
.stat-blue  { border-color: hsla(217,91%,62%,0.25); }
.stat-blue  .stat-val { color: var(--accent); }
.stat-green { border-color: hsla(142,72%,46%,0.25); }
.stat-green .stat-val { color: var(--green); }
.stat-amber { border-color: hsla(38,95%,54%,0.25); }
.stat-amber .stat-val { color: var(--amber); }

/* ── Progress bar ─────────────────────────────────────────── */
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.progress-wrap {
  flex: 1;
  min-width: 200px;
  background: var(--surface-2);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  transition: width 0.4s ease;
  width: 0%;
}
.progress-label {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
}
.toolbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── Data table ──────────────────────────────────────────── */
.results-card { padding: 0; overflow: hidden; }
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 540px;
  overflow-y: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  transition: background var(--transition);
  animation: rowIn 0.25s ease;
}
.data-table tbody tr:hover { background: hsla(220,18%,100%,0.03); }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.row-num { color: var(--text-3); font-size: 0.78rem; }
.email-cell { font-family: 'JetBrains Mono', 'Fira Code', monospace; color: var(--text); font-size: 0.82rem; }

/* ── Status badges ───────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.status-verified   { background: var(--green-dim);  color: var(--green);  border: 1px solid hsla(142,72%,46%,0.25); }
.status-scraped    { background: var(--accent-dim);  color: var(--accent); border: 1px solid hsla(217,91%,62%,0.25); }
.status-catch_all  { background: var(--amber-dim);   color: var(--amber);  border: 1px solid hsla(38,95%,54%,0.25); }
.status-pattern_only { background: var(--amber-dim); color: var(--amber);  border: 1px solid hsla(38,95%,54%,0.25); }
.status-not_found  { background: var(--surface-2);   color: var(--text-3); border: 1px solid var(--border); }
.status-pre_existing { background: var(--green-dim); color: var(--green);  border: 1px solid hsla(142,72%,46%,0.25); }
.status-insufficient_data { background: var(--red-dim); color: var(--red); border: 1px solid hsla(0,82%,61%,0.25); }

/* ── Confidence bar ──────────────────────────────────────── */
.conf-wrap { display: flex; align-items: center; gap: 6px; }
.conf-bar {
  width: 48px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.conf-fill { height: 100%; border-radius: inherit; transition: width 0.4s; }
.conf-num { font-size: 0.75rem; color: var(--text-3); }

/* ── Source badge ─────────────────────────────────────────── */
.source-badge {
  font-size: 0.72rem;
  color: var(--text-3);
  font-style: italic;
}

/* ── Li link ─────────────────────────────────────────────── */
.li-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.78rem;
  max-width: 140px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.li-link:hover { text-decoration: underline; }

/* ── Empty / processing state ─────────────────────────────── */
.empty-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--text-3);
}
.pulse-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-h); }

/* ── Tabs & Search UI ─────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 24px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.3s ease; }

.search-card {
  max-width: 500px;
  margin: 0 auto;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}
.form-input {
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  transition: border-color var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}
.w-full { width: 100%; justify-content: center; }

.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 0.9rem;
}
.pulse-ring.sm { width: 24px; height: 24px; border-width: 2px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .main   { padding: 28px 16px 60px; }
  .hiw-arrow { display: none; }
  .hiw-step { min-width: 130px; }
  .stats-bar { gap: 8px; }
  .stat { min-width: 80px; padding: 12px; }
  .stat-val { font-size: 1.3rem; }
}
