/* Layout: one mobile column of gift "tags" in a 2-up grid, a sticky header with the bag,
   and bottom sheets for product details and the bag. Wider screens get 3–4 columns. */
/* Brand palette from the UniGifts by Sahar logo: navy, magenta, orange, teal, green on cream. */
:root {
  --tissue: #FFF8EF;      /* page ground: warm paper */
  --card: #FFFFFF;
  --ink: #1E2A4A;         /* brand navy */
  --ink-soft: #5D6180;
  --line: #EFE3DA;
  --ribbon: #D81B72;      /* brand magenta */
  --ribbon-ink: #FFFFFF;
  --ribbon-soft: #FCE2EE;
  --sun: #F7931E;         /* brand orange */
  --teal: #14A7B5;
  --leaf: #6CBF3F;
  --whatsapp: #128C4A;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(31, 36, 64, .06), 0 8px 24px rgba(31, 36, 64, .08);
  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tissue: #141728; --card: #1E2238; --ink: #F3F1F8; --ink-soft: #B3B6CE; --line: #33385A;
    --ribbon: #FF5C9E; --ribbon-ink: #2A0716; --ribbon-soft: #43203A; --sun: #FFA347; --teal: #3CC8D8; --leaf: #5CCB78;
    --whatsapp: #3FCB7E; --danger: #FF8A80;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tissue: #141728; --card: #1E2238; --ink: #F3F1F8; --ink-soft: #B3B6CE; --line: #33385A;
  --ribbon: #FF5C9E; --ribbon-ink: #2A0716; --ribbon-soft: #43203A; --sun: #FFA347; --teal: #3CC8D8; --leaf: #5CCB78;
  --whatsapp: #3FCB7E; --danger: #FF8A80;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--tissue); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ribbon); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: 16px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--tissue) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 72px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; flex: 1; min-width: 0; text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand .logo { height: 58px; width: auto; display: block; }
.brand .admin-tag { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.brand b { font-weight: 800; background: linear-gradient(90deg, var(--ribbon), var(--sun)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.signin-link {
  flex: none; color: var(--ink); font-weight: 700; text-decoration: none; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card);
}
.signin-link:hover { border-color: var(--ink); }
.bag-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: var(--ink); color: var(--tissue); border-radius: 999px; padding: 9px 16px; font-weight: 700;
}
.bag-btn .count {
  min-width: 22px; height: 22px; border-radius: 11px; background: var(--ribbon); color: var(--ribbon-ink);
  font-size: .8rem; display: inline-grid; place-items: center; padding: 0 6px; font-variant-numeric: tabular-nums;
}
.bag-btn.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

/* ---------- intro ---------- */
.intro { padding-block: 22px 8px; display: grid; gap: 6px; }
.intro h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 6vw, 2.6rem); line-height: 1.05; margin: 0; letter-spacing: -.03em; text-wrap: balance; }
.intro h1 em { font-style: normal; background: linear-gradient(90deg, var(--ribbon), var(--sun)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.intro p { margin: 0; color: var(--ink-soft); max-width: 46ch; }
.group-link {
  justify-self: start; margin-top: 6px; display: inline-flex; align-items: center; gap: 6px;
  color: var(--whatsapp); font-weight: 700; text-decoration: none; border: 1.5px solid currentColor; border-radius: 999px; padding: 7px 14px; font-size: .92rem;
}
.demo-banner a { color: var(--ribbon); font-weight: 700; }
.demo-banner { margin-top: 12px; background: var(--ribbon-soft); color: var(--ink); border-radius: 12px; padding: 10px 14px; font-size: .9rem; }

/* ---------- filters ---------- */
.filters { display: grid; gap: 10px; padding-block: 14px 6px; }
.search {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 11px 16px; font-size: 1rem;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .92rem;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--tissue); border-color: var(--ink); box-shadow: inset 0 -3px 0 var(--sun); }

/* ---------- product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-block: 12px 40px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left; border: 0; padding: 0;
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-width: 0;
  transition: transform .15s ease;
}
.card:active { transform: scale(.98); }
.card .ph { aspect-ratio: 1; width: 100%; background: var(--ribbon-soft); object-fit: cover; }
.card .body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.card .name { font-weight: 700; line-height: 1.25; font-size: .98rem; overflow-wrap: anywhere; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.price { font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 4px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); background: var(--sw, var(--line)); }
.tag {
  position: absolute; top: 10px; left: 10px; background: var(--ink); color: var(--tissue);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
}
.tag.low { background: var(--sun); color: #1E2A4A; }
.card.soldout .ph { filter: grayscale(.7); opacity: .65; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); padding: 40px 0; }
.skeleton { aspect-ratio: .78; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--ribbon-soft), var(--card)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- sheets (product + bag) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 8, 18, .45); z-index: 40; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  padding-bottom: env(safe-area-inset-bottom, 0px); animation: up .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, calc(100% - 32px)); transform: translate(-50%, -50%); border-radius: 22px; max-height: 88vh; animation: fade .2s ease; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 1.25rem; letter-spacing: -.02em; }
.icon-btn { border: 0; background: var(--tissue); width: 38px; height: 38px; border-radius: 50%; font-size: 1.2rem; line-height: 1; display: grid; place-items: center; flex: none; }
.sheet-body { padding: 16px; display: grid; gap: 16px; }

.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 16px; background: var(--ribbon-soft); scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; aspect-ratio: 1; object-fit: cover; scroll-snap-align: center; }
.gallery-dots { display: flex; justify-content: center; gap: 6px; margin-top: -6px; }
.gallery-dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: var(--line); }
.gallery-dots button.on { background: var(--ribbon); }
.gallery-wrap { position: relative; }
.gal-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.92); color: #1E2A4A; font-size: 1.9rem; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); padding-bottom: 4px;
}
.gal-arrow.prev { left: 10px; }
.gal-arrow.next { right: 10px; }
.gal-arrow:hover { background: #fff; }
.detail-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.detail-title h3 { margin: 0; font-family: var(--font-display); font-size: 1.4rem; line-height: 1.15; letter-spacing: -.02em; min-width: 0; overflow-wrap: anywhere; }
.detail-title .price { font-size: 1.35rem; color: var(--ribbon); white-space: nowrap; }
.desc { margin: 0; color: var(--ink-soft); white-space: pre-line; }
.label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-bottom: 8px; }
.color-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.color-opt { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px 7px 8px; font-weight: 600; }
.color-opt .dot { width: 18px; height: 18px; }
.color-opt.no-sw { padding-left: 14px; }
.color-opt[aria-pressed="true"] { border-color: var(--ribbon); background: var(--ribbon-soft); }
.stock-note { font-size: .9rem; color: var(--ink-soft); }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { border: 0; background: transparent; width: 40px; height: 38px; font-size: 1.2rem; font-weight: 700; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn {
  background-image: linear-gradient(100deg, var(--ribbon), color-mix(in srgb, var(--ribbon) 70%, var(--sun)));
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 14px 20px; font-weight: 800; font-size: 1rem; background: var(--ribbon); color: var(--ribbon-ink); width: 100%;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--tissue); background-image: none; color: var(--ink); border: 1px solid var(--line); }
.btn.wa { background: var(--whatsapp); background-image: none; color: #fff; }
.btn.small { width: auto; padding: 9px 14px; font-size: .9rem; }
.btn.danger { background: transparent; background-image: none; color: var(--danger); border: 1px solid currentColor; }
.add-row { display: flex; gap: 12px; align-items: center; }
.add-row .btn { flex: 1; }

/* bag */
.bag-items { display: grid; gap: 12px; }
.bag-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.bag-item img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--ribbon-soft); }
.bag-item .info { min-width: 0; display: grid; gap: 6px; }
.bag-item .top { display: flex; justify-content: space-between; gap: 8px; }
.bag-item .nm { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.bag-item .meta { font-size: .88rem; color: var(--ink-soft); }
.bag-item .bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.bag-item .line-total { font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.link-btn { border: 0; background: none; color: var(--ink-soft); text-decoration: underline; padding: 0; font-size: .85rem; }
.warn { color: var(--danger); font-size: .85rem; }
.totals { display: grid; gap: 4px; background: var(--tissue); border-radius: 14px; padding: 14px 16px; }
.totals .r { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.totals .grand { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: .92rem; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 13px; font-size: 1rem;
}
.field textarea { min-height: 76px; resize: vertical; }
.hint { font-size: .85rem; color: var(--ink-soft); margin: 0; }
.bag-empty { text-align: center; padding: 30px 0; color: var(--ink-soft); display: grid; gap: 12px; justify-items: center; }

.toast {
  position: fixed; left: 50%; top: calc(84px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--tissue); padding: 11px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); text-align: center; animation: up .2s ease;
}
footer { border-top: 1px solid var(--line); padding-block: 22px 40px; color: var(--ink-soft); font-size: .9rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: inherit; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
footer a:hover { color: var(--ribbon); }

/* ---------- admin ---------- */
.admin-main { padding-block: 20px 60px; display: grid; gap: 16px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; }
.login { max-width: 420px; margin: 40px auto; }
.login h1, .admin-head h1 { font-family: var(--font-display); margin: 0; letter-spacing: -.02em; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; color: var(--ink-soft); font-size: .92rem; }
.stats span { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.admin-list { display: grid; gap: 10px; }
.arow { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 12px; background: var(--card); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); align-items: center; }
.arow img { width: 60px; height: 60px; border-radius: 12px; object-fit: cover; background: var(--ribbon-soft); }
.arow .info { min-width: 0; display: grid; gap: 6px; }
.arow .nm { font-weight: 700; overflow-wrap: anywhere; }
.arow .sub { font-size: .86rem; color: var(--ink-soft); }
.arow .ctrls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.arow.hidden-item { opacity: .6; }
.pill { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--tissue); border: 1px solid var(--line); }
.pill.out { background: var(--ribbon-soft); color: var(--ink); border-color: transparent; }
.form-grid { display: grid; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--ribbon); }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo { position: relative; width: 84px; height: 84px; }
.photo img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.photo .x { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ink); color: var(--tissue); font-size: .9rem; }
.photo .main { position: absolute; bottom: 4px; left: 4px; font-size: .65rem; background: var(--ink); color: var(--tissue); padding: 1px 6px; border-radius: 6px; }
.photo-add { width: 84px; height: 84px; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; text-align: center; font-size: .8rem; font-weight: 700; color: var(--ink-soft); cursor: pointer; padding: 6px; }
.photo-add input { display: none; }
.err { color: var(--danger); font-weight: 600; margin: 0; }
.confirm-box { background: var(--ribbon-soft); border-radius: 14px; padding: 12px 14px; display: grid; gap: 10px; }
.confirm-box .row { display: flex; gap: 8px; flex-wrap: wrap; }

.optional { font-weight: 400; color: var(--ink-soft); }
.sent { display: grid; gap: 14px; justify-items: center; text-align: center; padding-block: 16px; }
.sent p { margin: 0; max-width: 34ch; }
.sent-check { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 800; background: var(--whatsapp); color: #fff; }

/* ---------- laptop and desktop ---------- */
@media (min-width: 700px) {
  /* Bag slides in from the right like a cart drawer */
  .sheet#bagSheet {
    left: auto; right: 0; top: 0; bottom: 0; transform: none; width: min(440px, 100%); max-height: none; height: 100%;
    border-radius: 22px 0 0 22px; animation: slideIn .25s cubic-bezier(.2,.8,.2,1);
  }
  .grid { gap: 20px; }
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
@media (min-width: 900px) {
  /* Product details: photo on the left, info on the right */
  .sheet#productSheet { width: min(900px, calc(100% - 48px)); }
  #productSheet .sheet-body { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); column-gap: 28px; row-gap: 14px; align-content: start; padding: 24px; }
  #productSheet .sheet-body > :first-child { grid-row: 1 / span 6; position: sticky; top: 24px; }
  #productSheet .sheet-body > :not(:first-child) { grid-column: 2; }
  .intro { padding-block: 34px 8px; }
  .filters { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); align-items: center; gap: 16px; }
  .admin-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet#editSheet { width: min(640px, calc(100% - 48px)); }
}
@media (min-width: 1200px) {
  .wrap { max-width: 1240px; }
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Netlify adds a "Powered by Netlify" badge in the bottom corner; keep buttons clear of it */
.sheet-body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
footer { padding-bottom: 110px; }
.admin-main { padding-bottom: 120px; }
.color-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.color-preview .color-opt { padding-block: 4px; font-size: .88rem; cursor: default; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
