/* ============================================================
   AI Search Readiness Checker — Design System
   Uses CSS custom properties from seoClarity brand guide.
   ============================================================ */

/* --- Design Tokens --- */
:root {
  /* Primary brand palette */
  --sc-navy-900: #0a1628;
  --sc-navy-800: #0f172a;
  --sc-navy-700: #1e293b;
  --sc-slate-600: #475569;
  --sc-slate-400: #94a3b8;
  --sc-slate-200: #e2e8f0;

  /* Brand blue */
  --sc-blue-500: #3b82f6;
  --sc-blue-600: #2563eb;
  --sc-blue-400: #60a5fa;

  /* Scoring colors */
  --sc-green-500: #22c55e;
  --sc-amber-500: #f59e0b;
  --sc-red-500: #ef4444;

  /* Surfaces */
  --sc-white: #ffffff;
  --sc-gray-50: #f8fafc;
  --sc-gray-100: #f1f5f9;

  /* Typography */
  --sc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --sc-text-xs: 0.75rem;
  --sc-text-sm: 0.875rem;
  --sc-text-base: 1rem;
  --sc-text-lg: 1.125rem;
  --sc-text-xl: 1.25rem;
  --sc-text-2xl: 1.5rem;
  --sc-text-4xl: 2.25rem;
  --sc-text-5xl: 3rem;

  /* Spacing */
  --sc-space-xs: 4px;
  --sc-space-sm: 8px;
  --sc-space-md: 16px;
  --sc-space-lg: 24px;
  --sc-space-xl: 32px;
  --sc-space-2xl: 48px;

  /* Radii */
  --sc-radius-sm: 8px;
  --sc-radius-md: 12px;
  --sc-radius-full: 9999px;

  /* Shadows */
  --sc-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1);
  --sc-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sc-font-family);
  font-size: var(--sc-text-base);
  color: var(--sc-navy-800);
  background: var(--sc-gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.widget-root {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.widget-main {
  flex: 1;
}

/* --- Header --- */
.header {
  background: linear-gradient(135deg, var(--sc-navy-800), var(--sc-navy-700));
  padding: var(--sc-space-2xl) var(--sc-space-lg);
  text-align: center;
  color: var(--sc-white);
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sc-space-sm);
  margin-bottom: var(--sc-space-md);
}

.header-brand img {
  height: 28px;
  width: auto;
}

.header-brand span {
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-400);
  font-weight: 500;
}

.header h1 {
  font-size: var(--sc-text-4xl);
  font-weight: 700;
  margin-bottom: var(--sc-space-sm);
  line-height: 1.2;
}

.header p {
  font-size: var(--sc-text-lg);
  color: var(--sc-slate-400);
  max-width: 540px;
  margin: 0 auto;
}

/* --- Cards --- */
.card {
  background: var(--sc-white);
  border-radius: var(--sc-radius-md);
  box-shadow: var(--sc-shadow-card);
  padding: var(--sc-space-lg);
  margin-bottom: var(--sc-space-lg);
}

/* --- Section Titles --- */
.section-title {
  font-size: var(--sc-text-xl);
  font-weight: 600;
  margin-bottom: var(--sc-space-md);
  display: flex;
  align-items: center;
  gap: var(--sc-space-sm);
}

/* --- URL Input --- */
.url-input-form {
  display: flex;
  gap: var(--sc-space-sm);
  max-width: 600px;
  margin: var(--sc-space-lg) auto 0;
}

.url-input-form input {
  flex: 1;
  padding: 12px 16px;
  font-size: var(--sc-text-base);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--sc-radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--sc-white);
  outline: none;
  transition: border-color 0.2s;
}

.url-input-form input::placeholder {
  color: var(--sc-slate-400);
}

.url-input-form input:focus {
  border-color: var(--sc-blue-400);
  background: rgba(255, 255, 255, 0.15);
}

.url-input-form button {
  padding: 12px 24px;
  font-size: var(--sc-text-base);
  font-weight: 600;
  background: var(--sc-blue-500);
  color: var(--sc-white);
  border: none;
  border-radius: var(--sc-radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.url-input-form button:hover:not(:disabled) {
  background: var(--sc-blue-600);
}

.url-input-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.url-input-error {
  color: var(--sc-red-500);
  font-size: var(--sc-text-sm);
  text-align: center;
  margin-top: var(--sc-space-sm);
}

/* --- Loading Progress --- */
.loading-container {
  padding: var(--sc-space-2xl) var(--sc-space-lg);
  text-align: center;
}

.loading-url {
  font-size: var(--sc-text-xl);
  font-weight: 600;
  margin-bottom: var(--sc-space-lg);
  color: var(--sc-navy-800);
}

.loading-steps {
  list-style: none;
  text-align: left;
  max-width: 400px;
  margin: 0 auto var(--sc-space-lg);
}

.loading-step {
  padding: var(--sc-space-sm) 0;
  font-size: var(--sc-text-base);
  display: flex;
  align-items: center;
  gap: var(--sc-space-sm);
  color: var(--sc-slate-400);
  transition: color 0.3s;
}

.loading-step.done {
  color: var(--sc-green-500);
}

.loading-step.active {
  color: var(--sc-navy-800);
  font-weight: 500;
}

.loading-step-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.progress-bar {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--sc-gray-100);
  border-radius: var(--sc-radius-full);
  margin: 0 auto var(--sc-space-md);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--sc-blue-500);
  border-radius: var(--sc-radius-full);
  transition: width 0.5s ease;
}

.loading-tip {
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
  max-width: 420px;
  margin: var(--sc-space-md) auto 0;
  line-height: 1.5;
}

.loading-timeout-msg {
  font-size: var(--sc-text-sm);
  color: var(--sc-amber-500);
  margin-top: var(--sc-space-sm);
}

/* --- Score Card --- */
.score-section {
  text-align: center;
  padding: var(--sc-space-lg) 0;
}

.score-domain {
  font-size: var(--sc-text-xl);
  font-weight: 600;
  margin-bottom: var(--sc-space-md);
  color: var(--sc-navy-800);
}

.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 8px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sc-space-md);
}

.score-circle.risk-low {
  border-color: var(--sc-green-500);
}
.score-circle.risk-medium {
  border-color: var(--sc-amber-500);
}
.score-circle.risk-high {
  border-color: var(--sc-red-500);
}
.score-circle.risk-unknown {
  border-color: var(--sc-slate-400);
}

.score-number {
  font-size: var(--sc-text-5xl);
  font-weight: 700;
  line-height: 1;
}

.score-label {
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
  margin-top: 2px;
}

.risk-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: var(--sc-radius-full);
  font-size: var(--sc-text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-badge.risk-low {
  background: rgba(34, 197, 94, 0.1);
  color: var(--sc-green-500);
}
.risk-badge.risk-medium {
  background: rgba(245, 158, 11, 0.1);
  color: var(--sc-amber-500);
}
.risk-badge.risk-high {
  background: rgba(239, 68, 68, 0.1);
  color: var(--sc-red-500);
}
.risk-badge.risk-unknown {
  background: rgba(148, 163, 184, 0.1);
  color: var(--sc-slate-400);
}

/* --- Screenshots --- */
.screenshots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sc-space-md);
}

.screenshot-panel {
  text-align: center;
}

.screenshot-panel h3 {
  font-size: var(--sc-text-sm);
  font-weight: 600;
  color: var(--sc-slate-600);
  margin-bottom: var(--sc-space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.screenshot-panel img {
  width: 100%;
  height: auto;
  border: 1px solid var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
}

.screenshot-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--sc-gray-100);
  border: 1px dashed var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sc-slate-400);
  font-size: var(--sc-text-sm);
}

/* --- Content Diff Table --- */
.diff-table {
  width: 100%;
  border-collapse: collapse;
}

.diff-table th {
  background: var(--sc-gray-100);
  padding: 10px 16px;
  text-align: left;
  font-size: var(--sc-text-sm);
  font-weight: 600;
  color: var(--sc-slate-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.diff-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--sc-slate-200);
  font-size: var(--sc-text-base);
}

.diff-table tr:nth-child(even) td {
  background: var(--sc-gray-50);
}

.diff-table .diff-delta {
  font-weight: 600;
  font-size: var(--sc-text-sm);
}

.diff-delta.positive {
  color: var(--sc-red-500);
}

.diff-delta.zero {
  color: var(--sc-green-500);
}

/* --- Crawler Access --- */
.crawler-table {
  width: 100%;
  border-collapse: collapse;
}

.crawler-table th {
  background: var(--sc-gray-100);
  padding: 10px 16px;
  text-align: left;
  font-size: var(--sc-text-sm);
  font-weight: 600;
  color: var(--sc-slate-600);
}

.crawler-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--sc-slate-200);
  font-size: var(--sc-text-sm);
}

.crawler-table tr:nth-child(even) td {
  background: var(--sc-gray-50);
}

.crawler-status {
  font-weight: 600;
}

.crawler-status.allowed {
  color: var(--sc-green-500);
}
.crawler-status.blocked {
  color: var(--sc-red-500);
}
.crawler-status.no_rule {
  color: var(--sc-slate-400);
}
.crawler-status.partially_blocked {
  color: var(--sc-amber-500);
}

.crawler-summary {
  margin-top: var(--sc-space-md);
  padding: var(--sc-space-md);
  border-radius: var(--sc-radius-sm);
  font-size: var(--sc-text-sm);
}

.crawler-summary.level-open {
  background: rgba(34, 197, 94, 0.08);
  border-left: 3px solid var(--sc-green-500);
}
.crawler-summary.level-mixed {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--sc-amber-500);
}
.crawler-summary.level-critical {
  background: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--sc-red-500);
}

.crawler-summary-headline {
  font-weight: 600;
  margin-bottom: 4px;
}

/* Mobile: stacked cards for crawlers */
.crawler-cards {
  display: none;
}

.crawler-card {
  padding: var(--sc-space-md);
  border: 1px solid var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
  margin-bottom: var(--sc-space-sm);
}

.crawler-card-name {
  font-weight: 600;
  font-size: var(--sc-text-base);
  margin-bottom: 4px;
}

.crawler-card-company {
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
}

.crawler-card-status {
  margin-top: var(--sc-space-sm);
  font-weight: 600;
}

/* --- Benchmark --- */
.benchmark-bar-container {
  position: relative;
  height: 32px;
  background: var(--sc-gray-100);
  border-radius: var(--sc-radius-full);
  margin: var(--sc-space-md) 0;
  overflow: visible;
}

.benchmark-bar-fill {
  height: 100%;
  border-radius: var(--sc-radius-full);
  background: linear-gradient(90deg, var(--sc-red-500), var(--sc-amber-500), var(--sc-green-500));
  transition: width 0.6s ease;
}

.benchmark-marker {
  position: absolute;
  top: -6px;
  width: 4px;
  height: 44px;
  background: var(--sc-navy-800);
  border-radius: 2px;
  transform: translateX(-50%);
}

.benchmark-label {
  position: absolute;
  top: 44px;
  transform: translateX(-50%);
  font-size: var(--sc-text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.benchmark-stats {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sc-space-2xl);
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
}

.benchmark-stat-value {
  font-weight: 600;
  font-size: var(--sc-text-lg);
  color: var(--sc-navy-800);
}

/* --- Share Buttons --- */
.share-row {
  display: flex;
  align-items: center;
  gap: var(--sc-space-sm);
  flex-wrap: wrap;
  justify-content: center;
  padding: var(--sc-space-md) 0;
}

.share-btn {
  padding: 8px 16px;
  font-size: var(--sc-text-sm);
  font-weight: 500;
  border: 1px solid var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
  background: var(--sc-white);
  color: var(--sc-navy-800);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.share-btn:hover {
  background: var(--sc-gray-50);
  border-color: var(--sc-blue-500);
}

.share-btn.copied {
  background: var(--sc-green-500);
  color: var(--sc-white);
  border-color: var(--sc-green-500);
}

/* --- Email Gate --- */
.email-gate {
  text-align: center;
  padding: var(--sc-space-xl) var(--sc-space-lg);
  border-top: 1px solid var(--sc-slate-200);
  margin-top: var(--sc-space-lg);
}

.email-gate h2 {
  font-size: var(--sc-text-xl);
  margin-bottom: var(--sc-space-sm);
}

.email-gate p {
  color: var(--sc-slate-600);
  font-size: var(--sc-text-base);
  margin-bottom: var(--sc-space-lg);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.email-gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--sc-space-sm);
  max-width: 360px;
  margin: 0 auto;
}

.email-gate-form input {
  padding: 12px 16px;
  font-size: var(--sc-text-base);
  border: 1px solid var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.email-gate-form input:focus {
  border-color: var(--sc-blue-500);
}

.email-gate-form button {
  padding: 12px 24px;
  font-size: var(--sc-text-base);
  font-weight: 600;
  background: var(--sc-blue-500);
  color: var(--sc-white);
  border: none;
  border-radius: var(--sc-radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.email-gate-form button:hover:not(:disabled) {
  background: var(--sc-blue-600);
}

.email-gate-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.email-gate-privacy {
  font-size: var(--sc-text-xs);
  color: var(--sc-slate-400);
  margin-top: var(--sc-space-sm);
}

/* --- LLM Results --- */
.llm-table {
  width: 100%;
  border-collapse: collapse;
}

.llm-table th {
  background: var(--sc-gray-100);
  padding: 10px 16px;
  text-align: left;
  font-size: var(--sc-text-sm);
  font-weight: 600;
  color: var(--sc-slate-600);
}

.llm-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--sc-slate-200);
  font-size: var(--sc-text-sm);
}

/* --- Recommendations --- */
.recommendation-list {
  list-style: none;
}

.recommendation-item {
  padding: var(--sc-space-md);
  border-left: 4px solid;
  margin-bottom: var(--sc-space-sm);
  border-radius: 0 var(--sc-radius-sm) var(--sc-radius-sm) 0;
  background: var(--sc-gray-50);
}

.recommendation-item.severity-critical {
  border-left-color: var(--sc-red-500);
}
.recommendation-item.severity-high {
  border-left-color: var(--sc-red-500);
}
.recommendation-item.severity-medium {
  border-left-color: var(--sc-amber-500);
}
.recommendation-item.severity-info {
  border-left-color: var(--sc-blue-500);
}

.recommendation-title {
  font-weight: 600;
  font-size: var(--sc-text-base);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: var(--sc-space-sm);
}

.recommendation-body {
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
  line-height: 1.5;
}

/* --- Error State --- */
.error-state {
  text-align: center;
  padding: var(--sc-space-2xl) var(--sc-space-lg);
}

.error-icon {
  font-size: 48px;
  margin-bottom: var(--sc-space-md);
}

.error-state h2 {
  font-size: var(--sc-text-xl);
  margin-bottom: var(--sc-space-sm);
  color: var(--sc-navy-800);
}

.error-state p {
  color: var(--sc-slate-600);
  font-size: var(--sc-text-base);
  max-width: 480px;
  margin: 0 auto var(--sc-space-lg);
}

.error-detail {
  background: var(--sc-gray-100);
  padding: var(--sc-space-md);
  border-radius: var(--sc-radius-sm);
  font-size: var(--sc-text-sm);
  color: var(--sc-slate-600);
  max-width: 480px;
  margin: 0 auto var(--sc-space-lg);
  word-break: break-word;
}

.error-actions {
  display: flex;
  gap: var(--sc-space-sm);
  justify-content: center;
}

.btn-primary {
  padding: 12px 24px;
  font-size: var(--sc-text-base);
  font-weight: 600;
  background: var(--sc-blue-500);
  color: var(--sc-white);
  border: none;
  border-radius: var(--sc-radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--sc-blue-600);
}

.btn-secondary {
  padding: 12px 24px;
  font-size: var(--sc-text-base);
  font-weight: 500;
  background: var(--sc-white);
  color: var(--sc-navy-800);
  border: 1px solid var(--sc-slate-200);
  border-radius: var(--sc-radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--sc-gray-50);
}

/* --- Footer --- */
.footer {
  background: var(--sc-navy-900);
  padding: var(--sc-space-lg);
  text-align: center;
  color: var(--sc-slate-400);
  font-size: var(--sc-text-sm);
  margin-top: auto;
}

.footer a {
  color: var(--sc-blue-400);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sc-space-sm);
  margin-bottom: var(--sc-space-sm);
}

.footer-brand img {
  height: 20px;
  width: auto;
}

/* --- LLM Loading --- */
.llm-loading {
  text-align: center;
  padding: var(--sc-space-xl) var(--sc-space-lg);
  border-top: 1px solid var(--sc-slate-200);
  margin-top: var(--sc-space-lg);
}

.llm-loading h2 {
  font-size: var(--sc-text-xl);
  margin-bottom: var(--sc-space-lg);
}

.llm-loading-steps {
  list-style: none;
  text-align: left;
  max-width: 360px;
  margin: 0 auto var(--sc-space-lg);
}

/* --- Divider --- */
.section-divider {
  border: none;
  border-top: 1px solid var(--sc-slate-200);
  margin: var(--sc-space-xl) 0;
}

/* --- Spinner --- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--sc-slate-200);
  border-top-color: var(--sc-blue-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* --- Responsive: Mobile --- */
@media (max-width: 640px) {
  .header {
    padding: var(--sc-space-xl) var(--sc-space-md);
  }

  .header h1 {
    font-size: var(--sc-text-2xl);
  }

  .header p {
    font-size: var(--sc-text-base);
  }

  .url-input-form {
    flex-direction: column;
  }

  .card {
    padding: var(--sc-space-md);
    margin-bottom: var(--sc-space-md);
  }

  .screenshots {
    grid-template-columns: 1fr;
  }

  .score-circle {
    width: 120px;
    height: 120px;
    border-width: 6px;
  }

  .score-number {
    font-size: var(--sc-text-4xl);
  }

  /* Hide table, show cards on mobile */
  .crawler-table-wrapper {
    display: none;
  }

  .crawler-cards {
    display: block;
  }

  .benchmark-stats {
    flex-direction: column;
    gap: var(--sc-space-sm);
  }

  .share-row {
    flex-direction: column;
  }

  .share-btn {
    width: 100%;
    justify-content: center;
  }

  .error-actions {
    flex-direction: column;
  }
}

/* --- Responsive: Tablet+ shows table --- */
@media (min-width: 641px) {
  .crawler-table-wrapper {
    display: block;
  }

  .crawler-cards {
    display: none;
  }
}

/* Turnstile container — invisible */
.turnstile-container {
  position: absolute;
  left: -9999px;
  top: -9999px;
}
