/* ShapeClip Admin Panel — single-file styles.
   Visual language: same Inter-ish system stack as shapeclip.com, calmer palette
   (admin should feel professional, not playful). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6fa;
  color: #1a1c23;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted  { color: #6b7280; font-size: 14px; }
.hint   { color: #9ca3af; font-weight: normal; font-size: 12px; }

/* ─── Forms / inputs ─── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin: 14px 0 6px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  color: #1a1c23;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button.primary {
  background: #4f46e5;
  color: white;
  width: 100%;
  padding: 12px 16px;
  margin-top: 18px;
}
button.primary:hover { background: #4338ca; }
button.primary:disabled { background: #a5b4fc; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: #4b5563;
  border-color: #d1d5db;
  padding: 7px 14px;
}
button.ghost:hover { background: #f3f4f6; color: #111827; }

.error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ─── Splash / centered card layouts (setup, login) ─── */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.splash-card {
  text-align: center;
}
.card {
  background: white;
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 10px 30px rgba(0,0,0,0.06);
}
.card .logo {
  font-size: 18px;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: 24px;
}
.card h1 {
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #4f46e5;
  border-radius: 50%;
  margin: 24px auto 0;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Dashboard chrome ─── */
.topbar {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-weight: 700;
  color: #4f46e5;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Web Page tab — one card per content blob (landing, checkout, tracking,
   editor defaults). Just enough breathing room to make the form scannable
   without being precious. */
.webpage-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 22px;
  margin: 0 0 18px;
}
.webpage-section h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: #1a1c23;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
}
#webpage-form .row {
  margin-bottom: 12px;
}
#webpage-form .row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
#webpage-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #1a1c23;
  margin-bottom: 4px;
}
#webpage-form input[type="text"],
#webpage-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: #1a1c23;
}
#webpage-form input[type="text"]:focus,
#webpage-form textarea:focus {
  outline: 2px solid #6366f1;
  outline-offset: 1px;
  border-color: #6366f1;
}

/* Features tab bulk-action bar — six buttons that flip every feature in
   the current sub-tab in a single save. Sits above the group headers. */
.features-bulkbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  margin: 0 0 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.features-bulkbar button {
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.features-bulkbar button:hover {
  background: #e0e7ff;
  border-color: #6366f1;
  color: #3730a3;
}
.features-bulkbar button.reset-btn {
  color: #991b1b;
  border-color: #fecaca;
}
.features-bulkbar button.reset-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #7f1d1d;
}

/* Scope bar — sits between the topbar and the tabs nav. When the admin is
   editing a non-default scope (a theme), the bar shifts to a warm-amber
   accent so it's impossible to forget you're editing a theme, not global. */
.scope-bar {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  position: sticky;
  top: 96px;             /* sits below the topbar (56px) + global nav row (40px) */
  z-index: 49;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
/* Hide the scope bar entirely on global-management tabs (Themes, Products,
   Audit Log). Those tabs aren't scoped, so the dropdown would be confusing. */
.scope-bar.scope-hidden {
  display: none;
}
/* The two nav rows look the same; the only structural difference is which
   ones sit above vs. below the scope bar. The global row is slightly more
   compact so the overall header doesn't grow too tall. */
.tabs-global {
  padding: 0 24px;
  min-height: 40px;
}
.tabs-global .tab {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
}
.tabs-global .tab.active {
  color: #4f46e5;
}
.scope-bar .scope-label {
  font-weight: 600;
  color: #4b5563;
}
.scope-bar .scope-select {
  height: 30px;
  padding: 0 26px 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: #1a1c23;
  cursor: pointer;
  min-width: 220px;
}
.scope-bar .scope-select:focus {
  outline: 2px solid #6366f1;
  outline-offset: 1px;
  border-color: #6366f1;
}
.scope-bar .scope-hint {
  color: #6b7280;
  font-size: 12px;
}
/* Themed scope: amber warning band so the admin always knows they're
   editing a niche configuration and not the global default. */
.scope-bar[data-scope]:not([data-scope="default"]) {
  background: #fffbeb;
  border-bottom-color: #fbbf24;
}
.scope-bar[data-scope]:not([data-scope="default"]) .scope-hint {
  color: #92400e;
  font-weight: 600;
}
/* On tabs that aren't scope-aware (Dashboard, Themes, Audit), the bar
   dims down to indicate the selector is informational only. */
.scope-bar.scope-inactive {
  opacity: 0.55;
}

.tabs {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  border-radius: 0;
  padding: 14px 18px;
  color: #6b7280;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
}
.tab:hover:not(.active) { color: #374151; }

.tab-pane {
  padding: 28px 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.tab-head {
  margin-bottom: 24px;
}
.tab-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.tab-head .muted {
  margin-bottom: 16px;
}

/* ─── Card list (featured shapes) ─── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.shape-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s;
}
.shape-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.shape-card.inactive {
  opacity: 0.55;
  background: #f9fafb;
}
.shape-thumb {
  width: 100%;
  height: 140px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.shape-thumb svg {
  max-width: 80%;
  max-height: 80%;
}
/* Force every SVG element in the admin shape card thumbnail to render in
   dark gray on light background — handles the all-black baked-in fills that
   tracer outputs use. EXCEPTION: elements tagged data-zone (photo or solid)
   come from the Mask Zones painter and carry their own inline fills set by
   applyZoneColorsInElement (zone color for solid, gray-translucent for photo).
   Without the exclusion, !important wipes those out and every card looks
   like a black silhouette regardless of the admin's choices. */
.shape-thumb svg,
.shape-thumb svg :not([data-zone]):not([data-overlay-text]) {
  fill: #1f2937 !important;
  stroke: none !important;
}
.shape-meta {
  flex: 1;
}
.shape-meta .label {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}
.shape-meta .dates {
  font-size: 12px;
  color: #6b7280;
}
.shape-actions {
  display: flex;
  gap: 8px;
}
.shape-actions button {
  flex: 1;
  font-size: 13px;
  padding: 6px 8px;
}

/* ─── Dashboard ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.dash-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 20px;
}
.dash-num {
  font-size: 32px;
  font-weight: 700;
  color: #4f46e5;
  line-height: 1.1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.dash-lbl {
  font-size: 13px;
  color: #6b7280;
}
.dash-recent-h {
  font-size: 16px;
  margin: 8px 0 12px;
  font-weight: 600;
  color: #374151;
}

/* ─── Audit list ─── */
.audit-list {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.audit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.audit-row:last-child { border-bottom: none; }
.audit-action {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #4f46e5;
  font-size: 12px;
}
.audit-detail {
  color: #6b7280;
  font-size: 12px;
  margin-top: 2px;
  word-break: break-word;
}
.audit-time {
  color: #9ca3af;
  font-size: 12px;
  white-space: nowrap;
}
.audit-empty {
  padding: 24px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

/* ─── App settings list ─── */
.settings-list {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid #f3f4f6;
}
.settings-row:last-child { border-bottom: none; }
.settings-meta { min-width: 0; }
.settings-meta .lbl {
  font-weight: 600;
  font-size: 14px;
  color: #1a1c23;
  margin-bottom: 3px;
}
.settings-meta .hint {
  font-size: 12px;
  color: #6b7280;
}
.settings-meta .key {
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #9ca3af;
  margin-top: 2px;
}
.settings-row input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.settings-actions {
  display: flex;
  gap: 6px;
}
.settings-actions button {
  font-size: 12px;
  padding: 5px 10px;
}

@media (max-width: 640px) {
  .settings-row {
    grid-template-columns: 1fr;
  }
  .settings-actions { justify-self: end; }
}

/* ─── Standard shapes list ─── */
.standard-list {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.standard-row {
  display: grid;
  grid-template-columns: 60px 1fr 110px auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.standard-row:last-child { border-bottom: none; }
.standard-row.disabled { opacity: 0.5; }

.standard-thumb {
  width: 44px; height: 44px;
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
}
.standard-thumb svg { max-width: 32px; max-height: 32px; }
/* Force any uploaded SVG (which may have baked-in dark fills) to render
   in the thumbnail color. !important is required because inline style or
   fill attrs on nested elements otherwise override our rule. */
.standard-thumb svg,
.standard-thumb svg * {
  fill: #1f2937 !important;
  stroke: none !important;
}

.standard-meta { min-width: 0; }
.standard-key {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.standard-label-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  transition: border-color 0.12s, background 0.12s;
}
.standard-label-input:hover { border-color: #d1d5db; background: white; }
.standard-label-input:focus { border-color: #6366f1; background: white; outline: none; }

.standard-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b7280;
  user-select: none;
  cursor: pointer;
}
.standard-toggle input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: #4f46e5;
}

.standard-actions {
  display: flex;
  gap: 6px;
}
.standard-actions button {
  font-size: 12px;
  padding: 5px 10px;
}
.standard-actions .reset-btn { color: #b91c1c; }
.standard-actions .reset-btn:hover { background: #fee2e2; }

.override-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 640px) {
  .standard-row {
    grid-template-columns: 44px 1fr;
    grid-template-areas:
      "thumb meta"
      "toggle toggle"
      "actions actions";
    row-gap: 8px;
  }
  .standard-thumb { grid-area: thumb; }
  .standard-meta  { grid-area: meta; }
  .standard-toggle{ grid-area: toggle; }
  .standard-actions { grid-area: actions; }
}

.empty-state {
  background: white;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 36px 24px;
  text-align: center;
  color: #6b7280;
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: white;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.18);
}
.modal-card.narrow { max-width: 420px; }
.modal-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: flex-end;
}
.modal-actions button { width: auto; margin: 0; }

.row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-row input[type=file] { width: auto; padding: 6px 0; }
.svg-preview {
  margin-top: 12px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.svg-preview-inner {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.svg-preview-inner svg {
  max-width: 60px;
  max-height: 60px;
  fill: #1f2937;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  z-index: 200;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── Mobile tweaks ─── */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .topbar-right .muted { display: none; }
  .tabs { padding: 0 8px; }
  .tab-pane { padding: 20px 16px; }
  .row.two-col { grid-template-columns: 1fr; }
}


/* ─── Features tab ────────────────────────────────────────────────── */
.features-list {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.features-group-header {
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #4b5563;
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  gap: 12px;
  align-items: center;
}
.features-group-header .col-platform {
  text-align: center;
  font-size: 11px;
}
.features-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.features-row:last-child { border-bottom: none; }
.features-meta { min-width: 0; }
.features-meta .lbl {
  font-weight: 600;
  font-size: 14px;
  color: #1a1c23;
  margin-bottom: 2px;
}
.features-meta .key {
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #9ca3af;
}
.features-row .platform-cell {
  display: flex;
  justify-content: center;
  align-items: center;
}
.features-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: #00bcd4;
}

@media (max-width: 640px) {
  .features-group-header,
  .features-row {
    grid-template-columns: 1fr 60px 60px;
    gap: 8px;
    padding: 10px 12px;
  }
}

/* ── Features tab — editor-mirroring tabs (Shape / Adjust / Style / Export) ── */
.features-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 0;
  border-bottom: 2px solid #e5e7eb;
}
.features-tab {
  background: transparent;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  width: auto;
}
.features-tab:hover { color: #4338ca; }
.features-tab.active { color: #4338ca; border-bottom-color: #4338ca; }
.features-pane.hidden { display: none; }
.features-pane .features-group-header:first-child { margin-top: 0; }


/* ── Editor parent tab — sub-tab strip (Shapes / App Settings / Features / Fonts) ── */
.editor-subtabs {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  border-bottom: 2px solid #e5e7eb;
  flex-wrap: wrap;
}
.editor-subtab {
  background: transparent;
  border: none;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  width: auto;
}
.editor-subtab:hover { color: #4338ca; }
.editor-subtab.active { color: #4338ca; border-bottom-color: #4338ca; font-weight: 700; }
.editor-subpane.hidden { display: none; }

/* Toggle button active state (Bold, Stacked, etc. in the Text Overlay
   editor) — added 2026-05-23. Without this the click handler toggles a
   class but the button looks identical, so admin has no visual feedback
   for whether the toggle is on. */
.ghost.active {
  background: var(--accent, #4f46e5);
  color: #ffffff;
  border-color: var(--accent, #4f46e5);
}
.ghost.active:hover {
  background: var(--accent, #4f46e5);
  filter: brightness(1.08);
}

/* Slider reset pill — clickable ↻ next to each slider value in the
   Text Overlay editor. Small but tappable. */
.overlay-slider-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  background: #fff;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
}
.overlay-slider-reset:hover {
  border-color: var(--accent, #4f46e5);
  color: var(--accent, #4f46e5);
  background: #f3f4f6;
}
