/* ============================================================================
   ZapSync AI — Design tokens
   Background: dark navy #0B0F19 · Accent: electric cyan #00A3FF/#0082FF
   Secondary accents (used sparingly): purple #8B7CFF, orange #FF9B52
============================================================================ */

:root {
  --bg: #0b0f19;
  --surface: #0f1524;
  --surface-raised: #131a2c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #f5f7fb;
  --text-muted: #93a0bd;
  --text-faint: #5d6a89;

  --accent: #00a3ff;
  --accent-deep: #0082ff;
  --accent-glow: rgba(0, 163, 255, 0.35);

  --purple: #8b7cff;
  --orange: #ff9b52;
  --green: #35d488;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(0, 163, 255, 0.12), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(139, 124, 255, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Shell ---------------------------------------------------------- */

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 56px;
}

.brand__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 0 24px var(--accent-glow);
}

.brand__wordmark {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__wordmark span {
  color: var(--text-muted);
  font-weight: 400;
}

section[id^="view-"] {
  display: none;
}

section[id^="view-"].is-active {
  display: block;
}

/* --- Form view -------------------------------------------------------- */

.form-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 64px;
  align-items: center;
  min-height: 60vh;
}

.form-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.2vw, 48px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
}

.form-intro p {
  color: var(--text-muted);
  font-size: 17px;
  max-width: 46ch;
  margin: 0 0 32px;
}

.stat-row {
  display: flex;
  gap: 32px;
}

.stat-row dt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat-row dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--accent);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.6);
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 4px;
}

.panel .panel-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s ease;
}

.field input::placeholder {
  color: var(--text-faint);
}

.field input:focus {
  border-color: var(--accent);
}

.field-error {
  display: block;
  min-height: 18px;
  color: var(--orange);
  font-size: 13px;
  margin-top: 6px;
}

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #04101d;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 30px -12px var(--accent-glow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px -12px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: rgba(0, 163, 255, 0.08);
}

.banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

.banner--error {
  background: rgba(255, 91, 91, 0.1);
  border: 1px solid rgba(255, 91, 91, 0.3);
  color: #ffb4b4;
}

/* --- Processing view -------------------------------------------------- */

.processing-layout {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.radar {
  position: relative;
  width: 220px;
  height: 220px;
  margin-bottom: 40px;
}

.radar__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
}

.radar__ring--mid {
  inset: 32px;
}

.radar__ring--inner {
  inset: 64px;
}

.radar__sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent-glow), transparent 35%);
  animation: radar-spin 2.4s linear infinite;
}

.radar__core {
  position: absolute;
  inset: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent), var(--accent-deep));
  box-shadow: 0 0 30px var(--accent-glow);
}

.radar__blip {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
  animation: blip-pulse 2.6s ease-in-out infinite;
}

.radar__blip--1 { top: 28%; left: 68%; animation-delay: 0.2s; }
.radar__blip--2 { top: 62%; left: 24%; animation-delay: 1.1s; }
.radar__blip--3 { top: 74%; left: 66%; animation-delay: 1.9s; }

@keyframes radar-spin {
  to { transform: rotate(360deg); }
}

@keyframes blip-pulse {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1); }
}

.processing-layout h1 {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0 0 10px;
}

.processing-layout .status-line {
  color: var(--text-muted);
  font-size: 15px;
  min-height: 22px;
  margin-bottom: 28px;
}

.processing-meta {
  display: flex;
  gap: 28px;
  align-items: center;
}

.processing-meta .meta-item dt {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.processing-meta .meta-item dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
}

.processing-hint {
  margin-top: 32px;
  color: var(--text-faint);
  font-size: 13px;
  max-width: 40ch;
}

#processing-error {
  margin-top: 32px;
  max-width: 420px;
}

#processing-error .banner {
  margin-bottom: 14px;
}

/* --- Results view ------------------------------------------------------ */

.results-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.results-summary h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
}

.results-summary .summary-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.job-id-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-block;
  margin-top: 8px;
}

.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 900px;
}

.results-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.results-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table .col-company {
  color: var(--text);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge--new {
  background: rgba(0, 163, 255, 0.14);
  color: var(--accent);
}

.badge--neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.results-cards {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.lead-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.lead-card__header h3 {
  margin: 0;
  font-size: 16px;
}

.lead-card__body {
  display: grid;
  gap: 10px;
  margin: 0;
}

.lead-card__body dt {
  font-size: 11px;
  color: var(--text-faint);
}

.lead-card__body dd {
  margin: 2px 0 0;
  font-size: 14px;
}

.results-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.results-empty h2 {
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 8px;
}

.results-footer {
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

[hidden] {
  display: none !important;
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 860px) {
  .form-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .stat-row {
    gap: 24px;
  }

  .results-table-wrap {
    display: none;
  }

  .results-cards {
    display: flex;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 24px 16px 48px;
  }

  .panel {
    padding: 24px 20px;
  }

  .radar {
    width: 170px;
    height: 170px;
  }

  .radar__ring--mid { inset: 24px; }
  .radar__ring--inner { inset: 48px; }
  .radar__core { inset: 72px; }
}
