/* Lead Gen Factory — Admin Interface
   Same vanilla philosophy as the lead gen template: no framework, system fonts, minimal. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --admin-primary: #1a1a2e;
  --admin-accent: #4361ee;
  --admin-accent-hover: #3a56d4;
  --admin-bg: #f8f9fb;
  --admin-surface: #ffffff;
  --admin-border: #e2e6ed;
  --admin-text: #1a1a2e;
  --admin-muted: #6b7280;
  --admin-error: #dc2626;
  --admin-success: #16a34a;
  --admin-radius: 8px;
  --admin-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.admin-header {
  background: var(--admin-primary);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pm-logo {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  font-style: italic;
}

.pm-popular {
  color: #cc0000;
}

.pm-marketing {
  color: #ffffff;
}

.logo-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.25);
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-style: normal;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Nav toggle */
.nav-toggle {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 2px;
}

.nav-link {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }

/* Banners */
.compliance-banner {
  background: #fef2f2;
  border-bottom: 2px solid #dc2626;
  padding: 16px 24px;
  position: sticky;
  top: 56px;
  z-index: 90;
}

.compliance-banner .banner-inner {
  max-width: 720px;
  margin: 0 auto;
}

.banner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #991b1b;
  font-size: 14px;
}

.banner-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #991b1b;
  padding: 0 4px;
}

.compliance-banner ul {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 8px;
}

.compliance-banner li {
  font-size: 13px;
  color: #7f1d1d;
  margin-bottom: 4px;
}

.banner-action {
  font-size: 13px;
  font-weight: 600;
  color: #991b1b;
}

.success-banner {
  background: #f0fdf4;
  border-bottom: 2px solid #16a34a;
  padding: 16px 24px;
  position: sticky;
  top: 56px;
  z-index: 90;
}

.success-banner .banner-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #166534;
}

.success-banner a {
  color: #16a34a;
  font-weight: 600;
}

/* Section error highlight */
.form-section.section-error {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
  animation: pulse-error 0.5s ease;
}

@keyframes pulse-error {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15); }
  50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.25); }
}

/* Build & Deploy accent button */
.btn-accent {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: #16a34a;
  color: #fff;
  transition: background 0.15s;
}

/* Header deploy button */
.btn-deploy-header {
  padding: 6px 16px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: #16a34a;
  color: #fff;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-deploy-header:hover { background: #15803d; }
.btn-deploy-header:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-deploy-header.btn-confirm {
  background: #b45309;
  font-size: 11px;
}

.btn-deploy-header.btn-confirm:hover { background: #92400e; }

.btn-confirm {
  background: #b45309 !important;
  font-size: 12px !important;
  white-space: nowrap;
}

.btn-confirm:hover { background: #92400e !important; }

/* Auto-populated badge */
.auto-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  color: var(--admin-accent);
  background: rgba(67, 97, 238, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Main */
.admin-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* Sections */
.form-section {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--admin-shadow);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--admin-border);
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--admin-bg);
  border-radius: 6px;
  color: var(--admin-accent);
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
}

/* Field groups */
.field-group {
  margin-bottom: 16px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--admin-text);
}

.req {
  color: var(--admin-error);
}

.field-hint {
  font-size: 12px;
  color: var(--admin-muted);
  margin-top: 4px;
}

.field-warning {
  font-size: 12px;
  color: #b45309;
  margin-top: 4px;
  padding: 6px 10px;
  background: #fef3c7;
  border-radius: 4px;
  border-left: 3px solid #f59e0b;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--admin-text);
  background: var(--admin-surface);
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

textarea {
  resize: vertical;
  min-height: 64px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Field rows (side by side) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Color inputs */
.color-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-input input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.color-input input[type="text"] {
  flex: 1;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

/* File upload */
.file-upload {
  position: relative;
}

.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-placeholder {
  border: 2px dashed var(--admin-border);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  color: var(--admin-muted);
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-placeholder span {
  font-size: 13px;
}

.upload-hint {
  font-size: 11px !important;
  opacity: 0.7;
}

.file-upload:hover .upload-placeholder {
  border-color: var(--admin-accent);
}

.upload-preview {
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  text-align: center;
}

.upload-preview img {
  max-height: 60px;
  max-width: 200px;
}

/* Checkbox grid */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.checkbox-card:has(input:checked) {
  border-color: var(--admin-accent);
  background: rgba(67, 97, 238, 0.04);
}

/* Radio cards (audience/traffic temperature) */
.radio-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.radio-card:has(input:checked) {
  border-color: var(--admin-accent);
  background: rgba(67, 97, 238, 0.04);
}

.radio-card input[type="radio"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--admin-accent);
  flex-shrink: 0;
}

.radio-card-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-card-content strong {
  font-size: 13px;
}

.radio-card-content span {
  font-size: 12px;
  color: var(--admin-muted);
  line-height: 1.4;
}

.checkbox-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--admin-accent);
}

/* Toggle label */
.toggle-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--admin-accent);
}

/* Custom pixel rows */
.pixel-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.pixel-row input {
  flex: 1;
}

.pixel-row .btn-remove {
  background: none;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--admin-muted);
  font-size: 14px;
  transition: color 0.15s, border-color 0.15s;
}

.pixel-row .btn-remove:hover {
  color: var(--admin-error);
  border-color: var(--admin-error);
}

/* Buttons */
.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary,
.btn-disabled {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--admin-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--admin-accent-hover);
}

.btn-secondary {
  background: var(--admin-surface);
  color: var(--admin-text);
  border: 1px solid var(--admin-border);
}

.btn-secondary:hover {
  background: var(--admin-bg);
}

.btn-disabled {
  background: var(--admin-bg);
  color: var(--admin-muted);
  cursor: not-allowed;
  border: 1px solid var(--admin-border);
}

.btn-copy {
  background: none;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  color: var(--admin-muted);
}

.btn-copy:hover {
  color: var(--admin-accent);
  border-color: var(--admin-accent);
}

/* Config Preview */
.output-section {
  /* Flows naturally at end of form — not sticky */
}

#config-preview {
  margin-top: 16px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  overflow: hidden;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--admin-bg);
  border-bottom: 1px solid var(--admin-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--admin-muted);
}

#config-preview pre {
  margin: 0;
  padding: 16px;
  background: #1a1a2e;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

/* Footer */
.admin-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--admin-muted);
}

/* Responsive */
@media (max-width: 600px) {
  .admin-main {
    padding: 16px 12px 80px;
  }

  .form-section {
    padding: 16px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }

  .output-section {
    /* already static */
  }
}

/* ============================================================
   DASHBOARD STYLES
   ============================================================ */

/* Metrics bar */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--admin-shadow);
}

.metric-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--admin-text);
  line-height: 1;
}

.metric-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--admin-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Site grid */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.site-card {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 16px;
  background: var(--admin-bg);
  transition: border-color 0.15s;
}

.site-card:hover {
  border-color: var(--admin-accent);
}

.card-header {
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: capitalize;
}

.tag-vertical { background: #ede9fe; color: #5b21b6; }
.tag-audience { background: #e0f2fe; color: #075985; }

.card-id {
  font-size: 11px;
  color: var(--admin-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Status badges */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: capitalize;
}

.status-live { background: #dcfce7; color: #166534; }
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-archived { background: #f3f4f6; color: #9ca3af; }
.status-blocked { background: #fef2f2; color: #991b1b; }

/* Card metrics */
.card-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--admin-border);
  border-bottom: 1px solid var(--admin-border);
}

.card-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-metric-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--admin-text);
}

.card-metric-label {
  font-size: 10px;
  color: var(--admin-muted);
  text-transform: uppercase;
}

.card-sparkline {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.card-sparkline svg {
  display: block;
}

/* Card meta */
.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--admin-muted);
  margin-bottom: 12px;
}

/* Card actions */
.card-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px !important;
  font-size: 12px !important;
}

/* Loading / empty states */
.loading-state, .empty-state, .error-state {
  text-align: center;
  padding: 32px;
  color: var(--admin-muted);
  font-size: 14px;
}

.empty-state p { margin-bottom: 0; }
.error-state { color: var(--admin-error); }

/* Builds table */
.builds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.builds-table th {
  text-align: left;
  font-weight: 600;
  color: var(--admin-muted);
  font-size: 11px;
  text-transform: uppercase;
  padding: 8px 12px;
  border-bottom: 1px solid var(--admin-border);
}

.builds-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text);
}

.builds-table tr:last-child td {
  border-bottom: none;
}

/* Inline leads viewer */
.site-card-clickable { cursor: pointer; }
.site-card-clickable .card-header { position: relative; }
.site-card-clickable .expand-chevron {
  position: absolute; right: 0; top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s;
  color: var(--admin-muted); font-size: 18px;
}
.site-card-clickable.expanded .expand-chevron { transform: translateY(-50%) rotate(180deg); }
.site-card-clickable.expanded { border-color: var(--admin-accent); background: #fff; grid-column: 1 / -1; }
.leads-panel { overflow-x: auto; padding: 0 0 8px; }
.leads-table { font-size: 12px; min-width: 600px; }
.leads-table td { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* Clickable summary metric */
.metric-card-clickable { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.metric-card-clickable:hover { border-color: var(--admin-accent); }
.all-leads-panel { margin-top: -8px; margin-bottom: 16px; overflow-x: auto; }
.all-leads-panel .leads-table { min-width: 600px; }

/* Page Content section */
.subsection-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--admin-text);
  margin: 20px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--admin-border);
}

.subsection-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.subsection-hint {
  font-size: 12px;
  color: var(--admin-muted);
  margin-bottom: 12px;
}

.content-row {
  display: grid;
  grid-template-columns: 130px 1fr 1.5fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}

.hiw-row {
  display: grid;
  grid-template-columns: 36px 1fr 1.5fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--admin-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.faq-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}

.faq-row textarea {
  resize: vertical;
  min-height: 38px;
}

.trust-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.trust-stat-col input {
  margin-bottom: 4px;
}

.trust-stat-col input:first-child {
  font-weight: 600;
  text-align: center;
}

.icon-select {
  font-size: 13px;
}

#add-faq-btn {
  margin-top: 4px;
  font-size: 12px;
  padding: 4px 12px;
  background: none;
  border: 1px dashed var(--admin-border);
  border-radius: 4px;
  color: var(--admin-muted);
  cursor: pointer;
}

#add-faq-btn:hover {
  border-color: var(--admin-accent);
  color: var(--admin-accent);
}

#add-faq-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.faq-remove {
  background: none;
  border: none;
  color: var(--admin-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
}

.faq-remove:hover {
  color: var(--admin-error);
}

@media (max-width: 600px) {
  .content-row { grid-template-columns: 1fr; }
  .hiw-row { grid-template-columns: 36px 1fr; }
  .faq-row { grid-template-columns: 1fr; }
  .trust-stats-grid { grid-template-columns: 1fr; }
}

/* Dashboard responsive */
@media (max-width: 600px) {
  .metrics-bar { grid-template-columns: repeat(2, 1fr); }
  .sites-grid { grid-template-columns: 1fr; }
}
