/* ColdSEO analyzer / directory / agents — module-only styles.
 * Reuses the existing design system (.hero, .section, .feature-grid, .steps, .accordion,
 * .answer-summary, .card, .badge, .btn, .feature-card, etc.). Only audit-specific UI lives here.
 * Loaded only on /analyzer/, /directory/, /agents/ and admin analyzer pages.
 */

:root {
  --grade-a: var(--success);
  --grade-b: var(--accent);
  --grade-c: var(--warning);
  --grade-d: #f97316;
  --grade-f: var(--danger);
  --grade-na: var(--text-muted);
}

/* Defensive: prevent any module-level horizontal overflow on /analyzer/, /directory/, /agents/.
   `clip` doesn't establish a containing block, so position: sticky on the site header still works. */
.page-analyzer, .page-directory, .page-agents { overflow-x: clip; }

/* Audit form (input + button on same row, wraps below 540px) */
.analyzer-form {
  display: flex; gap: var(--space-2); align-items: stretch;
  max-width: 560px; margin: var(--space-5) auto 0;
  flex-wrap: nowrap;
}
.analyzer-form .input { flex: 1 1 auto; min-width: 0; min-height: 52px; font-size: 1rem; }
.analyzer-form .btn { flex: 0 0 auto; }
.analyzer-form-meta { font-size: 0.875rem; margin-top: var(--space-3); text-align: center; }
@media (max-width: 540px) {
  .analyzer-form { flex-wrap: wrap; }
  .analyzer-form .btn { width: 100%; }
}

/* Audit form status banner */
.audit-status {
  margin: var(--space-4) auto 0; max-width: 560px; padding: 12px 16px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--bg-secondary); text-align: left;
}
.audit-status.loading { border-color: rgba(59,130,246,0.4); }
.audit-status.success { border-color: rgba(16,185,129,0.4); color: #6ee7b7; }
.audit-status.error   { border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* Guest preview (3 score cards above bars) */
.audit-preview {
  margin: var(--space-5) auto 0; text-align: left; max-width: 920px;
}
.preview-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}
.preview-score, .preview-issue, .preview-cta {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 180px; text-align: center;
}
.preview-score { border-width: 2px; }
.preview-letter { font-size: 4rem; line-height: 1; font-weight: 800; }
.preview-score-num { font-size: 1.05rem; font-weight: 600; }
.preview-issue .big { font-size: 3rem; font-weight: 800; color: var(--danger); line-height: 1; }
.preview-cta { gap: var(--space-3); }

.score-bars {
  margin-top: var(--space-4); padding: var(--space-4);
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; gap: 12px;
}
.bar-row { display: grid; grid-template-columns: 110px 1fr 40px; gap: var(--space-3); align-items: center; }
.bar-label { font-size: 0.875rem; color: var(--text-secondary); }
.bar-track { background: var(--bg-tertiary); height: 10px; border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width var(--transition-base); }
.bar-num { text-align: right; font-weight: 600; font-size: 0.875rem; }

/* Sr-only utility (used for form labels) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ─── Report page ─────────────────────────────────────────── */

.report-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-5); flex-wrap: wrap;
}

.score-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: var(--space-5); align-items: stretch;
}
.score-card { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 160px; justify-content: center; text-align: center; }
.score-card.overall { border-width: 2px; }
.score-card .label { color: var(--text-muted); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; }
.score-card .score-num { font-weight: 600; }

.grade {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.7rem; font-weight: 800;
  border: 3px solid currentColor;
}
.grade-sm { width: 32px; height: 32px; font-size: 0.9rem; border-width: 2px; }
.grade-a { color: var(--grade-a); }
.grade-b { color: var(--grade-b); }
.grade-c { color: var(--grade-c); }
.grade-d { color: var(--grade-d); }
.grade-f { color: var(--grade-f); }
.grade-na { color: var(--grade-na); }

.critical-issues {
  border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.05);
  margin-bottom: var(--space-5);
}
.critical-issues h3 { margin: 0 0 var(--space-3); color: #fca5a5; }
.rec-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }

.rec-table-wrap { position: relative; }
.rec-table th { white-space: nowrap; }
.priority-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 600; border: 1px solid var(--border);
}
.priority-critical .priority-badge { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.priority-high     .priority-badge { background: rgba(245,158,11,0.15); color: #fbbf24; border-color: rgba(245,158,11,0.4); }
.priority-medium   .priority-badge { background: rgba(59,130,246,0.15); color: #93c5fd; border-color: rgba(59,130,246,0.4); }
.priority-low      .priority-badge { background: var(--bg-tertiary); color: var(--text-secondary); }

.upgrade-overlay {
  margin-top: var(--space-4); padding: var(--space-5);
  background: linear-gradient(180deg, rgba(59,130,246,0.05) 0%, rgba(139,92,246,0.08) 100%);
  border: 1px dashed rgba(59,130,246,0.4); border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  text-align: center;
}

/* Tabs (report detail) */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin: 0 0 var(--space-4); flex-wrap: wrap;
}
.tab {
  padding: 10px 16px; border: 0; background: transparent; color: var(--text-secondary);
  cursor: pointer; font: inherit; border-bottom: 2px solid transparent;
  border-radius: 0; min-height: auto; text-decoration: none;
}
.tab.is-active { color: var(--text-primary); border-color: var(--accent); }
.tab:hover:not(.is-active) { color: var(--text-primary); background: var(--bg-tertiary); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.check-status {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-weight: 700; font-size: 0.875rem;
}
.check-status.pass { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.check-status.warn { background: rgba(245,158,11,0.18); color: #fbbf24; }
.check-status.fail { background: rgba(239,68,68,0.18); color: #fca5a5; }
.check-status.info { background: var(--bg-tertiary); color: var(--text-muted); }

.directory-cta { background: linear-gradient(180deg, rgba(16,185,129,0.05), rgba(59,130,246,0.05)); border-color: rgba(59,130,246,0.4); }
.directory-cta h3 { margin-top: 0; }

/* Verify file preview */
.verify-file-preview {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4);
  margin: var(--space-4) 0;
}
.verify-file-preview .block {
  display: block; background: var(--bg-primary); padding: 12px 14px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.875rem; color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-all;
}
.instructions { margin: var(--space-4) 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: var(--space-2); }
.trouble summary { cursor: pointer; }

/* ─── Directory ───────────────────────────────────────────── */

.dir-filter {
  display: grid; gap: var(--space-3); align-items: stretch;
  grid-template-columns: 2fr 1fr 1fr auto;
  margin-bottom: var(--space-4);
}
@media (max-width: 720px) { .dir-filter { grid-template-columns: 1fr; } }

.dir-grid {
  display: grid; gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: stretch;
}
.dir-card { display: flex; flex-direction: column; gap: var(--space-2); transition: transform var(--transition-base), box-shadow var(--transition-base); }
.dir-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.dir-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.dir-card-name { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); text-decoration: none; }
.dir-card-name:hover { color: var(--accent); }
.dir-card-domain { color: var(--text-muted); font-size: 0.875rem; margin: 0; }
.dir-card-desc { color: var(--text-secondary); font-size: 0.9rem; margin: 0; line-height: 1.5; }
.dir-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dir-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: var(--space-3); }
.mini-bars { display: flex; flex-direction: column; gap: 6px; margin: var(--space-2) 0; }
.mini-bars .bar-row { grid-template-columns: 60px 1fr 30px; gap: 8px; }

.badge.featured { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.4); }

.pager {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
  margin-top: var(--space-5);
}
/* NOTE: cannot name this .page — it would collide with <body class="page"> set by header.php */
.pager .pager-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-secondary); text-decoration: none;
  font-weight: 600;
}
.pager .pager-link.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager .pager-link:hover:not(.is-active) { background: var(--bg-tertiary); color: var(--text-primary); }

.site-profile-head {
  padding-bottom: var(--space-4); border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

/* ─── Agents store ────────────────────────────────────────── */

.agent-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}
.agent-card, .agent-card-lg {
  display: flex; flex-direction: column; gap: var(--space-2);
}
.agent-card-lg { padding: var(--space-6); }
.agent-price, .agent-price-lg { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.agent-price-lg { font-size: 1.8rem; }

/* Inline row helper used in module markup */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.between { justify-content: space-between; }

/* ==== Download Gate / Reverify / Download buttons ==== */
.download-gate {
  background: var(--color-card, var(--bg-elevated));
  border: 1px solid var(--color-border, var(--border));
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.download-gate .gate-icon {
  font-size: 2.5rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.download-gate h3 { margin: 0; font-size: 1.25rem; }
.download-gate p { margin: 0; color: var(--text-muted); max-width: 540px; }
.download-gate .btn { margin-top: 4px; }

/* Verified download section */
.download-section {
  background: var(--color-card, var(--bg-elevated));
  border: 1px solid var(--success);
  border-radius: 12px;
  padding: 32px;
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.download-section h3 { margin: 0; font-size: 1.25rem; }
.download-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: stretch;
  margin: 8px 0 4px;
  width: 100%;
}
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  min-height: 44px;
  transition: opacity 200ms ease, transform 200ms ease;
}
.btn-download--pdf  { background: var(--danger); color: #fff; }
.btn-download--word { background: #2563eb; color: #fff; }
.btn-download--txt  { background: #374151; color: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .btn-download:hover { opacity: 0.9; transform: translateY(-1px); }
}
.btn-download:hover { opacity: 0.9; }
.download-note {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--success);
  font-size: 0.875rem;
  margin: 0;
}
.download-fine-print {
  color: #6b7280;
  font-size: 0.8rem;
  margin: 4px 0 0;
}
.download-fine-print a { color: var(--accent); text-decoration: underline; }

@media (max-width: 480px) {
  .download-gate, .download-section { padding: 24px; }
  .btn-download { width: 100%; justify-content: center; }
}

/* ============================================================
   BACKLINK GATE CARD
   ============================================================ */

.backlink-gate-card {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--warning);
  background: linear-gradient(135deg, #0f1e35 0%, var(--bg-elevated) 100%);
  box-shadow: 0 0 40px rgba(245,158,11,0.12), 0 4px 24px rgba(0,0,0,0.4);
  margin: 40px 0;
  font-family: 'Inter', sans-serif;
}

/* ── Banner ── */
.gate-banner {
  background: linear-gradient(90deg, #b45309 0%, var(--warning) 50%, #b45309 100%);
  background-size: 200% 100%;
  animation: gate-shimmer 3s linear infinite;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
@keyframes gate-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.gate-banner__icon { font-size: 1rem; }
.gate-banner__text {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
}

/* ── Body: 2-col grid ── */
.gate-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
@media (max-width: 768px) {
  .gate-body { grid-template-columns: 1fr; }
}

/* ── Left panel ── */
.gate-messaging {
  padding: 28px 32px;
  border-right: 1px solid var(--border);
}
@media (max-width: 768px) {
  .gate-messaging {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
.gate-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 8px;
  line-height: 1.35;
}
.gate-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 24px;
}
.gate-subtitle strong { color: var(--warning); }

/* ── Feature list ── */
.gate-features {
  list-style: none !important;
  padding: 0 !important;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gate-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  padding: 9px 13px;
  border-radius: 8px;
  line-height: 1;
}
.gate-feature--unlocked {
  background: rgba(16,185,129,0.09);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,0.2);
}
.gate-feature--locked {
  background: rgba(255,255,255,0.03);
  color: #64748b;
  border: 1px solid rgba(255,255,255,0.06);
}
.gate-feature .feature-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.feature-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(245,158,11,0.15);
  color: var(--warning);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(245,158,11,0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Right panel ── */
.gate-action {
  padding: 28px 32px;
}
.gate-action__inner { width: 100%; }

.gate-action__label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
  display: block;
}
.gate-action__label--step2,
.gate-action__label--step3 { margin-top: 22px; }

.gate-action__hint {
  font-size: 0.8rem;
  color: #64748b;
  margin: -5px 0 14px;
}

/* ── Code box ── */
.gate-code-box {
  background: #07111f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.gate-code-box code {
  font-family: 'Fira Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: #7dd3fc;
  flex: 1;
  word-break: break-all;
  line-height: 1.5;
  background: none !important;
  padding: 0 !important;
  border: none !important;
}
.btn-copy-code {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--border);
  color: var(--text-muted);
  border: 1px solid #2d4a6e;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms ease;
  flex-shrink: 0;
}
.btn-copy-code:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-copy-code.copied {
  background: #064e3b;
  color: var(--success);
  border-color: var(--success);
}

/* ── Verify button ── */
.btn-verify-backlink {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #0a0e1a;
  font-weight: 800;
  font-size: 0.9rem;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  padding: 15px 20px;
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: 0 4px 20px rgba(245,158,11,0.3);
  letter-spacing: 0.01em;
}
.btn-verify-backlink:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(245,158,11,0.5);
  background: linear-gradient(135deg, #fbbf24, var(--warning));
}
.btn-verify-backlink:active { transform: translateY(0); }
.btn-verify-backlink:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-verify__icon { font-size: 1rem; }

.gate-action__fine-print {
  font-size: 0.73rem;
  color: #475569;
  margin-top: 14px;
  line-height: 1.55;
  text-align: center;
}

/* ── Reverify status messages ── */
.reverify-status {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.reverify-status--loading {
  background: var(--border);
  color: var(--text-muted);
}
.reverify-status--success {
  background: #064e3b;
  color: var(--success);
  border: 1px solid var(--success);
}
.reverify-status--error {
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid var(--danger);
}
.reverify-status code {
  display: block;
  margin-top: 8px;
  background: #0a1628;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #7dd3fc;
}
