/* ============================================================================
 * EDI Analyzer — styles for 837/835 module.
 *
 * Reuses tokens from style.css (--ink, --ink-soft, --bg, --card-bg,
 * --border, --accent, --accent-soft, --danger, --success, etc.). Anything
 * named `.edi-*` is module-scoped so it cannot leak.
 * ============================================================================
 */

/* ---- Topbar accent ------------------------------------------------------ */
.topbar-accent {
  color: var(--accent, #4f46e5);
  font-weight: 600;
}

/* ---- Dropzone ----------------------------------------------------------- */
.edi-dropzone {
  border: 2px dashed var(--border, #d4d4d8);
  border-radius: 14px;
  padding: 38px 24px;
  text-align: center;
  background: var(--card-bg, #fff);
  margin: 6px 0 22px;
  transition: border-color .15s ease, background .15s ease;
}
.edi-dropzone.drag {
  border-color: var(--accent, #4f46e5);
  background: var(--accent-soft, #eef2ff);
}
.edi-dropzone .dz-icon {
  width: 42px !important; height: 42px !important;
  color: var(--ink-soft, #6b7280);
}
.edi-dz-title {
  font-size: 16px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--ink, #18181b);
}
.edi-dz-sub {
  font-size: 13px;
  color: var(--ink-soft, #6b7280);
  margin: 0 0 12px;
}
.edi-dz-actions { margin-bottom: 10px; }
.edi-dz-hint {
  font-size: 11px;
  color: var(--ink-soft, #6b7280);
  margin: 8px 0 0;
  font-family: 'JetBrains Mono', monospace, ui-monospace;
}

/* ---- Cards & tables ----------------------------------------------------- */
.edi-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.edi-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.edi-card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #18181b);
}
.edi-meta {
  font-size: 12px;
  color: var(--ink-soft, #6b7280);
  font-family: 'JetBrains Mono', monospace, ui-monospace;
}
.edi-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.edi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.edi-table th, .edi-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  text-align: left;
  vertical-align: top;
}
.edi-table thead th {
  background: var(--bg-soft, #f9fafb);
  font-weight: 600;
  color: var(--ink-soft, #4b5563);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  position: sticky;
  top: 0;
}
.edi-table tbody tr:hover { background: var(--accent-soft, #eef2ff); cursor: pointer; }
.edi-table th.num, .edi-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Banner ------------------------------------------------------------- */
.edi-banner {
  background: var(--accent-soft, #eef2ff);
  border: 1px solid var(--accent, #4f46e5);
  color: var(--ink, #18181b);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 13px;
}
.edi-banner.error {
  background: #fee2e2; border-color: #ef4444; color: #7f1d1d;
}
.edi-banner.success {
  background: #ecfdf5; border-color: #10b981; color: #065f46;
}
.edi-banner ul { margin: 6px 0 0 18px; padding: 0; }

/* ---- Upload progress bar ----------------------------------------------- */
.edi-progress {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 13px;
}
.edi-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.edi-progress-track {
  width: 100%;
  height: 8px;
  background: var(--accent-soft, #eef2ff);
  border-radius: 999px;
  overflow: hidden;
}
.edi-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent, #4f46e5);
  border-radius: 999px;
  transition: width 200ms ease-out;
}
.edi-progress-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.edi-progress-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px dashed var(--border, #e4e4e7);
}
.edi-progress-list li:first-child { border-top: 0; }
.edi-progress-list .pr-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.edi-progress-list .pr-status {
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.edi-progress-list li.done .pr-status    { color: #065f46; }
.edi-progress-list li.error .pr-status   { color: #991b1b; }
.edi-progress-list li.dup .pr-status     { color: #92400e; }
.edi-progress-list .pr-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--accent-soft, #eef2ff);
  border-top-color: var(--accent, #4f46e5);
  border-radius: 50%;
  animation: edi-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
.edi-progress-list li.done .pr-spinner,
.edi-progress-list li.error .pr-spinner,
.edi-progress-list li.dup .pr-spinner { display: none; }
.edi-progress-list .pr-mark { flex: 0 0 auto; font-weight: 700; width: 12px; text-align: center; display: none; }
.edi-progress-list li.done .pr-mark  { display: inline-block; color: #10b981; }
.edi-progress-list li.error .pr-mark { display: inline-block; color: #ef4444; }
.edi-progress-list li.dup .pr-mark   { display: inline-block; color: #f59e0b; }
@keyframes edi-spin { to { transform: rotate(360deg); } }

/* ---- Form controls ------------------------------------------------------ */
.edi-input, .edi-select {
  height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #d4d4d8);
  border-radius: 8px;
  color: var(--ink, #18181b);
  min-width: 160px;
}
.edi-input:focus, .edi-select:focus {
  outline: none;
  border-color: var(--accent, #4f46e5);
}
.edi-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft, #6b7280);
}

/* ---- Empty + paginator -------------------------------------------------- */
.edi-empty {
  padding: 32px 18px;
  text-align: center;
  color: var(--ink-soft, #6b7280);
  font-size: 13px;
}
.edi-paginator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  font-size: 13px;
  color: var(--ink-soft, #6b7280);
}

/* ---- Analysis dashboard ------------------------------------------------- */
.edi-analysis-shell { padding: 0; }
.edi-analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.edi-stat-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 14px 16px;
}
.edi-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft, #6b7280);
  margin-bottom: 4px;
}
.edi-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink, #18181b);
  font-variant-numeric: tabular-nums;
}
.edi-stat-card.error .edi-stat-value { color: #b91c1c; }
.edi-stat-card.warning .edi-stat-value { color: #b45309; }
.edi-stat-card.success .edi-stat-value { color: #15803d; }

.edi-analysis-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.edi-breakdown {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
}
.edi-breakdown h4 {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  background: var(--bg-soft, #f9fafb);
}
.edi-breakdown-list { padding: 4px 0; }
.edi-breakdown-row {
  display: flex; justify-content: space-between;
  padding: 6px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border, #f8fafc);
}
.edi-breakdown-row:last-child { border-bottom: 0; }
.edi-breakdown-row span:first-child { color: var(--ink, #18181b); }
.edi-breakdown-row span:last-child {
  color: var(--ink-soft, #6b7280);
  font-variant-numeric: tabular-nums;
}

/* ---- Issue badges + table ---------------------------------------------- */
.edi-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-soft, #f3f4f6);
  color: var(--ink-soft, #4b5563);
  line-height: 1.4;
}
.edi-chip.error    { background: #fee2e2; color: #991b1b; }
.edi-chip.warning  { background: #fef3c7; color: #92400e; }
.edi-chip.info     { background: #dbeafe; color: #1e40af; }
.edi-chip.success  { background: #dcfce7; color: #166534; }
.edi-chip.matched  { background: #dcfce7; color: #166534; }
.edi-chip.unmatched{ background: #fee2e2; color: #991b1b; }
.edi-chip.posted   { background: var(--accent-soft, #eef2ff); color: var(--accent, #4f46e5); }
.edi-chip.unposted { background: #f1f5f9; color: #475569; }

.edi-issues-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.edi-issues-table th, .edi-issues-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  text-align: left;
}
.edi-issues-table thead th {
  background: var(--bg-soft, #f9fafb);
  color: var(--ink-soft, #4b5563);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ---- Posting toolbar ---------------------------------------------------- */
.edi-posting-toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 0 14px;
}

/* ---- Validation rules tab ---------------------------------------------- */
.edi-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}
.edi-rules-col {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
}
.edi-rules-col h3 {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  background: var(--bg-soft, #f9fafb);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.edi-rules-list {
  padding: 4px 0;
  max-height: 540px;
  overflow-y: auto;
}
.edi-rule-row {
  display: grid;
  grid-template-columns: 32px 1fr 100px;
  gap: 10px;
  padding: 9px 14px;
  align-items: center;
  border-bottom: 1px solid var(--border, #f8fafc);
}
.edi-rule-row:last-child { border-bottom: 0; }
.edi-rule-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, #18181b);
}
.edi-rule-desc {
  font-size: 11.5px;
  color: var(--ink-soft, #6b7280);
  margin-top: 1px;
}
.edi-rule-row select {
  font-size: 11px;
  padding: 3px 5px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
}
.edi-rule-row input[type=checkbox] { transform: scale(1.1); }

/* ---- Claim detail drawer ------------------------------------------------ */
.edi-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}
.edi-drawer-backdrop[hidden] { display: none; }
.edi-drawer {
  width: min(960px, 100%);
  height: 100%;
  background: var(--card-bg, #fff);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 23, 42, .25);
  animation: ediDrawerIn .18s ease-out;
}
@keyframes ediDrawerIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.edi-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.edi-drawer-head h3 {
  margin: 0;
  font-size: 17px;
}
.edi-drawer-sub {
  font-size: 12px;
  color: var(--ink-soft, #6b7280);
  margin-top: 4px;
}
.edi-drawer-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft, #6b7280);
}
.edi-drawer-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.edi-section {
  margin-bottom: 22px;
}
.edi-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft, #6b7280);
  margin: 0 0 8px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  padding-bottom: 4px;
}
.edi-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 18px;
  font-size: 13px;
}
.edi-kv-grid .k {
  font-size: 11px;
  color: var(--ink-soft, #6b7280);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.edi-kv-grid .v {
  font-family: 'JetBrains Mono', monospace, ui-monospace;
  color: var(--ink, #18181b);
  margin-bottom: 6px;
  word-break: break-word;
}

.edi-svc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.edi-svc-table th, .edi-svc-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  text-align: left;
}
.edi-svc-table thead th {
  background: var(--bg-soft, #f9fafb);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft, #4b5563);
}
.edi-svc-table .num { text-align: right; font-variant-numeric: tabular-nums; }

[data-theme="dark"] .edi-dropzone,
[data-theme="dark"] .edi-card,
[data-theme="dark"] .edi-stat-card,
[data-theme="dark"] .edi-breakdown,
[data-theme="dark"] .edi-rules-col,
[data-theme="dark"] .edi-drawer {
  background: var(--card-bg, #1f2937);
  border-color: var(--border, #334155);
}
[data-theme="dark"] .edi-table thead th,
[data-theme="dark"] .edi-breakdown h4,
[data-theme="dark"] .edi-rules-col h3,
[data-theme="dark"] .edi-svc-table thead th {
  background: var(--bg-soft, #111827);
}
