:root { --bg:#f4f4f4; --card:#fff; --muted:#666; --accent:#0b5; --danger:#c33; --ink:#111; }

* { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background:var(--bg);
  margin:0;
  padding:20px;
  color:var(--ink);
}

/* Center login page when unauthenticated */
body.auth-only {
  display:flex;
  min-height:100vh;
  align-items:center;
  justify-content:center;
  padding:20px;
}

h1, h2, h3 { margin:0 0 12px 0; }

.container { max-width: 980px; margin:auto; }

.card {
  background:var(--card);
  border-radius:10px;
  padding:18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.pad-small { padding:12px; }

.stack { display:grid; gap:10px; }

.row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

input, button, select {
  padding:10px 12px;
  border-radius:8px;
  border:1px solid #ddd;
  font-size:14px;
}

input, select { min-width:140px; }

button {
  cursor:pointer;
  border:1px solid #ccc;
  background:#fafafa;
}

button.primary { background:var(--accent); color:white; border-color:var(--accent); }
button.danger  { background:var(--danger); color:white; border-color:var(--danger); }
button.link    { background:transparent; border:none; color:#06c; padding-left:0; }

/* tiny variant for inline utility buttons */
button.tiny { font-size:12px; padding:4px 8px; border-radius:6px; }

.muted { color:var(--muted); font-size:13px; }
.right { margin-left:auto; }

.error {
  background:#ffecec;
  color:#a40000;
  padding:8px 10px;
  border-radius:8px;
  border:1px solid #ffcdcd;
  font-size:13px;
}

.success {
  background:#ecfff1;
  color:#035c2b;
  padding:8px 10px;
  border:1px solid #c9f2da;
  font-size:13px;
}

table { width:100%; border-collapse:collapse; margin-top:10px; }
th, td { border:1px solid #ddd; padding:8px; text-align:center; }
tfoot td { font-weight:bold; }

.topbar { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
.spacer { flex:1; }

.hidden { display:none !important; }

.pill {
  padding:4px 8px;
  border-radius:999px;
  background:#efefef;
  font-size:12px;
}

.kbd {
  padding:2px 6px;
  border-radius:4px;
  border:1px solid #ccc;
  font-family:monospace;
  font-size:12px;
  background:#fff;
}

.divider { height:1px; background:#eee; margin:6px 0; }

.grid2 { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
@media (max-width:900px){ .grid2 { grid-template-columns: 1fr; } }

.tiny { font-size:12px; }
.nowrap { white-space: nowrap; }

/* ===== Auth (login) page polish ===== */
.auth-card { max-width: 520px; width: 100%; margin-inline:auto; }
.auth-hero { text-align:center; }
.auth-hero .muted { margin-top:-4px; }

.input-stack input {
  font-size:16px;
  padding:14px 12px;
}

.password-wrap {
  position: relative;
  display: grid;
}
.password-wrap input {
  padding-right: 72px; /* room for toggle button */
}
.pass-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.auth-controls { justify-content: space-between; }

/* ===== Search table tweaks ===== */
#searchTable tbody tr { cursor: pointer; }

/* Double vertical size for SEARCH ITEMS rows only (stronger & explicit) */
#searchTable tbody td {
  padding-top: 16px !important;
  padding-bottom: 16px !important;
}
#searchTable tbody tr { line-height: 1.7 !important; }

/* Zebra striping for SEARCH ITEMS rows — apply to cells for stronger effect */
#searchTable tbody tr:nth-child(odd)  td { background:#fff !important; }
#searchTable tbody tr:nth-child(even) td { background:#f9f9f9 !important; }
#searchTable tbody td { background-clip: padding-box; }

/* ===== Edit mode highlight for the list panel ===== */
.edit-on { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px; }

/* ===== Featured slot states ===== */
.slot-empty  { color: var(--muted); font-style: italic; }
.slot-missing { background: #fff5f5; color: #a40000; }

/* ===== Slot Picker Overlay (purely local) ===== */
#slotPickerOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: grid;
  place-items: center;
  z-index: 9999;
}

#slotPickerPanel {
  background: var(--card);
  width: min(880px, 92vw);
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: grid;
  grid-template-rows: min-content min-content 1fr min-content;
  gap: 10px;
  padding: 14px;
}

#slotPickerList { overflow: auto; border:1px solid #eee; border-radius: 8px; }
#slotPickerList table { margin: 0; }

/* ===== Single-line Flash Alert Clamp ===== */
#flash {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  padding: 8px 12px;
  max-height: calc(1.25em + 16px);
  border-radius: 8px;
}

#flash.success, #flash.error { display: block; }

/* ===== POS table footer tweaks ===== */
#posTable tfoot td { vertical-align: middle; }
#posTable tfoot td:last-child { text-align: right; }

/* =========================================================
   Checkout table visual changes — 3 columns total
   ========================================================= */
#posTable { table-layout: auto; }

/* Item column: take remaining space and align left */
#posTable thead th:nth-child(1),
#posTable tbody td:nth-child(1) {
  width: auto;
  text-align: left;
}

/* Qty column: compact, centered */
#posTable thead th:nth-child(2),
#posTable tbody td:nth-child(2) {
  width: 72px;
  white-space: nowrap;
  text-align: center;
}

/* Total column: fixed-ish, align right */
#posTable thead th:nth-child(3),
#posTable tbody td:nth-child(3) {
  width: 120px;
  white-space: nowrap;
  text-align: right;
}

/* Row hover for readability */
#posTable tbody tr { cursor: pointer; }
#posTable tbody tr:hover td { background:#f7f7f7; }

/* =========================================================
   Qty Editor Overlay
   ========================================================= */
#qtyEditorOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: grid;
  place-items: center;
  z-index: 10000;
}

/* Keep panel within viewport and comfy width */
#qtyEditorPanel { width: min(640px, 92vw) !important; }

/* Header grid */
#qtyHeader {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
#qtyHeader .spacer { display:none; }
#btnQtyRemove { justify-self: center; }
#qtyEditorClose { justify-self: end; }
#qtyHeader button { white-space: nowrap; }

/* Qty controls */
#qtyRowControls {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  column-gap: 12px;
  align-items: center;
  width: 100%;
}
#qtyRowControls button { min-width: 56px; justify-self: center; }

/* Input width */
#qtyEditorPanel #qtyInput {
  width: 100%;
  min-width: 160px;
  max-width: 100%;
  text-align: center;
}

/* Remove number spinners */
#qtyEditorPanel input[type="number"]::-webkit-outer-spin-button,
#qtyEditorPanel input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none !important; margin: 0 !important; }
#qtyEditorPanel input[type="number"] { -webkit-appearance: textfield !important; appearance: textfield !important; -moz-appearance: textfield !important; }

/* Actions */
#qtyEditorPanel .stack { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#qtyRowActions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
#qtyRowActions .spacer { display: none !important; }
#btnQtyCancel { justify-self: start; min-width: 120px; }
#btnQtySave   { justify-self: end;   min-width: 120px; }

/* Discount row */
#qtyRowDiscount { justify-content: center; }
#qtyRowDiscount button { min-width: 200px; }

/* Focus ring for accessibility */
#qtyEditorPanel:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Discounted rows */
tr.discounted td { color: #a40000; background: #fff5f5; }

/* =========================================================
   Payment layout & controls
   ========================================================= */
#payView .grid2 { align-items: start; min-height: 0; }
#payView .grid2 > .stack { min-height: 0; }
#payView .panel-left { display: grid; grid-template-rows: min-content 1fr; min-height: 0; }
#payView .panel-left .scroll-y { overflow: auto; min-height: 0; }
#payView .panel-right { align-content: start; min-height: 0; }

/* NEW: segmented buttons to replace dropdown (two equal buttons) */
.pay-methods { width: 100%; }
.segmented-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fafafa;
  font-size: 14px;
}
.seg-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.change-display { display: grid; gap: 6px; margin-top: 4px; margin-bottom: 12px; }
.change-amount { font-size: 2.7em; line-height: 1.1; font-weight: bold; color: var(--accent); }

.amount-wrap { width: 100%; margin-bottom: 12px; }
.amount-wrap #payAmount {
  width: 100%;
  font-size: 28px;
  padding: 20px 16px;
}

/* Make GCash input match Amount Received size */
#gcashContact {
  width: 100%;
  font-size: 28px;
  padding: 20px 16px;
  /* keep same border/radius from base input styles */
}

.cash-quick-row { gap: 12px; margin-bottom: 12px; }
.cash-btn {
  font-size: 21px;
  padding: 12px 18px;
  border-radius: 10px;
}

.pay-actions { gap: 12px; margin-top: 4px; }
.pay-actions #btnBack,
.pay-actions #btnConfirmPay {
  font-size: 28px;
  padding: 16px 28px;
}

@media (max-width: 420px){
  .cash-btn { font-size: 18px; padding: 10px 14px; }
  .pay-actions #btnBack,
  .pay-actions #btnConfirmPay { font-size: 24px; padding: 14px 22px; }
}

/* ====== GCash input validation states ====== */
#gcashContact.invalid {
  border-color: #e66;
  background: #fff5f5;
}
