:root {
    --primary: #1f7a6b;
    --primary-2: #145b4f;
    --accent: #ffcc00;
    --bg: #f7faf9;
    --text: #111827;
    --muted: #6b7280;
    --gray: #e5e7eb;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: system-ui, sans-serif;
    color: var(--text);
    overflow-x: hidden;          /* กัน scroll ด้านข้าง */
    overscroll-behavior: none;   /* กัน bounce effect */
    touch-action: manipulation;  /* กัน double-tap zoom */
}

.phone {
    width: 414px;
    max-width: 100vw;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 16px 16px 90px;
    background: var(--bg);
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-weight: 800;
    background: var(--primary);
    color: #fff;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.table-badge {
    background: var(--accent);
    color: #000;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
}

/* Categories */
.categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 14px;
}

.cat-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    background: #eef2f7;
    cursor: pointer;
    font-weight: 600;
}

.cat-btn.active {
    background: var(--primary);
    color: #fff;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.menu-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
}

.menu-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.menu-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-title {
    margin: 0;
    font-weight: 700;
}

.menu-desc {
    font-size: 13px;
    color: var(--muted);
}

.menu-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price {
    font-weight: 700;
    color: var(--primary-2);
}

.add-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
}

/* Cart Bar */
.cart-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    display: none;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 400px;
}

.checkout-btn {
    margin-left: 8px;
    padding: 6px 12px;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

/* ข้อความใน confirm modal */
.confirm-text{
  margin-top: 6px;
  color: var(--text);
  font-size: 14px;
}

/* ปุ่มใน bottom sheet */
.modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}



/* ===== Bottom Sheet Modal (ใหม่) ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}

.modal.show {
    display: block;
}

/* เปิด/ปิดด้วย .show */

.modal-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: saturate(110%) blur(4px);
}

/* แผ่น bottom sheet ยึดความกว้าง 414px เหมือน phone */
.sheet {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 414px;
    max-width: 100vw;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, .25);
    padding: 16px;
    animation: sheetUp .25s ease-out;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes sheetUp {
    from {
        transform: translate(-50%, 8%);
    }

    to {
        transform: translate(-50%, 0);
    }
}

.handle {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #E5E7EB;
    margin: 0 auto 4px;
}

.sheet-title {
    text-align: center;
    font-weight: 800;
    font-size: 18px;
    line-height: 1.2;
}

.qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 4px;
}

.qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(31, 122, 107, .25);
}

.qty-btn:active {
    transform: scale(.98);
}

.qty-value {
    min-width: 34px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
}

.note-label {
    font-size: 13px;
    color: var(--muted);
}

#itemNote {
    width: 93%;
    border: 1px solid var(--gray);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    line-height: 1.4;
    background: #FAFAFA;
}

#itemNote::placeholder {
    color: #9CA3AF;
}

/* ปุ่มแอคชัน */
.btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(31, 122, 107, .22);
    font-size: 16px;
}

.btn.ghost {
    background: transparent;
    color: var(--muted);
}

@media (prefers-reduced-motion:reduce) {
    .sheet {
        animation: none;
    }
}


/* ===== Cart Page ===== */
.cart-page {
    padding: 8px;
}

.cart-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #fff;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}

.cart-row .info {
    flex: 1;
}

.cart-row .name {
    font-weight: 800;
}

.cart-row .note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.cart-row .price {
    font-weight: 700;
    color: var(--primary-2);
    margin-top: 6px;
}

.cart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.cart-controls .qty-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.cart-controls .qty {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
}

.cart-edit {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.cart-edit .small {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--gray);
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.cart-summary {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 12px 4px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-actions {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

.btn.ghost {
    background: #111827;
    color: #fff;
    opacity: .85;
}

/* ===== Cart page refined ===== */
.cart-container {
    padding: 8px 8px 120px;
}

/* กันชนให้พ้น footer sticky */
.item-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .06);
}

.item-thumb {
    width: 68px;
    height: 68px;
    border-radius: 12px;
    object-fit: cover;
    background: #F3F4F6;
}

.item-fallback {
    width: 68px;
    height: 68px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #E6F4F1;
    color: #0f5132;
    font-weight: 800;
}

.item-meta {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 800;
    margin-bottom: 4px;
}

.item-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.item-price {
    margin-top: 6px;
    font-weight: 800;
    color: var(--primary-2);
}

.steppers {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.steppers .step {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(31, 122, 107, .2);
}

.steppers .qty {
    min-width: 28px;
    text-align: center;
    font-weight: 800;
}

.item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--gray);
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.chip.danger {
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ===== Footer bar — เสถียร ไม่หาย ===== */
.footer-bar{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  z-index: 999;                   /* ให้อยู่เหนือเนื้อหาอื่น */
  width: min(414px, 90vw);
  background: #0f172a;
  color: #fff;
  border-radius: 20px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
}

.footer-sum{
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  line-height: 1;
}
.sum-text{ opacity: .9; font-weight: 600; font-size: 14px; }
.sum-amount{ font-weight: 800; font-size: 16px; }

/* ปุ่มใน footer ให้สวยและกว้างพอดีตัวอักษร */
.footer-actions{ display: flex; gap: 8px; }
.footer-bar .btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 20px;          /* กว้างขึ้นแบบพอดีข้อความ */
  min-width: 96px;          /* กันแคบเกิน */
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.footer-bar .btn.dark{ background:#1f2937; color:#fff; }
.footer-bar .btn.primary{ background: var(--primary); color:#fff; }
.footer-bar .btn[disabled]{ opacity:.55; cursor:not-allowed; }



.btn {
    padding: 10px 14px;
    border-radius: 12px;

    border: none;
    cursor: pointer;
    font-weight: 700;
}

.btn.block {
    width: 100%;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

.btn.dark {
    background: #1f2937;
    color: #fff;
}

.btn.secondary {
    background: #EEF2F7;
    color: #111827;
}

.btn.ghost {
    background: transparent;
    color: var(--muted);
}

.btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.empty {
    text-align: center;
    padding: 24px 12px;
}

.hidden {
    display: none;
}

.empty-emoji {
    font-size: 38px;
}

.empty-title {
    font-weight: 800;
    margin-top: 8px;
}

.empty-sub {
    color: var(--muted);
    font-size: 13px;
    margin: 6px 0 12px;
}

/* ===== Receipt (Bill) ===== */
.receipt {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .08);
    padding: 16px;
}

.receipt-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.shop-name {
    font-weight: 800;
    font-size: 18px;
}

.shop-sub {
    color: var(--muted);
    font-size: 12px;
}

.meta {
    text-align: right;
}

.muted {
    color: #6b7280;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    margin-top: 6px;
}

.badge.tone {
    background: #e6f4f1;
    color: #0f5132;
    border-color: #d1fae5;
}

.divider {
    height: 1px;
    background: #eef2f7;
    margin: 12px 0;
}

.receipt-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.r-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.r-left {
    max-width: 66%;
}

.r-name {
    font-weight: 700;
}

.r-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.r-right {
    text-align: right;
    font-weight: 700;
    color: var(--primary-2);
}

.receipt-total .line {
    display: flex;
    justify-content: space-between;
    font-weight: 900;
    font-size: 18px;
}

.receipt-note {
    margin-top: 10px;
}

.actions {
    margin-top: 14px;
}

.btn.block {
    width: 100%;
}