/* ==========================================================================
   DoctorPayments Design Tokens
   A centralized design system for colors, typography, spacing, shadows,
   border-radius, and transitions. All CSS files should reference these
   custom properties instead of hardcoded values.
   ========================================================================== */

:root {
  /* ── Color Palette ─────────────────────────────────────────────────────── */

  /* Primary brand */
  --color-primary: #0039a6;
  --color-primary-hover: #002d80;
  --color-primary-active: #00236a;
  --color-primary-light: rgba(0, 57, 166, 0.08);
  --color-primary-ring: rgba(0, 57, 166, 0.35);

  /* Accent */
  --color-accent: #e98300;
  --color-accent-hover: #d17600;
  --color-accent-light: rgba(233, 131, 0, 0.1);

  /* Teal */
  --color-teal: #00add0;
  --color-teal-light: rgba(0, 173, 208, 0.1);

  /* Neutrals */
  --color-text: #4d4f53;
  --color-text-secondary: #6b6d71;
  --color-text-muted: #8a8c90;
  --color-text-on-dark: #ffffff;
  --color-heading: #0039a6;

  /* Borders */
  --color-border: #e0e0e0;
  --color-border-light: #e7e7e7;
  --color-border-focus: #0039a6;

  /* Backgrounds */
  --color-bg: #ffffff;
  --color-bg-subtle: #f8f9fa;
  --color-bg-muted: #f2f3f4;
  --color-bg-well: #f6f6f6;
  --color-bg-overlay: rgba(0, 0, 0, 0.5);

  /* Feedback */
  --color-error: #e98300;
  --color-error-bg: #fef3e6;
  --color-error-border: #f5c480;
  --color-success: #dfdf00;
  --color-success-bg: #fcfce6;
  --color-success-border: #eded80;
  --color-warning: #8a6d00;
  --color-warning-bg: #fef9e7;
  --color-warning-border: #f0ea9b;
  --color-info: #0c6ebd;
  --color-info-bg: #e8f4fd;
  --color-info-border: #a8d4f2;

  /* ── Typography ────────────────────────────────────────────────────────── */

  --font-family: 'CenturyGothic', 'Century Gothic', 'AppleGothic', sans-serif;
  --font-family-bold:
    'CenturyGothic-Bold', 'Century Gothic', 'CenturyGothic', 'AppleGothic',
    sans-serif;

  /* Type scale — fluid sizing with clamp() */
  --text-xs: clamp(0.6875rem, 0.65rem + 0.1vw, 0.75rem); /* 11–12px */
  --text-sm: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem); /* 12–13px */
  --text-base: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem); /* 13–14px */
  --text-md: clamp(0.875rem, 0.84rem + 0.15vw, 1rem); /* 14–16px */
  --text-lg: clamp(1rem, 0.95rem + 0.2vw, 1.125rem); /* 16–18px */
  --text-xl: clamp(1.125rem, 1.05rem + 0.3vw, 1.375rem); /* 18–22px */
  --text-2xl: clamp(1.375rem, 1.25rem + 0.5vw, 1.75rem); /* 22–28px */
  --text-3xl: clamp(1.75rem, 1.55rem + 0.8vw, 2.25rem); /* 28–36px */

  --line-height: 1.6;
  --line-height-tight: 1.3;
  --line-height-loose: 1.8;

  /* ── Spacing Scale ─────────────────────────────────────────────────────── */

  --space-xs: 0.25rem; /* 4px */
  --space-sm: 0.5rem; /* 8px */
  --space-md: 1rem; /* 16px */
  --space-lg: 1.5rem; /* 24px */
  --space-xl: 2rem; /* 32px */
  --space-2xl: 3rem; /* 48px */
  --space-3xl: 4rem; /* 64px */

  /* ── Border Radius ─────────────────────────────────────────────────────── */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ── Shadows ───────────────────────────────────────────────────────────── */

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-focus: 0 0 0 3px var(--color-primary-ring);
  --shadow-error-focus: 0 0 0 3px rgba(197, 66, 0, 0.3);

  /* ── Transitions ───────────────────────────────────────────────────────── */

  --transition-fast: 150ms ease;
  --transition-base: 200ms;
  --transition-slow: 300ms ease;
  --transition-spring: 200ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Z-Index Scale ─────────────────────────────────────────────────────── */

  --z-dropdown: 50;
  --z-sticky: 100;
  --z-overlay: 200;
  --z-modal: 300;
  --z-toast: 400;
}

/* ==========================================================================
   Global Enhancements — Applied on top of existing styles
   These provide modern polish without breaking existing layouts.
   ========================================================================== */

/* ── Skip-to-Content Link (Accessibility) ──────────────────────────────── */

.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: var(--color-text-on-dark);
  font-size: var(--text-base);
  font-family: var(--font-family);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: 0;
  outline: none;
}

/* ── Focus-Visible Ring (Global) ───────────────────────────────────────── */

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Smooth Scrolling ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ── Page Load Fade-In ─────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  main .content-wrapper {
    animation: fadeInUp 0.4s ease-out both;
  }
}

/* ── Button Enhancements ─────────────────────────────────────────────────
   Applies hover, focus, active, and disabled states globally.
   ========================================================================== */

a.btn,
form .form-control input[type='submit'],
.btn-bar a.btn,
button.btn,
.btn-primary {
  border-radius: var(--radius-sm);
  transition:
    background-color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-fast);
}

a.btn:hover,
form .form-control input[type='submit']:hover,
button.btn:hover,
.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
}

a.btn:focus-visible,
form .form-control input[type='submit']:focus-visible,
button.btn:focus-visible,
.btn-primary:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

a.btn:active,
form .form-control input[type='submit']:active,
button.btn:active,
.btn-primary:active {
  background-color: var(--color-primary-active);
  transform: scale(0.97);
  box-shadow: none;
}

a.btn[disabled],
form .form-control input[type='submit']:disabled,
button.btn:disabled,
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Accent/Active state buttons */
a.btn.active:hover,
form .form-control input[type='submit'].active:hover {
  background-color: var(--color-accent-hover);
}

/* Secondary buttons */
.btn-secondary {
  border-radius: var(--radius-sm);
  transition:
    background-color var(--transition-base),
    color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--color-primary);
  color: var(--color-text-on-dark);
}

.btn-secondary:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

.btn-secondary:active {
  transform: scale(0.97);
}

/* ── Form Input Enhancements ─────────────────────────────────────────────
   Adds focus rings, border-radius, and transitions to all inputs.
   ========================================================================== */

form .form-control input[type='text'],
form .form-control input[type='email'],
form .form-control input[type='date'],
form .form-control textarea {
  border-radius: var(--radius-sm);
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

form .form-control input[type='text']:focus,
form .form-control input[type='email']:focus,
form .form-control input[type='date']:focus,
form .form-control textarea:focus {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* Select wrapper focus state */
form .select-wrapper {
  border-radius: var(--radius-sm);
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

form .select-wrapper:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}

form .select-wrapper select:focus {
  outline: none; /* Parent shows the ring via :focus-within */
}

/* Error state on inputs */
form .form-control input.error,
form .form-control textarea.error,
form .form-control .select-wrapper.error {
  border-color: var(--color-error) !important;
  box-shadow: var(--shadow-error-focus) !important;
}

/* ── Error Message Styling ───────────────────────────────────────────────
   NOTE: brand palette --color-error (#e98300) fails WCAG AA (3.0:1 on
   white) and --color-success (#dfdf00) fails at 1.7:1. Flagged for the
   brand team in AB#260130; change tokens once brand sanctions new hexes.
   ========================================================================== */

form label.error {
  color: var(--color-error);
  font-size: var(--text-sm);
}

form #other-errors:not(:empty) {
  color: var(--color-error);
  background-color: var(--color-error-bg);
  border-left: 3px solid var(--color-error);
  padding: var(--space-sm) var(--space-md);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
}

/* ── Validation Error Summary ────────────────────────────────────────────
   Shown at the top of a form when validation fails (WCAG 3.3.1).
   ========================================================================== */

.validation-summary {
  color: var(--color-error);
  background-color: var(--color-error-bg);
  border: 1px solid var(--color-error);
  border-left-width: 3px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
}

.validation-summary:focus {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

.validation-summary strong {
  display: block;
  margin-bottom: var(--space-xs);
}

.validation-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.validation-summary li {
  margin-bottom: var(--space-xs);
}

.validation-summary a {
  color: var(--color-error);
  text-decoration: underline;
}

.validation-summary a:hover,
.validation-summary a:focus {
  text-decoration: none;
}

/* ARIA-live error container */
[role='alert'] {
  color: var(--color-error);
}

/* ── Card & Container Depth ──────────────────────────────────────────────
   Adds subtle shadows and border-radius to content areas.
   ========================================================================== */

.well {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--color-border);
}

.confirmation-block {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* Jump links on homepage */
.jump-links a {
  border-radius: var(--radius-sm);
  transition:
    background-color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.jump-links a:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.jump-links a:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

/* Hero card overlay */
.hero__details {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.9);
}

/* ── Loading Spinner Modernization ───────────────────────────────────────
   Faster rotation, accessible labeling, smooth fade.
   ========================================================================== */

#svgspin {
  animation: spin 1.2s linear infinite;
  fill: var(--color-primary);
}

.dancing-shell-container {
  transition: opacity var(--transition-slow);
}

.dancing-shell-container.hidden {
  opacity: 0;
  pointer-events: none;
}

.dancing-shell-container:not(.hidden) {
  opacity: 1;
}

/* ── Info Banners ────────────────────────────────────────────────────────── */

.spanish-verification-banner {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ── Header & Footer Polish ──────────────────────────────────────────────── */

header {
  box-shadow: var(--shadow-sm);
  border-bottom-color: var(--color-border);
}

footer {
  background: var(--color-primary);
}

/* ── Nav Link Active Indicator ───────────────────────────────────────────── */

@media screen and (min-width: 64.01rem) {
  nav ul li a {
    position: relative;
    transition: color var(--transition-base);
  }

  nav ul li a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: all var(--transition-base);
    transform: translateX(-50%);
  }

  nav ul li a:hover {
    color: var(--color-primary);
  }

  nav ul li a:hover::after,
  nav ul li a.active::after {
    width: 60%;
  }
}

/* ── Table Enhancements ──────────────────────────────────────────────────── */

#balanceDetails {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

#balanceDetails th {
  background-color: var(--color-bg-subtle);
}

/* ── Checkbox Modernization ──────────────────────────────────────────────── */

.checkbox-wrapper .outline {
  border-radius: 4px;
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

.checkbox-wrapper .outline.focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

/* ── Radio Button Enhancement ────────────────────────────────────────────── */

.radio input[type='radio'] + .radio-label:before {
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base),
    box-shadow var(--transition-base);
}

.radio input[type='radio']:focus-visible + .radio-label:before {
  box-shadow: var(--shadow-focus);
}

/* ── Popup / Modal Enhancement ───────────────────────────────────────────── */

#popup {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
}

#overlay {
  backdrop-filter: blur(4px);
}

/* ── Utility: Fade-in for dynamic content ────────────────────────────────── */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn var(--transition-slow) ease-out both;
}

/* ==========================================================================
   Tier 2 — Component-Level Modernization
   ========================================================================== */

/* ── Button Unification ──────────────────────────────────────────────────
   Three canonical variants: primary (default), secondary (outline), ghost.
   Consolidates duplicate .btn definitions across style.css, popup.css,
   and account-activity.css into a single source of truth.
   ========================================================================== */

/* Ghost variant — text-only, for tertiary actions */
a.btn.ghost,
button.btn-ghost,
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition:
    color var(--transition-base),
    background-color var(--transition-base);
}

a.btn.ghost:hover,
button.btn-ghost:hover,
.btn-ghost:hover {
  background-color: var(--color-primary-light);
  color: var(--color-primary-hover);
}

a.btn.ghost:focus-visible,
button.btn-ghost:focus-visible,
.btn-ghost:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

a.btn.ghost:active,
button.btn-ghost:active,
.btn-ghost:active {
  transform: scale(0.97);
}

/* Gray variant — for back/cancel anchors (replaces a.btn.gray) */
a.btn.gray,
button.btn-gray,
.btn-gray {
  background: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

a.btn.gray:hover,
button.btn-gray:hover,
.btn-gray:hover {
  background-color: var(--color-text-secondary);
}

/* ── Step Indicator (Multi-Step Flows) ───────────────────────────────────
   A horizontal progress bar for multi-step user flows:
   verification → pay, account-request → activity → details, etc.
   ========================================================================== */

.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: var(--space-lg) 0 var(--space-xl);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step-indicator__item {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
  text-align: center;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Connector line between steps */
.step-indicator__item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 20px);
  width: calc(100% - 40px);
  height: 2px;
  background: var(--color-border);
  transition: background-color var(--transition-base);
}

.step-indicator__item.completed:not(:last-child)::after {
  background: var(--color-primary);
}

/* Step circle */
.step-indicator__circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  position: relative;
  z-index: 1;
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base),
    color var(--transition-base);
  counter-increment: step;
}

/* Current step */
.step-indicator__item.active .step-indicator__circle {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-on-dark);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

/* Completed step */
.step-indicator__item.completed .step-indicator__circle {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-on-dark);
}

/* Checkmark for completed steps */
.step-indicator__item.completed .step-indicator__circle::after {
  content: '✓';
  font-size: var(--text-base);
}

/* Step label */
.step-indicator__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: color var(--transition-base);
}

.step-indicator__item.active .step-indicator__label {
  color: var(--color-primary);
  font-weight: 700;
}

.step-indicator__item.completed .step-indicator__label {
  color: var(--color-text);
}

/* ── Toast Notification System ───────────────────────────────────────────
   Floating notification bar for success, error, info, and warning messages.
   Slides in from the top, auto-dismisses after a configurable timeout.
   Usage: call showToast('message', 'success'|'error'|'info'|'warning') in JS
   ========================================================================== */

.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 300px;
  max-width: 420px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-family: var(--font-family);
  pointer-events: auto;
  animation: toastSlideIn var(--transition-slow) ease-out both;
  will-change: transform, opacity;
}

.toast.toast--dismissing {
  animation: toastSlideOut var(--transition-base) ease-in forwards;
}

.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
}

.toast__message {
  flex: 1;
  line-height: var(--line-height-tight);
}

.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  padding: 0 0 0 var(--space-sm);
}

.toast__close:hover {
  opacity: 1;
}

/* Toast variants */
.toast--success {
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  color: var(--color-success);
}

.toast--error {
  background: var(--color-error-bg);
  border-left: 4px solid var(--color-error);
  color: var(--color-error);
}

.toast--info {
  background: var(--color-info-bg);
  border-left: 4px solid var(--color-info);
  color: var(--color-info);
}

.toast--warning {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  color: var(--color-warning);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ── Mobile Nav Modernization ────────────────────────────────────────────
   Enhanced mobile drawer with smoother animation, backdrop blur,
   larger touch targets, and modern visual treatment.
   ========================================================================== */

/* Mobile overlay when nav is open */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg-overlay);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-base);
}

body.active-nav .nav-backdrop {
  display: block;
  opacity: 1;
}

/* Mobile nav enhancements (applied below desktop breakpoint) */
@media screen and (max-width: 64rem) {
  nav ul {
    box-shadow: var(--shadow-xl);
  }

  nav ul li a {
    font-size: var(--text-sm);
    letter-spacing: 0.04em;
    transition:
      background-color var(--transition-fast),
      color var(--transition-fast);
    padding: 0 1.25rem;
  }

  nav ul li a:hover,
  nav ul li a:focus-visible {
    background-color: rgba(255, 255, 255, 0.1);
  }

  nav ul li a.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--color-text-on-dark);
    font-weight: 700;
  }

  /* Language select in mobile nav */
  nav ul li.lang-nav-item {
    padding: var(--space-md) 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  nav ul li.lang-nav-item select {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-on-dark);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) 1.75rem var(--space-sm) var(--space-sm);
    font-size: var(--text-sm);
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 10px 6px;
  }
}

/* ── Focus Trap Styles ───────────────────────────────────────────────────
   Visual indicator for the focus-trap sentinel elements and
   keyboard-locked body state.
   ========================================================================== */

body.modal-open {
  overflow: hidden;
}

/* Hidden sentinel elements for focus trapping */
.focus-trap-sentinel {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ── Page Transition ─────────────────────────────────────────────────────
   Smooth fade when navigating between pages. Uses CSS on <main> content.
   ========================================================================== */

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  main {
    animation: pageEnter 0.35s ease-out both;
  }
}

/* ── Success Celebration Micro-Animations ────────────────────────────────
   For confirmation/success pages — checkmark draw and confetti burst.
   ========================================================================== */

@keyframes checkmarkDraw {
  0% {
    stroke-dashoffset: 48;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes scaleIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(60px) rotate(720deg);
    opacity: 0;
  }
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--space-lg) auto;
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-icon svg {
  width: 64px;
  height: 64px;
}

.success-icon__circle {
  fill: var(--color-success);
}

.success-icon__check {
  stroke: var(--color-text-on-dark);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkmarkDraw 0.4s ease-out 0.3s forwards;
}

/* Confetti particles */
.confetti {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
}

.confetti__piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall 1.2s ease-out both;
}

.confetti__piece:nth-child(1) {
  background: var(--color-primary);
  transform: translate(-30px, 0);
  animation-delay: 0.1s;
}
.confetti__piece:nth-child(2) {
  background: var(--color-accent);
  transform: translate(30px, 0);
  animation-delay: 0.15s;
}
.confetti__piece:nth-child(3) {
  background: var(--color-teal);
  transform: translate(-15px, -10px);
  animation-delay: 0.2s;
}
.confetti__piece:nth-child(4) {
  background: var(--color-success);
  transform: translate(15px, -10px);
  animation-delay: 0.25s;
}
.confetti__piece:nth-child(5) {
  background: var(--color-primary);
  transform: translate(0, -20px);
  animation-delay: 0.3s;
}
.confetti__piece:nth-child(6) {
  background: var(--color-accent);
  transform: translate(-25px, -5px);
  animation-delay: 0.35s;
}

/* ==========================================================================
   Dark Mode — Toggleable with OS-Preference Fallback
   Activated via `data-theme="dark"` on <html>, set by theme-toggle.js.
   Follows OS prefers-color-scheme by default; users can override via
   the ☀️/🌙 toggle button in the header.
   ========================================================================== */

:root[data-theme='dark'] {
  /* ── Color Palette (Dark) ──────────────────────────────────────────── */

  /* Primary brand — lightened for contrast on dark surfaces */
  --color-primary: #5b9bf5;
  --color-primary-hover: #79aff7;
  --color-primary-active: #4388e8;
  --color-primary-light: rgba(91, 155, 245, 0.12);
  --color-primary-ring: rgba(91, 155, 245, 0.4);

  /* Accent — warmed for dark backgrounds */
  --color-accent: #f5a623;
  --color-accent-hover: #f7b84d;
  --color-accent-light: rgba(245, 166, 35, 0.15);

  /* Teal */
  --color-teal: #26c6da;
  --color-teal-light: rgba(38, 198, 218, 0.12);

  /* Neutrals — inverted for dark surfaces */
  --color-text: #e1e3e6;
  --color-text-secondary: #b0b3b8;
  --color-text-muted: #8a8d93;
  --color-text-on-dark: #ffffff;
  --color-heading: #79aff7;

  /* Borders — subdued */
  --color-border: #3a3d42;
  --color-border-light: #2e3136;
  --color-border-focus: #5b9bf5;

  /* Backgrounds — dark surfaces */
  --color-bg: #1a1b1e;
  --color-bg-subtle: #222428;
  --color-bg-muted: #2a2d31;
  --color-bg-well: #252830;
  --color-bg-overlay: rgba(0, 0, 0, 0.7);

  /* Feedback — brightened for legibility */
  --color-error: #ffa030;
  --color-error-bg: rgba(233, 131, 0, 0.12);
  --color-error-border: rgba(233, 131, 0, 0.3);
  --color-success: #e8e830;
  --color-success-bg: rgba(223, 223, 0, 0.12);
  --color-success-border: rgba(223, 223, 0, 0.3);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251, 191, 36, 0.12);
  --color-warning-border: rgba(251, 191, 36, 0.3);
  --color-info: #60a5fa;
  --color-info-bg: rgba(96, 165, 250, 0.12);
  --color-info-border: rgba(96, 165, 250, 0.3);

  /* ── Shadows (Dark) ────────────────────────────────────────────────── */

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl:
    0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* ── Hardcoded-Color Overrides ────────────────────────────────────────
   style.css uses hardcoded hex values in many places. These selectors
   provide dark-mode equivalents for elements that don't use tokens.
   ======================================================================== */

/* Body + Page chrome */
:root[data-theme='dark'] body {
  background-color: var(--color-bg);
  color: var(--color-text);
}

:root[data-theme='dark'] header {
  background: var(--color-bg-subtle);
  border-bottom-color: var(--color-border);
}

:root[data-theme='dark'] main {
  background: var(--color-bg);
}

/* Hero banner */
:root[data-theme='dark'] .hero__details {
  background: rgba(26, 27, 30, 0.92);
}

:root[data-theme='dark'] .hero__details h3 {
  color: var(--color-accent);
}

:root[data-theme='dark'] .hero__details p {
  color: var(--color-primary);
}

/* Buttons */
:root[data-theme='dark'] a {
  color: var(--color-primary);
}

:root[data-theme='dark'] a:hover {
  color: var(--color-primary-hover);
}

:root[data-theme='dark'] a.btn,
:root[data-theme='dark'] form .form-control input[type='submit'] {
  background: var(--color-primary);
  color: var(--color-text-on-dark);
}

:root[data-theme='dark'] a.btn.active,
:root[data-theme='dark'] form .form-control input[type='submit'].active {
  background: var(--color-accent);
}

:root[data-theme='dark'] a.btn.gray {
  background: var(--color-text-muted);
}

/* Jump links on homepage */
:root[data-theme='dark'] .jump-links a {
  background: var(--color-primary);
}

/* Form controls */
:root[data-theme='dark'] form .form-control input[type='text'],
:root[data-theme='dark'] form .form-control input[type='email'],
:root[data-theme='dark'] form .form-control input[type='date'],
:root[data-theme='dark'] form .form-control textarea {
  background: var(--color-bg-muted);
  color: var(--color-text);
  border-color: var(--color-border);
}

:root[data-theme='dark'] form .form-control input:disabled,
:root[data-theme='dark'] form .form-control select:disabled {
  background: var(--color-bg-well);
  color: var(--color-text-muted);
}

:root[data-theme='dark'] form .select-wrapper {
  background: var(--color-bg-muted);
  border-color: var(--color-border);
}

:root[data-theme='dark'] form .select-wrapper select {
  color: var(--color-text);
  background: var(--color-bg-muted);
}

:root[data-theme='dark'] form .select-wrapper::after {
  border-color: var(--color-text-secondary) transparent transparent;
}

:root[data-theme='dark'] form label {
  color: var(--color-text);
}

:root[data-theme='dark'] form legend h4,
:root[data-theme='dark'] legend h4,
:root[data-theme='dark'] .legend h4 {
  color: var(--color-primary);
}

:root[data-theme='dark'] form fieldset {
  border-color: var(--color-border);
}

/* Tables */
:root[data-theme='dark'] table,
:root[data-theme='dark'] th,
:root[data-theme='dark'] td {
  border-color: var(--color-border);
}

:root[data-theme='dark'] th {
  color: var(--color-text);
}

/* Footer */
:root[data-theme='dark'] footer {
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
}

:root[data-theme='dark'] footer a {
  color: var(--color-text-secondary);
}

/* Navigation — mobile slide-out panel */
:root[data-theme='dark'] nav ul {
  background: var(--color-bg-subtle);
}

:root[data-theme='dark'] nav ul li {
  border-color: var(--color-border);
}

/* Desktop: keep nav transparent (sits inline with header) */
@media screen and (min-width: 64.01rem) {
  :root[data-theme='dark'] nav ul {
    background: transparent;
  }

  :root[data-theme='dark'] nav ul li {
    border-top-color: transparent;
    border-bottom-color: transparent;
  }

  :root[data-theme='dark']
    nav
    ul
    li:not(:first-child):not(.lang-nav-item):not(.theme-nav-item) {
    border-left-color: transparent;
  }

  :root[data-theme='dark'] .theme-nav-item #theme-toggle {
    color: var(--color-text-secondary);
    background: var(--color-bg-subtle);
    border-color: transparent;
  }

  :root[data-theme='dark'] .theme-nav-item #theme-toggle:hover {
    color: var(--color-text);
    background: var(--color-bg-well);
    border-color: transparent;
  }
}

:root[data-theme='dark'] nav ul li a {
  color: var(--color-text-secondary);
}

:root[data-theme='dark'] nav ul li a.active {
  color: var(--color-primary);
}

/* Hamburger icon */
:root[data-theme='dark'] #nav-icon::before,
:root[data-theme='dark'] #nav-icon::after,
:root[data-theme='dark'] #nav-icon div {
  background-color: var(--color-text-muted);
}

:root[data-theme='dark'] #nav-icon-wrapper {
  color: var(--color-text-muted);
}

/* Wells + Containers */
:root[data-theme='dark'] .well {
  background: var(--color-bg-well);
}

:root[data-theme='dark'] .confirmation-block {
  background: var(--color-bg-subtle);
}

/* Page header */
:root[data-theme='dark'] #page-header h2 {
  color: var(--color-primary);
  border-bottom-color: var(--color-border);
}

/* Payment due emphasis */
:root[data-theme='dark'] .payDue {
  color: var(--color-primary);
}

/* Radio buttons */
:root[data-theme='dark'] .radio input[type='radio'] + label::before {
  border-color: var(--color-border);
  background: var(--color-bg-muted);
}

/* Checkbox */
:root[data-theme='dark'] .checkbox-wrapper .outline {
  border-color: var(--color-border);
  background: var(--color-bg-muted);
}

/* Timeout overlay */
:root[data-theme='dark'] .timeout-overlay {
  background: rgba(0, 0, 0, 0.75);
}

:root[data-theme='dark'] .timeout-overlay-content {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

/* Horizontal rules + borders */
:root[data-theme='dark'] hr {
  border-color: var(--color-border);
}

:root[data-theme='dark'] .border-top {
  border-top-color: var(--color-border);
}

:root[data-theme='dark'] .border-bottom {
  border-bottom-color: var(--color-border);
}

/* Browser warning */
:root[data-theme='dark'] #browser-warning {
  background: var(--color-bg-muted);
  color: var(--color-text);
}

/* Spanish verification banner */
:root[data-theme='dark'] .spanish-verification-banner {
  background-color: var(--color-bg-muted);
  border-color: var(--color-teal);
}

/* Language selector */
:root[data-theme='dark'] #languageSelect {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
  border-color: var(--color-border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23b0b3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:root[data-theme='dark'] #languageSelect:hover {
  border-color: var(--color-primary);
  background-color: rgba(0, 57, 166, 0.15);
}

/* Maintenance */
:root[data-theme='dark'] .maintenance__details {
  background: rgba(26, 27, 30, 0.92);
}

:root[data-theme='dark'] .maintenance__details p {
  color: var(--color-text);
}

/* File input */
:root[data-theme='dark'] input[type='file']::file-selector-button {
  background: var(--color-primary);
  color: var(--color-text-on-dark);
}

/* FAQ + misc */
:root[data-theme='dark'] .faq-question {
  color: var(--color-primary);
}

:root[data-theme='dark'] .return-btn {
  color: var(--color-primary);
}

/* Scrollbar (Webkit) */
:root[data-theme='dark'] ::-webkit-scrollbar-track {
  background: var(--color-bg-muted);
}

:root[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

:root[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Toast dark adjustments — tokens handle most of it automatically */
:root[data-theme='dark'] .toast {
  background: var(--color-bg-subtle);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* ── Theme Toggle Button ─────────────────────────────────────────────── */

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition:
    color var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast);
}

#theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
  border-color: var(--color-border);
}

#theme-toggle:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

#theme-toggle svg {
  display: block;
}

/* ── Theme Toggle — Nav List Item ────────────────────────────────────── */

.theme-nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1.25rem;
  line-height: 4rem;
}

.theme-nav-item #theme-toggle {
  color: #fff;
}

.theme-nav-item #theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

@media screen and (min-width: 64.01rem) {
  .theme-nav-item #theme-toggle {
    color: var(--color-primary);
    background: none;
    border: none;
  }

  .theme-nav-item #theme-toggle:hover {
    color: var(--color-primary-hover);
    background: none;
    border: none;
  }
}
