/* ============================================
   form.css — Form + Preview styles
   Clean professional look inspired by ThePayStubs
   ============================================ */

/* ---- Validation Error ---- */
.field-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15) !important;
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Form Sections ---- */
.form-section {
  background: #fff;
  border: none;
  border-bottom: 1px solid #e8e8e8;
  border-radius: 0;
  padding: 28px 0;
  margin-bottom: 0;
}

.form-section:first-of-type {
  padding-top: 20px;
}

.form-section legend {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1B2A4A;
  padding: 0;
  margin-bottom: 20px;
  display: block;
  width: 100%;
}

.form-section legend small,
.optional-label {
  font-weight: 400;
  color: #999;
  font-size: 0.8rem;
}

/* ---- Form Layout ---- */
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row.two-col .form-group { flex: 1; }
.form-row.three-col .form-group { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full { flex: 1; }

/* ---- Labels ---- */
.form-group > label,
.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
  line-height: 1.4;
}

.req { color: #e53935; font-weight: 700; }

.help-text {
  font-size: 0.78rem;
  color: #999;
  margin-top: 2px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.note-green,
.note-green em {
  color: #2196F3;
  font-style: italic;
}

/* ---- Inputs ---- */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #333;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
  padding-right: 32px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.12);
}

input:disabled, select:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

input::placeholder {
  color: #bbb;
}

/* Input with $ prefix */
.input-prefix {
  display: flex;
  align-items: stretch;
}

.input-prefix .prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f5f5f5;
  border: 1px solid #d0d0d0;
  border-right: none;
  border-radius: 4px 0 0 4px;
  color: #666;
  font-weight: 600;
  font-size: 0.9rem;
}

.input-prefix input {
  border-radius: 0 4px 4px 0;
}

/* Input with suffix (Hrs) */
.input-suffix {
  display: flex;
  align-items: stretch;
}

.input-suffix input {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.input-suffix .suffix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f5f5f5;
  border: 1px solid #d0d0d0;
  border-left: none;
  border-radius: 0 4px 4px 0;
  color: #666;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ---- SSN Mask Input ---- */
.ssn-mask-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f9f9f9;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 8px 12px;
  max-width: 220px;
}

.ssn-prefix {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  letter-spacing: 1px;
}

.ssn-last4 {
  max-width: 60px;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 2px;
  box-shadow: none !important;
}

.ssn-last4:focus {
  outline: none;
}

/* ---- File Upload ---- */
.file-upload-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.file-name {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #d0d0d0;
  border-right: none;
  border-radius: 4px 0 0 4px;
  background: #fff;
  font-size: 0.85rem;
  color: #999;
}

.btn-file {
  display: inline-block;
  background: #1B2A4A;
  color: #fff;
  padding: 9px 16px;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-file:hover { background: #2a3d66; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ---- Toggle Groups (Employee/Contractor, Hourly/Salary) ---- */
.toggle-group {
  display: flex;
  gap: 0;
  align-items: center;
  margin-top: 4px;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 20px;
  border: 1px solid #d0d0d0;
  background: #fff;
  transition: all 0.15s;
  color: #555;
}

.toggle-label:first-child {
  border-radius: 4px 0 0 4px;
}

.toggle-label:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.toggle-label:has(input:checked) {
  background: #2196F3;
  border-color: #2196F3;
  color: #fff;
}

.toggle-label input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: #fff;
}

/* ---- Checkboxes ---- */
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  color: #333;
}

.checkbox-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2196F3;
  cursor: pointer;
}

.checkbox-block {
  display: block;
  padding: 6px 0;
  font-size: 0.85rem;
  cursor: pointer;
  color: #333;
}

.checkbox-block input {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  accent-color: #2196F3;
  vertical-align: middle;
}

/* Direct Deposit highlight checkbox */
.checkbox-highlight {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1B2A4A;
  color: #ffffff !important;
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-highlight,
.checkbox-highlight * {
  color: #ffffff;
}

.checkbox-highlight input {
  width: 18px;
  height: 18px;
  accent-color: #2196F3;
}

.checkbox-highlight strong {
  color: #64B5F6 !important;
}

/* ---- EIN Input ---- */
.ein-input-wrapper input {
  letter-spacing: 1.5px;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
}

/* ---- Advanced Toggle Links ---- */
.advanced-toggle {
  margin: 12px 0 4px;
}

.toggle-link {
  color: #2196F3;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-block;
}

.toggle-link:hover {
  text-decoration: underline;
}

.toggle-hint {
  color: #2196F3;
  font-weight: 400;
  font-size: 0.78rem;
}

.toggle-arrow {
  font-size: 0.65rem;
  margin-left: 3px;
}

.advanced-fields {
  border-top: 1px solid #eee;
  padding-top: 16px;
  margin-top: 8px;
}

/* ---- Exemption Checkboxes ---- */
.exemption-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- Pay Date Sections (collapsible) ---- */
.pay-date-section {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}

.pay-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f9fb;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
  user-select: none;
}

.pay-date-title {
  font-weight: 700;
  color: #1B2A4A;
  font-size: 0.9rem;
}

.pay-date-value {
  color: #999;
  font-size: 0.8rem;
  margin-left: auto;
  margin-right: 10px;
}

.pay-date-arrow {
  font-size: 0.7rem;
  color: #999;
}

.pay-date-body {
  padding: 18px 16px;
}

/* ---- Sub-sections (Additions, Policies) ---- */
.sub-section {
  margin-top: 18px;
  padding-top: 14px;
}

.sub-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.sub-section-dash {
  flex: 1;
  height: 1px;
  background: #ddd;
}

.sub-section-title {
  font-weight: 700;
  color: #1B2A4A;
  font-size: 0.85rem;
  white-space: nowrap;
}

.add-link {
  color: #2196F3;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}

.add-link:hover { text-decoration: underline; }

/* ---- Addition / Deduction Rows ---- */
.addition-row,
.policy-row {
  background: #f9fafb;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 10px;
}

.addition-row-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.remove-link {
  color: #e53935;
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
}

.remove-link:hover { text-decoration: underline; }

/* ---- Form Actions ---- */
.form-actions {
  text-align: center;
  padding: 28px 0 20px;
}

.form-note {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #999;
}

.form-note a {
  color: #2196F3;
}

/* ============================================
   PREVIEW PANEL
   ============================================ */
.preview-sticky {
  position: sticky;
  top: 20px;
}

.preview-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.preview-heading small {
  color: #999;
  font-weight: 400;
  font-size: 0.75rem;
}

.preview-panel {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  font-size: 0.68rem;
  position: relative;
  overflow: hidden;
  min-height: 260px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 6px;
  margin-bottom: 0;
}

.preview-company-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1B2A4A;
}

.preview-right-header {
  text-align: right;
}

.preview-label {
  font-size: 0.7rem;
  color: #2196F3;
  font-weight: 600;
}

/* Preview Info Bar */
.preview-info-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #2196F3;
  color: #fff;
  padding: 4px 8px;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.preview-info-bar.preview-info-values {
  background: #f5f7fa;
  color: #333;
  font-weight: 400;
  text-transform: none;
  border-bottom: 1px solid #e0e0e0;
  padding: 5px 8px;
  font-size: 0.62rem;
}

/* ---- Preview Tables ---- */
.preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  font-size: 0.62rem;
}

.preview-table th {
  background: #e8f0fe;
  text-align: left;
  padding: 3px 6px;
  font-size: 0.56rem;
  text-transform: uppercase;
  color: #1B2A4A;
  border-bottom: 1px solid #ccc;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.preview-table th:nth-child(n+2),
.preview-table td:nth-child(n+2) {
  text-align: right;
}

.preview-table td {
  padding: 2px 6px;
  border-bottom: 1px solid #eee;
  color: #444;
}

.preview-table .total-row td {
  border-top: 1.5px solid #1B2A4A;
  font-weight: 700;
  color: #1B2A4A;
}

/* ---- Preview Summary Row ---- */
.preview-summary-row {
  margin-top: 6px;
}

.preview-summary-row .preview-table th {
  font-size: 0.5rem;
  background: #e3eaf4;
}

.preview-summary-row .preview-table td {
  font-size: 0.58rem;
}

/* ---- Preview Overlay ---- */
.preview-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(27, 42, 74, 0.7);
  color: #fff;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-panel:hover .preview-overlay {
  opacity: 1;
}

/* ---- Preview Watermark ---- */
.preview-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 2.5rem;
  font-weight: 900;
  color: rgba(200, 200, 200, 0.2);
  pointer-events: none;
  user-select: none;
  letter-spacing: 6px;
  white-space: nowrap;
  z-index: 4;
}

/* ---- Template Switcher ---- */
.template-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  justify-content: center;
}

.tmpl-arrow {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
  line-height: 1;
}

.tmpl-arrow:hover { border-color: #2196F3; color: #2196F3; }

.tmpl-dot {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  border: 1px solid #d0d0d0;
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: #444;
  line-height: 26px;
  text-align: center;
  padding: 0;
}

.tmpl-dot.active {
  background: #2196F3;
  color: #fff;
  border-color: #2196F3;
}

.btn-change-template {
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.75rem;
  color: #666;
  margin-left: 6px;
  font-weight: 500;
}

.btn-change-template:hover { border-color: #2196F3; color: #2196F3; }

/* ---- Preview Submit ---- */
.preview-submit-btn {
  width: 100%;
  margin-top: 14px;
  font-size: 1rem;
  padding: 12px 20px;
  background: #2196F3;
  border-radius: 4px;
}

.preview-submit-btn:hover {
  background: #1976D2;
}

.preview-note {
  text-align: center;
  font-size: 0.75rem;
  color: #999;
  margin-top: 5px;
}

/* ---- Order Summary ---- */
.order-summary {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f5f7fa;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.order-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}

/* ============================================
   CONDITIONAL FIELDS — hidden by default
   ============================================ */
.conditional-field {
  display: none;
}

.conditional-field.visible {
  display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .form-row.two-col .form-group,
  .form-row.three-col .form-group {
    flex: unset;
  }

  .toggle-group {
    flex-direction: row;
  }

  .ssn-mask-input {
    max-width: 100%;
  }

  .file-upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .file-name {
    border-right: 1px solid #d0d0d0;
    border-radius: 4px;
  }

  .btn-file {
    border-radius: 4px;
    text-align: center;
  }

  .preview-panel {
    font-size: 0.6rem;
  }

  .preview-watermark {
    font-size: 1.8rem;
  }

  .preview-info-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .template-switcher {
    flex-wrap: wrap;
  }

  .form-section {
    padding: 20px 0;
  }
}

/* ---- Template Selector ---- */
.form-section-template {
  padding-top: 20px;
  padding-bottom: 20px;
}

.template-selector {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.template-option {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex: 1;
  min-width: 100px;
  max-width: 160px;
}

.template-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-option:hover {
  border-color: #90caf9;
}

.template-option.selected {
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
  background: #f5faff;
}

.template-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1B2A4A;
}

.template-preview {
  width: 100%;
  aspect-ratio: 8.5 / 11;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Classic template mini preview */
.template-preview-classic .tp-header {
  height: 14%;
  background: #1B2A4A;
  border-radius: 2px;
}

.template-preview-classic .tp-banner {
  height: 6%;
  background: #2196F3;
  border-radius: 1px;
}

.template-preview-classic .tp-row {
  height: 10%;
  background: #f0f2f5;
  border-radius: 1px;
}

.template-preview-classic .tp-row-short {
  width: 60%;
}

.template-preview-classic .tp-footer {
  height: 10%;
  background: #1B2A4A;
  border-radius: 1px;
  margin-top: auto;
}

/* Modern template mini preview */
.template-preview-modern {
  flex-direction: row;
  gap: 4px;
}

.template-preview-modern .tp-sidebar {
  width: 28%;
  background: #1B2A4A;
  border-radius: 2px;
}

.template-preview-modern .tp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.template-preview-modern .tp-row {
  height: 14%;
  background: #f0f2f5;
  border-radius: 1px;
}

.template-preview-modern .tp-row-short {
  width: 70%;
}

.template-preview-modern .tp-footer {
  height: 12%;
  background: #2196F3;
  border-radius: 1px;
  margin-top: auto;
}

/* Compact template mini preview */
.template-preview-compact {
  gap: 2px;
  justify-content: center;
}

.template-preview-compact .tp-row-thin {
  height: 8%;
  background: #e8e8e8;
  border-radius: 1px;
}

.template-preview-compact .tp-row-thin:nth-child(odd) {
  background: #f0f2f5;
}

.template-preview-compact .tp-row-thin:first-child {
  background: #1B2A4A;
  height: 10%;
}

@media (max-width: 480px) {
  .template-selector {
    gap: 10px;
  }
  .template-option {
    min-width: 80px;
    padding: 8px;
  }
}
