/* ===========================================================================
 * store-product-form.css — shared styles for the store-product editor drawer.
 *
 * Used by BOTH:
 *   - public/store-products.html  (global admin "New product" / edit drawer)
 *   - public/my-white-label.html  (White Label Studio "Add a store product")
 *
 * Everything is scoped under `.spf` and uses `spf-`-prefixed class names so it
 * can be dropped into either page without colliding with that page's own
 * global `.field` / `.switch` / `.drawer-*` styles. The single source of truth
 * for the editor markup + behaviour is store-product-form.js — keep the two in
 * lockstep so the two surfaces never drift (the WL studio is identical to the
 * global admin editor except it hides the SendGrid template-id field).
 *
 * Relies on the shared design tokens (--teal, --ink, --border, …) that both
 * pages already define via app.css.
 * ========================================================================= */

.spf {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* --- Tab strip ------------------------------------------------------------ */
.spf-tabs {
  display: flex; gap: 4px; padding: 8px 0 12px;
  overflow-x: auto;
  position: sticky; top: 0; z-index: 2;
  background: var(--card, #fff);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.spf-tab {
  flex-shrink: 0;
  background: transparent; border: 0;
  padding: 7px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500; color: var(--ink-muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.spf-tab:hover { background: var(--teal-soft); color: var(--teal-dark); }
.spf-tab.is-active { background: var(--teal); color: #fff; }
.spf-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: rgba(255,255,255,0.20); font-size: 10px; font-weight: 700;
}
.spf-tab:not(.is-active) .spf-pill { background: var(--border); color: var(--ink-muted); }

/* --- Panes ---------------------------------------------------------------- */
.spf-panes { flex: 1; min-height: 0; }
.spf-pane { display: none; flex-direction: column; gap: 14px; padding: 6px 2px 8px; }
.spf-pane.is-active { display: flex; }

/* --- Fields --------------------------------------------------------------- */
.spf-field { display: flex; flex-direction: column; gap: 6px; }
.spf-label { font-size: 12px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .4px; display: flex; align-items: center; gap: 6px; }
.spf-label .spf-req { color: var(--rose); }
.spf-hint { font-size: 11px; color: var(--ink-soft); margin-top: -2px; line-height: 1.5; }
.spf-hint code { background: var(--border); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.spf input[type=text],
.spf input[type=url],
.spf input[type=email],
.spf input[type=number],
.spf textarea,
.spf select {
  width: 100%;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
}
.spf textarea { min-height: 90px; resize: vertical; }
.spf input:focus, .spf select:focus, .spf textarea:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-ring); }
.spf-money { position: relative; display: block; }
.spf-money-sym {
  position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink-soft); pointer-events: none;
}
.spf-money input[type=number] { padding-left: 28px; }
.spf-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spf-id-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.spf-id-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.spf-suggest { padding: 0 14px; background: var(--teal-soft); border: 1px solid #cdebe0; color: var(--teal-dark); border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.spf-suggest:hover { background: #d6eee5; }

/* --- Toggle switch -------------------------------------------------------- */
.spf-switch-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 11px;
}
.spf-switch-card .spf-grow { flex: 1; }
.spf-switch-card .spf-sw-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.spf-switch-card .spf-sw-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; line-height: 1.5; }
.spf-switch {
  position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0;
}
.spf-switch input { opacity: 0; width: 0; height: 0; }
.spf-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 999px;
  transition: background .15s;
}
.spf-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.spf-switch input:checked + .spf-slider { background: var(--teal); }
.spf-switch input:checked + .spf-slider::before { transform: translateX(18px); }
.spf-switch.is-blue input:checked + .spf-slider { background: var(--blue); }

/* --- Price live preview --------------------------------------------------- */
.spf-price {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--teal-soft);
  border: 1px solid #cdebe0; border-radius: 9px; color: var(--teal-dark);
  font-size: 13px;
}
.spf-price .spf-price-big { font-size: 18px; font-weight: 700; color: var(--ink); }
.spf-price .spf-price-cents { color: var(--ink-soft); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-left: auto; }

/* --- Chip multi-select ---------------------------------------------------- */
.spf-chip-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 9px;
  min-height: 40px;
}
.spf-chip-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-ring); }
.spf-chip-input input {
  flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent;
  font-size: 13px; padding: 4px;
}
.spf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 6px 4px 10px; background: var(--teal-soft); color: var(--teal-dark);
  border: 1px solid #cdebe0; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.spf-chip button {
  background: transparent; border: 0; color: var(--teal-dark); cursor: pointer;
  width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
}
.spf-chip button:hover { background: var(--teal); color: #fff; }
.spf-chip.is-primary { background: var(--teal); color: #fff; border-color: var(--teal-dark); }
.spf-chip.is-primary button { color: #fff; }
.spf-chip.is-primary button:hover { background: rgba(255,255,255,0.20); }
.spf-chip.is-email { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.spf-chip.is-email button { color: var(--blue); }
.spf-chip.is-email button:hover { background: var(--blue); color: #fff; }
.spf-chip-sug {
  max-height: 180px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow-md); display: none;
}
.spf-chip-sug.is-open { display: block; }
.spf-chip-sug-item {
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.spf-chip-sug-item:hover { background: var(--teal-soft); color: var(--teal-dark); }

/* --- Image gallery editor ------------------------------------------------- */
.spf-dropzone {
  border: 2px dashed var(--border-strong); border-radius: 14px;
  padding: 22px; text-align: center; color: var(--ink-muted);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  cursor: pointer; transition: border-color .12s, color .12s, background .12s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.spf-dropzone:hover, .spf-dropzone.is-hover {
  border-color: var(--teal); color: var(--teal-dark);
  background: var(--teal-soft);
}
.spf-dropzone-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--teal-soft); color: var(--teal-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.spf-dropzone:hover .spf-dropzone-icon, .spf-dropzone.is-hover .spf-dropzone-icon { background: #fff; }
.spf-dropzone-icon svg { width: 18px; height: 18px; }
.spf-dropzone-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.spf-dropzone-sub { font-size: 11.5px; color: var(--ink-soft); }
.spf-dropzone-sub code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; }

.spf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
}
.spf-cell {
  position: relative; aspect-ratio: 1 / 1;
  border-radius: 10px; overflow: hidden;
  background: #f1f5f9; border: 1px solid var(--border);
  cursor: grab;
}
.spf-cell:active { cursor: grabbing; }
.spf-cell img { width: 100%; height: 100%; object-fit: cover; }
.spf-cell.is-primary { border: 2px solid var(--teal); box-shadow: 0 0 0 3px var(--teal-ring); }
.spf-cell .spf-primary-label {
  position: absolute; top: 6px; left: 6px;
  background: var(--teal); color: #fff;
  font-size: 9.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
}
.spf-cell .spf-cell-x {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(15,23,42,0.65); color: #fff;
  border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.spf-cell .spf-cell-x:hover { background: var(--rose); }
.spf-cell.is-uploading { cursor: progress; }
.spf-cell.is-uploading::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.spf-cell .spf-uploading {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; font-size: 10.5px; font-weight: 600; gap: 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.spf-cell .spf-uploading .spf-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.30); border-top-color: #fff; border-radius: 50%;
  animation: spf-spin .8s linear infinite;
}
@keyframes spf-spin { to { transform: rotate(360deg); } }
.spf-cell .spf-cdn-badge {
  position: absolute; bottom: 6px; left: 6px;
  background: rgba(15, 23, 42, 0.70); color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.spf-cell .spf-cdn-badge svg { width: 9px; height: 9px; }

.spf-add {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed var(--border-strong); border-radius: 10px;
  color: var(--ink-soft); font-size: 11.5px; font-weight: 500; cursor: pointer;
  background: #f8fafc; transition: border-color .12s, color .12s, background .12s;
}
.spf-add:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-soft); }
.spf-add svg { width: 22px; height: 22px; margin-bottom: 4px; }

.spf-url-row { display: flex; gap: 6px; }
.spf-url-row input { flex: 1; padding: 8px 10px; font-size: 12px; }
.spf-url-row .spf-add-url {
  padding: 8px 12px; background: #fff; color: var(--teal-dark); border: 1px solid #cdebe0; border-radius: 8px;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.spf-url-row .spf-add-url:hover { background: var(--teal-soft); }

.spf-url-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  background: transparent; border: 0; padding: 0; cursor: pointer;
}
.spf-url-toggle:hover { color: var(--ink-muted); }
.spf-url-toggle svg { width: 12px; height: 12px; transition: transform .15s; }
.spf-url-toggle.is-open svg { transform: rotate(180deg); }
.spf-url-wrap { display: none; flex-direction: column; gap: 6px; margin-top: 8px; }
.spf-url-wrap.is-open { display: flex; }
