/* ============================================================
   Restro POS — stylesheet
   Layout: sidebar (88px) | content (flex) | order panel (340px)
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #ececef;
  --border-strong: #d9dade;

  --text: #1a1a1f;
  --text-muted: #7d7d86;
  --text-light: #b0b0b8;

  --primary: #ff7a1a;          /* orange — Select Table, Lunch tab, Home active */
  --primary-soft: #fff1e3;
  --primary-strong: #ea6b0f;
  --success: #1fb958;          /* green — Proceed */
  --success-strong: #19a64d;
  --danger: #ef4444;

  --strikethrough: #b8b8c0;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04);
  --shadow: 0 4px 14px rgba(20, 20, 30, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 20, 30, 0.08);

  --font-en: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-lo: 'Noto Sans Lao', 'Plus Jakarta Sans', sans-serif;
  --font-zh: 'Noto Sans SC', 'Plus Jakarta Sans', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.lang-lo { font-family: var(--font-lo); }
body.lang-zh { font-family: var(--font-zh); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.topbar-left {
  display: flex; align-items: center; gap: 24px;
  flex: 1; min-width: 0;
}

.brand {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.brand-mark {
  width: 8px; height: 22px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  border-radius: 2px;
}
.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  flex: 1; max-width: 420px;
  transition: border-color .15s, background .15s;
}
.search:focus-within {
  border-color: var(--primary);
  background: #fff;
}
.search svg { color: var(--text-light); flex-shrink: 0; }
.search input {
  border: none; outline: none; background: transparent;
  flex: 1; font-size: 14px; color: var(--text);
  font-family: inherit;
}
.search input::placeholder { color: var(--text-light); }

.topbar-right {
  display: flex; align-items: center; gap: 10px;
}

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all .15s;
}
.icon-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

/* Language switcher */
.lang-switcher { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  font-size: 13px;
  transition: all .15s;
}
.lang-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.lang-btn .flag { font-size: 16px; line-height: 1; }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 170px;
  list-style: none;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all .18s;
  z-index: 100;
}
.lang-switcher.open .lang-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.lang-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background .12s;
}
.lang-menu li a:hover { background: var(--surface-2); }
.lang-menu li a.active { background: var(--primary-soft); color: var(--primary-strong); }
.lang-menu .flag { font-size: 18px; }
.lang-menu .check { margin-left: auto; color: var(--primary); font-weight: 700; }

/* Primary button (Select Table, etc.) */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(180deg, #ff8a33 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.28);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 122, 26, 0.35);
}
.btn-table { padding: 11px 20px; }

/* ============================================================
   LAYOUT (sidebar | content | order panel)
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 88px 1fr 360px;
  min-height: calc(100vh - 67px);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 8px;
  display: flex; flex-direction: column;
  justify-content: space-between;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: all .15s;
  animation: slideIn .35s both;
  animation-delay: var(--d, 0ms);
}
.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  position: relative;
}
.nav-item.active::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 24px;
  background: var(--primary);
  border-radius: 2px 0 0 2px;
}
.nav-icon { width: 22px; height: 22px; }
.nav-icon svg { width: 100%; height: 100%; }
.nav-label { text-align: center; line-height: 1.2; }

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  padding: 22px 26px;
  background: var(--bg);
  overflow-y: auto;
}

.category-tabs {
  display: flex; gap: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  padding-bottom: 0;
}
.cat-tab {
  position: relative;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all .15s;
  white-space: nowrap;
  animation: fadeUp .4s both;
  animation-delay: var(--d, 0ms);
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.28);
}
.cat-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px; background: var(--primary);
}

/* Product grid — 4 columns */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
  animation: pop .35s both;
  animation-delay: var(--d, 0ms);
  display: flex; flex-direction: column; gap: 10px;
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.product-card:active { transform: translateY(-1px); }

.product-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  max-width: 130px;
  box-shadow: inset 0 -8px 20px rgba(0,0,0,0.08), 0 6px 14px rgba(0,0,0,0.10);
}
.product-emoji {
  font-size: 54px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
  position: relative; z-index: 1;
}
.product-shine {
  position: absolute;
  top: 8%; left: 14%;
  width: 35%; height: 25%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.55) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.product-meta { padding: 0 4px; }
.product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   ORDER PANEL (right)
   ============================================================ */
.order-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 18px 18px 16px;
  display: flex; flex-direction: column;
  gap: 14px;
}

.order-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.order-action {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s;
}
.order-action:hover { border-color: var(--primary); color: var(--primary); border-style: solid; }
.plus-circle {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.order-top-icons { display: flex; gap: 6px; }
.icon-btn-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.icon-btn-sm:hover { color: var(--primary); border-color: var(--primary); }

/* Order list */
.order-list {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: calc(100vh - 380px);
  padding: 4px 0;
}
.order-line {
  display: grid;
  grid-template-columns: 24px 1fr auto 20px;
  gap: 10px;
  align-items: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  transition: background .12s;
  animation: fadeIn .25s both;
}
.order-line:hover { background: var(--surface-2); }
.order-line.editing {
  background: #fff;
  border: 1.5px solid #5dd07a;
  padding-bottom: 14px;
  box-shadow: 0 2px 8px rgba(31, 185, 88, 0.08);
}
.line-qty {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--text-light);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  background: #fff;
}
.line-info { min-width: 0; }
.line-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.line-price {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
}
.line-orig {
  display: block;
  font-size: 11px;
  color: var(--strikethrough);
  text-decoration: line-through;
  font-weight: 400;
}
.line-remove {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-light);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all .15s;
}
.line-remove:hover { background: var(--danger); color: #fff; }

/* Expanded edit row */
.line-edit {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.line-edit-field { display: flex; flex-direction: column; gap: 4px; }
.line-edit-label { font-size: 11px; color: var(--text-muted); }
.line-edit-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.line-edit-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Add discount/coupon/note row */
.order-extras {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 6px 12px;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.extra-label { color: var(--text-muted); font-weight: 500; }
.extra-link {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s;
}
.extra-link:hover { opacity: 0.75; }

/* Totals */
.order-totals {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 6px;
}
.total-row {
  display: flex; justify-content: space-between;
  font-size: 14px;
  color: var(--text);
}
.total-row > span:first-child { color: var(--text-muted); }
.total-row-final {
  font-size: 16px;
  font-weight: 700;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.total-row-final > span:first-child { color: var(--text); }

/* Action buttons */
.order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
}
.btn-hold, .btn-proceed {
  padding: 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  transition: all .15s;
}
.btn-hold {
  background: linear-gradient(180deg, #ff8a33 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 122, 26, 0.28);
}
.btn-hold:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 122, 26, 0.35);
}
.btn-proceed {
  background: linear-gradient(180deg, #2bcb6a 0%, var(--success) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(31, 185, 88, 0.28);
}
.btn-proceed:hover {
  background: linear-gradient(180deg, var(--success) 0%, var(--success-strong) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(31, 185, 88, 0.35);
}

/* Empty cart state */
.order-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   RESPONSIVE — collapse columns on narrow screens
   ============================================================ */
@media (max-width: 1200px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 72px 1fr; }
  .order-panel { display: none; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .brand-name { display: none; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translate(-50%, 12px);
  background: #1a1a1f;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transition: all .25s cubic-bezier(.2,.7,.3,1);
  z-index: 200;
  max-width: 80vw;
}
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.toast.success { background: linear-gradient(180deg, #2bcb6a 0%, #19a64d 100%); }
.toast.error   { background: linear-gradient(180deg, #f87171 0%, #c92a2a 100%); }

/* Scrollbar polish */
.order-list::-webkit-scrollbar,
.content::-webkit-scrollbar { width: 6px; height: 6px; }
.order-list::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.order-list::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover { background: var(--text-light); }
