/* ==========================================================================
   Fonts & Design Tokens
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #12141C;
  --surface: #1B1E2B;
  --surface-2: #232838;
  --line: #343C54;
  --ink: #FFFFFF;
  --ink-dim: #A6ACC0;
  --magenta: #D6247A;
  --magenta-deep: #6E1F5C;
  --coral: #F2764C;
  --green: #34B27B;
}

/* ==========================================================================
   Base / Layout
   ========================================================================== */
* { box-sizing: border-box; }

#root {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wrap { 
  display: flex;
  flex-direction: column;
  font-size: var(--text-xs);
  line-height: var(--text-xs);
  gap: var(--space-3);
  width: 100%;
}

/* ==========================================================================
   Search Form
   ========================================================================== */
.wrap form {
  display: flex;
  gap: var(--space-1);
  margin-bottom: 8px;
}

.wrap input[type="text"], .wrap input[type="email"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--purple);
  border-radius: 10px;
  padding: var(--space-1) var(--space-2);
  color: var(--black);
  font-family: 'Poppins', sans-serif;
  font-size: var(--text-s);
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s ease;
}

.wrap input[type="text"]::placeholder, .wrap input[type="email"]::placeholder { color: #626B87; }
.wrap input[type="text"]:focus { border-color: var(--pink); }

.wrap input[type="text"].field-url {
  background-color: var(--white);
}

button.run {
  background: var(--magenta);
  border: none;
  border-radius: var(--text-xs);
  color: var(--white);
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: var(--text-s);
  line-height: var(--text-m);
  max-width: fit-content;
  padding: var(--space-2) var(--space-3);
  text-align: center;
  transition: filter 0.3s ease-in-out, transform 0.3s ease-in-out;
  width: auto;
}

button.run:hover:not(:disabled) { 
  filter: brightness(1.1);
  transform: scale(1.04);
}

button.run:active:not(:disabled) { transform: scale(0.98); }
button.run:disabled { opacity: 0.5; cursor: not-allowed; }
button.run:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

.row-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  justify-content: space-between;
  margin-bottom: 0;
}

.strategy-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  font-size: var(--text-s);
  font-weight: 600;
}
.strategy-toggle button {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
}
.strategy-toggle button.active { background: var(--magenta); color: #fff; border-radius: 999px; }
.strategy-toggle button:focus-visible { outline: 2px solid var(--coral); outline-offset: -2px; }

.status {
  font-size: var(--text-s);
  font-weight: 500;
  color: var(--ink-dim);
  line-height: var(--text-m);
  min-height: 20px;
  margin-bottom: 6px;
}
.status.err { color: var(--yellow); }

/* ==========================================================================
   Loader
   ========================================================================== */
.loader {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin-top: 20px;
}

.spinner { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.spinner svg { width: 100%; height: 100%; animation: spin 1.4s linear infinite; }
.spinner circle {
  fill: none;
  stroke: var(--magenta);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 90 150;
  transform-origin: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.loader-text .lt-title {
  font-size: var(--text-s);
  font-weight: 600;
  margin-bottom: 4px;
}
.loader-text .lt-msg {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-dim);
  min-height: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .spinner svg { animation: none; }
}

/* ==========================================================================
   Section Titles (shared by every result section below)
   ========================================================================== */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-s);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  margin: 24px 0 10px;
}
.section-title::before {
  content: '';
  width: 14px;
  height: 2px;
  background: var(--coral);
  display: inline-block;
}

/* ==========================================================================
   Website Preview
   ========================================================================== */
.preview-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}
.preview-chrome {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.preview-chrome .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.preview-chrome .u {
  font-size: var(--text-s);
  font-weight: 500;
  color: var(--ink-dim);
  line-height: var(--text-m);
  margin-left: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-card img { display: block; width: 100%; max-height: 260px; object-fit: cover; object-position: top; }

/* ==========================================================================
   Technical Checks
   ========================================================================== */
.checks-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-1);
}
.check-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: var(--text-xs);
  gap: var(--space-1);
  padding: 10px 12px;
  font-weight: 500;
}
.check-row .mark { flex-shrink: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.check-row.pass .mark svg { stroke: var(--green); }
.check-row.fail .mark svg { stroke: var(--coral); }

/* ==========================================================================
   Top Issues
   ========================================================================== */
.issue-card {
  display: flex;
  gap: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
}
.issue-card .i-num {
  flex-shrink: 0;
  font-size: var(--text-m);
  font-weight: 800;
  color: var(--pink);
  line-height: 1;
  min-width: 40px;
}
.issue-card .i-title { font-size: var(--text-s); font-weight: 700; margin-bottom: var(--space-2); }
.issue-card .i-desc { font-size: var(--text-xs); color: var(--ink-dim); line-height: 1.5; }
.issue-card .i-savings {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--coral);
}

/* ==========================================================================
   AI & Search Visibility Cards
   ========================================================================== */
.ai-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
}
.ai-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
}
.ai-card .ai-label {
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.ai-card .ai-score { font-size: var(--text-m); font-weight: 800; }
.ai-card .ai-desc { font-size: var(--text-xs); color: var(--ink-dim); margin-top: 6px; line-height: var(--text-s); }

.ai-locked {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(160deg, var(--magenta-deep) 0%, var(--surface) 100%);
}
.ai-locked .lock-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-s);
  font-weight: 700;
  color: var(--coral);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.ai-locked .lock-badge svg { stroke: var(--coral); }
.ai-locked .ai-desc { font-size: var(--text-xs); color: #E4D8E8; line-height: var(--text-s); }

/* ==========================================================================
   AI-Written Report
   ========================================================================== */
.ai-report-card {
  background: linear-gradient(160deg, var(--magenta-deep) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-top: 8px;
}
.ai-report-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-s);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--coral);
  margin-bottom: var(--space-3);
}
.ai-report-badge svg { stroke: var(--coral); }
.ai-report-headline { font-size: var(--text-s); font-weight: 800; margin: 0 0 8px; }

.ai-report-summary { 
  font-size: var(--text-xs); 
  color: #E4D8E8; 
  line-height: var(--text-m); 
  margin: 0 0 16px; 
}

.ai-action-list { 
  list-style: none; 
  padding: 0; 
  margin: var(--space-3) 0 0 0; 
  display: flex; 
  flex-direction: column; 
  gap: var(--space-2); 
}

.ai-action-item { 
  display: flex; 
  margin: var(--space-1) 0;
  gap: var(--space-2); 
}

.ai-action-item:last-of-type {
  margin-bottom: 0;
}

.ai-action-num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-size: var(--text-s);
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.ai-action-item .ai-a-title { 
  font-size: var(--text-s); 
  font-weight: 700; 
  line-height: var(--text-m);
  margin-bottom: 2px; 
}

.ai-action-item .ai-a-reason { 
  font-size: var(--text-xs); 
  color: #E4D8E8; 
  line-height: var(--text-s);
  margin: var(--space-2) 0; 
}

/* ==========================================================================
   Partial Report Extras
   ========================================================================== */
.checks-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: var(--text-s);
  font-weight: 600;
}

.more-issues {
  font-size: var(--text-s);
  font-weight: 600;
  color: var(--coral);
  margin: -4px 0 4px 4px;
}

/* ==========================================================================
   Email Capture
   ========================================================================== */
.result { 
  display: flex;
  flex-direction: column;
  font-size: var(--text-xs);
  line-height: var(--text-xs);
  margin-top: var(--space-2);
  gap: var(--space-3); 
}

.email-capture {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--black);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: 28px;
  padding: 22px;
}

.email-capture .section-title {
  color: var(--purple);
  font-size: var(--text-l);
  line-height: var(--text-l);
  margin-bottom: var(--space-2);
}

.ec-sub {
  font-size: var(--text-s);
  line-height: var(--text-m);
  margin: 0 0 16px;
  max-width: 50ch;
}
.ec-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.ec-form-fields {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
}

.ec-form input[type="text"],
.ec-form input[type="email"] {
  flex: 1;
  width: 100%;
}
.ec-consent {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--black);
  line-height: 1.4;
  cursor: pointer;
}
.ec-consent input { margin-top: 2px; flex-shrink: 0; }

.sent-confirm {
  margin-top: 28px;
  background: var(--white);
  border-radius: var(--text-xs);
  padding: var(--space-4);
  text-align: center;
}
.sent-title { 
  color: var(--purple);
  font-size: var(--text-l);
  font-weight: 800;
  line-height: var(--text-l);
  margin-bottom: var(--space-3);
}

.sent-confirm p {
  font-size: var(--text-s);
  color: var(--black);
  line-height: var(--text-m);
  margin: 0;
}

/* ==========================================================================
   CTA Banner (full report only)
   ========================================================================== */
.cta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: linear-gradient(120deg, var(--magenta-deep) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: var(--space-3);
  margin-top: 24px;
}
.cta-text { 
  font-size: var(--text-s); 
  font-weight: 700; 
  line-height: var(--text-m);
}

.cta-button {
  background: var(--purple);
  color: var(--white);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--text-s);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--text-xs);
  text-align: center;
  transition: all 0.3s ease-in-out;
  white-space: nowrap;
}
.cta-button:hover { 
  filter: brightness(1.08);
  transform: scale(1.04);
 }

/* ==========================================================================
   Gauge & Verdict
   ========================================================================== */
.gauge-block {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 18px;
}

.gauge-wrap { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.gauge-wrap svg { transform: rotate(-90deg); }
.gauge-num {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  inset: 0;
  justify-content: center;
  position: absolute;
}
.gauge-num .n {
  font-weight: 800;
  font-size: var(--text-xl);
}
.gauge-num .label {
  font-size: var(--text-s);
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.verdict h2 { font-size: var(--text-m); font-weight: 800; margin: 0 0 6px; }
.verdict p { font-size: var(--text-s); color: var(--ink-dim); line-height: 1.5; margin: 0; }

/* ==========================================================================
   Core Metrics
   ========================================================================== */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-1);
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 14px 16px;
}
.metric .m-label {
  font-size: calc(var(--text-s)/1.2);
  font-weight: 600;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.metric .m-val {
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ==========================================================================
   Footnote
   ========================================================================== */
.note {
  margin-top: 20px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-dim);
  line-height: 1.6;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.note code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 5px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
}

/* ==========================================================================
   Responsive (≤768px)
   ========================================================================== */
@media (max-width: 768px) {
  form { flex-direction: column; align-items: stretch; }
  
  button.run {
    margin-top: var(--space-2);
    max-width: stretch;
    width: 100%;
  }

  .checks-grid, .ai-grid { grid-template-columns: 1fr; }
  .gauge-block { flex-direction: column; text-align: center; }

  .ec-form-fields {
    display: flex;
    flex-direction: column;
  }

  .cta-button {
    width: 100%;
  }

}
