/* ============================================================
   PLATYPUS PAYROLL – ACH AUTHORIZATION FORM STYLES
   ============================================================ */

:root {
  --color-primary: #0f4c8a;
  --color-primary-dark: #0a3566;
  --color-primary-light: #e8f0f9;
  --color-accent: #1a7fbf;
  --color-success: #1a7a4a;
  --color-success-bg: #e8f5ee;
  --color-error: #c0392b;
  --color-error-bg: #fdf0ef;
  --color-warning: #b7700a;
  --color-warning-bg: #fef8ec;
  --color-text: #1a1a2e;
  --color-text-muted: #5a6170;
  --color-border: #ccd5e0;
  --color-border-focus: #0f4c8a;
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-step-inactive: #c8d0db;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --font-base: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: 180ms ease;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Page Wrapper ─────────────────────────────────────────── */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────── */
.form-header {
  background: var(--color-primary);
  color: #fff;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.header-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  white-space: nowrap;
}

.form-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-bar-wrapper {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.progress-steps {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-step-inactive);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background var(--transition), transform var(--transition);
}

.step.active .step-circle {
  background: var(--color-primary);
  transform: scale(1.1);
}

.step.completed .step-circle {
  background: var(--color-success);
}

.step.completed .step-circle::before {
  content: "✓";
}

.step-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.step.active .step-label {
  color: var(--color-primary);
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--color-step-inactive);
  margin: 0 0.5rem;
  margin-bottom: 1.2rem;
  transition: background var(--transition);
}

.step-connector.completed {
  background: var(--color-success);
}

/* ── Form Container ───────────────────────────────────────── */
.form-container {
  flex: 1;
  max-width: 780px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

/* ── Form Page / Section ──────────────────────────────────── */
.form-page {
  display: none;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2.5rem 2rem;
  animation: fadeIn 0.25s ease;
}

.form-page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--color-primary-light);
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.4rem;
}

.section-subtitle {
  color: var(--color-text-muted);
  font-size: 0.93rem;
}

/* ── Form Grid ────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 1.75rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-group.full-width {
  grid-column: 1 / -1;
}

/* ── Labels ───────────────────────────────────────────────── */
.field-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  display: block;
}

.required-star {
  color: var(--color-error);
  margin-left: 2px;
}

/* ── Inputs ───────────────────────────────────────────────── */
.field-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 0.95rem;
  color: var(--color-text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.field-input::placeholder { color: #aab2be; }

.field-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(15, 76, 138, 0.15);
}

.field-input:read-only {
  background: var(--color-bg);
  cursor: default;
  color: var(--color-text-muted);
}

.field-input.input-valid {
  border-color: var(--color-success);
}

.field-input.input-invalid {
  border-color: var(--color-error);
}

/* Signature field */
.signature-input {
  font-style: italic;
  font-size: 1.05rem;
}

/* ── Input with status (routing number) ───────────────────── */
.input-with-status {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.input-with-status .field-input { flex: 1; }

.routing-status {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.routing-status.checking { color: var(--color-warning); }
.routing-status.valid    { color: var(--color-success); }
.routing-status.invalid  { color: var(--color-error); }

.bank-name-confirmed {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-success);
  padding: 0.4rem 0.7rem;
  background: var(--color-success-bg);
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.bank-name-confirmed.visible { display: flex; }

/* ── Input with visibility toggle (account number) ───────── */
.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-toggle .field-input { padding-right: 2.6rem; }

.toggle-visibility {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.toggle-visibility:hover { color: var(--color-primary); }

/* ── Hints & Errors ───────────────────────────────────────── */
.field-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
}

.hint-icon { font-style: normal; flex-shrink: 0; }

.field-error {
  font-size: 0.8rem;
  color: var(--color-error);
  font-weight: 500;
  min-height: 1.1em;
}

/* ── Radio Buttons ────────────────────────────────────────── */
.radio-fieldset {
  border: none;
  padding: 0;
}

.radio-fieldset legend.field-label {
  margin-bottom: 0.75rem;
}

.radio-group {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition);
}

.radio-custom::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.radio-option input[type="radio"]:checked ~ .radio-custom {
  border-color: var(--color-primary);
}

.radio-option input[type="radio"]:checked ~ .radio-custom::after {
  opacity: 1;
}

.radio-option input[type="radio"]:focus-visible ~ .radio-custom {
  outline: 3px solid rgba(15, 76, 138, 0.35);
  outline-offset: 2px;
}

.radio-label {
  font-size: 0.95rem;
  font-weight: 500;
}

/* ── Checkboxes ───────────────────────────────────────────── */
.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 4px;
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition);
}

.checkbox-custom::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0;
  transition: opacity var(--transition);
}

.checkbox-option input[type="checkbox"]:checked ~ .checkbox-custom {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-option input[type="checkbox"]:checked ~ .checkbox-custom::after {
  opacity: 1;
}

.checkbox-option input[type="checkbox"]:focus-visible ~ .checkbox-custom {
  outline: 3px solid rgba(15, 76, 138, 0.35);
  outline-offset: 2px;
}

.checkbox-label {
  font-size: 0.93rem;
  font-weight: 500;
  line-height: 1.5;
}

/* ── Authorization Text ───────────────────────────────────── */
.authorization-text {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-bottom: 2rem;
  max-height: 400px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.authorization-text h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1rem;
  text-align: center;
  letter-spacing: 0.05em;
}

.auth-section {
  margin-bottom: 1.25rem;
}

.auth-section:last-child { margin-bottom: 0; }

.auth-section h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-section p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.auth-section ul {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  list-style: disc;
  padding-left: 1.5rem;
  line-height: 1.65;
}

/* ── Form Actions ─────────────────────────────────────────── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 76, 138, 0.35);
}

.btn:active { transform: translateY(1px); }

.btn-next,
.btn-submit {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 76, 138, 0.35);
}

.btn-next:hover,
.btn-submit:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 4px 10px rgba(15, 76, 138, 0.45);
}

.btn-submit {
  background: var(--color-success);
  box-shadow: 0 2px 6px rgba(26, 122, 74, 0.35);
}

.btn-submit:hover {
  background: #15623b;
  box-shadow: 0 4px 10px rgba(26, 122, 74, 0.45);
}

.btn-submit:disabled {
  background: var(--color-step-inactive);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-back {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.btn-back:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn-arrow { font-style: normal; }

/* ── Success & Error Pages ────────────────────────────────── */
.success-container,
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 2rem;
  gap: 1.25rem;
}

.success-icon { color: var(--color-success); }
.error-icon   { color: var(--color-error); }

.success-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-success);
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-error);
}

.success-message,
.error-message {
  font-size: 1rem;
  color: var(--color-text-muted);
  max-width: 500px;
  line-height: 1.65;
}

.success-ref {
  background: var(--color-success-bg);
  border: 1px solid #b2dfc4;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  color: var(--color-success);
}

/* ── Footer ───────────────────────────────────────────────── */
.form-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  text-align: center;
}

.form-footer p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ── Loading Overlay ──────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 9999;
}

.loading-overlay.visible { display: flex; }

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.95rem;
  color: var(--color-primary);
  font-weight: 600;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-page {
    padding: 1.75rem 1.25rem 1.5rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .field-group.full-width {
    grid-column: 1;
  }

  .form-title {
    font-size: 1.1rem;
  }

  .step-label {
    display: none;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn { justify-content: center; }

  .input-with-status {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .routing-status {
    min-width: unset;
  }

  .authorization-text {
    max-height: 280px;
  }
}

@media (max-width: 400px) {
  .radio-group {
    flex-direction: column;
    gap: 0.75rem;
  }
}
