/* ============================================================
   ດີຊາຍລະບົບ POS - POS SAMMY
   ພື້ນຫຼັງສີຂຽວເຂັ້ມ · ແຖບຕ່າງໆສີສົ້ມ · ປຸ່ມສີແດງ/ຟ້າ/ເຫຼືອງ
   Font: Phetsarath OT 18px Bold ຕົວອັກສອນສີດຳ
   ============================================================ */

@font-face {
  font-family: 'Phetsarath OT';
  src: local('Phetsarath OT'), local('PhetsarathOT'), local('Phetsarath');
  font-display: swap;
}

:root {
  --green: #0A6B36;        /* ສີຂຽວເຂັ້ມ (ພື້ນຫຼັງ) */
  --green-dark: #07522A;
  --green-light: #0E8443;
  --orange: #FF8C1A;       /* ສີສົ້ມ (ແຖບຕ່າງໆ) */
  --orange-dark: #E67700;
  --red: #E23B32;          /* ປຸ່ມສີແດງ */
  --blue: #1E7BD6;         /* ປຸ່ມສີຟ້າ */
  --yellow: #FFD21E;       /* ປຸ່ມສີເຫຼືອງ */
  --ink: #111111;          /* ຕົວອັກສອນສີດຳ */
  --paper: #FFFFFF;
  --muted: #6B6B6B;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Phetsarath OT', 'Phetsarath', 'Noto Sans Lao', 'Lao Sans', 'Arial', sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: var(--green);
  min-height: 100vh;
}

img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 10px; }

.container { width: min(1180px, 94vw); margin: 0 auto; }

/* ================= ແຖບຕ່າງໆ (ສີສົ້ມ) ================= */
.topbar {
  background: var(--orange);
  border-bottom: 4px solid var(--orange-dark);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .25);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; flex-wrap: wrap;
}
.brand {
  font-size: 22px; font-weight: bold; color: var(--ink);
  text-decoration: none; display: flex; align-items: center; gap: 8px;
}
.mainmenu { display: flex; gap: 8px; flex-wrap: wrap; }
.mainmenu .btn.active { outline: 3px solid var(--ink); }

/* ================= ປຸ່ມຕ່າງໆ ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 16px; min-height: 42px;
  font-family: inherit; font-size: 18px; font-weight: bold; color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: filter .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.93); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-red { background: var(--red); }
.btn-blue { background: var(--blue); }
.btn-yellow { background: var(--yellow); }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: 15px; border-radius: 8px; }
.btn-block { width: 100%; }

.badge {
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 2px 9px; font-size: 14px; font-weight: bold; margin-left: 4px;
}

/* ================= ພື້ນທີ່ໃຫຍ່ ================= */
.view { padding: 18px 0 30px; }
.card {
  background: var(--paper); border-radius: 14px; padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
}

.hero {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  border-radius: 16px; padding: 22px; margin: 16px 0; color: var(--ink);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.hero h1 { font-size: 26px; margin: 0 0 6px; }
.hero p { margin: 0; }

.section-title {
  background: var(--orange); color: var(--ink);
  border-radius: 12px; padding: 12px 16px; margin: 16px 0; font-size: 20px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}
.section-title .spacer { flex: 1; }

/* ================= ຊອນຄົ້ນຫາ & Chips ================= */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
#search-input { flex: 1; min-width: 200px; }

.input {
  font-family: inherit; font-size: 18px; color: var(--ink);
  border: 2px solid #DDD; border-radius: 10px; padding: 10px 12px;
  background: #fff; width: 100%;
}
.input:focus { outline: none; border-color: var(--blue); }
.input.sm { padding: 6px 8px; font-size: 15px; width: auto; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.chip {
  background: var(--yellow); color: var(--ink); border: 2px solid transparent;
  border-radius: 999px; padding: 8px 16px;
  font-family: inherit; font-size: 16px; font-weight: bold; cursor: pointer;
}
.chip.active { background: var(--blue); color: #fff; }

label { display: block; font-weight: bold; margin: 12px 0 4px; }
.hint { color: var(--muted); font-size: 15px; }

/* ================= ການຈັດລຽງສິນຄ້າ ================= */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 16px; }

.product-card {
  background: var(--paper); border-radius: 14px; overflow: hidden; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); box-shadow: 0 8px 22px rgba(0, 0, 0, .3); }
.product-card.is-out { opacity: .75; }

.imgwrap { position: relative; }
.imgwrap img { width: 100%; height: 170px; object-fit: cover; display: block; background: #f2f2f2; }
.soldout {
  position: absolute; top: 10px; left: 10px;
  background: var(--red); color: #fff;
  padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: bold;
}

.pc-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pc-cat { font-size: 13px; color: var(--muted); }
.pc-name { font-size: 18px; margin: 0; min-height: 46px; }
.pc-price { font-size: 20px; color: var(--red); }
.pc-stock { font-size: 14px; }
.pc-stock.ok { color: var(--green-light); }
.pc-stock.out { color: var(--red); }
.pc-body .btn { margin-top: auto; }

.empty { text-align: center; padding: 40px 16px; font-size: 18px; }

/* ================= ກະຕ່າ ================= */
.cart-item {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 12px; padding: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.cart-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #f2f2f2; }
.ci-info { flex: 1; min-width: 130px; }
.ci-name { font-weight: bold; }
.ci-price { color: var(--muted); font-size: 15px; }
.qtybox { display: flex; align-items: center; gap: 6px; }
.qnum { min-width: 34px; text-align: center; font-weight: bold; }
.ci-sub { min-width: 110px; text-align: right; font-weight: bold; color: var(--red); }

.cart-summary { margin-top: 12px; }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 20px; }
.cart-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.cart-actions .btn { flex: 1; min-width: 180px; }

/* ================= Checkout ================= */
.checkout-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.searchrow { display: flex; gap: 8px; }
.searchrow .input { flex: 1; }
.map-actions { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }

.mapbox {
  height: 320px; border: 3px solid var(--orange); border-radius: 12px;
  overflow: hidden; z-index: 1; background: #EAF3EA;
}
.map-fail {
  display: flex; align-items: center; justify-content: center;
  height: 100%; text-align: center; color: var(--muted); padding: 16px;
}
.coords {
  background: #F4FBF4; border: 2px dashed var(--green-light);
  border-radius: 10px; padding: 10px; margin-top: 10px;
  font-size: 15px; word-break: break-word;
}
textarea.input { resize: vertical; }

.payopt {
  display: flex; align-items: center; gap: 10px;
  background: #F7F7F7; border: 2px solid #E2E2E2;
  border-radius: 12px; padding: 12px; margin: 8px 0; cursor: pointer; font-weight: bold;
}
.payopt input { width: 20px; height: 20px; accent-color: var(--blue); }
.payopt:has(input:checked) { border-color: var(--blue); background: #EAF3FF; }

.qr {
  display: block; width: 220px; max-width: 100%; margin: 10px auto;
  border: 3px solid var(--orange); border-radius: 12px; padding: 6px; background: #fff;
}
.slip, .preview { display: block; width: 220px; max-width: 100%; margin: 10px 0; border: 2px solid #DDD; border-radius: 10px; }
.slip[hidden], .preview[hidden] { display: none; }

.order-review { background: #F7FBF7; border-radius: 12px; padding: 12px; margin: 14px 0; }
.rev-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 16px; }
.rev-row.total { border-top: 2px dashed #CCC; margin-top: 6px; padding-top: 8px; font-size: 19px; }

/* ================= ສຳເລັດ ================= */
.success-card { max-width: 560px; margin: 30px auto; text-align: center; padding: 34px 20px; }
.success-card .big { font-size: 64px; line-height: 1; margin-bottom: 8px; }
.success-card .oid { font-size: 22px; color: var(--red); }

/* ================= Modal & Lightbox ================= */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .62);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box { position: relative; width: min(880px, 100%); max-height: 92vh; overflow: auto; padding: 20px; }
.modal-close { position: absolute; top: 10px; right: 10px; z-index: 2; }

.pdp { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pdp-imgwrap img {
  width: 100%; max-height: 380px; object-fit: contain;
  background: #F6F6F6; border-radius: 12px; cursor: zoom-in;
}
.zoomhint { display: block; text-align: center; color: var(--muted); font-size: 14px; margin-top: 6px; }
.price { font-size: 26px; color: var(--red); margin: 6px 0; }
.stock.ok { color: var(--green-light); }
.stock.out { color: var(--red); }
.qtyrow { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.qtyrow .qty { width: 70px; text-align: center; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .9);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; cursor: zoom-out; padding: 16px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(17, 17, 17, .95); color: var(--yellow);
  padding: 12px 20px; border-radius: 999px; font-weight: bold;
  opacity: 0; pointer-events: none; transition: all .25s;
  z-index: 400; max-width: 92vw; text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= Footer ================= */
.footer {
  background: var(--orange); border-top: 4px solid var(--orange-dark);
  color: var(--ink); text-align: center; padding: 14px;
  margin-top: 30px; font-weight: bold;
}

/* ================= Admin ================= */
.login-screen {
  position: fixed; inset: 0; background: var(--green);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 16px; overflow: auto;
}
.login-screen[hidden] { display: none; }
.login-box { width: min(420px, 100%); }
.login-box h1 {
  background: var(--orange); margin: -16px -16px 16px; padding: 16px;
  border-radius: 12px 12px 0 0; font-size: 21px;
}
.err {
  background: #FDECEA; color: var(--red); border-radius: 10px;
  padding: 10px; margin-top: 10px; font-weight: bold;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.stat {
  background: #fff; border-left: 10px solid var(--orange);
  border-radius: 12px; padding: 12px 14px; box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
}
.stat-num { font-size: 24px; font-weight: bold; }
.stat-label { color: var(--muted); font-size: 15px; }

.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filterbar .input { min-width: 220px; flex: 1; }

.order-card { margin-bottom: 16px; }
.oc-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
  border-bottom: 2px dashed #E4E4E4; padding-bottom: 10px; margin-bottom: 12px;
}
.oc-id { font-size: 19px; font-weight: bold; color: var(--blue); }
.oc-date { color: var(--muted); font-size: 14px; }
.oc-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.st-badge { border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: bold; }
.st-yellow { background: var(--yellow); }
.st-blue { background: var(--blue); }
.st-green { background: #2E9E5B; }

.oc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.info-block h4 { background: #FFF3E2; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; padding: 3px 0; }
.kv.total { border-top: 2px dashed #DDD; margin-top: 6px; padding-top: 6px; font-size: 17px; }
.note {
  background: #F6F6F6; border-radius: 10px; padding: 14px;
  text-align: center; color: var(--muted); font-size: 15px;
}

.thumb {
  width: 100%; max-width: 170px; border-radius: 10px; border: 2px solid #EEE;
  cursor: zoom-in; display: block; background: #F6F6F6;
}
.thumb.sm { max-width: 64px; }
.map-embed { width: 100%; height: 200px; border: 2px solid var(--orange); border-radius: 10px; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
table { width: 100%; border-collapse: collapse; min-width: 660px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #EDEDED; vertical-align: middle; }
th { background: var(--orange); font-weight: bold; }
td.num { text-align: right; }
td.actions { white-space: nowrap; }
.sub { color: var(--muted); font-size: 14px; }
.danger-text { color: var(--red); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }

/* ================= Responsive ================= */
@media (max-width: 860px) {
  .checkout-grid, .pdp, .form-grid { grid-template-columns: 1fr; }
  .ci-sub { min-width: 90px; }
  .hero h1 { font-size: 21px; }
  .brand { font-size: 19px; }
  .cart-actions .btn { min-width: 140px; }
  .mapbox { height: 280px; }
}
