/* =====================================================================
   POS COFFEE SHOP & RESTO — Mobile-first Compact Design System
   ===================================================================== */
:root {
  --primary: #6f4e37;      /* coffee brown */
  --primary-dark: #4a3226;
  --primary-light: #a97c50;
  --accent: #d4a373;
  --success: #2e7d32;
  --warning: #f9a825;
  --danger: #c62828;
  --bg: #f7f4f1;
  --surface: #ffffff;
  --text: #2b2320;
  --text-muted: #8a7d73;
  --border: #e8e0d8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(43,35,32,0.08);
  --shadow-lg: 0 8px 24px rgba(43,35,32,0.15);
  --header-h: 52px;
  --nav-h: 56px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar .user-chip { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; }
.topbar .icon-btn { color: #fff; padding: 6px; font-size: 18px; }

.main-content { flex: 1; overflow-y: auto; padding-bottom: var(--nav-h); position: relative; }

/* Bottom nav for mobile */
.side-nav { display: none; }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: #fff; border-top: 1px solid var(--border);
  display: flex; z-index: 30;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-muted); font-size: 10px; text-decoration: none;
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .ic { font-size: 18px; }

/* Desktop: side nav instead of bottom nav */
@media (min-width: 900px) {
  .app-shell { flex-direction: row; }
  .side-nav {
    width: 76px; background: var(--primary-dark); flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 4px;
    height: 100vh; overflow-y: auto;
  }
  .side-nav a {
    width: 60px; padding: 8px 0; display: flex; flex-direction: column; align-items: center;
    gap: 4px; color: rgba(255,255,255,0.65); text-decoration: none; font-size: 10px; border-radius: 8px;
  }
  .side-nav a.active { background: rgba(255,255,255,0.12); color: #fff; }
  .side-nav a .ic { font-size: 20px; }
  .bottom-nav { display: none; }
  .content-col { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
  .main-content { padding-bottom: 0; }
}

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 600px) { .grid-4-sm { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .grid-6-md { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #2b2320; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Menu grid (Fast Lane / Bar Mode) ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px; }
@media (min-width: 600px) { .menu-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .menu-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .menu-grid { grid-template-columns: repeat(5, 1fr); } }

.menu-item {
  background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; text-align: left; position: relative;
}
.menu-item .thumb { height: 72px; background: linear-gradient(135deg, var(--accent), var(--primary-light)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; }
.menu-item .info { padding: 8px; }
.menu-item .name { font-size: 12.5px; font-weight: 600; line-height: 1.25; height: 32px; overflow: hidden; }
.menu-item .price { font-size: 12px; color: var(--primary); font-weight: 700; margin-top: 4px; }
.menu-item .fav-badge { position: absolute; top: 6px; right: 6px; background: var(--warning); color: #2b2320; font-size: 9px; padding: 2px 5px; border-radius: 4px; font-weight: 700; }

.category-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; -webkit-overflow-scrolling: touch; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button { flex-shrink: 0; padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.category-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Cart / order panel ---------- */
.cart-panel { display: flex; flex-direction: column; height: 100%; background: #fff; }
.cart-header { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px 10px; }
.cart-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.cart-item .mods { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.cart-footer { padding: 10px 12px; border-top: 1px solid var(--border); }
.cart-totals-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.cart-totals-row.total { font-size: 15px; font-weight: 700; color: var(--primary); padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }

/* mobile: cart as bottom drawer */
.cart-drawer-toggle {
  position: fixed; bottom: calc(var(--nav-h) + 10px); right: 12px; z-index: 25;
  background: var(--primary); color: #fff; border-radius: 50px; padding: 10px 16px;
  box-shadow: var(--shadow-lg); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px;
}
.cart-drawer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; display: none;
}
.cart-drawer.open { display: flex; align-items: flex-end; }
.cart-drawer .sheet { background: #fff; width: 100%; max-height: 85vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }

@media (min-width: 900px) {
  .pos-layout { display: flex; height: 100%; }
  .pos-menu-col { flex: 1; overflow-y: auto; }
  .pos-cart-col { width: 340px; flex-shrink: 0; border-left: 1px solid var(--border); }
  .cart-drawer-toggle, .cart-drawer { display: none; }
}

/* ---------- Floor plan (Table Mode) ---------- */
.floor-plan { position: relative; padding: 16px; min-height: 500px; }
.floor-area-tabs { display: flex; gap: 6px; padding: 8px 10px; }
.floor-area-tabs button { padding: 6px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.floor-area-tabs button.active { background: var(--primary-dark); color: #fff; }

.table-tile {
  width: 84px; height: 84px; border-radius: var(--radius); background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow); border: 2px solid transparent; gap: 2px;
}
.table-tile .code { font-weight: 700; font-size: 13px; }
.table-tile .status-label { font-size: 9px; font-weight: 600; text-transform: uppercase; }
.table-tile .amount { font-size: 10px; color: var(--text-muted); }
.table-tile.status-empty { border-color: #c8e6c9; }
.table-tile.status-empty .status-label { color: var(--success); }
.table-tile.status-occupied { border-color: #ffe0b2; background: #fff8f0; }
.table-tile.status-occupied .status-label { color: #e65100; }
.table-tile.status-waiting_food { border-color: #ffcc80; background: #fff3e0; }
.table-tile.status-waiting_food .status-label { color: var(--warning); }
.table-tile.status-unpaid { border-color: #ef9a9a; background: #ffebee; }
.table-tile.status-unpaid .status-label { color: var(--danger); }

.table-grid-wrap { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px; }

/* ---------- KDS ---------- */
.kds-shell { background: #1a1512; height: 100vh; overflow: hidden; display: flex; flex-direction: column; color: #fff; }
.kds-header { padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; background: #100d0b; flex-shrink: 0; }
.kds-header h1 { font-size: 16px; }
.kds-clock { font-size: 13px; opacity: 0.7; }
.kds-board { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
@media (min-width: 700px) { .kds-board { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 1100px) { .kds-board { grid-template-columns: repeat(4,1fr); } }
@media (min-width: 1500px) { .kds-board { grid-template-columns: repeat(5,1fr); } }

.kds-ticket { border-radius: 10px; padding: 10px; background: #2a2320; border-left: 6px solid #666; }
.kds-ticket.urgency-green { border-left-color: #4caf50; }
.kds-ticket.urgency-yellow { border-left-color: #ffb300; background: #35291a; }
.kds-ticket.urgency-red { border-left-color: #e53935; background: #3a1f1e; animation: pulse-red 1.5s infinite; }
@keyframes pulse-red { 0%,100% { box-shadow: 0 0 0 rgba(229,57,53,0); } 50% { box-shadow: 0 0 12px rgba(229,57,53,0.5); } }

.kds-ticket .head { display: flex; justify-content: space-between; font-size: 11px; opacity: 0.75; margin-bottom: 6px; }
.kds-ticket .prod-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.kds-ticket .qty-badge { background: #fff; color: #1a1512; border-radius: 6px; padding: 1px 7px; font-weight: 800; font-size: 12px; }
.kds-ticket .mods-list { font-size: 12px; opacity: 0.85; margin-bottom: 8px; }
.kds-ticket .notes { font-size: 11.5px; background: rgba(255,255,255,0.08); padding: 4px 6px; border-radius: 6px; margin-bottom: 8px; }
.kds-ticket .actions { display: flex; gap: 6px; }
.kds-ticket .actions button { flex: 1; padding: 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.kds-timer { font-weight: 700; }

/* ---------- Forms / modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--radius); width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; }
.modal-box .modal-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-box .modal-header h3 { font-size: 15px; }
.modal-box .modal-body { padding: 14px 16px; }
.modal-box .modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.form-control { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px; }
.form-row { display: flex; gap: 8px; }
.form-row .form-group { flex: 1; }

.modifier-group-section { margin-bottom: 14px; }
.modifier-group-section .group-title { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.modifier-options { display: flex; flex-wrap: wrap; gap: 6px; }
.modifier-options .opt-chip { padding: 7px 12px; border-radius: 20px; border: 1.5px solid var(--border); font-size: 12px; }
.modifier-options .opt-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Badges / utility ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10.5px; font-weight: 700; }
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-danger { background: #ffebee; color: var(--danger); }
.badge-muted { background: #f0ece7; color: var(--text-muted); }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .ic { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }

.toast-container { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; width: 90%; max-width: 380px; }
.toast { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: slideDown 0.2s ease; }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes slideDown { from { opacity:0; transform: translateY(-10px);} to {opacity:1; transform: translateY(0);} }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--primary-dark), var(--primary)); padding: 20px; }
.login-box { background: #fff; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); }
.login-box h1 { text-align: center; font-size: 20px; color: var(--primary); margin-bottom: 4px; }
.login-box .sub { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th, table.data-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--border); }
table.data-table th { color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; }
