/* ============================================================================
   ClayPOS — Claymorphism Design System
   Mobile-first. All colors/geometry flow from the :root tokens below.
   Raised clay = soft outer drop shadow + dual INNER shadows
   (light top-left, dark bottom-right). Pressed clay inverts them.
   ========================================================================== */

:root {
  /* ---- Surface palette (matte pastels) -------------------------------- */
  --clay-bg:            #EDEAF6;   /* lavender mist page background        */
  --clay-surface:       #F6F3FC;   /* card/button base                     */
  --clay-surface-deep:  #E3DEF1;   /* wells, input troughs                 */

  /* ---- Accent pastels -------------------------------------------------- */
  --clay-primary:       #B9A5F0;   /* lilac  — primary actions             */
  --clay-primary-deep:  #9B82E0;
  --clay-success:       #A8E6CF;   /* mint   — pay/confirm                 */
  --clay-success-deep:  #7BCFAC;
  --clay-warning:       #FFD3A5;   /* peach  — attention                   */
  --clay-danger:        #FFAAA5;   /* rose   — void/delete                 */
  --clay-danger-deep:   #F2837C;
  --clay-info:          #A5D8FF;   /* sky    — neutral highlights          */

  /* ---- Ink ------------------------------------------------------------- */
  --clay-text:          #4A4458;
  --clay-text-soft:     #837B96;
  --clay-text-onaccent: #3A3060;

  /* ---- Shadow recipes --------------------------------------------------- */
  --clay-shadow-drop:   10px 10px 22px rgba(93, 84, 120, 0.20),
                        -8px -8px 18px rgba(255, 255, 255, 0.90);
  --clay-shadow-inner:  inset 4px 4px 8px rgba(255, 255, 255, 0.70),
                        inset -4px -4px 8px rgba(0, 0, 0, 0.10);
  /* raised = drop + dual inner highlights */
  --clay-raised:        var(--clay-shadow-drop), var(--clay-shadow-inner);
  /* pressed / debossed = dual inner shadows only, inverted orientation */
  --clay-pressed:       inset 4px 4px 8px rgba(0, 0, 0, 0.10),
                        inset -4px -4px 8px rgba(255, 255, 255, 0.70);

  /* ---- Geometry --------------------------------------------------------- */
  --clay-radius:        24px;
  --clay-radius-sm:     16px;
  --clay-radius-lg:     32px;
  --clay-radius-full:   999px;

  --clay-gap:           16px;
  --clay-touch:         48px;      /* minimum touch target                 */
  --clay-tabbar-h:      68px;

  --clay-font: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--clay-font);
  background: var(--clay-bg);
  color: var(--clay-text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* keep content clear of the fixed tab bar + phone home indicator */
  padding-bottom: calc(var(--clay-tabbar-h) + env(safe-area-inset-bottom));
}

body.no-tabbar { padding-bottom: 0; }

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================================================
   LAYOUT PRIMITIVES
   ========================================================================== */

.clay-page {
  max-width: 480px;                 /* phone-first canvas */
  margin: 0 auto;
  padding: var(--clay-gap);
  display: flex;
  flex-direction: column;
  gap: var(--clay-gap);
}

/* Widen for tablets / desktop without changing the phone experience */
@media (min-width: 768px)  { .clay-page { max-width: 720px; } }
@media (min-width: 1100px) { .clay-page { max-width: 1000px; } }

.clay-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
}
.clay-topbar h1 { font-size: 1.35rem; font-weight: 800; }
.clay-topbar .sub { color: var(--clay-text-soft); font-size: 0.85rem; }

.clay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--clay-gap);
}
.clay-grid--tight { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }

.clay-row { display: flex; align-items: center; gap: 12px; }
.clay-row--between { justify-content: space-between; }
.clay-stack { display: flex; flex-direction: column; gap: 12px; }

/* ============================================================================
   CORE CLAY SURFACES
   ========================================================================== */

.clay-card {
  background: var(--clay-surface);
  border-radius: var(--clay-radius);
  box-shadow: var(--clay-raised);
  padding: 20px;
}

.clay-card--flush { padding: 12px; }

/* A recessed "well" — carved into the page rather than sitting on it */
.clay-well {
  background: var(--clay-surface-deep);
  border-radius: var(--clay-radius);
  box-shadow: var(--clay-pressed);
  padding: 16px;
}

/* ============================================================================
   BUTTONS — every variant guarantees the 48px touch target
   ========================================================================== */

.clay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--clay-touch);
  min-width: var(--clay-touch);
  padding: 12px 22px;
  border-radius: var(--clay-radius);
  background: var(--clay-surface);
  box-shadow: var(--clay-raised);
  font-weight: 800;
  font-size: 1rem;
  color: var(--clay-text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

/* The tactile squish: pressing sinks the button into the clay */
.clay-btn:active,
.clay-btn.is-pressed {
  box-shadow: var(--clay-pressed);
  transform: translateY(1px) scale(0.985);
}

.clay-btn:disabled { opacity: 0.45; pointer-events: none; }

.clay-btn--primary { background: var(--clay-primary); color: var(--clay-text-onaccent); }
.clay-btn--success { background: var(--clay-success); color: #1F4D3A; }
.clay-btn--danger  { background: var(--clay-danger);  color: #5C1F1B; }
.clay-btn--warning { background: var(--clay-warning); color: #5C3A12; }

.clay-btn--block { display: flex; width: 100%; }
.clay-btn--lg    { min-height: 60px; font-size: 1.15rem; border-radius: var(--clay-radius-lg); }

/* Icon-only round button (qty steppers, scanner toggle, back arrows) */
.clay-btn--icon {
  width: var(--clay-touch);
  height: var(--clay-touch);
  padding: 0;
  border-radius: var(--clay-radius-full);
}

/* ============================================================================
   FORMS — inputs are recessed troughs in the clay
   ========================================================================== */

.clay-field { display: flex; flex-direction: column; gap: 8px; }
.clay-field label { font-weight: 700; font-size: 0.9rem; padding-left: 6px; }

.clay-input,
.clay-select,
.clay-textarea {
  width: 100%;
  min-height: var(--clay-touch);
  padding: 12px 18px;
  border: 0;
  border-radius: var(--clay-radius);
  background: var(--clay-surface-deep);
  box-shadow: var(--clay-pressed);
  outline: none;
}

.clay-input::placeholder { color: var(--clay-text-soft); }

.clay-input:focus,
.clay-select:focus,
.clay-textarea:focus {
  box-shadow: var(--clay-pressed), 0 0 0 3px var(--clay-primary);
}

.clay-input--error,
.clay-input--error:focus {
  box-shadow: var(--clay-pressed), 0 0 0 3px var(--clay-danger);
}

.clay-error-text { color: #B4423B; font-size: 0.85rem; padding-left: 6px; }

/* Toggle switch (MailChimp sync, active flags) */
.clay-toggle { position: relative; display: inline-block; width: 64px; height: 36px; }
.clay-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.clay-toggle .track {
  position: absolute; inset: 0;
  border-radius: var(--clay-radius-full);
  background: var(--clay-surface-deep);
  box-shadow: var(--clay-pressed);
  transition: background 150ms ease;
}
.clay-toggle .track::after {
  content: "";
  position: absolute; top: 4px; left: 4px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--clay-surface);
  box-shadow: var(--clay-shadow-drop), var(--clay-shadow-inner);
  transition: transform 150ms ease;
}
.clay-toggle input:checked + .track { background: var(--clay-success); }
.clay-toggle input:checked + .track::after { transform: translateX(28px); }

/* ============================================================================
   CHIPS, BADGES, ALERTS
   ========================================================================== */

.clay-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--clay-radius-full);
  background: var(--clay-surface);
  box-shadow: var(--clay-raised);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}
.clay-chip.is-active {
  background: var(--clay-primary);
  color: var(--clay-text-onaccent);
  box-shadow: var(--clay-pressed);
}

.clay-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--clay-radius-full);
  background: var(--clay-danger);
  color: #5C1F1B;
  font-size: 0.78rem;
  font-weight: 800;
}

.clay-alert {
  border-radius: var(--clay-radius);
  box-shadow: var(--clay-pressed);
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.95rem;
}
.clay-alert--error   { background: #FBD9D7; color: #7A2822; }
.clay-alert--success { background: #D9F3E6; color: #1F4D3A; }
.clay-alert--info    { background: #DCEDFD; color: #234A6B; }

/* ============================================================================
   BOTTOM TAB BAR — fixed, thumb-reach navigation
   ========================================================================== */

.clay-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: calc(var(--clay-tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--clay-surface);
  border-radius: var(--clay-radius-lg) var(--clay-radius-lg) 0 0;
  box-shadow: 0 -8px 24px rgba(93, 84, 120, 0.18), var(--clay-shadow-inner);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

/* On wide screens the bar becomes a floating pill so it never spans oddly */
@media (min-width: 768px) {
  .clay-tabbar {
    left: 50%; right: auto; bottom: 12px;
    transform: translateX(-50%);
    width: 480px;
    border-radius: var(--clay-radius-lg);
    box-shadow: var(--clay-raised);
  }
}

.clay-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--clay-touch);
  border-radius: var(--clay-radius-sm);
  color: var(--clay-text-soft);
  font-size: 0.72rem;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
}
.clay-tab svg { width: 24px; height: 24px; }
.clay-tab.is-active {
  color: var(--clay-text-onaccent);
  background: var(--clay-primary);
  box-shadow: var(--clay-pressed);
}
.clay-tab:active { box-shadow: var(--clay-pressed); }

/* ============================================================================
   MODAL SHEET — slides up from the bottom, mobile-app style
   ========================================================================== */

.clay-sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(74, 68, 88, 0.35);
  display: none;
}
.clay-sheet-backdrop.is-open { display: block; }

.clay-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--clay-surface);
  border-radius: var(--clay-radius-lg) var(--clay-radius-lg) 0 0;
  box-shadow: 0 -10px 30px rgba(93, 84, 120, 0.30), var(--clay-shadow-inner);
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform 220ms cubic-bezier(0.3, 1.1, 0.4, 1);
}
.clay-sheet.is-open { transform: translateY(0); }
.clay-sheet .grab {
  width: 48px; height: 5px;
  margin: 4px auto 14px;
  border-radius: var(--clay-radius-full);
  background: var(--clay-surface-deep);
  box-shadow: var(--clay-pressed);
}

@media (min-width: 768px) {
  .clay-sheet {
    left: 50%; right: auto; bottom: 50%;
    transform: translate(-50%, 50%) scale(0.96);
    opacity: 0;
    pointer-events: none;
    width: min(560px, 92vw);
    border-radius: var(--clay-radius-lg);
  }
  .clay-sheet.is-open {
    transform: translate(-50%, 50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}

/* ============================================================================
   TOAST
   ========================================================================== */

.clay-toast {
  position: fixed;
  left: 50%; bottom: calc(var(--clay-tabbar-h) + 20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 120;
  background: var(--clay-text);
  color: #F6F3FC;
  padding: 12px 22px;
  border-radius: var(--clay-radius-full);
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.clay-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================================
   UTILITIES
   ========================================================================== */

.u-center   { text-align: center; }
.u-muted    { color: var(--clay-text-soft); }
.u-bold     { font-weight: 800; }
.u-price    { font-variant-numeric: tabular-nums; font-weight: 800; }
.u-mt-1     { margin-top: 8px; }
.u-mt-2     { margin-top: 16px; }
.u-mt-3     { margin-top: 24px; }
.u-hidden   { display: none !important; }
.u-scroll-x { overflow-x: auto; display: flex; gap: 10px; padding: 4px; scrollbar-width: none; }
.u-scroll-x::-webkit-scrollbar { display: none; }

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
