/* cameroon-form-action — vanilla styles */

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #111;
  background: #f5f7fa;
}
a { color: #0a7; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ─────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #006b3f 0%, #008751 100%);
  color: #fff;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 16px;
}
.app-header h1 { margin: 0; font-size: 16px; font-weight: 600; }
.app-header h1 a { color: #fff; }
.app-header .spacer { flex: 1; }

/* ─── LOCAL/PROD toggle + ngrok input ────────── */
.target-toggle {
  display: flex;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 2px;
}
.target-toggle button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.8);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.target-toggle button.active.local { background: #16a34a; color: #fff; }
.target-toggle button.active.prod { background: #dc2626; color: #fff; }

.ngrok-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.ngrok-input input {
  background: rgba(255,255,255,0.95);
  color: #111;
  border: 0;
  border-radius: 4px;
  padding: 4px 8px;
  width: 280px;
  font-size: 12px;
}
.ngrok-input button {
  background: #fff;
  color: #006b3f;
  border: 0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.ngrok-input.hidden { display: none; }

/* ─── Containers ─────────────────────────────── */
.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }
.container-wide { max-width: 1600px; }
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar input, .toolbar select {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
.toolbar .grow { flex: 1; }

/* ─── Tables ─────────────────────────────────── */
table.queue {
  width: 100%;
  background: #fff;
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
table.queue th, table.queue td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
table.queue th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
table.queue tr:last-child td { border-bottom: 0; }
table.queue tr:hover td { background: #f8fafc; cursor: pointer; }
table.queue td.actions { text-align: right; }

.empty-state {
  background: #fff;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  color: #64748b;
}

/* ─── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }

/* ─── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #006b3f; color: #fff; border-color: #006b3f; }
.btn-primary:hover { background: #008751; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: #64748b; }

/* ─── Review form layout ─────────────────────── */
.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  background: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  font-size: 13px;
}
.context-bar .ctx-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.context-bar .ctx-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
.context-bar .ctx-value { font-weight: 500; color: #111; word-break: break-word; }
.context-bar .ctx-value.error { color: #991b1b; font-weight: 400; }
.context-bar .ctx-spacer { flex: 1; }

.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.action-bar .spacer { flex: 1; }

.review-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
@media (min-width: 1100px) {
  .review-layout { grid-template-columns: minmax(420px, 1fr) minmax(0, 1fr); }
}

.pdf-panel {
  position: sticky;
  top: 72px;
  align-self: start;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: calc(100vh - 96px);
  min-height: 480px;
}
.pdf-panel .doc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pdf-panel .doc-tab {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #1f2937;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
}
.pdf-panel .doc-tab:hover { background: #cbd5e1; }
.pdf-panel .doc-tab.active { background: #006b3f; color: #fff; }
.pdf-panel .doc-tab.missing {
  background: transparent;
  border: 1px dashed #94a3b8;
  color: #64748b;
  cursor: default;
}
.pdf-panel .doc-tab.missing-upload {
  background: transparent;
  border: 1px dashed #94a3b8;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.pdf-panel .doc-tab.missing-upload:hover {
  background: #f1f5f9;
  border-color: #006b3f;
  color: #006b3f;
}
.pdf-panel .doc-tab.missing-upload.uploading {
  opacity: 0.5;
  cursor: wait;
}
.pdf-panel .doc-tab.missing-upload .upload-icon { margin-left: 4px; }
.pdf-panel .doc-tab a { color: inherit; text-decoration: none; margin-left: 6px; opacity: 0.7; }
.pdf-panel .doc-tab a:hover { opacity: 1; }
.pdf-panel .doc-tab .doc-tab-delete {
  margin-left: 6px;
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
  user-select: none;
}
.pdf-panel .doc-tab .doc-tab-delete:hover { opacity: 1; color: #b91c1c; }
.pdf-panel .doc-tab.active .doc-tab-delete { color: #fff; opacity: 0.7; }
.pdf-panel .doc-tab.active .doc-tab-delete:hover { color: #fecaca; opacity: 1; }

.pdf-frame-wrap { position: relative; flex: 1; min-height: 0; }
.pdf-panel iframe {
  width: 100%;
  height: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}
.pdf-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  pointer-events: none;
}
.pdf-empty.hidden { display: none; }

.form-panel { min-width: 0; }

.section {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  margin: 0 0 12px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.section-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #64748b;
  font-style: italic;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid #006b3f; outline-offset: -1px; }
.field-wide { grid-column: 1 / -1; }

.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-list .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
}

/* ─── Save indicator ─────────────────────────── */
.save-indicator {
  font-size: 11px;
  color: #64748b;
  margin-left: 8px;
  transition: opacity 0.2s;
}
.save-indicator.saving { color: #1e40af; }
.save-indicator.saved { color: #065f46; }
.save-indicator.failed { color: #991b1b; }

/* ─── Autocomplete dropdown ─────────────────── */
.autocomplete { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item:hover, .autocomplete-item.active { background: #f0fdf4; }
.autocomplete-item .name { font-weight: 500; flex: 1; }
.autocomplete-item .sub { color: #64748b; font-size: 12px; }
.autocomplete-empty { padding: 12px; color: #64748b; font-size: 12px; text-align: center; }

.match-badge { display: inline-flex; min-height: 18px; margin-top: 4px; }
.match-badge:empty { display: none; }
.match-badge .badge { font-size: 10px; padding: 2px 6px; }

/* ─── Toasts ─────────────────────────────────── */
#toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: #991b1b; }
.toast-success { background: #065f46; }

/* ─── Required-field markers ─────────────────── */
.field-required > label::after { content: " *"; color: #dc2626; }
.field-empty > input,
.field-empty > select,
.field-empty .ac-wrapper input {
  border-color: #dc2626;
  background: #fef2f2;
}
.field-empty > input:focus,
.field-empty > select:focus,
.field-empty .ac-wrapper input:focus {
  outline-color: #dc2626;
}

.missing-list {
  margin: 4px 0 0;
  padding-left: 20px;
}
.missing-list li {
  font-size: 13px;
  color: #475569;
  margin: 2px 0;
}
.missing-section {
  font-size: 11px;
  text-transform: uppercase;
  color: #94a3b8;
  margin-top: 10px;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ─── Confirm modal ─────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
}
.modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 420px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}
.modal h2 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 16px; color: #475569; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================================
   RAW DATA / CHANGES / LOGS TABS
   ============================================ */

.diff-count { background: #FEF3C7; color: #92400E; font-size: 11px; padding: 1px 7px; border-radius: 9999px; font-weight: 600; }

/* Raw data container */
.raw-data-container {
  background: #FEFBF1;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}
.raw-data-empty {
  text-align: center;
  padding: 40px 20px;
  color: #6B7280;
  font-size: 14px;
  font-style: italic;
}

/* JSON viewer */
.json-viewer {
  margin: 0;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #586E75;
  background: #FDF6E3;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
}
.json-viewer code { font-family: inherit; }
.json-key { color: #268BD2; font-weight: 600; }
.json-string { color: #111827; }
.json-number { color: #D33682; }
.json-boolean { color: #B58900; font-weight: 600; }
.json-null { color: #93A1A1; font-style: italic; }

/* Changes values */
.changes-value-old {
  color: #DC2626;
  text-decoration: line-through;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 12px;
}
.changes-value-new {
  color: #059669;
  font-weight: 500;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 12px;
}

/* Action badges */
.action-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 9999px;
  vertical-align: middle;
  margin-right: 4px;
}
.action-badge-manual { background: #FEF3C7; color: #92400E; }
.action-badge-actor  { background: #DBEAFE; color: #1E40AF; }
.action-badge-norm   { background: #F3F4F6; color: #9CA3AF; }

.change-entry-muted .changes-value-old,
.change-entry-muted .changes-value-new {
  color: #9CA3AF;
}

/* Logs (terminal style) */
.job-log-container {
  background: #1F2937;
  border-radius: 8px;
  padding: 4px 0;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.6;
}
.log-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9CA3AF;
  font-size: 14px;
  font-style: italic;
}
.log-entry {
  padding: 6px 16px;
  border-bottom: 1px solid #374151;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.log-entry:last-child { border-bottom: none; }
.log-entry:hover { background: #283547; }
.log-ts { color: #6B7280; flex-shrink: 0; font-size: 12px; }
.log-level {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  text-transform: uppercase;
}
.log-level-info { background: #1E40AF; color: #BFDBFE; }
.log-level-warn { background: #92400E; color: #FEF3C7; }
.log-level-error { background: #991B1B; color: #FEE2E2; }
.log-msg { color: #E5E7EB; word-break: break-word; }

/* Read-only display fields (Conditioning, Nb 20"/40", Nb vehicles, etc.) */
.field-readonly { position: relative; }
.field-readonly input {
  background: #f3f4f6;
  color: #475569;
  border-color: #e5e7eb;
  cursor: not-allowed;
}
.field-readonly input:focus { outline: none; }

/* Inline currency suffix for Invoice Value / FOB Value */
.field { position: relative; }
.field-suffix {
  position: absolute;
  right: 8px;
  bottom: 7px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
}
.field:has(> .field-suffix) input { padding-right: 56px; }
.field:has(> .field-suffix[data-suffix-for="numberOfPackages"]) input { padding-right: 90px; }
