/* Agri4All Products overview — read-only marketplace mirror.
   Scoped under .a4p-page; uses the app's theme tokens with safe fallbacks so it
   renders correctly in both light and dark. */

.a4p-page { padding: 24px 28px 48px; max-width: 1280px; margin: 0 auto; }

.a4p-head { margin-bottom: 18px; }
.a4p-title {
  font-size: 26px; font-weight: 700; margin: 0 0 6px;
  color: var(--text-primary, #1a1a1a);
}
.a4p-sub {
  font-size: 14px; line-height: 1.5; max-width: 720px;
  color: var(--text-muted, #666);
}

/* ── command bar ─────────────────────────────────────────────────────────── */
.a4p-bar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  justify-content: space-between; margin-bottom: 20px;
}
.a4p-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.a4p-pill {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 14px; min-width: 78px; cursor: pointer;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.a4p-pill:hover { border-color: var(--accent-color, #3b82f6); }
.a4p-pill:active { transform: translateY(1px); }
.a4p-pill.active {
  border-color: var(--accent-color, #3b82f6);
  box-shadow: 0 0 0 1px var(--accent-color, #3b82f6) inset;
}
.a4p-pill-n { font-size: 20px; font-weight: 700; color: var(--text-primary, #1a1a1a); line-height: 1; }
.a4p-pill-l { font-size: 12px; color: var(--text-muted, #666); }

.a4p-bar-right { display: flex; gap: 10px; align-items: center; flex: 1 1 260px; justify-content: flex-end; }
.a4p-search {
  flex: 0 1 300px; min-width: 160px;
  padding: 9px 12px; font-size: 14px;
  color: var(--text-primary, #1a1a1a);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md, 8px);
}
.a4p-search:focus { outline: none; border-color: var(--accent-color, #3b82f6); }

.a4p-btn {
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text-primary, #1a1a1a);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  transition: opacity .15s, filter .15s;
}
.a4p-btn:disabled { opacity: .6; cursor: default; }
.a4p-btn-primary {
  color: #fff; border-color: transparent;
  background: var(--accent-color, #3b82f6);
}
.a4p-btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

/* ── grid ────────────────────────────────────────────────────────────────── */
.a4p-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.a4p-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  transition: border-color .15s, box-shadow .15s;
}
.a4p-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.a4p-card-deleted { opacity: .72; }

.a4p-card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.a4p-name {
  font-size: 16px; font-weight: 650; line-height: 1.35;
  color: var(--text-primary, #1a1a1a);
  overflow-wrap: anywhere;
}

.a4p-meta { display: flex; flex-direction: column; gap: 5px; }
.a4p-meta-row { display: flex; gap: 10px; font-size: 13px; }
.a4p-meta-k { flex: 0 0 68px; color: var(--text-muted, #666); }
.a4p-meta-v { color: var(--text-secondary, #444); overflow-wrap: anywhere; }

.a4p-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: auto; padding-top: 8px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}
.a4p-synced { font-size: 12px; color: var(--text-muted, #666); }
.a4p-link { font-size: 13px; font-weight: 600; text-decoration: none; color: var(--accent-color, #3b82f6); white-space: nowrap; }
.a4p-link:hover { text-decoration: underline; }

/* ── chips ───────────────────────────────────────────────────────────────── */
.a4p-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; font-size: 11px; font-weight: 600; line-height: 1.4;
  border-radius: 999px; letter-spacing: .01em;
}
.a4p-origin-crm { background: rgba(59,130,246,.14); color: #2563eb; }
.a4p-origin-site { background: rgba(22,163,74,.15); color: #16a34a; }
.a4p-deleted { background: rgba(220,38,38,.14); color: #dc2626; }

.a4p-status { border: 1px solid transparent; }
.a4p-status-approved { background: rgba(22,163,74,.13); color: #16a34a; }
.a4p-status-pending  { background: rgba(217,119,6,.15); color: #d97706; }
.a4p-status-rejected { background: rgba(220,38,38,.13); color: #dc2626; }
.a4p-status-archived, .a4p-status-sold { background: rgba(100,116,139,.16); color: #64748b; }
.a4p-status-unknown, .a4p-status-incomplete { background: rgba(100,116,139,.12); color: #64748b; }

/* ── states ──────────────────────────────────────────────────────────────── */
.a4p-empty {
  padding: 48px 20px; text-align: center; font-size: 14px;
  color: var(--text-muted, #666);
  background: var(--card-bg, #fff);
  border: 1px dashed var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
}
.a4p-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 0; }
.a4p-loading-text { font-size: 14px; color: var(--text-muted, #666); }
.a4p-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border-color, #e5e7eb);
  border-top-color: var(--accent-color, #3b82f6);
  animation: a4p-spin .8s linear infinite;
}
@keyframes a4p-spin { to { transform: rotate(360deg); } }
.a4p-error {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  padding: 20px; border-radius: var(--radius-lg, 12px);
  background: rgba(220,38,38,.06);
  border: 1px solid rgba(220,38,38,.28);
}
.a4p-error-title { font-weight: 700; color: #dc2626; }
.a4p-error-msg { font-size: 13px; color: var(--text-secondary, #444); }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .a4p-page { padding: 18px 14px 40px; }
  .a4p-bar { flex-direction: column; align-items: stretch; }
  .a4p-bar-right { justify-content: stretch; }
  .a4p-search { flex: 1 1 auto; }
  .a4p-grid { grid-template-columns: 1fr; }
  .a4p-stats { justify-content: space-between; }
  .a4p-pill { flex: 1 1 auto; min-width: 0; }
}

/* ── seller accounts rail ────────────────────────────────────────────────── */
.a4p-sellers {
  display: grid; gap: 12px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.a4p-seller {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px; cursor: pointer; user-select: none;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  transition: border-color .15s, box-shadow .15s;
}
.a4p-seller:hover { border-color: var(--accent-color, #3b82f6); }
.a4p-seller:focus-visible { outline: 2px solid var(--accent-color, #3b82f6); outline-offset: 2px; }
.a4p-seller.active {
  border-color: var(--accent-color, #3b82f6);
  box-shadow: 0 0 0 1px var(--accent-color, #3b82f6) inset;
}
.a4p-seller-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.a4p-seller-name { font-size: 15px; font-weight: 700; color: var(--text-primary, #1a1a1a); overflow-wrap: anywhere; }
.a4p-seller-id { font-size: 12px; color: var(--text-muted, #666); }
.a4p-unlinked { background: rgba(217,119,6,.15); color: #d97706; }

.a4p-seller-stats { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.a4p-sstat { display: flex; align-items: baseline; gap: 5px; font-size: 12px; color: var(--text-muted, #666); }
.a4p-sstat b { font-size: 16px; font-weight: 700; color: var(--text-primary, #1a1a1a); }

.a4p-seller-clients { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.a4p-client-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 9px; font-size: 12px; font-weight: 600;
  border-radius: 999px;
  background: rgba(59,130,246,.12); color: #2563eb;
}
.a4p-client-chip-name { overflow-wrap: anywhere; }
.a4p-unlink {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer;
  color: inherit; background: transparent; border: none; border-radius: 999px;
}
.a4p-unlink:hover { background: rgba(220,38,38,.15); color: #dc2626; }
.a4p-unlink.armed { background: #dc2626; color: #fff; padding: 0 7px; }
.a4p-addlink {
  padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--accent-color, #3b82f6);
  background: transparent;
  border: 1px dashed var(--accent-color, #3b82f6);
  border-radius: 999px;
}
.a4p-addlink:hover { background: rgba(59,130,246,.08); }
.a4p-seller-sync { margin-top: auto; padding-top: 4px; font-size: 12px; color: var(--text-muted, #666); }
.a4p-seller-all .a4p-seller-name { color: var(--accent-color, #3b82f6); }

/* ── link modal ──────────────────────────────────────────────────────────── */
.a4p-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px;
  background: rgba(15,23,42,.45);
}
.a4p-modal {
  width: 100%; max-width: 460px; max-height: 84vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.a4p-modal-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-primary, #1a1a1a); }
.a4p-modal-sub { margin: -6px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted, #666); }
.a4p-field { display: flex; flex-direction: column; gap: 6px; }
.a4p-label { font-size: 13px; font-weight: 600; color: var(--text-secondary, #444); }
.a4p-input {
  padding: 10px 12px; font-size: 14px;
  color: var(--text-primary, #1a1a1a);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md, 8px);
}
.a4p-input:focus { outline: none; border-color: var(--accent-color, #3b82f6); }
.a4p-input:disabled { opacity: .7; }
.a4p-options { display: flex; flex-direction: column; border-radius: var(--radius-md, 8px); overflow: hidden; }
.a4p-options:not(:empty) { border: 1px solid var(--border-color, #e5e7eb); }
.a4p-option {
  padding: 9px 12px; font-size: 13px; text-align: left; cursor: pointer;
  color: var(--text-primary, #1a1a1a);
  background: var(--card-bg, #fff);
  border: none; border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.a4p-option:last-child { border-bottom: none; }
.a4p-option:hover, .a4p-option:focus-visible { background: rgba(59,130,246,.08); }
.a4p-option-empty { padding: 9px 12px; font-size: 13px; color: var(--text-muted, #666); }
.a4p-modal-msg { font-size: 13px; min-height: 0; }
.a4p-modal-msg.error { color: #dc2626; }
.a4p-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 640px) {
  .a4p-sellers { grid-template-columns: 1fr; }
  .a4p-modal-overlay { padding: 4vh 10px 10px; }
}

/* ── #134 dark mode overrides ─────────────────────────────── */
/* Nearly everything here is token-driven, so theme.css already covers the
   surfaces, borders and text. Only the raw literals are flipped below. */
html[data-theme="dark"] .a4p-card:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); }

html[data-theme="dark"] .a4p-origin-crm  { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
html[data-theme="dark"] .a4p-origin-site { background: rgba(34, 197, 94, 0.16); color: #86efac; }
html[data-theme="dark"] .a4p-deleted     { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

html[data-theme="dark"] .a4p-status-approved { background: rgba(34, 197, 94, 0.16); color: #86efac; }
html[data-theme="dark"] .a4p-status-pending  { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
html[data-theme="dark"] .a4p-status-rejected { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
html[data-theme="dark"] .a4p-status-archived,
html[data-theme="dark"] .a4p-status-sold { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
html[data-theme="dark"] .a4p-status-unknown,
html[data-theme="dark"] .a4p-status-incomplete { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

html[data-theme="dark"] .a4p-error {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.32);
}
html[data-theme="dark"] .a4p-error-title { color: #fca5a5; }

/* seller rail + modal raw literals */
html[data-theme="dark"] .a4p-unlinked { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
html[data-theme="dark"] .a4p-client-chip { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
html[data-theme="dark"] .a4p-unlink:hover { background: rgba(239, 68, 68, 0.22); color: #fca5a5; }
html[data-theme="dark"] .a4p-addlink:hover { background: rgba(59, 130, 246, 0.14); }
html[data-theme="dark"] .a4p-modal-overlay { background: rgba(2, 6, 23, 0.65); }
html[data-theme="dark"] .a4p-modal { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .a4p-option:hover,
html[data-theme="dark"] .a4p-option:focus-visible { background: rgba(59, 130, 246, 0.14); }
html[data-theme="dark"] .a4p-modal-msg.error { color: #fca5a5; }
