/* Buyer Admin — list + tabbed editor
 * Loaded from admin/index.html. Mirrors admin/css/funnel-creator.css style.
 * All rules scoped under #buyer-admin-root or .buyer-* classes to avoid
 * bleeding into single-page / funnel creator surfaces.
 */

#buyer-admin-root { display: none; }
body.mode-buyers #buyer-admin-root { display: block; }
body.mode-buyers form#config-form { display: none; }
body.mode-buyers #funnel-tab { display: none !important; }
body.mode-buyers .tab-bar { display: none; }
/* Admin <main> constrains its children with a narrow max-width for the
 * single-page form. Buyer admin wants the full viewport. */
body.mode-buyers .admin-main {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Toolbar */
.buyer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 96px;
  z-index: 40;
}
.buyer-toolbar-left { flex: 1; display: flex; align-items: center; gap: 12px; }
.buyer-toolbar-right { display: flex; align-items: center; gap: 8px; }
.buyer-toolbar h2 { margin: 0; font-size: 18px; font-weight: 600; color: #111827; }
.buyer-dirty { color: #f59e0b; font-size: 12px; font-weight: 500; }

/* Banner */
.buyer-banner {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.buyer-banner.ok { background: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.buyer-banner.err { background: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }

/* Two-column layout */
.buyer-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px 24px 32px;
  min-height: calc(100vh - 220px);
}

/* Left list */
.buyer-list-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}
.buyer-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.buyer-list-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: #374151; }
.buyer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.buyer-row {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 100ms, border-color 100ms;
}
.buyer-row:hover { background: #f9fafb; }
.buyer-row.active { background: #eff6ff; border-color: #3b82f6; }
.buyer-row-main { font-size: 13px; color: #111827; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.buyer-row-meta { font-size: 11px; color: #6b7280; margin-top: 3px; }
.buyer-empty { padding: 16px; font-size: 12px; color: #9ca3af; text-align: center; }
.buyer-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.buyer-status-pill.active { background: #d1fae5; color: #065f46; }
.buyer-status-pill.paused { background: #fef3c7; color: #92400e; }
.buyer-status-pill.deleted { background: #e5e7eb; color: #6b7280; }

/* Editor panel */
.buyer-editor-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  min-height: 600px;
}
.buyer-editor-empty {
  padding: 80px 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}
.buyer-editor-header { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #e5e7eb; }
.buyer-editor-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.buyer-name-input {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #111827;
}
.buyer-name-input:focus {
  outline: none;
  border-bottom-color: #3b82f6;
}
.buyer-status-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}
.buyer-editor-meta { font-size: 11px; color: #9ca3af; margin-top: 4px; }

/* Tabs */
.buyer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 20px;
  overflow-x: auto;
}
.buyer-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
}
.buyer-tab:hover { color: #111827; }
.buyer-tab.active {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

/* Tab body */
.buyer-tab-body { min-height: 300px; }
.buyer-help {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f9fafb;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
}
.buyer-help-secondary {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 16px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 4px;
}

.buyer-field { margin-bottom: 14px; }
.buyer-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.buyer-field input[type="text"],
.buyer-field input[type="email"],
.buyer-field input[type="tel"],
.buyer-field input[type="url"],
.buyer-field input[type="number"],
.buyer-field textarea,
.buyer-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #111827;
  background: #fff;
  box-sizing: border-box;
  font-family: inherit;
}
.buyer-field input:focus,
.buyer-field textarea:focus,
.buyer-field select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.buyer-field textarea { resize: vertical; min-height: 80px; }
.buyer-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.buyer-field-note { font-size: 11px; color: #6b7280; margin-top: 4px; }

/* Vertical checkbox grid */
.buyer-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.buyer-checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  font-weight: normal;
}
.buyer-checkbox-grid label:hover { background: #f3f4f6; }

/* State grid */
.buyer-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 4px;
  margin-bottom: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.buyer-state-chk {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}
.buyer-state-chk:hover { background: #eff6ff; }
.buyer-state-bulk button {
  background: transparent;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 6px;
}

/* Assignments */
.buyer-site-group {
  margin-bottom: 16px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.buyer-site-name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}
.buyer-path-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.buyer-path-row label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}
.buyer-priority {
  width: 80px !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
}

/* Delivery field mapping */
.buyer-map-row {
  display: grid;
  grid-template-columns: 1fr 20px 1fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.buyer-map-row span { text-align: center; color: #9ca3af; font-size: 14px; }
.buyer-map-del {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  color: #ef4444;
  font-size: 16px;
  width: 28px;
  height: 28px;
  padding: 0;
}
.buyer-map-del:hover { background: #fee2e2; }
.buyer-map-row input {
  padding: 6px 10px !important;
  font-size: 12px !important;
}
.buyer-test-result {
  margin-top: 10px;
  padding: 12px;
  background: #111827;
  color: #d1fae5;
  border-radius: 6px;
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* Editor footer */
.buyer-editor-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
}
.btn-danger {
  background: #fff;
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #fee2e2; }

/* Responsive */
@media (max-width: 900px) {
  .buyer-grid { grid-template-columns: 1fr; }
  .buyer-field-row { grid-template-columns: 1fr; }
}
