/* ============================================================================
   Product editor
   ----------------------------------------------------------------------------
   Layout for the product dialog, shared by the till and the back office. Sits
   on top of the design's `.cu-*` chrome — that carries the frame, this carries
   what is inside it.

   Loaded by both index.html and dashboard.html so the two stay identical: the
   form is one module, and its styles should be one file for the same reason.
   ========================================================================= */

/* ── sections ──────────────────────────────────────────────────
   The form was one column of inputs with small grey captions, which reads as
   a list of fields rather than three decisions. A titled section with a rule
   line groups what belongs together and gives the eye a place to stop. */
.pf-section { grid-column: 1 / -1; }

.pf-section + .pf-section { margin-top: 18px; }

.pf-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pf-section-head b {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
  flex: none;
}

/* The rule fills whatever the title leaves, so sections read as bands. */
.pf-section-head .rule {
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
}

.pf-section-head .pf-add {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
}

.pf-section-head .pf-add:hover { border-color: var(--brand); color: var(--brand); }

/* ── identity row ──────────────────────────────────────────────
   Photo beside the fields rather than above them: it is one decision among
   several, not the headline. */
.pf-identity {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  /* Stretch, not start: the photo block then takes its height from the rows of
     inputs beside it and stays level with them however those rows change. */
  align-items: stretch;
}

.pf-photo { display: flex; flex-direction: column; }

.pf-fields { display: grid; gap: 12px; }

/* ── photo dropzone ────────────────────────────────────────────
   The tile is the control. A dashed outline with a plus is the shape people
   already read as "put a picture here", so the labelled button beside it was
   saying out loud what the box was already saying. */
.pf-drop-wrap { position: relative; display: flex; flex-wrap: wrap; flex: 1; }

/* Whose photo the tile is showing, when it is not this POS's own. It takes the
   full row under the tile — `.pf-drop-wrap` is a flex row, so a note without
   this would sit beside the picture and squeeze it. */
.pf-drop-note {
  flex-basis: 100%;
  margin-block-start: 6px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-3);
}

.pf-drop {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-m);
  background: var(--surface-2);
  overflow: hidden;
  padding: 10px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
  color: var(--ink-3);
}

.pf-drop:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.pf-drop:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.pf-drop:active { transform: scale(.97); }

/* The plus sits in a chip so it reads as a control rather than a stray mark
   in the middle of an empty box. */
.pf-drop-chip {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  flex: none;
  transition: border-color .15s ease, background .15s ease;
}

.pf-drop-chip svg { width: 18px; height: 18px; }

.pf-drop:hover .pf-drop-chip { border-color: var(--brand); background: var(--brand-soft); }

/* One short line saying what the box wants. Small, muted, and never the
   reason the column is a given height. */
.pf-drop-text {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: var(--ink-3);
}

/* Once there is a photo the dashes have done their job: a solid edge reads as
   content rather than as an empty slot still waiting to be filled. */
.pf-drop.has-photo { border-style: solid; border-color: var(--line-strong); background: var(--surface); }
.pf-drop.has-photo { padding: 0; }

/* `.ph` is only given position:relative when it sits inside `.cat` or `.tile`
   (pos-design.css:204). Here its parent is the dropzone, so without this the
   absolutely-positioned `.ph-img` escaped to `.pf-drop-wrap` and covered the
   whole block — including the remove button. */
.pf-drop.has-photo .ph {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0;
  font-size: 34px;
  color: var(--ink);
}

/* Sits on the corner of the tile, clear of the tap target that replaces it. */
.pf-drop-remove {
  position: absolute;
  /* Above `.ph-img`, which carries z-index:1. */
  z-index: 3;
  inset-block-start: -8px;
  inset-inline-end: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
  .pf-drop { transition: none; }
  .pf-drop:active { transform: none; }
}
.pf-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Required is marked, not implied. */
.pf-req { color: var(--brand); margin-inline-start: 3px; }

/* Persistent, not a placeholder that vanishes the moment it is needed. */
.pf-help {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  margin-top: 6px;
  line-height: 1.4;
}

/* ── switches ──────────────────────────────────────────────────
   Was a checkbox inside a ghost button, which looked like a button that also
   happened to have a tick in it. A switch states which of two positions it is
   in without being read. */
/* Tax percentage and the three settings it governs share one band: the field
   was alone on a half-width row with the other half empty, which read as a
   mistake rather than a layout. */
.pf-pricing {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 2fr;
  gap: 16px;
  align-items: start;
}

/* Three equal columns rather than a wrapping flex row: at this width the
   third switch fell to a second line on its own, which read as an odd one out
   rather than one of three settings. */
.pf-switches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  /* Clears the height of the label above the tax field, so the switches sit
     level with the input rather than with its caption. */
  margin-top: 22px;
}
.pf-switch { padding: 0 12px; font-size: 12.5px; gap: 8px; }

.pf-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* Comfortably past the 44px touch minimum on a till. */
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--r-m);
  border: 2px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.pf-switch input { position: absolute; opacity: 0; pointer-events: none; }

.pf-switch .track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  flex: none;
  transition: background .15s ease;
}

.pf-switch .track::after {
  content: '';
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform .15s ease;
}

.pf-switch:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.pf-switch:has(input:checked) .track { background: var(--brand); }

/* Logical, so the knob travels the correct way in Arabic. */
.pf-switch:has(input:checked) .track::after { transform: translateX(16px); }
[dir="rtl"] .pf-switch:has(input:checked) .track::after { transform: translateX(-16px); }

.pf-switch:has(input:focus-visible) { outline: 3px solid var(--brand-ring); outline-offset: 2px; }

/* ── variants ──────────────────────────────────────────────────
   Each variant is a titled card rather than an unlabelled grey box, so a
   product with three of them is three things and not twelve inputs. */
.pf-variant {
  border: 2px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface-2);
  padding: 13px;
}

.pf-variant + .pf-variant { margin-top: 10px; }

.pf-variant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

.pf-variant-head b {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-2);
}

.pf-variant-head .pf-remove {
  margin-inline-start: auto;
  padding: 6px 11px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-3);
}

.pf-variant-head .pf-remove:hover { border-color: var(--danger); color: var(--danger); }

/* All five fields on one row, weighted by how much each needs. Split over two
   rows, the second row could never fill its columns and always left a hole
   where the grid expected a field. */
.pf-variant-grid {
  display: grid;
  grid-template-columns: 1.5fr 1.1fr 1.1fr 1fr .8fr;
  gap: 10px;
}

/* ── header and footer ─────────────────────────────────────────
   `.cu-form` is the scroll container, so these two are already pinned as flex
   items — sticky would do nothing here. They only need to refuse to shrink
   when the form inside them grows. */
.cu-modal .cu-head,
.cu-modal .cu-foot { flex: none; background: var(--surface); }

.cu-modal .cu-form { min-height: 0; }

@media (max-width: 760px) {
  .pf-identity { grid-template-columns: 1fr; }
  .pf-pricing,
  .pf-row-2,
  .pf-switches,
  .pf-variant-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-switch,
  .pf-switch .track,
  .pf-switch .track::after { transition: none; }
}

/* ── 2026-10 polish ────────────────────────────────────────────
   Each section is now a card of its own, its title marked with a short brand
   bar instead of a hairline, so the dialog reads as three panels rather than
   one long form. The photo tile is square and the variant blocks sit on the
   surface like the cards elsewhere in the back office. */
.pf-section {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 14px 16px 16px;
}
.pf-section + .pf-section { margin-top: 12px; }
.pf-section-head { margin-bottom: 12px; }
.pf-section-head b {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: none;
  color: var(--ink);
}
.pf-section-head b::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: var(--brand);
}
.pf-section-head .rule { background: transparent; }

.pf-section .cu-in,
.pf-section input:not([type="checkbox"]):not([type="file"]),
.pf-section select { background: var(--surface); }

.pf-photo .pf-drop {
  aspect-ratio: 1;
  border-radius: 18px;
  background: var(--surface);
}
.pf-photo .pf-drop.has-photo { box-shadow: 0 6px 18px -8px rgba(0,0,0,.35); }

.pf-switch { background: var(--surface); }

.pf-variant {
  background: var(--surface);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(20,20,40,.06);
  border-radius: 14px;
  animation: pf-in .45s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes pf-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.pf-variant-head b {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .pf-variant { animation: none; }
}

/* ── the photo tile keeps its size ─────────────────────────────
   A chosen picture used to arrive at its own size and stretch the tile (and
   the dialog with it). The tile is a fixed square now and the picture is
   cropped to fill it, whatever its shape or resolution. */
.pf-drop {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  height: auto;
  min-height: 0 !important;
  flex: none;
  align-self: start;
}
.pf-photo .pf-drop { max-width: 132px; }
.pf-drop.has-photo { padding: 0; }
.pf-drop-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: pf-in .35s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .pf-drop-img { animation: none; }
}
