/**
 * PNWv3 — Enterprise Design System (Phase 10 Wave 1)
 * Consistent, accessible, Stripe-Dashboard-inspired UI.
 * Self-hosted, zero dependencies, dark-mode-ready tokens.
 *
 * SINGLE SOURCE OF TRUTH: every color / spacing / type / radius / shadow
 * lives in the :root token block below. Components consume tokens only —
 * no raw hex values outside the token blocks (light :root + the
 * prefers-color-scheme dark overrides). URL is stable: /assets/app.css.
 *
 * ===========================================================================
 * COMPONENT CLASS VOCABULARY
 * ===========================================================================
 * Layout shell (_layout.php renders these):
 *   .page-wrapper            flex column body, full viewport height
 *   .skip-link               a11y "skip to main content" jump link
 *   .nav-top / .nav-brand / .nav-links / .nav-link(.active) / .nav-user /
 *   .nav-user-email          operator topbar
 *   .nav-group / .nav-group-toggle / .nav-dropdown
 *                            pure-CSS dropdown sections (hover +
 *                            :focus-within; inline on narrow screens)
 *   .breadcrumbs / .breadcrumbs-separator      in-page trail strip
 *   .page-container (-wide|-narrow)            centered content column
 *   .page-header / .page-title / .page-description
 *   .footer / .footer-links / .footer-link     standard support·terms·privacy
 *   .auth-main / .auth-card / .auth-header / .auth-title / .auth-subtitle /
 *   .auth-links                                centered sign-in shell
 * Buttons:
 *   .btn + .btn-primary | .btn-secondary | .btn-danger | .btn-success |
 *          .btn-ghost     (sizes: .btn-sm .btn-lg; .btn-block full width)
 * Forms:
 *   .form-group .form-label(.form-label-required) .form-input .form-select
 *   .form-textarea .form-help .form-error .has-error .honeypot
 *   .form-row (flex wrap group row) .form-actions (button row)
 *   .filter-bar (GET filter bar on list consoles)
 * Tables:
 *   .table-container > .table (+ .table-striped .table-compact; thead.sticky)
 * Cards & stats:
 *   .card (+ .card-header .card-body .card-footer .card-compact)
 *   .stat-card > .stat-label + .stat-value (accent border via .sev-1..5)
 * Badges:
 *   .badge + .badge-default | .badge-primary | .badge-success |
 *            .badge-warning | .badge-danger | .badge-info
 * Alerts:
 *   .alert + .alert-success | .alert-warning | .alert-error/.alert-danger |
 *            .alert-info
 * Grid & utilities:
 *   .grid .grid-cols-1..4 .grid-auto .gap-sm/md/lg .gap-2/3/4
 *   .flex .flex-col .items-center .justify-between
 *   .mt-2 .mt-4 .mt-6 .mt-8 .mb-2 .mb-4 .mb-6 .mb-8
 *   .text-muted .text-sm .text-xs .text-right .text-center
 * States:
 *   .empty-state(-icon/-title/-description) .loading-state
 *   .error-state(-code/-title/-description)
 * Customer surfaces (/pay, /pay/t/, /receipt):
 *   .pay-header .pay-title .price-grid .price .session-timer
 *   .summary-row .summary-label .summary-total .row-2col
 * Severity:
 *   .sev-indicator .sev-1..sev-5 (border accent, Sev1=danger … Sev5=success)
 * A11y:
 *   .sr-only, :focus-visible outlines, .skip-link
 * ===========================================================================
 */

/* =============================================================================
   DESIGN TOKENS — Custom Properties
   ============================================================================= */

:root {
  /* Color Palette — Primary & Accent */
  --color-primary: #635bff;
  --color-primary-hover: #524ae5;
  --color-primary-active: #4239cc;
  --color-primary-light: #e6e4ff;
  
  /* Semantic Colors */
  --color-success: #0f8347;
  --color-success-bg: #e7f7ef;
  --color-success-border: #86efac;
  
  --color-warning: #e3a000;
  --color-warning-bg: #fef8e7;
  --color-warning-border: #fcd34d;
  
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-danger-border: #fca5a5;
  
  --color-info: #0369a1;
  --color-info-bg: #e0f2fe;
  --color-info-border: #7dd3fc;
  
  /* Neutral Scale */
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  
  /* Semantic UI Colors */
  --color-background: #f6f7fb;
  --color-surface: #ffffff;
  --color-surface-hover: var(--color-gray-50);
  --color-text: #0f172a;
  --color-text-secondary: #64748b;
  --color-text-tertiary: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* Semantic surfaces (unified: thead/striped rows/card footers/hovers) —
     every former raw gray-50/gray-100 component value routes through these
     so dark mode flips them in one place. */
  --color-bg-subtle: var(--color-gray-50);    /* thead, stripes, card-footer */
  --color-bg-muted: var(--color-gray-100);    /* code chips, ghost hover    */
  --color-border-strong: var(--color-gray-300);
  --color-border-hover: var(--color-gray-400);
  --color-text-on-primary: #ffffff;

  /* Alert/badge foregrounds (readable on the semantic -bg tints) */
  --color-success-text: #166534;
  --color-warning-text: #92400e;
  --color-danger-text: #991b1b;
  --color-info-text: #0c4a6e;

  /* Button state colors */
  --color-danger-hover: #b91c1c;
  --color-success-hover: #0c6b3a;
  --color-success-active: #0a5a30;
  
  /* Spacing Scale (rem units) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* Typography Scale */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
  
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */
  
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;
  
  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  
  /* Focus Ring */
  --focus-ring: 0 0 0 3px rgba(99, 91, 255, 0.15);
  --focus-ring-danger: 0 0 0 3px rgba(220, 38, 38, 0.15);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens — every semantic token flips here; components never
   hardcode light values, so the whole system follows prefers-color-scheme. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #7a73ff;
    --color-primary-hover: #8d87ff;
    --color-primary-active: #635bff;
    --color-primary-light: #2a2750;

    --color-success: #34d399;
    --color-success-bg: #10291d;
    --color-success-border: #14532d;
    --color-success-text: #86efac;
    --color-success-hover: #2bc08a;
    --color-success-active: #25a878;

    --color-warning: #fbbf24;
    --color-warning-bg: #2a2110;
    --color-warning-border: #78350f;
    --color-warning-text: #fcd34d;

    --color-danger: #f87171;
    --color-danger-bg: #2f1517;
    --color-danger-border: #7f1d1d;
    --color-danger-text: #fca5a5;
    --color-danger-hover: #ef4444;

    --color-info: #38bdf8;
    --color-info-bg: #0c2436;
    --color-info-border: #075985;
    --color-info-text: #7dd3fc;

    --color-background: #0a0a0b;
    --color-surface: #1a1a1e;
    --color-surface-hover: #25252a;
    --color-text: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-tertiary: #64748b;
    --color-border: #2d3748;
    --color-border-light: #1e293b;

    --color-bg-subtle: #202024;
    --color-bg-muted: #2a2a31;
    --color-border-strong: #3d4757;
    --color-border-hover: #4a5568;

    --focus-ring: 0 0 0 3px rgba(122, 115, 255, 0.25);
    --focus-ring-danger: 0 0 0 3px rgba(248, 113, 113, 0.25);
  }
}

/* =============================================================================
   RESET & BASE STYLES
   ============================================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-background);
}

/* The hidden attribute always wins (pay-flow step cards toggle via [hidden]). */
[hidden] {
  display: none !important;
}

/* =============================================================================
   TYPOGRAPHY
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); margin-bottom: var(--space-4); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-3); }
h3 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
h4 { font-size: var(--text-lg); margin-bottom: var(--space-2); }

p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-muted);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  text-decoration: none;
}

.btn-primary:active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-border-strong);
  text-decoration: none;
}

.btn-secondary:active {
  background: var(--color-bg-muted);
}

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

.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-on-primary);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  text-decoration: none;
}

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

.btn-success {
  background: var(--color-success);
  color: var(--color-text-on-primary);
  border-color: var(--color-success);
}

.btn-success:hover {
  background: var(--color-success-hover);
  border-color: var(--color-success-hover);
  text-decoration: none;
}

.btn-success:active {
  background: var(--color-success-active);
  border-color: var(--color-success-active);
}

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

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-bg-muted);
  color: var(--color-text);
  text-decoration: none;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-label-required::after {
  content: " *";
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--color-border-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--color-bg-subtle);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
}

.form-textarea {
  min-height: 6rem;
  resize: vertical;
}

.form-help {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.form-error {
  color: var(--color-danger);
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.form-input.has-error,
.form-select.has-error,
.form-textarea.has-error {
  border-color: var(--color-danger);
}

.form-input.has-error:focus,
.form-select.has-error:focus,
.form-textarea.has-error:focus {
  box-shadow: var(--focus-ring-danger);
}

/* Inline forms (row actions inside tables) */
.form-inline {
  display: inline;
}

/* Horizontal group of form fields (filter bars, multi-field editors) */
.form-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: var(--space-4);
}

.form-row .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  /* Fields share the row evenly and wrap on narrow screens — replaces the
     per-page inline min-width styles (Users re-theme, Phase 10 W2). */
  flex: 1 1 12rem;
  min-width: 0;
}

/* Button row under a form */
.form-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-4);
}

/* GET filter bar on list consoles */
.filter-bar {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar .form-group {
  margin-bottom: 0;
}

/* Honeypot (accessibility-hidden spam trap) */
.honeypot {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
  overflow: hidden;
}

/* =============================================================================
   BADGES & PILLS
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.badge-default {
  background: var(--color-bg-muted);
  color: var(--color-text-secondary);
}

.badge-primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

/* =============================================================================
   ALERTS
   ============================================================================= */

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  margin-bottom: var(--space-4);
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning-text);
}

.alert-error,
.alert-danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}

.alert-info {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: var(--color-info-text);
}

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-body {
  padding: var(--space-6);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  font-weight: var(--font-weight-semibold);
}

.card-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}

.card-compact .card-body {
  padding: var(--space-4);
}

/* Stat Cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.stat-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.stat-value {
  display: block;
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: 1;
}

/* Description list (labelled facts, e.g. Connect onboarding state) */
.desc-list {
  margin-top: var(--space-4);
}

.desc-list dt {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-3);
}

.desc-list dd {
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-left: 0;
}

/* =============================================================================
   TABLES
   ============================================================================= */

.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead {
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

.table thead.sticky {
  position: sticky;
  top: 0;
  z-index: 10;
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

/* Row headers inside tbody (receipt-style label/value tables) */
.table tbody th[scope="row"] {
  width: 1%;
  white-space: nowrap;
  font-weight: var(--font-weight-medium);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--color-bg-subtle);
}

.table-striped tbody tr:nth-child(even) {
  background: var(--color-bg-subtle);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--color-bg-muted);
}

.table-compact th,
.table-compact td {
  padding: var(--space-2) var(--space-3);
}

/* =============================================================================
   NAVIGATION
   ============================================================================= */

.nav-top {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-8);
  box-shadow: var(--shadow-xs);
}

.nav-brand {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}

.nav-brand:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.nav-link {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--color-primary);
}

.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* --- Dropdown sections (Phase 10 Wave 2) ---------------------------------
   Pure-CSS disclosure menus: hover OR keyboard focus inside the group opens
   the panel (:focus-within). No JS. Child anchors keep the exact
   .nav-link(.active) markup the suites pin; styling is by descendant
   selector. On narrow screens the panels unfold inline (see RESPONSIVE). */
.nav-group {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-group-toggle::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.65;
}

.nav-group-toggle:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.nav-group-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav-group.active .nav-group-toggle {
  color: var(--color-primary);
}

.nav-dropdown {
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  min-width: 14rem;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

/* Invisible bridge over the trigger→panel gap so hover never drops. */
.nav-dropdown::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--space-2));
  left: 0;
  right: 0;
  height: var(--space-2);
}

.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  display: flex;
}

.nav-dropdown .nav-link {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

.nav-dropdown .nav-link:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.nav-dropdown .nav-link.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: var(--font-weight-semibold);
}

/* Keep the last section's panel inside the viewport. */
.nav-group:last-child .nav-dropdown {
  left: auto;
  right: 0;
}

.nav-user-email {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  overflow-wrap: break-word;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

.breadcrumbs a {
  color: var(--color-text-secondary);
}

.breadcrumbs a:hover {
  color: var(--color-primary);
}

.breadcrumbs-separator {
  color: var(--color-text-tertiary);
}

/* =============================================================================
   LAYOUT
   ============================================================================= */

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  width: 100%;
  flex: 1;
}

.page-container-wide {
  max-width: 1400px;
}

.page-container-narrow {
  max-width: 800px;
}

.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.page-description {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.gap-sm { gap: var(--space-3); }
.gap-md { gap: var(--space-6); }
.gap-lg { gap: var(--space-8); }

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Spacing Utilities */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Text Utilities */
.text-muted { color: var(--color-text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-upper { text-transform: uppercase; }

/* "Last updated" meta line on static/content pages */
.updated {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* =============================================================================
   AUTH SHELL (centered sign-in / password-reset cards)
   ============================================================================= */

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: 0;
}

.auth-links {
  text-align: center;
  margin-top: var(--space-6);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* =============================================================================
   CUSTOMER SURFACES (/pay, /pay/t/<token>, /receipt)
   Customer-facing polish on the same token set (Phase 10 Wave 2).
     .pay-header / .pay-title        sticky branded lot header
     .price-grid / .price            rate preview tiles (span label + b price)
     .session-timer                  live parking clock (tabular numerals)
     .summary-row / .summary-label /
     .summary-total                  label↔value lines (ticket totals, ...)
     .row-2col                       two-field grid (state + email, ...)
   ============================================================================= */

.pay-header {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  padding: var(--space-4) var(--space-6);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.pay-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  color: inherit;
  margin: 0;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-3);
}

.price {
  text-align: center;
  padding: var(--space-3);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.price b {
  display: block;
  font-size: var(--text-lg);
  color: var(--color-text);
}

.price span {
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
}

.session-timer {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: 1;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  color: var(--color-text-secondary);
}

.summary-total {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.row-2col {
  display: grid;
  grid-template-columns: minmax(90px, 110px) 1fr;
  gap: var(--space-4);
}

@media (max-width: 480px) {
  .row-2col {
    grid-template-columns: 1fr;
  }
}

/* =============================================================================
   FOOTER
   ============================================================================= */

.footer {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.footer-link {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--color-text);
  text-decoration: none;
}

/* =============================================================================
   STATES
   ============================================================================= */

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-secondary);
}

.empty-state-icon {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: var(--color-text-secondary);
}

.error-state {
  padding: var(--space-8);
  text-align: center;
}

.error-state-code {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-4);
}

.error-state-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-2);
}

.error-state-description {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

/* =============================================================================
   SEVERITY INDICATORS
   ============================================================================= */

.sev-indicator {
  border-left: 4px solid;
  padding-left: var(--space-3);
}

.sev-1 { border-color: var(--color-danger); }
.sev-2 { border-color: var(--color-warning); }
.sev-3 { border-color: var(--color-info); }
.sev-4 { border-color: var(--color-gray-400); }
.sev-5 { border-color: var(--color-success); }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
  .nav-top {
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
  }
}

@media (max-width: 768px) {
  :root {
    --text-3xl: 1.5rem;
    --text-2xl: 1.25rem;
  }
  
  .nav-top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
  
  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    width: 100%;
  }
  
  /* Narrow screens: dropdown panels unfold inline (always visible, no
     hover on touch) — sections stay identical, just stacked. */
  .nav-group {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
  
  .nav-group-toggle {
    padding: var(--space-1) 0;
  }
  
  .nav-dropdown,
  .nav-group:hover .nav-dropdown,
  .nav-group:focus-within .nav-dropdown {
    display: flex;
    position: static;
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0 0 var(--space-1) var(--space-4);
  }
  
  .nav-dropdown::before {
    display: none;
  }
  
  .nav-dropdown .nav-link {
    padding: var(--space-1) 0;
  }
  
  .nav-user {
    margin-left: 0;
    width: 100%;
  }
  
  .page-container {
    padding: var(--space-6) var(--space-4);
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  .table-container {
    border-radius: 0;
    margin: 0 calc(-1 * var(--space-4));
  }
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  padding: var(--space-3) var(--space-5);
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for all interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Respect reduced-motion preferences (transitions are cosmetic only) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
