/* ══════════════════════════════════════════
   MiniApp Chocolat — Night Indigo v4
   Rubik · Inter · Flat · Mobile-first
   ══════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  --bg:         #07090F;
  --bg2:        #0F1320;
  --bg3:        #161C2D;
  --text:       #EEF2FF;
  --text2:      #C7D2FE;
  --hint:       #6B7280;
  --accent:     #6366F1;
  --accent2:    #818CF8;
  --cta:        #F59E0B;
  --border:     rgba(99,102,241,0.1);
  --border-md:  rgba(99,102,241,0.2);
  --danger:     #EF4444;
  --warning:    #F59E0B;
  --success:    #10B981;
  --choco:      #C47A2E;
  --radius:     18px;
  --radius-sm:  12px;
  --radius-xs:  8px;
  --nav-h:      66px;
  --safe-b:     env(safe-area-inset-bottom, 0px);
  --t:          0.15s ease;
  --t-fast:     0.1s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}

/* ══ NAVIGATION ══ */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 100;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 9px;
  font-family: 'Rubik', inherit;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.2px;
  padding: 6px 2px;
  transition: color var(--t);
  position: relative;
}

.nav-ico {
  width: 44px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 15px;
  transition: background var(--t);
  position: relative;
}
.nav-ico svg { width: 22px; height: 22px; transition: transform var(--t-fast); }
.nav-btn:active .nav-ico svg { transform: scale(0.87); }

.nav-btn.active { color: var(--accent2); }
.nav-btn.active .nav-ico { background: rgba(99,102,241,0.16); }
.nav-btn.active .nav-ico svg { stroke-width: 2.5; }

/* Cart badge */
.cart-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--cta);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  font-family: 'Rubik', inherit;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.cart-badge.show { display: flex; }

/* ══ SECTIONS ══ */
.section { display: none; padding: 20px 16px 8px; }
.section.active { display: block; }

/* ══ PAGE HEADER ══ */
.page-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-hdr-ico {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: rgba(99,102,241,0.1);
  border: 1px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
  flex-shrink: 0;
}
.page-hdr h2 {
  font-family: 'Rubik', inherit;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
  margin: 0;
}

/* ══ TYPOGRAPHY ══ */
h2 {
  font-family: 'Rubik', inherit;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -0.2px;
}
h3 {
  font-family: 'Rubik', inherit;
  font-size: 10px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 14px;
}

/* ══ CARDS ══ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

/* ══ CATEGORY CHIPS ══ */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 99px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--hint);
  font-family: 'Rubik', inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.chip.active {
  background: rgba(99,102,241,0.15);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ══ PRODUCT CARD ══ */
.product-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.product-card.unavailable { opacity: 0.5; }
.product-emoji {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: rgba(99,102,241,0.08);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name {
  font-family: 'Rubik', inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 3px;
}
.product-desc {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 8px;
  line-height: 1.4;
}
.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.product-price {
  font-family: 'Rubik', inherit;
  font-size: 17px;
  font-weight: 800;
  color: var(--cta);
}

/* ══ QTY CONTROL ══ */
.qty-ctrl {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.qty-btn {
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  color: var(--accent2);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.qty-btn:active { background: var(--border-md); }
.qty-val {
  width: 32px;
  text-align: center;
  font-family: 'Rubik', inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ══ FORMS ══ */
.form-group { margin-bottom: 14px; }
label {
  display: block;
  font-family: 'Rubik', inherit;
  font-size: 11px;
  color: var(--hint);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
input, select, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t), background var(--t);
  -webkit-appearance: none;
  min-height: 50px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: rgba(99,102,241,0.06);
}
input::placeholder, textarea::placeholder { color: var(--hint); opacity: 1; }
select option { background: var(--bg2); }
textarea { min-height: 80px; resize: none; }

/* ══ BUTTONS ══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: 'Rubik', inherit;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t-fast), background var(--t);
  min-height: 50px;
  letter-spacing: 0.1px;
}
.btn:active { opacity: 0.75; transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; width: 100%; border-color: var(--accent); }
.btn-primary:active { background: var(--accent2); }
.btn-cta { background: var(--cta); color: #000; width: 100%; border-color: var(--cta); font-weight: 700; }
.btn-cta:active { filter: brightness(0.9); }
.btn-secondary { background: var(--bg3); color: var(--text2); border-color: var(--border-md); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(239,68,68,0.25); }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; border-radius: var(--radius-xs); }
.btn-icon {
  width: 36px; height: 36px; min-height: 36px;
  padding: 0;
  border-radius: var(--radius-xs);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--hint);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t);
}
.btn-icon:active { background: var(--border-md); color: var(--text); }

/* ══ CART ITEMS ══ */
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-emoji { font-size: 24px; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; font-size: 14px; }
.cart-item-price { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* ══ STAT CARDS ══ */
.stat-card {
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  text-align: center;
  margin-bottom: 12px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(99,102,241,0.04) 100%);
  border: 1px solid var(--border-md);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(99,102,241,0.07);
}
.stat-card .stat-value {
  font-family: 'Rubik', inherit;
  font-size: 44px;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 8px;
  position: relative;
}
.stat-card .stat-label {
  font-family: 'Rubik', inherit;
  font-size: 10px;
  color: var(--hint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  position: relative;
}

/* ══ MINI STATS ══ */
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.mini-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 6px;
  text-align: center;
}
.mini-stat .val {
  font-family: 'Rubik', inherit;
  font-size: 19px;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: -0.5px;
}
.mini-stat .lbl {
  font-family: 'Rubik', inherit;
  font-size: 10px;
  color: var(--hint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-top: 3px;
}

/* ══ ORDER CARD ══ */
.order-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.order-id {
  font-family: 'Rubik', inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.5px;
}
.order-date { font-size: 11px; color: var(--hint); }
.order-customer { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.order-items { font-size: 13px; color: var(--hint); margin-bottom: 10px; line-height: 1.6; }
.order-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.order-total {
  font-family: 'Rubik', inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--cta);
}
.order-actions { display: flex; gap: 6px; }

/* ══ STATUS BADGES ══ */
.status-badge {
  display: inline-block;
  font-family: 'Rubik', inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.status-pending   { background: rgba(99,102,241,0.12); color: var(--accent2); border: 1px solid rgba(99,102,241,0.25); }
.status-confirmed { background: rgba(16,185,129,0.1);  color: var(--success); border: 1px solid rgba(16,185,129,0.25); }
.status-ready     { background: rgba(245,158,11,0.1);  color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }
.status-done      { background: rgba(16,185,129,0.08); color: var(--success); border: 1px solid rgba(16,185,129,0.2);  }
.status-cancelled { background: rgba(239,68,68,0.1);   color: var(--danger);  border: 1px solid rgba(239,68,68,0.22); }

/* ══ CATALOG ITEM (admin) ══ */
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.catalog-item:last-child { border-bottom: none; }
.catalog-item .info { flex: 1; min-width: 0; }
.catalog-item .info .item-name { font-weight: 600; font-size: 14px; }
.catalog-item .info .item-meta { font-size: 12px; color: var(--hint); margin-top: 3px; }
.catalog-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ══ STOCK BADGES ══ */
.stock-badge {
  font-family: 'Rubik', inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.22);
  white-space: nowrap;
}
.stock-badge.warn   { background: rgba(245,158,11,0.1); color: var(--warning); border-color: rgba(245,158,11,0.22); }
.stock-badge.danger { background: rgba(239,68,68,0.1);  color: var(--danger);  border-color: rgba(239,68,68,0.22); }

/* ══ MODAL ══ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0 16px calc(24px + var(--safe-b));
  width: 100%;
  max-height: 88dvh;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--border-md);
  border-radius: 2px;
  margin: 12px auto 18px;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-title {
  font-family: 'Rubik', inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--hint);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.modal-close:active { background: var(--border-md); color: var(--text); }

/* ══ TOAST ══ */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  left: 16px; right: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Rubik', inherit;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--success); color: #000; }
#toast.error   { background: var(--danger);  color: #fff; }
#toast.info    { background: var(--accent);  color: #fff; }

/* ══ SPINNER ══ */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ LOCKED SCREEN ══ */
#locked-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 24px;
  text-align: center;
  gap: 14px;
}
#locked-screen .lock-icon {
  width: 80px; height: 80px;
  border-radius: 24px;
  background: rgba(99,102,241,0.1);
  border: 1px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
  margin-bottom: 8px;
}
#locked-screen h2 { font-family: 'Rubik', inherit; font-size: 22px; font-weight: 800; margin: 0; }
#locked-screen p  { color: var(--hint); font-size: 15px; max-width: 280px; line-height: 1.6; margin: 0; }

/* ══ PIN SCREEN ══ */
#pin-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0 24px;
  background: var(--bg);
}
.pin-wrapper {
  width: 100%;
  max-width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: clamp(8px, 2dvh, 24px) 0;
}
.pin-icon {
  width: 72px; height: 72px;
  border-radius: 22px;
  background: rgba(99,102,241,0.1);
  border: 1px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
}
.pin-title  { font-family: 'Rubik', inherit; font-size: clamp(18px, 3.5dvh, 24px); font-weight: 700; text-align: center; }
.pin-subtitle { font-size: clamp(12px, 1.8dvh, 14px); color: var(--hint); text-align: center; min-height: 1em; }
.pin-dots { display: flex; gap: clamp(16px, 5vw, 26px); }
.pin-dot {
  width: clamp(13px, 4vw, 18px); height: clamp(13px, 4vw, 18px);
  border-radius: 50%;
  border: 2px solid var(--border-md);
  background: transparent;
  transition: background 0.12s, border-color 0.12s, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); transform: scale(1.2); }
.pin-error { font-size: clamp(12px, 1.8dvh, 14px); color: var(--danger); text-align: center; min-height: 1em; font-weight: 600; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-10px); }
  30%  { transform: translateX(10px); }
  45%  { transform: translateX(-7px); }
  60%  { transform: translateX(7px); }
  75%  { transform: translateX(-4px); }
  90%  { transform: translateX(4px); }
}
.pin-dots.shake { animation: pin-shake 0.45s ease; }
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 2.5dvh, 16px);
  width: 100%;
}
.numpad-btn {
  width: min(76px, 26vw, 11dvh); height: min(76px, 26vw, 11dvh);
  justify-self: center;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: min(26px, 7.5vw, 3.8dvh);
  font-weight: 600;
  font-family: 'Rubik', inherit;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
  display: flex; align-items: center; justify-content: center;
}
.numpad-btn:active { background: var(--bg3); transform: scale(0.91); }
.numpad-del { color: var(--hint); }

/* ══ EMPTY STATE ══ */
.empty { text-align: center; color: var(--hint); padding: 40px 0; font-size: 14px; }

/* ══ PIN BADGE ══ */
.pin-badge {
  display: inline-block;
  font-family: 'Rubik', inherit;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  vertical-align: middle; margin-left: 4px;
}
.pin-badge.no-pin  { background: rgba(245,158,11,0.1);  color: var(--warning); border: 1px solid rgba(245,158,11,0.22); }
.pin-badge.has-pin { background: rgba(16,185,129,0.08); color: var(--success); border: 1px solid rgba(16,185,129,0.22); }

/* ══ REDUCED MOTION ══ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
