/* StockChecker web — accessible-first design system.
   Built for older / less tech-savvy warehouse users: huge targets, big type,
   high contrast, one decision per screen. Mobile-first, scales to tablet/desktop. */

:root {
  /* brand */
  --navy: #15233f;
  --navy-700: #1d3157;
  --navy-50: #eef2f9;
  --ink: #16203a;
  --paper: #f4f6fb;
  --card: #ffffff;
  --line: #d8deeb;
  --muted: #59657f;

  /* action colours — deliberately blunt so meaning is obvious */
  --take: #c4361f;       /* Take Out  (stock leaves) */
  --take-700: #9c2917;
  --put: #1f8a4c;        /* Put Back  (stock returns) */
  --put-700: #166c3a;
  --warn: #b9791a;
  --warn-bg: #fff5e3;
  --danger-bg: #fdeceA;

  /* type scale — driven by --ui-scale so the A+ button can grow everything */
  --ui-scale: 1;
  --fs-base: calc(19px * var(--ui-scale));
  --fs-lg: calc(24px * var(--ui-scale));
  --fs-xl: calc(32px * var(--ui-scale));
  --fs-huge: calc(44px * var(--ui-scale));

  --tap: 64px;           /* minimum interactive height */
  --radius: 18px;
  --shadow: 0 6px 22px rgba(21, 35, 63, 0.10);
  --shadow-lg: 0 14px 40px rgba(21, 35, 63, 0.18);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}

/* ---- app shell ---- */
.app { max-width: 760px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.topbar img.logo { height: 38px; width: auto; border-radius: 8px; background: #fff; padding: 3px; }
.topbar .title { font-size: var(--fs-lg); font-weight: 800; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }

.iconbtn {
  min-width: 52px; min-height: 52px;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.10);
  color: #fff; border-radius: 14px;
  font-size: var(--fs-lg); font-weight: 800;
  cursor: pointer;
}
.iconbtn:active { transform: scale(.96); }

.view { padding: 18px 16px 110px; flex: 1; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- big primary action buttons ---- */
.bigbtn {
  display: flex; align-items: center; gap: 16px;
  width: 100%;
  min-height: 96px;
  border: none; border-radius: var(--radius);
  color: #fff;
  font-size: var(--fs-xl); font-weight: 800;
  padding: 0 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
}
.bigbtn .emoji { font-size: calc(40px * var(--ui-scale)); line-height: 1; }
.bigbtn small { display: block; font-size: var(--fs-base); font-weight: 600; opacity: .92; }
.bigbtn:active { transform: scale(.985); }
.bigbtn.take { background: linear-gradient(135deg, var(--take), var(--take-700)); }
.bigbtn.put  { background: linear-gradient(135deg, var(--put), var(--put-700)); }
.bigbtn.row  { margin-bottom: 14px; }

/* secondary tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tile {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  min-height: var(--tap); padding: 16px; cursor: pointer; text-align: left;
  font-size: var(--fs-base); font-weight: 700; color: var(--ink);
  display: flex; flex-direction: column; gap: 4px;
}
.tile .em { font-size: calc(28px * var(--ui-scale)); }
.tile small { font-weight: 600; color: var(--muted); }
.tile:active { transform: scale(.98); }

/* ---- search ---- */
.search { position: relative; margin-bottom: 16px; }
.search input {
  width: 100%; min-height: var(--tap);
  font-size: var(--fs-lg);
  padding: 0 18px 0 54px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2359657f' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4-4'/%3E%3C/svg%3E") no-repeat 16px center / 26px;
}
.search input:focus { outline: 4px solid #9fc0ff; border-color: var(--navy); }

/* ---- item cards / list ---- */
.itemgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .itemgrid { grid-template-columns: 1fr 1fr; } }

.itemcard {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; min-height: 84px; cursor: pointer; text-align: left; width: 100%;
}
.itemcard:active { transform: scale(.99); }
.itemcard .thumb {
  width: 58px; height: 58px; border-radius: 14px; flex: none;
  background: var(--navy-50); display: flex; align-items: center; justify-content: center;
  font-size: 28px; overflow: hidden;
}
.itemcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.itemcard .meta { flex: 1; min-width: 0; }
.itemcard .name { font-size: var(--fs-lg); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.itemcard .cat { color: var(--muted); font-weight: 600; }
.badge {
  flex: none; padding: 8px 14px; border-radius: 999px; font-weight: 800;
  font-size: var(--fs-base); background: var(--navy-50); color: var(--navy);
  white-space: nowrap;
}
.badge.low { background: var(--warn-bg); color: var(--warn); }
.badge.out { background: var(--danger-bg); color: var(--take); }

/* ---- chips (size / site / who) ---- */
.field-label { font-size: var(--fs-lg); font-weight: 800; margin: 18px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 58px; padding: 0 20px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card);
  font-size: var(--fs-base); font-weight: 700; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip .sub { font-weight: 600; opacity: .8; }
.chip:active { transform: scale(.97); }

/* ---- quantity stepper ---- */
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 8px 0 4px; }
.stepper button {
  width: 86px; height: 86px; border-radius: 50%;
  border: none; color: #fff; font-size: 46px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow); line-height: 0;
}
.stepper button.minus { background: var(--navy-700); }
.stepper button.plus { background: var(--navy); }
.stepper button:disabled { opacity: .35; }
.stepper button:active { transform: scale(.92); }
.stepper .count { font-size: var(--fs-huge); font-weight: 800; min-width: 92px; text-align: center; }
.qty-note { text-align: center; color: var(--muted); font-weight: 600; margin-top: 4px; }

/* ---- the big item header on the action screen ---- */
.item-hero { display: flex; align-items: center; gap: 16px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.item-hero .thumb { width: 78px; height: 78px; border-radius: 16px; background: var(--navy-50); display: flex; align-items: center; justify-content: center; font-size: 38px; overflow: hidden; }
.item-hero .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-hero .name { font-size: var(--fs-xl); font-weight: 800; }
.item-hero .cat { color: var(--muted); font-weight: 600; }

/* ---- confirm bar (sticky) ---- */
.confirmbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(244,246,251,0), var(--paper) 30%);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.confirmbar .confirm {
  width: 100%; min-height: 78px; border: none; border-radius: var(--radius);
  color: #fff; font-size: var(--fs-xl); font-weight: 800; cursor: pointer; box-shadow: var(--shadow-lg);
}
.confirmbar .confirm.take { background: linear-gradient(135deg, var(--take), var(--take-700)); }
.confirmbar .confirm.put { background: linear-gradient(135deg, var(--put), var(--put-700)); }
.confirmbar .confirm:disabled { background: #aeb6c7; box-shadow: none; }

/* ---- back / nav ---- */
.backbtn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 0 18px 0 12px; margin-bottom: 6px;
  border: 2px solid var(--line); background: var(--card); border-radius: 14px;
  font-size: var(--fs-base); font-weight: 800; color: var(--ink); cursor: pointer;
}
.backbtn:active { transform: scale(.97); }
.screen-title { font-size: var(--fs-xl); font-weight: 800; margin: 8px 0 16px; }

/* ---- alert strip ---- */
.alertstrip {
  display: flex; align-items: center; gap: 12px;
  background: var(--warn-bg); border: 2px solid #f0d9a8; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; font-weight: 700; color: #7a5310; cursor: pointer;
}
.alertstrip .em { font-size: calc(26px * var(--ui-scale)); }
.alertstrip .count { margin-left: auto; background: var(--warn); color: #fff; padding: 4px 12px; border-radius: 999px; font-weight: 800; }

/* ---- success overlay ---- */
.success {
  position: fixed; inset: 0; z-index: 50; background: rgba(21,35,63,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease;
}
.success .card {
  background: #fff; border-radius: 24px; padding: 30px 24px; text-align: center;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.success .tick { font-size: 72px; }
.success .msg { font-size: var(--fs-xl); font-weight: 800; margin: 8px 0 4px; }
.success .sub { color: var(--muted); font-weight: 600; margin-bottom: 22px; }
.success .undo {
  width: 100%; min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line);
  background: #fff; font-size: var(--fs-base); font-weight: 800; cursor: pointer; margin-bottom: 10px;
}
.success .done {
  width: 100%; min-height: var(--tap); border-radius: 14px; border: none;
  background: var(--navy); color: #fff; font-size: var(--fs-lg); font-weight: 800; cursor: pointer;
}

/* ---- history rows ---- */
.logrow { display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.logrow .pill { flex: none; padding: 6px 12px; border-radius: 999px; font-weight: 800; }
.logrow .pill.out { background: var(--danger-bg); color: var(--take); }
.logrow .pill.in { background: #e7f6ec; color: var(--put-700); }
.logrow .meta { flex: 1; min-width: 0; }
.logrow .l1 { font-weight: 800; }
.logrow .l2 { color: var(--muted); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-weight: 600; }
.empty .em { font-size: 54px; display: block; margin-bottom: 8px; }

/* settings list */
.setrow { display: flex; align-items: center; gap: 14px; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 10px; font-weight: 700; }
.setrow .em { font-size: 26px; }
.setrow button { margin-left: auto; min-height: 48px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, .view, .success { animation: none !important; }
  .bigbtn:active, .chip:active, .stepper button:active, .itemcard:active { transform: none; }
}

:focus-visible { outline: 4px solid #9fc0ff; outline-offset: 2px; }
