/* ==========================================================================
   KF.Social Static Pages — Shared Component Styles
   Loaded by all SEO-generated pages alongside Tailwind (styles.css).
   Handles light + dark mode for every component.
   ========================================================================== */

/* ---------- Base ---------- */
:root {
  color-scheme: light dark;
  --bg-body: #f8fafb;
  --bg-surface: #ffffff;
  --bg-surface-raised: #ffffff;
  --bg-hero: #faf9f6;
  --bg-hero-alt: #ecfdf5;
  --bg-muted: #f1f5f9;
  --border: #e5e7eb;
  --border-subtle: rgba(0,0,0,0.04);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --text-heading: #111827;
  --text-link: #1d4ed8;
  --text-link-hover: #1e40af;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #09090b;
    --bg-surface: #18181b;
    --bg-surface-raised: #1c1c1f;
    --bg-hero: #111113;
    --bg-hero-alt: #111113;
    --bg-muted: #27272a;
    --border: #27272a;
    --border-subtle: #27272a;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-faint: #52525b;
    --text-heading: #fafafa;
    --text-link: #93b4ff;
    --text-link-hover: #bdd0ff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-card: 0 4px 16px rgba(0,0,0,0.4);
  }
}

/* ---------- Global resets for dark mode ---------- */
.seo-page {
  background: var(--bg-body);
  color: var(--text-primary);
}

.seo-page a {
  color: var(--text-link);
  text-decoration: none;
}

.seo-page a:hover {
  color: var(--text-link-hover);
}

/* ---------- Header ---------- */
.sp-header {
  background-color: #0242DA;
  color: white;
}

.sp-header a {
  color: white !important;
}

.sp-header svg {
  color: white !important;
  fill: white !important;
}

.sp-header a.sp-header-cta {
  background: white !important;
  color: #0242DA !important;
  font-weight: 600 !important;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
}

/* ---------- Hero sections ---------- */
.sp-hero {
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1rem 1.75rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sp-hero-green {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 30%, #a7f3d0 60%, #6ee7b7 100%);
  border-bottom: none;
}

.sp-hero-purple {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 30%, #ddd6fe 60%, #c4b5fd 100%);
  border-bottom: none;
}

@media (prefers-color-scheme: dark) {
  .sp-hero {
    background: var(--bg-hero) !important;
    border-bottom-color: var(--border) !important;
  }
  .sp-hero-green {
    background: #111113 !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .sp-hero-green::before {
    opacity: 0 !important;
  }
  .sp-hero-purple {
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 50%, #4c1d95 100%) !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .sp-hero::before {
    opacity: 0;
  }
}

.sp-hero h1 {
  color: var(--text-heading);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.sp-hero p {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---------- Breadcrumb ---------- */
.sp-breadcrumb {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.sp-breadcrumb a {
  color: var(--text-muted);
}

.sp-breadcrumb a:hover {
  text-decoration: underline;
}

.sp-breadcrumb-current {
  color: var(--text-secondary);
}

/* ---------- Cards ---------- */
.sp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.sp-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.sp-card-body {
  padding: 1.5rem;
}

.sp-card-lg {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  box-shadow: var(--shadow-card);
  padding: 2rem 2.5rem;
}

/* ---------- Content / Prose ---------- */
.sp-content {
  color: var(--text-primary);
}

.sp-content h2, .sp-content h3 {
  color: var(--text-heading);
}

.sp-content p, .sp-content li {
  color: var(--text-primary);
  line-height: 1.7;
}

.sp-content strong {
  color: var(--text-heading);
}

.sp-content a {
  color: var(--text-link);
}

.sp-content a:hover {
  color: var(--text-link-hover);
}

/* ---------- Badges / Pills ---------- */
.sp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.sp-badge-green {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

@media (prefers-color-scheme: dark) {
  .sp-badge-green {
    background: #052e16;
    color: #4ade80;
    border-color: #14532d;
  }
}

.sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sp-pill:hover {
  transform: translateY(-1px);
}

/* ---------- Trust badges ---------- */
.sp-trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: var(--text-secondary);
}

@media (prefers-color-scheme: dark) {
  .sp-trust-badge {
    background: var(--bg-muted);
    border-color: #3f3f46;
    color: #a1a1aa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
}

/* ---------- FAQ accordion ---------- */
.sp-faq {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.sp-faq:hover {
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16,185,129,0.08);
}

@media (prefers-color-scheme: dark) {
  .sp-faq {
    background: var(--bg-surface);
    border-color: var(--border);
  }
  .sp-faq:hover {
    border-color: #3f3f46;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
}

.sp-faq summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  border-radius: 0.75rem;
}

.sp-faq summary:hover {
  background: var(--bg-muted);
}

.sp-faq[open] summary {
  color: var(--text-link);
}

.sp-faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---------- CTA block ---------- */
.sp-cta {
  background: linear-gradient(135deg, #1e3a8a 0%, #312e81 50%, #1e40af 100%);
  border-radius: 1.5rem;
  box-shadow: 0 16px 40px rgba(15,23,42,0.1);
  padding: 3rem 2rem;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .sp-cta {
    box-shadow: 0 16px 40px rgba(0,0,0,0.4);
  }
}

.sp-cta h2 {
  color: #ffffff !important;
}

.sp-cta p {
  color: rgba(248,250,252,0.8) !important;
}

.sp-cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 2.25rem;
  border-radius: 999px;
  color: #0242DA !important;
  font-weight: 600;
  background: white !important;
  box-shadow: 0 8px 20px rgba(15,23,42,0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none !important;
}

.sp-cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15,23,42,0.3);
  color: #0242DA !important;
}

@keyframes sp-pulse {
  0%, 100% { box-shadow: 0 8px 20px rgba(15,23,42,0.2); }
  50% { box-shadow: 0 12px 30px rgba(37,99,235,0.35); }
}

.sp-cta-button-pulse {
  animation: sp-pulse 2.5s ease-in-out infinite;
}

/* ---------- Related cards ---------- */
.sp-related-card {
  background: var(--bg-surface);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  display: block;
  color: var(--text-primary);
}

.sp-related-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #10b981;
}

.sp-related-card span {
  color: var(--text-link);
  font-weight: 600;
}

/* ---------- Share buttons ---------- */
.sp-share-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
}

.sp-share-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-right: 0.375rem;
}

.sp-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  text-decoration: none;
  padding: 0;
}

.sp-share-btn:hover {
  color: var(--text-primary);
  background: var(--bg-muted);
}

/* ---------- Section headings ---------- */
.sp-section-heading {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 1.5rem;
}

/* ---------- Icon circles ---------- */
.sp-icon-circle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- Pricing cards ---------- */
.sp-pricing-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}

/* ---------- Area chips ---------- */
.sp-area-chip {
  display: block;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.sp-area-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ---------- Footer ---------- */
.sp-footer {
  background-color: #0242DA;
  color: white;
}

@media (prefers-color-scheme: dark) {
  .sp-footer {
    background-color: #09090b !important;
  }
}

.sp-footer a {
  color: #93c5fd !important;
}

.sp-footer a:hover {
  color: white !important;
}

/* ---------- Skip link ---------- */
.sp-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 999;
  padding: 0.5rem 1rem;
  background: #0242DA;
  color: white;
  font-weight: 600;
}

.sp-skip-link:focus {
  left: 0;
  color: white;
}

/* ---------- Table ---------- */
.sp-table {
  width: 100%;
  border-collapse: collapse;
}

.sp-table th {
  background: var(--bg-muted);
  color: var(--text-heading);
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.sp-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.sp-table tr:hover td {
  background: var(--bg-muted);
}

/* ---------- Sidebar / TOC ---------- */
.sp-toc {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  position: sticky;
  top: 1rem;
}

.sp-toc-title {
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sp-toc-link {
  display: block;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-left: 2px solid var(--border);
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.sp-toc-link:hover {
  color: var(--text-link);
  border-left-color: var(--text-link);
  background: var(--bg-muted);
}

/* ==========================================================================
   GLOBAL DARK MODE OVERRIDES
   These catch ALL inline styles that templates set via style="..."
   Must come LAST in the file for maximum specificity.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  /* Force dark body on pages that set inline backgrounds on main/body */
  .seo-page,
  .seo-page main,
  .seo-page main[style] {
    background: var(--bg-body) !important;
  }

  /* Force dark on ANY element with inline light background */
  .seo-page [style*="background: white"],
  .seo-page [style*="background: #fff"],
  .seo-page [style*="background: #f"],
  .seo-page [style*="background:#f"],
  .seo-page [style*="background: rgb(2"],
  .seo-page section[style*="background"],
  .seo-page div[style*="background: #faf"],
  .seo-page div[style*="background: #fef"],
  .seo-page div[style*="background: #ecf"],
  .seo-page div[style*="background: #dcf"],
  .seo-page div[style*="background: #dbe"],
  .seo-page div[style*="background: #e0e"],
  .seo-page div[style*="background: #eef"],
  .seo-page div[style*="background: #f0f"],
  .seo-page div[style*="background: #f5f"],
  .seo-page div[style*="background: #F5F"] {
    background: var(--bg-surface) !important;
  }

  /* Force dark on inline linear-gradient backgrounds (except CTA/header) */
  .seo-page main [style*="background: linear-gradient"] {
    background: var(--bg-surface) !important;
  }

  /* Override inline text colors */
  .seo-page [style*="color: #0f172a"],
  .seo-page [style*="color: #1e293b"],
  .seo-page [style*="color: #022c22"],
  .seo-page [style*="color: #111827"],
  .seo-page [style*="color: #0f172a"],
  .seo-page [style*="color: #334155"] {
    color: var(--text-heading) !important;
  }

  .seo-page [style*="color: #475569"],
  .seo-page [style*="color: #4b5563"],
  .seo-page [style*="color: #64748b"],
  .seo-page [style*="color: #6b7280"],
  .seo-page [style*="color: #065f46"],
  .seo-page [style*="color: #064e3b"] {
    color: var(--text-secondary) !important;
  }

  .seo-page [style*="color: #9ca3af"],
  .seo-page [style*="color: #94a3b8"] {
    color: var(--text-muted) !important;
  }

  /* Override inline borders */
  .seo-page [style*="border: 1px solid #e"],
  .seo-page [style*="border: 1px solid rgba(0"],
  .seo-page [style*="border-top: 1px solid #e"],
  .seo-page [style*="border-bottom: 1px solid #e"] {
    border-color: var(--border) !important;
  }

  /* Force headings visible everywhere */
  .seo-page h1, .seo-page h2, .seo-page h3, .seo-page h4 {
    color: var(--text-heading) !important;
  }

  /* Force body text readable */
  .seo-page main p,
  .seo-page main li,
  .seo-page main td,
  .seo-page main dd {
    color: var(--text-primary) !important;
  }

  .seo-page main strong,
  .seo-page main b {
    color: var(--text-heading) !important;
  }

  /* Links in content */
  .seo-page main a {
    color: var(--text-link) !important;
  }

  /* Protect header — highest specificity */
  .seo-page .sp-header,
  .seo-page .sp-header a,
  .seo-page .sp-header nav a,
  .seo-page header[role="banner"] a {
    color: white !important;
  }
  .seo-page .sp-header-cta,
  .seo-page header[role="banner"] .sp-header-cta,
  .seo-page .sp-header .sp-header-cta {
    color: #0242DA !important;
    background: white !important;
  }

  /* Protect CTA buttons — must beat .seo-page main a */
  .seo-page .sp-cta-button,
  .seo-page main .sp-cta-button,
  .seo-page main .sp-cta a.sp-cta-button,
  .seo-page main a.sp-cta-button,
  .seo-page .sp-cta a,
  a.sp-cta-button {
    color: #0242DA !important;
    background: white !important;
    text-decoration: none !important;
  }

  /* Protect footer links */
  .seo-page .sp-footer a,
  .seo-page footer a {
    color: #93c5fd !important;
  }

  /* Category pills — darken bg for visibility */
  .seo-page .sp-pill,
  .seo-page a.sp-pill {
    background: #27272a !important;
    border-color: #3f3f46 !important;
  }

  /* Related card links should be readable */
  .seo-page .sp-related-card,
  .seo-page a.sp-related-card {
    color: var(--text-primary) !important;
  }
  .seo-page .sp-related-card span {
    color: var(--text-link) !important;
  }

  /* Hero sections — ensure text is bright on dark/gradient heroes */
  .seo-page .sp-hero h1,
  .seo-page .sp-hero-green h1,
  .seo-page .sp-hero-purple h1 {
    color: #ffffff !important;
  }
  .seo-page .sp-hero-green p,
  .seo-page .sp-hero-purple p {
    color: #e2e8f0 !important;
  }
  .seo-page .sp-hero-purple .sp-breadcrumb a {
    color: #c4b5fd !important;
  }
  .seo-page .sp-hero-purple .sp-breadcrumb-current {
    color: #ffffff !important;
  }

  /* Utility classes */
  .dark-surface {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
  }
}
