/* ==========================================================================
   TaxMate AI — Design System
   ========================================================================== */

:root {
  --color-bg: #f7f8fb;
  --color-surface: #ffffff;
  --color-border: #e6e9f0;
  --color-text: #1a2033;
  --color-text-muted: #5b6478;
  --color-primary: #4338ca;
  --color-primary-dark: #372e9e;
  --color-primary-light: #eef0fe;
  --color-indigo-50: #f2f1fd;
  --color-success: #0f9d58;
  --color-success-bg: #eafaf1;
  --color-warning: #b45309;
  --color-warning-bg: #fff7e6;
  --color-error: #c0261e;
  --color-error-bg: #fdecec;
  --color-info: #1d4ed8;
  --color-info-bg: #eaf0ff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20,24,42,.06), 0 1px 1px rgba(20,24,42,.04);
  --shadow-md: 0 8px 24px rgba(20,24,42,.08);
  --shadow-lg: 0 20px 45px rgba(20,24,42,.12);
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --color-bg: #0e1120;
  --color-surface: #171b2e;
  --color-border: #2a2f45;
  --color-text: #eef0fa;
  --color-text-muted: #a3aac2;
  --color-primary: #8b85f7;
  --color-primary-dark: #a29bff;
  --color-primary-light: #211f3d;
  --color-success-bg: #0f2a1e;
  --color-warning-bg: #2c2110;
  --color-error-bg: #2c1414;
  --color-info-bg: #131e3a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 45px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; color: var(--color-text-muted); }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }

/* Skip link */
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--color-primary); color: #fff;
  padding: 10px 16px; z-index: 1000; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; max-width: var(--maxw); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--color-primary), #7c6cf6);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: .68rem; letter-spacing: -0.02em;
}
.nav-links { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; }
.nav-links a { font-size: .93rem; font-weight: 600; color: var(--color-text-muted); padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--color-text); border-color: var(--color-primary); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: .93rem; padding: 11px 20px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { color: var(--color-text); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--color-border);
  background: var(--color-surface); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem;
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700;
  color: var(--color-primary); background: var(--color-primary-light); padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}
.hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
.hero .lead { font-size: 1.08rem; max-width: 46ch; }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-note { font-size: .82rem; margin-top: 14px; color: var(--color-text-muted); }

/* Mock dashboard card in hero */
.mock-dash {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 22px; position: relative;
}
.mock-dash-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.mock-dash-head strong { font-size: .95rem; }
.score-ring {
  width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--color-success) 0deg 281deg, var(--color-border) 281deg 360deg);
  display: flex; align-items: center; justify-content: center; margin: 6px auto 14px;
}
.score-ring-inner {
  width: 74px; height: 74px; border-radius: 50%; background: var(--color-surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-ring-inner b { font-size: 1.3rem; }
.score-ring-inner span { font-size: .65rem; color: var(--color-text-muted); }
.mock-stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 12px; }
.mock-stat { background: var(--color-bg); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.mock-stat b { display: block; font-size: 1.1rem; }
.mock-stat span { font-size: .7rem; color: var(--color-text-muted); }

/* ---------- Sections ---------- */
section { padding: 56px 0; }
.section-head { max-width: 640px; margin: 0 auto 34px; text-align: center; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.section-head p { font-size: 1rem; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 22px; box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-icon {
  width: 42px; height: 42px; border-radius: 12px; background: var(--color-primary-light); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 14px;
}
.card h3 { font-size: 1.05rem; }
.card p { font-size: .9rem; margin-bottom: 0; }

/* Steps */
.steps { counter-reset: step; }
.step { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--color-border); }
.step:last-child { border-bottom: none; }
.step-num {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary-light);
  color: var(--color-primary); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.step h3 { font-size: 1rem; margin-bottom: 4px; }
.step p { font-size: .88rem; margin: 0; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em;
}
.badge-critical { background: var(--color-error-bg); color: var(--color-error); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }

/* Trust / disclaimer bar */
.disclaimer-bar {
  background: var(--color-warning-bg); border: 1px solid #f2d9a8; border-radius: var(--radius-md);
  padding: 14px 18px; font-size: .85rem; color: var(--color-text); display: flex; gap: 10px; align-items: flex-start;
}
[data-theme="dark"] .disclaimer-bar { border-color: #4a3a17; }
.disclaimer-bar strong { color: var(--color-warning); }

.legal-strip {
  background: var(--color-surface); border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
  padding: 12px 0; font-size: .8rem; color: var(--color-text-muted); text-align: center;
}

/* ---------- Footer ---------- */
.site-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 48px 0 24px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 30px; }
.footer-col h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); margin-bottom: 12px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-col a { font-size: .88rem; color: var(--color-text-muted); }
.footer-col a:hover { color: var(--color-primary); }
.footer-bottom { margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--color-border); font-size: .78rem; color: var(--color-text-muted); text-align: center; }

/* ---------- Forms ---------- */
label { font-size: .85rem; font-weight: 700; display: block; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-bg); color: var(--color-text); font-size: .92rem; font-family: inherit;
}
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 18px; }
.field-hint { font-size: .78rem; color: var(--color-text-muted); margin-top: 4px; }
.field-error { font-size: .78rem; color: var(--color-error); margin-top: 4px; display: none; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--color-error); }
.field.invalid .field-error { display: block; }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px; margin: 0 0 20px; }
legend { font-weight: 800; padding: 0 8px; }

/* Tabs */
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--color-border); margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 16px; font-weight: 700; font-size: .88rem; background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn[aria-selected="true"] { color: var(--color-primary); border-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Analyzer result cards */
.result-card { border-radius: var(--radius-md); padding: 18px; border: 1px solid var(--color-border); margin-bottom: 14px; }
.result-card.severity-critical { background: var(--color-error-bg); border-color: #f2c4c1; }
.result-card.severity-warning { background: var(--color-warning-bg); border-color: #f2d9a8; }
.result-card.severity-info { background: var(--color-info-bg); border-color: #c9d8fb; }
.result-card.severity-success { background: var(--color-success-bg); border-color: #bfe9cf; }
[data-theme="dark"] .result-card.severity-critical { border-color: #4a2020; }
[data-theme="dark"] .result-card.severity-warning { border-color: #4a3a17; }
[data-theme="dark"] .result-card.severity-info { border-color: #223561; }
[data-theme="dark"] .result-card.severity-success { border-color: #1e4630; }
.result-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.result-card h4 { font-size: .95rem; margin: 0; }
.result-card .confidence { font-size: .74rem; color: var(--color-text-muted); white-space: nowrap; }
.result-card p { font-size: .86rem; margin: 6px 0; }
.result-card .meta-label { font-weight: 700; font-size: .78rem; color: var(--color-text); }
.result-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Health score display (analyzer results) */
.score-panel { display: grid; grid-template-columns: auto 1fr; gap: 30px; align-items: center; padding: 26px; }
.subscore { margin-bottom: 12px; }
.subscore-label { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 700; margin-bottom: 4px; }
.subscore-bar { height: 8px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.subscore-fill { height: 100%; border-radius: 999px; background: var(--color-primary); }

/* Toasts */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--color-text); color: var(--color-bg); padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: .85rem; box-shadow: var(--shadow-md); animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to { opacity:1; transform:none; } }

/* Accordion (FAQ) */
.accordion-item { border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; background: var(--color-surface); }
.accordion-trigger {
  width: 100%; text-align: left; background: none; border: none; padding: 16px 18px; font-weight: 700; font-size: .93rem;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--color-text);
}
.accordion-panel { max-height: 0; overflow: hidden; transition: max-height .2s ease; padding: 0 18px; }
.accordion-panel p { font-size: .88rem; }
.accordion-item.open .accordion-panel { max-height: 600px; padding-bottom: 16px; }
.accordion-item.open .chev { transform: rotate(180deg); }
.chev { transition: transform .2s ease; }

/* Wizard progress */
.wizard-progress { display: flex; gap: 6px; margin-bottom: 26px; }
.wizard-progress span { flex: 1; height: 5px; border-radius: 999px; background: var(--color-border); }
.wizard-progress span.done { background: var(--color-primary); }

/* Utility */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.gap-8 { gap: 8px; }
.muted { color: var(--color-text-muted); }
.small { font-size: .82rem; }
.hidden { display: none !important; }
.chip {
  display: inline-block; font-size: .78rem; padding: 4px 10px; border-radius: 999px;
  background: var(--color-primary-light); color: var(--color-primary); font-weight: 700; margin: 3px 4px 0 0; cursor: pointer; border: none;
}
.divider { height: 1px; background: var(--color-border); margin: 28px 0; }
.skeleton { background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg) 50%, var(--color-border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0;} 100% { background-position: -200% 0;} }

/* Floating chat button */
.fab-chat {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; align-items: center; gap: 8px; background: var(--color-primary); color: #fff;
  padding: 13px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); border: none; cursor: pointer; font-weight: 700; font-size: .88rem;
}
.chat-window {
  position: fixed; bottom: 90px; right: 22px; width: 340px; max-width: calc(100vw - 32px); height: 460px; max-height: 70vh;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 200; display: flex; flex-direction: column; overflow: hidden;
}
.chat-window.hidden { display: none; }
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--color-border); font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: .85rem; }
.chat-msg.bot { background: var(--color-bg); align-self: flex-start; }
.chat-msg.user { background: var(--color-primary); color: #fff; align-self: flex-end; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--color-border); }
.chat-input-row input { flex: 1; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,12,20,.5); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); max-width: 480px; width: 100%; padding: 26px; box-shadow: var(--shadow-lg); }

/* Analyzer two-column layout (sidebar + form) */
.analyzer-layout { display: grid; grid-template-columns: 260px 1fr; gap: 28px; align-items: flex-start; }
.analyzer-sidebar { position: sticky; top: 90px; }

/* Prevent any stray element from forcing horizontal scroll on narrow viewports */
html, body { overflow-x: hidden; max-width: 100%; }

/* Responsive */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .score-panel { grid-template-columns: 1fr; text-align: center; }
  .analyzer-layout { grid-template-columns: 1fr; }
  .analyzer-sidebar { position: static; top: auto; }
}
@media (max-width: 720px) {
  .nav-links { position: fixed; top: 64px; left: 0; right: 0; background: var(--color-surface); flex-direction: column;
    padding: 16px 24px; border-bottom: 1px solid var(--color-border); display: none; gap: 14px; max-height: calc(100vh - 64px); overflow-y: auto; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: inline-flex; }
  .footer-grid { grid-template-columns: 1fr; }
  .mock-stat-row { gap: 8px; }
  .mock-stat { padding: 8px 6px; }
  .mock-stat b { font-size: 1rem; }
  .mock-stat span { font-size: .64rem; }
}
@media (max-width: 480px) {
  .nav { padding: 12px 16px; }
  .brand-text { display: none; }
  .nav-actions { gap: 6px; }
  .nav-actions .btn-primary { padding: 8px 12px; font-size: .78rem; }
  .hero { padding: 40px 0 28px; }
  .hero-ctas .btn, .hero-ctas a { width: 100%; }
  .hero-ctas { flex-direction: column; }
  section { padding: 40px 0; }
  .container { padding: 0 16px; }
  .card { padding: 16px; }
  .steps { padding: 0; }
  .score-ring { width: 80px; height: 80px; }
  .score-ring-inner { width: 60px; height: 60px; }
  .score-ring-inner b { font-size: 1.05rem; }
  .chat-window { right: 16px; bottom: 82px; width: calc(100vw - 32px); }
  .fab-chat { right: 16px; bottom: 16px; padding: 11px 16px; font-size: .82rem; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; }
  .toast { width: 100%; }
}

/* ==========================================================================
   Print / "Save as PDF" — the browser's native print dialog is what
   actually produces the PDF (there's no server here to render one), so
   this stylesheet is what makes that output look like a real report
   instead of a screenshot of the web page: site chrome, navigation, forms
   and interactive controls are stripped out, and only the diagnostic
   results are shown, laid out for paper.
   ========================================================================== */
.print-only { display: none; }

@media print {
  /* Site chrome never belongs on a printed page. */
  .site-header, .site-footer, .fab-chat, .chat-window, .toast-stack,
  .skip-link, .no-print { display: none !important; }

  /* Analyzer-specific: hide the intro copy, input controls, and sidebar —
     only the results/report content should print. These selectors are
     unique to analyzer.html so this has no effect on other pages. */
  .analyzer-intro, .analyzer-sidebar, .tabs, [data-mode-panel],
  [data-loading], [data-analyze-btn], [data-demo-btn] { display: none !important; }

  .print-only { display: block !important; }

  html, body { background: #fff !important; color: #000 !important; }
  body { font-size: 11.5pt; line-height: 1.4; }
  .container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
  main, .analyzer-layout, [data-results] { display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
  section { padding: 0 !important; }

  a { color: #000 !important; text-decoration: underline; }
  .btn, button { display: none !important; }

  /* Cards/badges/panels: keep structure legible on paper, avoid color
     dependence, and avoid a card splitting awkwardly across a page break. */
  .card, .result-card, .score-panel {
    box-shadow: none !important;
    border: 1px solid #999 !important;
    background: #fff !important;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 14px !important;
  }
  .badge {
    border: 1px solid #333 !important;
    background: #fff !important;
    color: #000 !important;
  }
  .subscore-bar { border: 1px solid #999; background: #fff; }
  .subscore-fill { background: #555 !important; }
  .score-ring { background: #fff !important; border: 2px solid #333; }
  .score-ring-inner { background: #fff !important; }

  h1, h2, h3, h4 { color: #000 !important; page-break-after: avoid; }
  p { color: #222 !important; }

  /* Avoid orphaned section headers at the bottom of a page. */
  h3 { page-break-after: avoid; break-after: avoid; }
}

