/* ArRahman Snack Shop — iOS-style billing UI */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.2);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --bar: rgba(249, 249, 249, 0.82);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.32);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --bar: rgba(22, 22, 24, 0.82);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
.num, .row-value, .row-sub, strong { font-variant-numeric: tabular-nums; }

.app { min-height: 100vh; }

/* ---------- Views ---------- */
.view { display: none; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
  padding: env(safe-area-inset-top, 0px) 0 0;
}
.nav-row, .large-title, .segmented, .content, .bill-layout {
  max-width: 1100px; margin-left: auto; margin-right: auto;
}
.nav-row {
  height: 44px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.nav-brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--label-2); min-width: 0; }
.nav-brand img { border-radius: 7px; flex: none; }
.nav-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btn { color: var(--blue); font-size: 17px; padding: 8px 0; }
.nav-btn:disabled { color: var(--label-3); }
.nav-btn-bold { font-weight: 600; }
.nav-spacer { width: 60px; }

.large-title { padding: 2px 16px 10px; }
.large-title h1 { margin: 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.01em; }
.subtitle { margin: 2px 0 0; color: var(--label-2); font-size: 15px; }

.content { padding: 0 16px; }
.content.narrow { max-width: 720px; }

/* ---------- Grouped lists ---------- */
.section-header {
  padding: 22px 16px 7px; font-size: 13px; text-transform: uppercase;
  color: var(--label-2); letter-spacing: 0.02em;
}
.section-footer { padding: 7px 16px 0; font-size: 13px; color: var(--label-2); }

.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
}
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 10px 16px;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px;
  border-top: 0.5px solid var(--sep);
}
.item-row + .item-row::before { left: 68px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 17px; }
.row-sub { font-size: 15px; color: var(--label-2); margin-top: 2px; }
.row-value { margin-left: auto; color: var(--label-2); }
.row-label { flex: none; }
.row-button { cursor: pointer; justify-content: center; }
.row-button:active { background: var(--fill); }
.tint { color: var(--blue); }
.destructive { color: var(--red) !important; }

/* tap feedback for rows */
.tappable { cursor: pointer; transition: background .15s; user-select: none; }
.tappable:active { background: var(--fill); }

/* Form rows */
.form-list .row label, .form-list .row .row-label { flex: none; min-width: 110px; }
.form-list input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  text-align: right; color: var(--label-2); padding: 2px 0;
}
.form-list input:focus { color: var(--label); }
.form-list input::placeholder { color: var(--label-3); }

/* ---------- Bill layout ---------- */
.bill-layout { padding: 0 16px; display: grid; gap: 0; }

.thumb {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px;
}
.item-row { padding-top: 12px; padding-bottom: 12px; }
.item-row.in-cart .row-title { font-weight: 600; }

.add-btn {
  flex: none; height: 30px; padding: 0 16px; border-radius: 15px;
  background: var(--fill); color: var(--blue); font-weight: 600; font-size: 15px;
}
.add-btn:active { background: var(--fill-2); }

.stepper {
  flex: none; display: flex; align-items: center; height: 32px;
  background: var(--fill); border-radius: 9px; overflow: hidden;
}
.stepper button { width: 40px; height: 32px; font-size: 22px; line-height: 1; color: var(--label); display: grid; place-items: center; }
.stepper button:active { background: var(--fill-2); }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }

/* Order panel */
.order-line .row-title { font-size: 16px; }
.order-line .qty-badge { color: var(--label-2); font-variant-numeric: tabular-nums; min-width: 28px; }
.order-line .amount { margin-left: auto; font-variant-numeric: tabular-nums; }
.order-empty { padding: 28px 16px; text-align: center; color: var(--label-2); font-size: 15px; }
.order-empty svg { width: 40px; height: 40px; color: var(--label-3); display: block; margin: 0 auto 8px; }
.sum-row { font-size: 15px; color: var(--label-2); min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.sum-row .row-value { color: var(--label-2); }
.total-row { font-size: 20px; font-weight: 700; }
.total-row .row-value { color: var(--label); }

/* Buttons */
.btn {
  height: 50px; padding: 0 22px; border-radius: 14px; font-size: 17px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .1s, opacity .15s, background .15s;
}
.btn:active:not(:disabled) { transform: scale(0.98); opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:disabled { background: var(--fill-2); color: var(--label-3); }
.btn-secondary { background: var(--fill); color: var(--blue); }
.btn-plain { background: transparent; color: var(--blue); font-weight: 400; }
.btn-block { width: 100%; }
.btn-lg { height: 54px; font-size: 18px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }

.wide-only { display: none; margin-top: 16px; }

.charge-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 25;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  transform: translateY(0); transition: transform .25s ease;
}
.charge-bar-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.charge-bar-info span { font-size: 13px; color: var(--label-2); }
.charge-bar-info strong { font-size: 20px; }
.charge-bar .btn { min-width: 130px; }
#view-bill { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }

@media (min-width: 900px) {
  .bill-layout { grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
  .col-order { position: sticky; top: 120px; }
  .wide-only { display: flex; }
  .charge-bar { display: none; }
  #view-bill { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); }
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: center;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--label-2); font-size: 11px; font-weight: 500;
}
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--blue); }

/* ---------- Segmented control ---------- */
.segmented {
  display: flex; padding: 2px; margin: 0 16px 12px; background: var(--fill); border-radius: 9px;
  max-width: 420px;
}
.nav .segmented { margin-left: 16px; }
@media (min-width: 1132px) { .nav .segmented { margin-left: calc((100% - 1100px) / 2 + 16px); } }
.segmented button {
  flex: 1; height: 30px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--label);
  transition: background .2s, box-shadow .2s;
}
.segmented button.active { background: var(--card); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented button.active { background: #636366; } }
.segmented-full { max-width: none; margin: 0 0 12px; }

/* ---------- Sales ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px; min-width: 0; }
.stat span { display: block; font-size: 13px; color: var(--label-2); }
.stat strong { display: block; font-size: 22px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.accent strong { color: var(--green); }
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat.accent { grid-column: 1 / -1; }
  .stat.accent strong { font-size: 28px; }
}

.bar-track { height: 6px; background: var(--fill); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 3px; }

.bill-row .bill-icon {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--label-2);
}
.bill-row .bill-icon svg { width: 18px; height: 18px; }
.bill-row .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bill-row .right strong { font-weight: 600; }
.chev { width: 8px; height: 13px; color: var(--label-3); flex: none; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--fill); color: var(--label-2); margin-left: 4px; vertical-align: 1px; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--label-2); }
.empty-state svg { width: 52px; height: 52px; color: var(--label-3); }
.empty-state h3 { margin: 10px 0 4px; color: var(--label); font-size: 20px; }
.empty-state p { margin: 0; font-size: 15px; }

/* ---------- Settings item editor ---------- */
.edit-row { gap: 10px; }
.edit-row .del {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--red); position: relative;
}
.edit-row .del::after { content: ""; position: absolute; left: 6px; right: 6px; top: 10px; height: 2px; background: #fff; border-radius: 1px; }
.edit-row .thumb { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.edit-row input.name { text-align: left; color: var(--label); }
.edit-row .price-wrap { flex: none; display: flex; align-items: center; gap: 4px; color: var(--label-2); }
.edit-row input.price { flex: none; width: 80px; }
.add-row { color: var(--blue); cursor: pointer; }
.add-row .plus {
  width: 22px; height: 22px; border-radius: 50%; background: var(--green); position: relative; flex: none;
}
.add-row .plus::before, .add-row .plus::after { content: ""; position: absolute; background: #fff; border-radius: 1px; }
.add-row .plus::before { left: 6px; right: 6px; top: 10px; height: 2px; }
.add-row .plus::after { top: 6px; bottom: 6px; left: 10px; width: 2px; }

/* ---------- Sheets ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 560px; margin: 0 auto; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 14px 14px 0 0; box-shadow: var(--shadow);
  transform: translateY(105%); transition: transform .38s cubic-bezier(.32,.72,0,1);
  padding-bottom: calc(20px + var(--safe-b));
  visibility: hidden;
}
.sheet.open { transform: translateY(0); visibility: visible; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; border-radius: 16px; transform: translateY(-40%) scale(.98); opacity: 0;
    transition: transform .3s cubic-bezier(.32,.72,0,1), opacity .2s; max-height: 88vh; }
  .sheet.open { transform: translateY(-50%) scale(1); opacity: 1; }
  .grabber { display: none; }
}
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; }
.sheet-nav {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 16px;
}
.sheet-nav h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-body { padding: 0 16px; }

.checkout-total { text-align: center; padding: 8px 0 20px; }
.checkout-total span { display: block; font-size: 15px; color: var(--label-2); }
.checkout-total strong { display: block; font-size: 44px; font-weight: 700; letter-spacing: -0.01em; margin: 2px 0; }
.checkout-total small { font-size: 13px; color: var(--label-2); }
#sheet-charge .form-list + .section-header { padding-top: 18px; }
#cash-box .list { margin-bottom: 10px; }
#co-change.positive { color: var(--green); font-weight: 600; }
#co-change.negative { color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chips button {
  height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card); color: var(--blue);
  font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.chips button:active { background: var(--fill); }
#btn-complete { margin-top: 6px; }

.success { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--green); font-weight: 600; padding: 2px 0 14px; }
.success svg { width: 24px; height: 24px; }
.success span { color: var(--label); }
#btn-delete-bill { margin-top: 8px; }

/* ---------- Receipt ---------- */
.receipt {
  background: #fff; color: #111; border-radius: var(--radius); padding: 22px 20px 18px;
  font-size: 14px; line-height: 1.45; font-variant-numeric: tabular-nums;
}
.receipt .r-head { text-align: center; padding-bottom: 12px; border-bottom: 1px dashed #c7c7cc; }
.receipt .r-shop { font-size: 18px; font-weight: 700; }
.receipt .r-sub { color: #6b6b70; font-size: 13px; }
.receipt .r-meta { display: flex; justify-content: space-between; color: #444; padding: 10px 0; font-size: 13px; border-bottom: 1px dashed #c7c7cc; }
.receipt table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.receipt th { text-align: left; font-weight: 600; font-size: 12px; color: #6b6b70; text-transform: uppercase; letter-spacing: .03em; padding: 4px 0; }
.receipt td { padding: 4px 0; vertical-align: top; }
.receipt .c { text-align: center; width: 40px; }
.receipt .r { text-align: right; width: 84px; }
.receipt .r-sum { border-top: 1px dashed #c7c7cc; padding-top: 8px; }
.receipt .r-line { display: flex; justify-content: space-between; padding: 2px 0; }
.receipt .r-total { font-size: 18px; font-weight: 700; padding: 8px 0 6px; border-top: 1px solid #111; margin-top: 6px; }
.receipt .r-pay { color: #444; font-size: 13px; border-top: 1px dashed #c7c7cc; padding-top: 8px; margin-top: 4px; }
.receipt .r-foot { text-align: center; color: #6b6b70; font-size: 13px; margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 60;
  transform: translate(-50%, -140%); transition: transform .35s cubic-bezier(.32,.72,0,1);
  background: var(--card); color: var(--label); box-shadow: var(--shadow);
  padding: 10px 18px; border-radius: 22px; font-size: 15px; font-weight: 500; white-space: nowrap;
}
.toast { visibility: hidden; transition: transform .35s cubic-bezier(.32,.72,0,1), visibility 0s .35s; }
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .35s cubic-bezier(.32,.72,0,1); }
.section-header .amt { text-transform: none; }

body.locked { overflow: hidden; }

/* ---------- Print ---------- */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .receipt { padding: 0; border-radius: 0; font-size: 12px; }
}
