/* Badge Add/Edit — layered on top of the site's main.css variables. */

/* Override site-wrapper constraint so the admin UI can use full width */
.site-wrapper { max-width: none; padding: 0; }

/* ===== Browser support banner ===== */
.not-supported-banner {
  background: #2a0a0a;
  border-bottom: 3px solid #dc2626;
  color: #fca5a5;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  padding: 14px 20px;
}
.not-supported-banner[hidden] { display: none; }

/* ===== Repo picker (shown before a repo is opened) ===== */
.repo-picker[hidden] { display: none; }
.repo-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 24px;
}
.repo-picker-inner {
  max-width: 480px;
  text-align: center;
}
.repo-picker-inner h2 { font-size: 1.5rem; margin-bottom: 14px; }
.repo-picker-inner p { margin-bottom: 20px; line-height: 1.6; }
.repo-picker-inner button + button { margin-top: 8px; }
.hint-note { font-size: 12px; margin-top: 16px; }
.repo-help { margin-top: 20px; margin-left: 16px; text-align: left; font-size: 13px; color: var(--text-muted); line-height: 1.8; }
.repo-help code { font-size: 11px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ===== Admin UI (shown after repo is opened) ===== */
.admin-header {
  padding: 16px 24px 0;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-toolbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.close-repo-btn { margin-left: auto; }

.editing-banner { font-size: 13px; color: var(--text-muted); }
.editing-banner strong { color: var(--text); }
.editing-banner a { color: var(--link); }

.admin-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-preview { position: static; max-height: none; }
}

/* ===== Browse / edit / duplicate overlay ===== */
.browse-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 200;
}
.browse-overlay[hidden] { display: none; }

.browse-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.browse-panel-header {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.browse-panel-header input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 7px 10px;
}

.browse-list { overflow-y: auto; padding: 8px; }

.browse-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
}
.browse-row:hover { background: var(--surface-2); }

.browse-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
}
.browse-thumb img { width: 100%; height: 100%; object-fit: cover; }

.browse-info { flex: 1; min-width: 0; }
.browse-title { font-size: 14px; font-weight: 600; }
.browse-meta { font-size: 12px; margin-top: 2px; }

.browse-actions { display: flex; gap: 6px; flex-shrink: 0; }
.browse-actions button { font-size: 12px; padding: 6px 10px; }

.browse-row-group { cursor: pointer; }
.browse-chevron { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }

.browse-back {
  display: block;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 6px 8px;
}
.browse-back:hover { text-decoration: underline; }

.browse-group-heading { font-size: 15px; font-weight: 600; padding: 4px 8px 10px; }

/* ===== Form ===== */
.admin-form { display: flex; flex-direction: column; gap: 20px; }

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px 20px;
}

.admin-section legend {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 6px;
}

.field-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.field-row:last-child { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; }
.field-narrow { flex: 0 0 180px; min-width: 140px; }
.field-xnarrow { flex: 0 0 130px; min-width: 110px; }
.field-link-btn { background: none; border: none; color: var(--link); cursor: pointer; font: inherit; font-size: 11px; padding: 0; text-decoration: underline; }
.field-link-btn:hover { opacity: 0.8; }
.field-warn { font-size: 11px; color: #f87171; }

.field span:first-child { font-size: 12px; color: var(--text-muted); }
.field .hint { font-weight: 400; opacity: 0.7; }
.req { color: #f87171; }

.field input,
.field select,
.field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  padding: 7px 10px;
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--accent-dim); }

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}

.electronics-fields[hidden],
.conditional-block[hidden],
.nested-fields[hidden] { display: none; }

.electronics-fields { display: flex; flex-direction: column; gap: 14px; }
.conditional-block { border-top: 1px dashed var(--border); padding-top: 12px; }
.nested-fields { margin-top: 10px; padding-left: 14px; border-left: 2px solid var(--border); }

/* Select-with-add-new */
.select-add-wrap { display: flex; flex-direction: column; gap: 4px; }
.select-add-new-input { display: none; margin-top: 4px; }
.select-add-new-input.active { display: block; }

/* Checkbox groups */
.checkbox-group { margin-bottom: 4px; }
.checkbox-group-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: block; }
.checkbox-group-options { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; }
.checkbox-option { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.checkbox-add-row { display: flex; gap: 6px; }
.checkbox-add-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
  flex: 1;
  max-width: 220px;
}

.btn-secondary,
.btn-primary {
  border-radius: var(--radius);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-primary {
  background: var(--accent-dim);
  color: #eafff0;
  border-color: var(--accent-dim);
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sold-at rows */
.sold-at-list { margin-top: 12px; }
.sold-at-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.sold-at-row input { flex: 1; }
.sold-at-remove { color: var(--text-muted); cursor: pointer; background: none; border: none; font-size: 16px; }
.sold-at-remove:hover { color: #f87171; }

/* External link rows */
.links-list { margin-top: 12px; }
.links-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.links-row input { flex: 1; }
.links-row select { width: 100px; }
.links-remove { color: var(--text-muted); cursor: pointer; background: none; border: none; font-size: 16px; }
.links-remove:hover { color: #f87171; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.dropzone.dragover { border-color: var(--accent); color: var(--text); }

/* Image cards */
.image-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }

.image-card {
  width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
}
.image-card.dragging { opacity: 0.4; }
.image-card.highlighted,
.video-card.highlighted { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.highlight-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  text-align: left;
}
.highlight-btn:hover { color: var(--text); border-color: var(--text-muted); }
.highlight-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(57, 211, 83, 0.08);
  font-weight: 600;
}

.image-card img { width: 100%; height: 100px; object-fit: cover; display: block; }
.image-card-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.image-card-body input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 6px;
}
.image-card-remove {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; cursor: pointer; text-align: left; padding: 0;
}
.image-card-remove:hover { color: #f87171; }

/* Video cards */
.video-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }

.video-card {
  width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.video-card.error { border-color: #dc2626; }

.video-card video { width: 100%; height: 120px; object-fit: cover; display: block; background: #000; }
.video-card-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.video-card-body input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 6px;
}
.video-card-status { font-size: 11px; color: var(--text-muted); }
.video-card-status.error { color: #f87171; }
.video-card-remove {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; cursor: pointer; text-align: left; padding: 0;
}
.video-card-remove:hover { color: #f87171; }

textarea { resize: vertical; width: 100%; }

.admin-actions { display: flex; align-items: center; gap: 14px; }
.save-status { font-size: 13px; color: var(--text-muted); }
.save-status.error { color: #f87171; }
.save-status.ok { color: var(--accent); }

/* ===== Preview pane ===== */
.admin-preview {
  position: sticky;
  top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.preview-header {
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.preview-header > span:first-child { flex-shrink: 0; }

.preview-mode-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.preview-mode-btn {
  background: var(--surface); border: none; color: var(--text-muted);
  font-size: 11px; font-family: var(--font-mono); text-transform: none; letter-spacing: normal;
  padding: 4px 10px; cursor: pointer;
}
.preview-mode-btn + .preview-mode-btn { border-left: 1px solid var(--border); }
.preview-mode-btn.active { color: var(--accent); background: rgba(57, 211, 83, 0.06); }

.preview-popout {
  margin-left: auto;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-size: 11px; font-family: var(--font-mono);
  text-transform: none; letter-spacing: normal; padding: 4px 8px; cursor: pointer; flex-shrink: 0;
}
.preview-popout:hover { color: var(--text); border-color: var(--text-muted); }

.preview-render-wrap { flex: 1; overflow-y: auto; }
.preview-render { padding: 20px; font-size: 14px; }
.preview-render[hidden] { display: none; }
.preview-render .badge-detail-body { grid-template-columns: 1fr; gap: 24px; }
.preview-render .badge-detail-header h1 { font-size: 1.4rem; }
.preview-render .breadcrumb { margin-bottom: 16px; }

.preview-content {
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1;
}
.preview-content[hidden] { display: none; }

.save-result { border-top: 1px solid var(--border); padding: 14px 16px; font-size: 13px; }
.save-result[hidden] { display: none; }
.save-result pre {
  background: var(--surface-2); border-radius: var(--radius); padding: 10px;
  font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap;
  margin-top: 8px; user-select: all;
}
