/* ================================================================
   Generate Screen — Payment Batch Upload & NACHA Styling
   ================================================================ */

/* ── Upload Drop Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-primary-muted);
  background-color: var(--color-primary-light);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-primary);
  background-color: hsla(220, 72%, 45%, 0.08);
  transform: translateY(-1px);
}

.upload-zone .upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  color: var(--color-primary);
}

.upload-zone .upload-title {
  font-size: var(--text-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.upload-zone .upload-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.upload-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
}

.upload-file-name {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Summary Stats Bar ─────────────────────────────────────────── */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-base);
  box-shadow: var(--shadow-sm);
}

.summary-val {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  line-height: 1.2;
}

.summary-lbl {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-xs);
}

/* ── Duplicate Detection Banner ────────────────────────────────── */
.duplicate-banner {
  background-color: var(--color-warning-light);
  border: 1px solid hsla(42, 95%, 55%, 0.4);
  border-radius: var(--radius-lg);
  padding: var(--space-base) var(--space-lg);
  margin-bottom: var(--space-lg);
}

.duplicate-title {
  font-size: var(--text-md);
  font-weight: var(--font-weight-bold);
  color: hsl(42, 70%, 30%);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.duplicate-sub {
  font-size: var(--text-sm);
  color: hsl(42, 60%, 30%);
  margin-bottom: var(--space-md);
}

.duplicate-actions {
  display: flex;
  align-items: center;
  gap: var(--space-base);
  flex-wrap: wrap;
}

.override-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: hsl(42, 70%, 25%);
  cursor: pointer;
}

.override-checkbox-label input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ── Error Details Panel ────────────────────────────────────────── */
.error-panel {
  background-color: var(--color-danger-light);
  border: 1px solid hsla(4, 68%, 52%, 0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.error-panel-title {
  font-size: var(--text-md);
  font-weight: var(--font-weight-bold);
  color: var(--color-danger-hover);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.error-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.error-table th {
  background: hsla(4, 68%, 52%, 0.1);
  color: var(--color-danger-hover);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid hsla(4, 68%, 52%, 0.2);
}

.error-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
  vertical-align: top;
}

/* ── Payments List Table ────────────────────────────────────────── */
.payments-table-wrap {
  overflow-x: auto;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}

.fixed-info-box {
  background: var(--color-primary-light);
  border: 1px solid hsla(220, 72%, 45%, 0.18);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-base);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  line-height: 1.8;
  margin-top: var(--space-md);
}

.fixed-info-box b {
  font-family: var(--font-body);
  color: var(--color-primary);
}

/* ── NACHA Preview & Output Styling ──────────────────────────────── */
/* Four control totals on one row, the two long identifiers on the next. auto-fit gave
   six tracks at desktop width, leaving File Record ID stranded alone on a second row. */
.nacha-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.summary-card-wide {
  grid-column: span 2;
}
@media (max-width: 900px) {
  .nacha-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .nacha-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .summary-card-wide {
    grid-column: 1 / -1;
  }
}

.nacha-preview-box {
  background: hsl(220, 24%, 12%);
  color: hsl(220, 20%, 90%);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: pre;
  border: 1px solid hsl(220, 20%, 20%);
  margin-bottom: var(--space-md);
  max-height: 320px;
}

.nacha-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Responsive adjustments */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.draft-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface-alt);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
}

@media (max-width: 768px) {
  .summary-bar {
    grid-template-columns: 1fr 1fr;
  }

  .upload-zone {
    padding: var(--space-xl) var(--space-md);
  }

  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ── Manual entry tables (Batch 1 manual, Batch 2, added batches) ── */
/* One class for every manual-entry grid. The same rules were repeated three times by
   element id, plus ~30 inline declarations per row in the JavaScript that built them. */
.manual-entry-table td {
  padding: 4px 6px;
  vertical-align: middle;
}

.manual-entry-table .form-select,
.manual-entry-table .form-input {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: var(--color-surface-raised);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.manual-entry-table .form-select:focus,
.manual-entry-table .form-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2.5px rgba(79, 70, 229, 0.15);
  outline: none;
}

.manual-entry-table .manual-row-num {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 11px;
}

.manual-entry-table .manual-row-routing,
.manual-entry-table .manual-row-account {
  font-size: 11px;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.manual-entry-table .manual-row-type .badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
}

.manual-entry-table .manual-row-actions {
  text-align: center;
}
.manual-entry-table .manual-row-remove {
  padding: 2px 8px;
  font-size: 12px;
  min-height: 1.75rem;
}

/* A row that failed validation. Replaces an inline background that referenced an
   undefined --color-danger-bg variable. */
.manual-entry-table tr.row-invalid {
  background-color: var(--color-danger-light);
}
.manual-entry-table tr.row-invalid td:first-child {
  box-shadow: inset 3px 0 0 var(--color-danger);
}
.manual-entry-table tbody tr.row-invalid:hover td {
  background: transparent;
}

/* The single file-level effective date, repeated in each batch for reference. */
.batch-settle-note {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  background: var(--color-primary-light);
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: var(--space-md);
}
.batch-settle-note strong {
  color: var(--color-primary);
}

.manual-batch-card {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-lg);
}
.manual-batch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}

/* Which rows were flagged as duplicates, and against what. */
.duplicate-list {
  margin: 0 0 var(--space-md) 1.1rem;
  font-size: var(--text-xs);
  color: hsl(42, 60%, 25%);
  line-height: 1.6;
}
.duplicate-list:empty {
  display: none;
}

/* ── Batch Validate Summary Bar ─────────────────────────────────── */
.batch-validate-summary {
  border-radius: 8px;
  border: 1px solid var(--color-border, #e2e8f0);
  background: var(--color-surface-alt, #f8fafc);
  padding: 8px;
  gap: 8px;
}

/* ── Payment History Table Enhancements ─────────────────────────── */
#view-history .card {
  padding: var(--space-lg);
}

#historyTableWrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md, 8px);
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  background: #FFFFFF;
}

#historyTableWrap::-webkit-scrollbar {
  height: 6px;
}

#historyTableWrap::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 3px;
}

#historyTableWrap::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

#historyTableWrap::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

#historyTable {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
  table-layout: auto;
}

#historyTable th {
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  letter-spacing: 0.04em;
  background: #F8FAFC;
  border-bottom: 2px solid #E2E8F0;
  white-space: nowrap;
}

#historyTable td {
  padding: 8px 6px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
  transition: background 0.12s ease;
}

#historyTable tbody tr:hover td {
  background: #F8FAFC;
}

.history-filter-row th {
  padding: 5px 6px !important;
  background: #F8FAFC !important;
  border-bottom: 2px solid #CBD5E1 !important;
}

.history-col-filter {
  height: 28px !important;
  padding: 3px 6px !important;
  font-size: 11.5px !important;
  border-radius: 5px !important;
  border: 1.5px solid #CBD5E1 !important;
  background: #FFFFFF !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.history-col-filter:focus {
  border-color: #3B82F6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15) !important;
  outline: none !important;
}

.history-action-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
}


/* ================================================================
   Visual audit fixes (layout at every width)
   ================================================================ */

/* "Included in <long file name>" ran 57px off a phone screen. */
#batch1StatusBadge {
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}

/* Tiny inline icon buttons in the History email cell (22-23px wide). */
#historyTableBody td[data-label="Recipient Email"] .btn {
  min-width: 28px;
  justify-content: center;
}

/* Row problems: badge and message side by side, message wrapping in its own column. */
.error-msg {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}
.error-msg + .error-msg {
  margin-top: var(--space-xs);
}
.error-msg .badge {
  flex-shrink: 0;
}

/* On a phone the three-column problem table left the raw-data column one word wide. */
@media (max-width: 640px) {
  .error-table thead {
    display: none;
  }
  .error-table,
  .error-table tbody,
  .error-table tr {
    display: block;
    width: 100%;
  }
  .error-table tr {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border-light);
  }
  .error-table td {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: var(--space-sm);
    border-bottom: none;
    padding: var(--space-xs) var(--space-md);
  }
  .error-table td > * {
    grid-column: 2;
    min-width: 0;
  }
  .error-table td::before {
    grid-column: 1;
    grid-row: 1;
    content: attr(data-label);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
  }
  .error-msg {
    flex-wrap: wrap;
  }
}

/* Vendor Book toolbar: one control height and one type size. */
.vendor-toolbar .form-input,
.vendor-toolbar .form-select {
  height: 2.25rem;
  font-size: var(--text-xs);
}
.vendor-toolbar #vendorSearchInput {
  width: 15rem;
}
.vendor-toolbar .form-select {
  width: 8.5rem;
  padding: 0 var(--space-sm);
  cursor: pointer;
}
.vendor-toolbar > .btn {
  min-height: 2.25rem;
  font-size: var(--text-xs);
}
@media (max-width: 640px) {
  .vendor-toolbar #vendorSearchInput {
    width: 100%;
  }
}

/* Vendor table: "•••• 5523" broke across two lines at the space. */
#vendorTableBody td.font-mono {
  white-space: nowrap;
}

/* Vendor card header: checkbox, name and status stay on one row; long names wrap
   inside their own column instead of dropping below the checkbox. */
.vendor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.vendor-card-title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  min-width: 0;
}
.vendor-card-title .vendor-select-cb {
  margin-top: 3px;
}
.vendor-card-title > div {
  min-width: 0;
}
.vendor-card-head > .badge {
  flex-shrink: 0;
}

/* Pending change notice inside a vendor card. */
.vendor-pending-notice {
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-xs);
  line-height: 1.55;
}

/* History range filters: four equal fields, labels above. */
.history-range-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
}
.history-range-grid .form-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
}
.history-range-grid .form-input {
  height: 2.5rem;
  font-size: var(--text-sm);
}
@media (max-width: 768px) {
  .history-range-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 400px) {
  .history-range-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* History header buttons: one consistent treatment. */
#view-history .history-toolbar-btn,
#historyExportCsvBtn,
#historyExportExcelBtn,
#historyViewLastNachaBtn,
#openEmailTemplateModalBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-raised);
}

/* History table: long vendor names no longer wrap one word per line, long emails are
   truncated (full address in the tooltip), and on screens where the table still has to
   scroll the Actions column stays pinned so Delete/Send are never scrolled out of view. */
.history-vendor-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 8.5rem;
  max-width: 16rem;
}
.history-email-text {
  display: inline-block;
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
/* "09/28/2026 00:23" may wrap onto two lines rather than widen the table. */
#historyTableBody td[data-label="Sent (ET)"] {
  white-space: normal;
  min-width: 5.5rem;
}
@media (min-width: 1101px) {
  #historyTable th:last-child,
  #historyTable td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: #FFFFFF;
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.25);
  }
  #historyTable thead th:last-child {
    background: #F8FAFC;
  }
  #historyTable tbody tr:hover td:last-child {
    background: #F8FAFC;
  }
}
@media (max-width: 1100px) {
  .history-vendor-name {
    display: block;
    min-width: 0;
    max-width: none;
  }
  .history-email-text {
    max-width: 100%;
  }
}
