/* ============================================================
   app.css — POS System Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  --primary:    #455275;
  --primary-dk: #2d3a52;
  --primary-lt: #52B788;
  --accent:     #F77F00;
  --accent-lt:  #FCA547;
  --green:      #10b981;
  --green-lt:   #d1fae5;
  --bg:         #F8F9FA;
  --card-bg:    #FFFFFF;
  --text:       #212529;
  --text-muted: #6C757D;
  --success:    #28A745;
  --warning:    #FFC107;
  --danger:     #DC3545;
  --border:     #DEE2E6;
  --shadow:     0 2px 8px rgba(0,0,0,0.08);
  --radius:     10px;
  --radius-sm:  6px;
  --sidebar-w:  220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: 'Prompt', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh;
  font-size: clamp(14px, 1.6vw, 16px); line-height: 1.6; }

/* ── Typography Scale (clamp: min 12px, paragraph 16px) ── */
h1 { font-size: clamp(1.6rem, 4vw, 2.25rem);  font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); font-weight: 700; line-height: 1.25; }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.4rem); font-weight: 600; line-height: 1.3; }
h4 { font-size: clamp(1rem, 2vw, 1.2rem);      font-weight: 600; line-height: 1.35; }
h5 { font-size: clamp(0.9rem, 1.6vw, 1.05rem); font-weight: 600; line-height: 1.4; }
h6 { font-size: clamp(0.82rem, 1.4vw, 0.95rem); font-weight: 600; line-height: 1.4; }
p  { font-size: clamp(14px, 1.6vw, 16px); line-height: 1.65; }
small { font-size: clamp(12px, 1.2vw, 13px); }
strong { font-weight: 600; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--primary-lt); border-radius: 10px; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--primary);
  display: flex; flex-direction: column; z-index: 40;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar.open { transform: translateX(0) !important; }
@media (min-width: 1024px) { .sidebar { transform: translateX(0); } }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; display: none; }
.sidebar-backdrop.active { display: block; }
@media (min-width: 1024px) { .sidebar-backdrop { display: none !important; } }

.sidebar-logo { padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar-logo h3 { color: #fff; font-size: clamp(13px, 1.4vw, 15px); font-weight: 600; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section-label { padding: 10px 18px 4px; font-size: clamp(12px, 1.1vw, 13px); font-weight: 700; color: rgba(255,255,255,0.28); text-transform: uppercase; letter-spacing: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 18px 10px 20px; color: rgba(255,255,255,0.7); font-size: clamp(13px, 1.4vw, 15px); font-weight: 500; cursor: pointer; border-left: 3px solid transparent; transition: background .15s, color .15s; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #10b981; padding-left: 17px; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; }
.sidebar-footer #nav-user-info { font-size: clamp(12px, 1.2vw, 13px); color: rgba(255,255,255,0.65); display: flex; align-items: center; gap: 12px; line-height: 1.4; width: 100%; }
.logout-btn { width: 100%; padding: 10px; background: rgba(224, 49, 49, 0.1); border: 1px solid rgba(224, 49, 49, 0.2); color: #ff8787; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: clamp(12px, 1.3vw, 14px); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s; }
.logout-btn:hover { background: rgba(224, 49, 49, 0.2); }

/* ── Main content ── */
.main-content { margin-left: 0; transition: margin-left .28s; }
@media (min-width: 1024px) { .main-content { margin-left: var(--sidebar-w); } }
.main-content-inner { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; }
.topbar-title { font-size: clamp(14px, 1.8vw, 17px); font-weight: 600; color: var(--primary); }
.ham-btn { background: none; border: none; cursor: pointer; padding: 6px; display: flex; align-items: center; }
@media (min-width: 1024px) { .ham-btn { display: none; } }
.page-content { padding: 20px; flex: 1; }

/* ── Cards ── */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: clamp(13px, 1.5vw, 16px); }
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }
.mb-3 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: clamp(13px, 1.5vw, 15px); font-weight: 500; cursor: pointer; transition: all .2s; white-space: nowrap; min-height: 40px; text-decoration: none; justify-content: center; }
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover   { background: var(--primary-dk); }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-sm  { padding: 5px 12px; font-size: clamp(12px, 1.2vw, 13px); min-height: 32px; }
.btn-lg  { padding: 12px 22px; font-size: clamp(14px, 1.7vw, 17px); min-height: 48px; }
.btn-icon { padding: 8px; min-width: 40px; width: 40px; border-radius: 50%; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: clamp(12px, 1.3vw, 14px); font-weight: 500; margin-bottom: 5px; color: var(--text-muted); }
.form-control { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: clamp(13px, 1.5vw, 15px); color: var(--text); background: var(--card-bg); outline: none; min-height: 40px; transition: border-color .2s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(69,82,117,0.1); }
.form-control::placeholder { color: #aaa; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: clamp(13px, 1.4vw, 15px); }
th { background: var(--bg); padding: 10px 14px; text-align: left; font-weight: 600; font-size: clamp(12px, 1.2vw, 13px); color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(69,82,117,0.03); }
tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: clamp(12px, 1.1vw, 13px); font-weight: 600; }
.badge-success { background: #D4EDDA; color: #155724; }
.badge-warning { background: #FFF3CD; color: #856404; }
.badge-danger  { background: #F8D7DA; color: #721C24; }
.badge-info    { background: #D1ECF1; color: #0C5460; }
.badge-muted   { background: var(--bg); color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal { background: var(--card-bg); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(20px); transition: transform .2s; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: clamp(14px, 1.6vw, 16px); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-lg .modal { max-width: 760px; }
@media (max-width: 600px) { .modal { max-height: 95vh; border-radius: var(--radius) var(--radius) 0 0; } .modal-overlay { align-items: flex-end; padding: 0; } }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: var(--radius-sm); color: #fff; font-size: clamp(13px, 1.4vw, 15px); font-weight: 500; min-width: 240px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); animation: slideIn .3s ease; max-width: 340px; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); color: #212529; }
.toast-info    { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Spinner ── */
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { border-color: rgba(0,0,0,0.15); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: clamp(13px, 1.4vw, 15px); margin-bottom: 14px; }
.alert-danger { background: #F8D7DA; color: #721C24; border-left: 4px solid var(--danger); }
.alert-info   { background: #D1ECF1; color: #0C5460; border-left: 4px solid #17A2B8; }

/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.kpi-card.accent  { border-left-color: var(--accent); }
.kpi-card.success { border-left-color: var(--success); }
.kpi-label { font-size: clamp(12px, 1.1vw, 13px); color: var(--text-muted); font-weight: 500; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 700; line-height: 1.1; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-input-wrap { position: relative; flex: 1; min-width: 180px; }
.search-input-wrap .form-control { padding-left: 36px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* ── POS Shell ── */
.pos-shell { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
@media (min-width: 1024px) { .pos-shell { left: var(--sidebar-w); } }
.pos-topbar { height: 52px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 14px; gap: 10px; flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.pos-grid { flex: 1; display: grid; grid-template-columns: 1fr 355px; overflow: hidden; }
@media (max-width: 1023px) { .pos-grid { grid-template-columns: 1fr; } }
.pos-left { display: flex; flex-direction: column; border-right: 2px solid var(--border); background: var(--bg); padding: 10px 12px; overflow: hidden; }
.cat-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-top: 8px; flex-shrink: 0; scrollbar-width: none; }
.cat-strip::-webkit-scrollbar { display: none; }
.cat-chip { flex-shrink: 0; padding: 5px 13px; border-radius: 20px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; font-size: clamp(12px, 1.2vw, 14px); font-weight: 500; color: var(--text-muted); white-space: nowrap; transition: all .15s; }
.cat-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.menu-scroll { flex: 1; overflow-y: auto; margin-top: 8px; }
.menu-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; padding-bottom: 12px; }
@media (min-width: 640px)  { .menu-grid { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 1024px) { .menu-grid { grid-template-columns: repeat(4,1fr); } }
.m-card { background: #fff; border-radius: 12px; border: 2px solid transparent; cursor: pointer; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.07); transition: all .15s; }
.m-card:hover { border-color: var(--primary-lt); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.m-card:active { transform: scale(0.97); }
.m-thumb { height: 110px; width: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; background: linear-gradient(135deg,#E8F5E9,#B7DFBB); overflow: hidden; }
.m-thumb img { width: 100%; height: 100%; object-fit: cover; }
.m-info { padding: 8px 9px 10px; }
.m-name { font-size: clamp(14px,3.5vw,16px); font-weight: 600; line-height: 1.3; margin-bottom: 3px; }
.m-price { font-size: clamp(13px,3vw,15px); color: var(--primary); font-weight: 700; }
.pos-right { display: flex; flex-direction: column; background: #fff; overflow: hidden; }
@media (max-width: 1023px) { .pos-right { position: fixed; inset: 0; z-index: 45; transform: translateX(100%); transition: transform .3s cubic-bezier(.4,0,.2,1); overflow-y: auto; } .pos-right.cart-visible { transform: translateX(0); } }
.cart-hdr { background: var(--primary); color: #fff; padding: 11px 14px; font-weight: 700; font-size: clamp(13px, 1.5vw, 15px); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.cart-clear-btn { background: rgba(255,255,255,0.15); color: #fff; border: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: clamp(12px, 1.1vw, 13px); font-family: inherit; font-weight: 600; }
.cart-body { flex: 1; overflow-y: auto; padding: 8px 12px; background: var(--bg); }
.cart-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 6px; padding: 40px 0; }
.c-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.c-item:last-child { border-bottom: none; }
.c-item-thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--bg); }
.c-item-thumb-empty { display: flex; align-items: center; justify-content: center; background: #eef2f3; }
.c-item-info { flex: 1; min-width: 0; }
.c-item-name { font-weight: 600; font-size: clamp(13px, 1.4vw, 15px); line-height: 1.3; }
.c-item-opts { font-size: clamp(12px, 1.1vw, 13px); color: var(--text-muted); margin-top: 2px; }
.c-item-price { font-weight: 700; color: var(--primary); font-size: clamp(13px, 1.4vw, 15px); white-space: nowrap; margin-left: 6px; }
.q-ctrl { display: flex; align-items: center; gap: 5px; margin-top: 5px; width: 100%; }
.q-btn { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--border); background: #fff; cursor: pointer; font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--primary); transition: all .15s; flex-shrink: 0; }
.q-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.q-num { font-weight: 700; font-size: 0.9rem; min-width: 22px; text-align: center; }
.cart-footer { border-top: 2px solid var(--border); padding: 10px 12px; background: #fff; flex-shrink: 0; }
.t-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: clamp(13px, 1.4vw, 15px); }
.t-row.grand { font-size: clamp(15px, 1.8vw, 18px); font-weight: 700; color: var(--primary); border-top: 2px solid var(--border); margin-top: 5px; padding-top: 7px; }
.pay-row { display: flex; gap: 6px; margin-top: 8px; }
.pay-chip { flex: 1; padding: 7px 4px; border: 2px solid var(--border); border-radius: 8px; text-align: center; cursor: pointer; font-size: clamp(12px, 1.1vw, 13px); font-weight: 600; transition: all .15s; background: #fff; }
.pay-chip.on { border-color: var(--primary); background: #E8F5E9; color: var(--primary); }
.pay-icon { font-size: 1.2rem; display: block; margin-bottom: 2px; }
.conf-btn { width: 100%; margin-top: 10px; padding: 13px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-family: inherit; font-size: clamp(14px, 1.7vw, 17px); font-weight: 700; cursor: pointer; transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.conf-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Cart FAB ── */
.cart-fab { display: none; }
@media (max-width: 1023px) {
  .cart-fab { display: flex; position: fixed; bottom: 24px; right: 20px; z-index: 44; width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 1.5rem; box-shadow: 0 4px 18px rgba(0,0,0,0.28); cursor: pointer; align-items: center; justify-content: center; transition: background .2s; }
  .cart-fab.is-open { background: var(--danger); }
}
.fab-badge { position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 0.68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; pointer-events: none; }
.fab-badge.hidden-badge { display: none; }

/* ── Material Icons ──────────────────────────────────────────── */
.material-icons-round {
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
  user-select: none;
}
.nav-item .material-icons-round { font-size: 20px; }
.ham-btn .material-icons-round  { font-size: 24px; color: var(--text-muted); }

/* ── Image Drop Zone ─────────────────────────────────────────── */
.img-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Customization Modal Styles ── */
.og {
  margin-bottom: 18px;
}
.og-lbl {
  font-size: clamp(14px, 1.6vw, 16px);
  font-weight: 700;
  color: var(--primary-dk);
  margin-bottom: 8px;
  display: block;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-item {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: clamp(14px, 1.4vw, 15px);
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  user-select: none;
}
.chip-item:hover {
  border-color: var(--primary-lt);
}
.chip-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.chip-item.dashed {
  border-style: dashed;
}

.size-card {
  flex: 1;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s ease;
  user-select: none;
}
.size-card.active {
  border-color: var(--primary);
  background: #E8F5E9;
}
.size-card-title {
  font-weight: 700;
  color: var(--primary);
  font-size: clamp(15px, 1.6vw, 18px);
}
.size-card-desc {
  font-size: clamp(12px, 1.2vw, 13px);
  color: #666;
  margin: 2px 0;
}
.size-card-price {
  font-size: clamp(13px, 1.3vw, 14px);
  font-weight: 700;
  color: var(--accent);
}

/* ── Card UI Quantity Controls on Grid ── */
.m-card.in-cart {
  border-color: var(--primary-lt);
  box-shadow: 0 4px 16px rgba(82, 183, 136, 0.18);
}

.m-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  width: 100%;
}

/* ปุ่มกลมสีเขียว — ใช้เมื่อยังไม่มีสินค้าในตะกร้า */
.m-card-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--primary-lt);
  background: #fff;
  color: var(--primary-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  flex-shrink: 0;
}
.m-card-add-btn:hover {
  background: var(--primary-lt);
  color: #fff;
}
.m-card-add-btn:active { transform: scale(0.9); }

/* แถบจัดการปริมาณบนการ์ด — ใช้ .q-btn เดียวกับในตะกร้า */
.m-card-q-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Badge จำนวนสินค้า (วงกลมสีเขียว) แบบ inline ระหว่างปุ่ม − และ + */
.m-badge-qty {
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  pointer-events: none;
  border: 1.5px solid #fff;
  flex-shrink: 0;
}
.img-drop-zone:hover    { border-color: var(--primary); background: #f0f4ff; }
.img-drop-zone.drag-over{ border-color: var(--primary); background: #e8f0fe; }

/* ── Menu thumb fallback — ใช้ CSS ::before แทน inline icon ── */
.m-thumb-empty::before {
  font-family: 'Material Icons Round';
  content: 'shopping_basket';
  font-size: 2.6rem;
  color: rgba(69,82,117,0.25);
}
/* pay-icon ใช้ block display */
.pay-icon { font-size: 1.4rem !important; display: block !important; margin-bottom: 2px; }

/* ── Image indicator & tooltip in menu table ─────────────────── */
.img-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  vertical-align: middle;
  margin-left: 6px;
  cursor: pointer;
}

.img-indicator .material-icons-round {
  font-size: 16px;
  color: var(--primary-lt);
  transition: color .2s, transform .2s;
  filter: drop-shadow(0 1px 2px rgba(82,183,136,0.3));
}

.img-indicator:hover .material-icons-round {
  color: var(--accent);
  transform: scale(1.2);
}

/* Tooltip popup */
.img-indicator .img-tooltip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 9999;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.10);
  padding: 8px;
  width: 160px;
  pointer-events: none;
  animation: tooltipFadeIn .18s ease;
}

.img-indicator:hover .img-tooltip {
  display: block;
}

.img-tooltip img {
  width: 144px;
  height: 144px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.img-tooltip-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 5px;
  font-weight: 500;
}

/* Arrow */
.img-indicator .img-tooltip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #fff;
  border-bottom: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.08));
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   Menu Form Panel — Full-screen slide-in (แทน modal popup)
   ══════════════════════════════════════════════════════════════ */

/* Panel container — ทับบน main-content ทั้งหมด */
.menu-form-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  visibility: hidden;
}
/* เมื่อ sidebar มีอยู่บน desktop ให้เว้นซ้าย */
@media (min-width: 1024px) {
  .menu-form-panel { left: var(--sidebar-w); }
}
.menu-form-panel.panel-open {
  transform: translateX(0);
  visibility: visible;
}

/* Topbar ของ panel */
.form-panel-topbar {
  height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.form-panel-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Scrollable body */
.form-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 40px;
}
@media (min-width: 768px) {
  .form-panel-body { padding: 32px 40px 60px; }
}
@media (min-width: 1200px) {
  .form-panel-body { padding: 36px 15%; }
}

/* Section cards ภายใน panel */
.form-section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.form-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.form-section-title .material-icons-round { font-size: 16px; color: var(--primary-lt); }

/* 2-col grid ที่ responsive */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
.col-span-full { grid-column: 1 / -1; }

/* Image upload zone ใน panel */
.panel-img-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 140px;
  position: relative;
}
.panel-img-zone:hover { border-color: var(--primary); background: #f0f4ff; }
.panel-img-zone.drag-over { border-color: var(--primary); background: #e8f0fe; }
.panel-img-zone.has-img { border-color: var(--success); background: #f0fff4; }
.panel-img-zone .panel-img-preview {
  max-height: 180px;
  max-width: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.panel-img-zone.has-img .panel-img-preview { display: block; }
.panel-img-zone.has-img .panel-img-placeholder { display: none; }
.panel-img-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.panel-img-zone .img-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform .15s;
}
.panel-img-zone.has-img .img-remove-btn { display: flex; }
.panel-img-zone .img-remove-btn:hover { transform: scale(1.15); }

/* Upload status bar */
.upload-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  margin-top: 6px;
  min-height: 20px;
}

/* Save button animation */
.btn-save-panel {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .2s, transform .15s;
  min-height: 40px;
}
.btn-save-panel:hover { background: var(--primary-dk); }
.btn-save-panel:active { transform: scale(0.97); }
.btn-save-panel:disabled { opacity: 0.5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   Mobile: ป้องกันหน้าจอซูมเมื่อแตะปุ่มหรือกรอกข้อมูล
   ══════════════════════════════════════════════════════════════ */

/* touch-action: manipulation — ตัด 300ms delay และ double-tap zoom บนทุกปุ่มและการ์ด */
button,
.btn,
.q-btn,
.m-q-btn,
.m-card-add-btn,
.m-qty-pill-btn,
.cat-chip,
.m-card,
.pay-chip,
.chip-item,
.size-card,
.conf-btn,
.nav-item,
a {
  touch-action: manipulation;
}

/* iOS Safari auto-zoom fix:
   ถ้า font-size < 16px → Safari จะซูมอัตโนมัติตอนแตะ input
   แก้โดยบังคับ 16px บนมือถือ แล้วใช้ transform scale ทำให้ดูเล็กลงแทน */
@media (max-width: 768px) {
  input.form-control,
  select.form-control,
  textarea.form-control,
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

