/* ── Set Apart Admin — the storefront's preview-chrome language promoted to an
   app skin. Cute lives in the chrome and microinteractions; data (tables,
   currency, emails, timestamps) stays plain ink-on-white, and destructive
   actions get no pop, no wiggle, no cute copy. ── */

:root {
  --teal: #117887;
  --teal-deep: #0b5f6d;
  --rose: #e39ca2;
  --rose-deep: #c9767e;
  --pink: #fee2e3;
  --cream: #faf1ee;
  --blush: #f5d9db;
  --paper: #fdf8f6;
  --ink: #2e2e2d;
  --muted: #6f6a74;
  --sky: #8ec7d1;
  --card-shadow: 0 18px 45px -20px rgba(11, 95, 109, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── shared motion (copied from the storefront's .pv-* chrome) ── */
@keyframes pv-pop {
  0%   { scale: 0.4; opacity: 0; }
  60%  { scale: 1.15; }
  100% { scale: 1; }
}

@keyframes pv-wiggle {
  0%   { transform: rotate(0deg) scale(1); }
  35%  { transform: rotate(-26deg) scale(1.3); }
  70%  { transform: rotate(6deg) scale(1.12); }
  100% { transform: rotate(-16deg) scale(1.2); }
}

/* ── login page ── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border: 1px solid var(--blush);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 22rem;
  text-align: center;
  animation: pv-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
}

.login-title {
  color: var(--teal);
  font-size: 1.15rem;
  margin: 0.9rem 0 0.15rem;
}

.login-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 1.4rem;
}

.login-form {
  display: grid;
  gap: 0.7rem;
}

.login-form input,
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--blush);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

.login-form input:focus,
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: 2px solid var(--sky);
  outline-offset: 1px;
  border-color: var(--teal);
}

.form-error {
  background: var(--pink);
  color: var(--rose-deep);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
}

/* ── buttons ── */
.btn-primary,
.btn-quiet,
.btn-danger {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-deep); }

.btn-quiet {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--blush);
}
.btn-quiet:hover { background: var(--paper); }

/* destructive: plain, explicit, never animated */
.btn-danger {
  background: var(--rose-deep);
  color: #fff;
}

/* the one earned wiggle: the "It's ready — email them" button's icon */
.btn-ready { background: var(--rose-deep); color: #fff; }
.btn-ready .btn-icon { display: inline-block; }
.btn-ready:hover .btn-icon,
.btn-ready:active .btn-icon {
  animation: pv-wiggle 0.5s ease forwards;
}

/* ── app shell ── */
.admin-body { min-height: 100vh; }

.admin-boot {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--blush);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo { width: 32px; height: 32px; border-radius: 50%; }
.topbar-title { color: var(--teal); font-weight: 700; font-size: 0.95rem; }
.topbar-user { margin-left: auto; color: var(--muted); font-size: 0.78rem; }

.screen {
  flex: 1;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem 1rem 5.5rem;   /* clear the tab bar */
}

/* ── bottom tab bar (mobile-first; desktop keeps it, it's honest) ── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: #fff;
  border-top: 1px solid var(--blush);
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
  z-index: 10;
}

.tab {
  display: grid;
  justify-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.62rem;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  border-radius: 10px;
}

.tab svg, .tab img { width: 22px; height: 22px; }

.tab[data-active="true"] {
  color: var(--teal);
  font-weight: 600;
}

.tab[data-active="true"] .tab-icon {
  animation: pv-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-badge {
  position: absolute;
  transform: translate(12px, -4px);
  background: var(--rose-deep);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  padding: 0 3px;
}

/* ── cards ── */
.card {
  background: #fff;
  border: 1px solid var(--blush);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.screen h1 {
  color: var(--teal);
  font-size: 1.15rem;
  margin: 0.5rem 0 1rem;
}

.screen h2 {
  color: var(--teal-deep);
  font-size: 0.95rem;
  margin: 1.2rem 0 0.6rem;
}

/* ── status pills (pencil-chip descendants) ── */
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.18rem 0.65rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.pill[data-status="pending"]     { border-color: var(--blush); color: var(--rose-deep); background: #fff; }
.pill[data-status="paid"]        { background: var(--teal); color: #fff; }
.pill[data-status="in-progress"] { background: var(--sky); color: var(--teal-deep); }
.pill[data-status="ready"]       { background: var(--rose-deep); color: #fff; }
.pill[data-status="completed"]   { background: var(--paper); color: var(--muted); }
.pill[data-status="cancelled"],
.pill[data-status="expired"],
.pill[data-status="refunded"]    { border-color: #d9d4d2; color: var(--muted); background: #fff; }

.pill[data-just-changed="true"] {
  animation: pv-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* message-kind pills */
/* the mailing list's statuses */
.pill[data-status="confirmed"]    { background: var(--teal); color: #fff; }
.pill[data-status="unsubscribed"],
.pill[data-status="bounced"],
.pill[data-status="complained"]   { border-color: #d9d4d2; color: var(--muted); background: #fff; }

.pill[data-kind="contact"]       { background: var(--paper); color: var(--teal-deep); border-color: var(--blush); }
.pill[data-kind="custom-order"]  { background: var(--pink); color: var(--rose-deep); }

/* ── count chips (Today) ── */
.chips { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.chip {
  background: #fff;
  border: 1px solid var(--blush);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  display: grid;
  gap: 0.1rem;
  min-width: 7.5rem;
}

.chip-num { color: var(--teal); font-size: 1.35rem; font-weight: 700; }
.chip-label { color: var(--muted); font-size: 0.72rem; }

/* ── plain data (restraint zone) ── */
.data-list { list-style: none; margin: 0; padding: 0; }

.data-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.4rem;
  border-bottom: 1px solid var(--paper);
  transition: background-color 0.15s ease;
}

.data-list li:hover { background: var(--paper); }

.data-main { flex: 1; min-width: 0; }
.data-title { font-weight: 600; font-size: 0.88rem; }
.data-sub { color: var(--muted); font-size: 0.76rem; }
.data-amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── forms ── */
.form-field { display: grid; gap: 0.25rem; margin-bottom: 0.8rem; }
.form-field label { font-size: 0.76rem; font-weight: 600; color: var(--teal-deep); }

/* checkboxes keep their natural size under the label, not the full-width
   text-input treatment */
.form-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  justify-self: start;
  accent-color: var(--teal);
}

/* ── empty states ── */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty-state img { width: 96px; opacity: 0.85; }

/* ── confirm dialog (restraint zone: plain, explicit) ── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 46, 45, 0.35);
  display: grid;
  place-items: center;
  z-index: 40;
}

.dialog {
  background: #fff;
  border-radius: 12px;
  padding: 1.3rem 1.4rem;
  max-width: 20rem;
  width: calc(100% - 2rem);
}

.dialog p { margin: 0 0 1rem; font-size: 0.9rem; }
.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

/* ── reduced motion: everything settles instantly ── */
@media (prefers-reduced-motion: reduce) {
  .login-card,
  .tab[data-active="true"] .tab-icon,
  .pill[data-just-changed="true"],
  .btn-ready:hover .btn-icon,
  .btn-ready:active .btn-icon {
    animation: none;
  }
}

/* ── desktop: tabs centered in the header, clear of the email at right ── */
@media (min-width: 900px) {
  .tabbar {
    top: 0;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    border-top: none;
    background: transparent;
    padding: 0.45rem 0.75rem;
  }

  .tab { font-size: 0.7rem; }
  .screen { padding-top: 1.5rem; padding-bottom: 2rem; }
}

/* ── market mode ─────────────────────────────────────────────────────────── */

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.market-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1.5px solid var(--blush);
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.market-item:active { background: var(--pink); }
.market-item:disabled { opacity: 0.45; cursor: default; }
.market-item-name { font-weight: 600; font-size: 0.85rem; }
.market-item-sub { font-size: 0.75rem; color: var(--muted); }

.market-tally { padding: 1rem 1.1rem; }
.market-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}
.market-line-name { flex: 1; min-width: 0; }
.market-line-label { color: var(--muted); }
.market-line-ctl { display: flex; align-items: center; gap: 0.35rem; }
.market-step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--blush);
  background: #fff;
  color: var(--teal);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.market-line-qty { min-width: 1.2em; text-align: center; font-variant-numeric: tabular-nums; }
.market-line-amt { min-width: 4.2em; text-align: right; font-variant-numeric: tabular-nums; }
.market-total {
  display: flex;
  justify-content: space-between;
  border-top: 1.5px dashed var(--rose);
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  font-weight: 700;
}
.market-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* customer-facing takeover: covers the admin chrome (topbar, tabs) entirely —
   the screen belongs to the shop, not the admin, while it faces the customer */
.market-takeover {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.4rem
           calc(1.1rem + env(safe-area-inset-bottom));
  text-align: center;
}
.market-takeover-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.market-takeover-brand img { width: 26px; height: 26px; border-radius: 8px; }
.market-takeover-main {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.market-takeover-cta { font-size: 1.35rem; font-weight: 700; margin: 0; }
.market-takeover-total {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  font-variant-numeric: tabular-nums;
}
.market-takeover .market-qr { width: min(78%, 55vh, 420px); max-width: none; }
.market-takeover-items {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.6rem 0 0;
  max-width: 32ch;
}

/* hold-to-cancel: the fill sweeps over 1.5s — keep in sync with hold-ms in
   market.cljs. Releasing early removes .holding, so the fill snaps back. */
.market-hold {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  border: 1.5px solid var(--blush);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 1.7rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.market-hold-fill {
  position: absolute;
  inset: 0;
  background: var(--pink);
  transform: scaleX(0);
  transform-origin: left center;
}
.market-hold.holding .market-hold-fill {
  transform: scaleX(1);
  transition: transform 1.5s linear;
}
.market-hold-label { position: relative; }

.market-qr { max-width: 320px; margin: 0 auto; }
.market-qr svg { display: block; width: 100%; height: auto; border-radius: 12px; }

/* the honor stand's printable QR, under the tally */
.market-stand { padding: 1rem 1.1rem; margin-top: 1rem; }
.market-stand-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}
.market-stand-body { margin-top: 0.9rem; text-align: center; }
.market-stand-body .market-qr { max-width: 200px; }
.market-stand-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  margin: 0.5rem 0 0.25rem;
}
/* the shelves (signs) manager under the QR */
.stand-shelves { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.9rem; }
.stand-shelf {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.stand-shelf-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.15rem 0;
  font: inherit;
  color: inherit;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stand-shelf-name:hover { color: var(--teal); }
.stand-shelf-input { flex: 1; min-width: 0; }
.stand-shelf-count { flex: 0 0 auto; white-space: nowrap; }
.stand-shelf-ctl { display: flex; gap: 0.1rem; flex: 0 0 auto; }
.stand-shelf-ctl .btn-quiet { padding: 0.1rem 0.45rem; }
.stand-shelf-ctl .btn-quiet:disabled { opacity: 0.35; cursor: default; }
.stand-shelf-new { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.stand-shelf-new input { flex: 1; min-width: 0; }
.market-wait { color: var(--muted); font-size: 0.9rem; margin: 0.8rem 0 1rem; }
.market-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  margin-right: 0.45em;
}
@media (prefers-reduced-motion: no-preference) {
  .market-dot { animation: market-pulse 1.6s ease-in-out infinite; }
  @keyframes market-pulse { 50% { opacity: 0.25; } }
}
.market-paid-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 1.7rem;
  line-height: 54px;
}
.market-paid-note { color: var(--muted); margin: -0.3rem 0 1rem; }
