/* ============================================================================
   Global Theme Tokens
   ----------------------------------------------------------------------------
   The widget relies heavily on CSS variables so we can swap light/dark themes
   without rewriting rule sets. Brand color stays consistent across modes.
============================================================================ */
:root {
  --brand-500: #485696;
  --brand-400: #5f6fba;
  --brand-300: #7f8ad8;
  --ink-900: #0f172a;
  --ink-700: #1f2937;
  --ink-500: #374151;
  --ink-300: #9ca3af;
  --ink-100: #e2e8f0;
  --ink-050: #f8fafc;
  --surface-100: #ffffff;
  --surface-200: rgba(255, 255, 255, 0.75);
  --border-200: rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 30px 80px rgba(15, 23, 42, 0.22);
  --shadow-soft: 0 10px 30px rgba(72, 86, 150, 0.22);
  --focus-ring: 0 0 0 3px rgba(72, 86, 150, 0.25);
  --error-500: #dc2626;
  --error-soft: rgba(220, 38, 38, 0.12);
  --success-500: #16a34a;
  --transition-fast: 200ms ease;
  --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --ink-900: #f9fafb;
  --ink-700: #e2e8f0;
  --ink-500: #cbd5f5;
  --ink-300: #94a3b8;
  --ink-100: rgba(148, 163, 184, 0.18);
  --ink-050: rgba(15, 23, 42, 0.6);
  --surface-100: rgba(15, 23, 42, 0.92);
  --surface-200: rgba(31, 41, 55, 0.85);
  --border-200: rgba(148, 163, 184, 0.18);
  --shadow-strong: 0 30px 80px rgba(8, 13, 25, 0.65);
  --shadow-soft: 0 10px 30px rgba(72, 86, 150, 0.35);
  --focus-ring: 0 0 0 3px rgba(94, 106, 196, 0.5);
  color-scheme: dark;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink-700);
  background: #020617;
  overflow-x: hidden;
  transition: background 400ms ease, color 400ms ease;
}

a {
  color: var(--brand-400);
  text-decoration: none;
  font-weight: 600;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

/* ============================================================================
   Animated Background Canvas
   ----------------------------------------------------------------------------
   Subtle moving gradient keeps the full-page backdrop lively without
   distracting from the widget.
============================================================================ */
.animated-background {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(94, 106, 196, 0.4), transparent),
    radial-gradient(circle at 80% 30%, rgba(59, 130, 246, 0.35), transparent),
    radial-gradient(circle at 50% 80%, rgba(236, 72, 153, 0.25), transparent),
    #020617;
  overflow: hidden;
  z-index: 0;
}

.animated-background::before,
.animated-background::after {
  content: "";
  position: absolute;
  width: 1400px;
  height: 1400px;
  top: 50%;
  left: 50%;
  border-radius: 45%;
  filter: blur(180px);
  opacity: 0.45;
  transform: translate(-50%, -50%) scale(1);
  animation: fluid-gradient 24s alternate infinite ease-in-out;
}

.animated-background::after {
  width: 1200px;
  height: 1200px;
  animation-duration: 28s;
  animation-direction: alternate-reverse;
  background: radial-gradient(circle, rgba(72, 86, 150, 0.5), transparent 60%);
}

@keyframes fluid-gradient {
  0% {
    transform: translate(-50%, -50%) scale(0.95) rotate(0deg);
  }
  50% {
    transform: translate(-52%, -48%) scale(1.05) rotate(10deg);
  }
  100% {
    transform: translate(-48%, -52%) scale(0.98) rotate(-8deg);
  }
}

/* ============================================================================
   Desktop Only Overlay
============================================================================ */
.desktop-notice {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.94);
  color: #fff;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2.5rem;
  text-align: center;
  z-index: 1000;
}

.desktop-notice.active {
  display: flex;
  animation: fade-in 300ms ease forwards;
}

.desktop-notice h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.desktop-notice p {
  max-width: 32rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================================
   Widget Shell
============================================================================ */
.widget-shell {
  position: relative;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
  width: min(1100px, 94vw);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 10;
}

.widget {
  background: var(--surface-100);
  backdrop-filter: blur(25px);
  border-radius: 32px;
  box-shadow: var(--shadow-strong);
  padding: 2.4rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  transition: background 350ms ease, box-shadow 350ms ease, color 350ms ease;
}

.widget-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
}

.widget-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
}

.widget-header h1 span.version-pill {
  background: rgba(72, 86, 150, 0.12);
  color: var(--brand-500);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.widget-header .toggle-wrapper {
  justify-self: center;
}

.widget-header .brand-logo {
  max-height: 46px;
  filter: drop-shadow(0 4px 8px rgba(72, 86, 150, 0.25));
}

/* ============================================================================
   Fancy Theme Toggle
============================================================================ */
.theme-toggle {
  --toggle-height: 44px;
  position: relative;
  width: 148px;
  height: var(--toggle-height);
  border-radius: 999px;
  padding: 4px;
  background: linear-gradient(135deg, rgba(72, 86, 150, 0.68), rgba(94, 106, 196, 0.46));
  box-shadow: 0 12px 30px rgba(72, 86, 150, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: visible;
  transition: transform var(--transition-bounce);
}

.theme-toggle::after {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 999px;
  border: 2px solid rgba(72, 86, 150, 0.45);
  animation: toggle-glow 4.8s linear infinite;
}

@keyframes toggle-glow {
  0% {
    transform: scale(1);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 0.35;
  }
}

.toggle-label {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 2;
  user-select: none;
}

.toggle-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(50% - 6px);
  background: var(--surface-200);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-bounce), background 400ms ease;
}

[data-theme="dark"] .toggle-thumb {
  transform: translateX(calc(100% + 8px));
}

[data-theme="light"] .toggle-thumb {
  transform: translateX(8px);
}

.theme-toggle:hover {
  transform: translateY(-3px);
}

.theme-toggle:active {
  transform: scale(0.98);
}

/* ============================================================================
   Progress Bar & Layout Grid
============================================================================ */
.progress-track {
  height: 10px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.25), rgba(148, 163, 184, 0.12));
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.progress-meter {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-300));
  box-shadow: 0 6px 22px rgba(72, 86, 150, 0.32);
  transition: width 500ms var(--transition-bounce);
}

.widget-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  min-height: 560px;
}

/* ============================================================================
   Sidebar Navigation
============================================================================ */
.toc {
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border-200);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .toc {
  background: rgba(31, 41, 55, 0.7);
}

.toc h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: 0.04em;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toc li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-500);
  transition: background 250ms ease, transform 250ms ease, color 250ms ease;
}

.toc li .status-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: rgba(148, 163, 184, 0.6);
  border: 1px solid transparent;
}

.toc li.is-complete {
  color: var(--ink-700);
  background: rgba(148, 205, 172, 0.2);
}

.toc li.is-complete .status-icon {
  background: var(--success-500);
}

.toc li.is-active {
  transform: translateX(6px);
  background: rgba(72, 86, 150, 0.2);
  color: var(--brand-500);
  box-shadow: 0 12px 30px rgba(72, 86, 150, 0.2);
}

.toc li.is-active .status-icon {
  background: var(--brand-500);
}

.toc li.is-locked .status-icon {
  background: rgba(148, 163, 184, 0.4);
}

[data-theme="dark"] .toc li {
  background: rgba(15, 23, 42, 0.55);
}

[data-theme="dark"] .toc li.is-active {
  background: rgba(72, 86, 150, 0.32);
}

/* ============================================================================
   Step Panels
============================================================================ */
.step-panel {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  padding: 2rem;
  border: 1px solid var(--border-200);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  display: none;
  flex-direction: column;
  gap: 1.6rem;
  max-height: 600px;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
}

.step-panel.active {
  display: flex;
  animation: slide-in 420ms var(--transition-bounce);
}

.step-panel::-webkit-scrollbar {
  width: 8px;
}

.step-panel::-webkit-scrollbar-thumb {
  background: rgba(72, 86, 150, 0.35);
  border-radius: 999px;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

[data-theme="dark"] .step-panel {
  background: rgba(15, 23, 42, 0.65);
}

.step-panel h2 {
  margin: 0;
  font-size: 1.8rem;
  color: var(--ink-900);
}

.step-description {
  color: var(--ink-500);
  line-height: 1.65;
  max-width: 50ch;
}

/* ============================================================================
   Buttons
============================================================================ */
.btn {
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform 180ms ease, box-shadow 180ms ease, background 240ms ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-300));
  color: #fff;
  box-shadow: 0 20px 35px rgba(72, 86, 150, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(72, 86, 150, 0.4);
  color: var(--brand-500);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:not(:disabled):hover {
  transform: translateY(-2px);
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

.actions-row {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.actions-row .right {
  margin-left: auto;
  display: flex;
  gap: 0.75rem;
}

/* ============================================================================
   Form Fields
============================================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem 1.6rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-weight: 600;
  color: var(--ink-900);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.form-field span.required {
  color: var(--error-500);
}

.field-instruction {
  font-size: 0.85rem;
  color: var(--ink-500);
  line-height: 1.5;
}

.field-control {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-700);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  transition: border 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

textarea.field-control {
  resize: vertical;
  min-height: 120px;
}

.field-control:focus-visible {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--focus-ring);
  background: #fff;
}

.is-hidden {
  display: none !important;
}

.form-field.has-error .field-control {
  border-color: var(--error-500);
  background: var(--error-soft);
}

.field-error {
  font-size: 0.8rem;
  color: var(--error-500);
}

.inline-options {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.option-tag {
  position: relative;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--ink-700);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 200ms ease, border 200ms ease, transform 200ms ease;
}

.option-tag input {
  appearance: none;
  position: absolute;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.option-tag.selected {
  background: rgba(72, 86, 150, 0.2);
  border-color: rgba(72, 86, 150, 0.5);
  color: var(--brand-500);
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(72, 86, 150, 0.16);
}

.llc-warning {
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px dashed rgba(220, 38, 38, 0.45);
  background: rgba(254, 226, 226, 0.4);
  color: var(--error-500);
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 2rem;
}

.modal-overlay.active {
  display: flex;
  animation: fade-in 220ms ease forwards;
}

.modal {
  background: var(--surface-100);
  border-radius: 24px;
  width: min(760px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}

.modal header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-200);
}

.modal header h3 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--ink-900);
}

.modal header p {
  margin: 0.4rem 0 0;
  color: var(--ink-500);
  font-size: 0.9rem;
}

.modal .modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal .modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal .modal-body::-webkit-scrollbar-thumb {
  background: rgba(72, 86, 150, 0.45);
  border-radius: 999px;
}

.modal footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-200);
  display: flex;
  justify-content: flex-end;
}

.modal footer .btn {
  min-width: 160px;
}

.no-access-modal .modal {
  text-align: center;
  padding: 2.5rem 2rem;
}

.no-access-modal h3 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--ink-900);
}

.no-access-modal p {
  max-width: 40ch;
  margin: 0 auto;
  line-height: 1.6;
  color: var(--ink-500);
}

.field-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(72, 86, 150, 0.1);
  color: var(--brand-500);
  font-weight: 600;
  font-size: 0.8rem;
}

.dual-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 12px;
  overflow: hidden;
}

.dual-input input {
  border: none;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  background: transparent;
  color: inherit;
}

.dual-input input:focus-visible {
  outline: none;
}

.dual-input span {
  padding: 0.85rem 1rem;
  background: rgba(72, 86, 150, 0.1);
  font-weight: 600;
  color: var(--brand-500);
  white-space: nowrap;
}

.dual-input.has-error {
  border-color: var(--error-500);
  background: var(--error-soft);
}

.iframe-wrapper {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border-200);
  box-shadow: var(--shadow-soft);
  background: rgba(255, 255, 255, 0.55);
}

.iframe-wrapper iframe {
  width: 100%;
  min-height: 998px;
  border: none;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--ink-500);
}

.loading-indicator span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(72, 86, 150, 0.35);
  border-top-color: var(--brand-500);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.submission-alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(72, 86, 150, 0.12);
  color: var(--brand-500);
  border: 1px solid rgba(72, 86, 150, 0.25);
  font-size: 0.9rem;
}

.submission-alert.is-error {
  background: rgba(220, 38, 38, 0.12);
  color: var(--error-500);
  border-color: rgba(220, 38, 38, 0.25);
}

/* ============================================================================
   Footer (outside widget)
============================================================================ */
footer.site-footer {
  margin: 2rem 0 1.5rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 5;
  position: relative;
}

footer.site-footer .footer-links {
  display: inline-flex;
  gap: 1.2rem;
  justify-content: center;
}

footer.site-footer a {
  color: rgba(255, 255, 255, 0.88);
}

/* ============================================================================
   Thank You Screen Extras
============================================================================ */
.celebration {
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 2rem 0;
}

.celebration svg {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 12px 30px rgba(22, 163, 74, 0.35));
}

.celebration h2 {
  margin: 0;
  font-size: 2.2rem;
  color: var(--ink-900);
  text-align: center;
}

.celebration p {
  color: var(--ink-500);
  text-align: center;
  max-width: 44ch;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  width: 8px;
  height: 16px;
  background: linear-gradient(180deg, rgba(72, 86, 150, 0.9), rgba(255, 255, 255, 0.9));
  top: -20px;
  animation: fall linear infinite;
  opacity: 0;
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(120vh) rotate(260deg);
    opacity: 0;
  }
}

/* ============================================================================
   Responsive Adjustments
============================================================================ */
@media (max-width: 1200px) {
  .widget-body {
    grid-template-columns: 230px 1fr;
  }
}

@media (max-width: 1024px) {
  body {
    overflow: hidden;
  }
}
