/* ═══════════════════════════════════════════════
   main.css — Ontable Shop Owner Design System
   ═══════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────── */
:root {
  --primary:        #4C1D95;
  --primary-mid:    #7C3AED;
  --primary-light:  #EDE9FE;
  --gold:           #FAC775;
  --success:        #059669;
  --success-light:  #D1FAE5;
  --warning:        #D97706;
  --warning-light:  #FEF3C7;
  --danger:         #DC2626;
  --danger-light:   #FEE2E2;
  --info:           #1D4ED8;
  --info-light:     #DBEAFE;
  --surface:        #FFFFFF;
  --bg:             #F7F6F3;
  --border:         #E5E7EB;
  --text-1:         #111827;
  --text-2:         #6B7280;
  --text-3:         #9CA3AF;
  --radius:         12px;
  --radius-lg:      16px;
  --shadow:         0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.12);
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  max-width: 390px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ── [v-cloak] hide ──────────────────────────────── */
[v-cloak] { display: none !important; }

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, #4C1D95, #7C3AED);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  color: #fff;
}
.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.topbar-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-back:active { background: rgba(255,255,255,.25); }

/* ── Bottom Nav ──────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  max-width: 390px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: 10px;
  color: var(--text-3);
  gap: 2px;
  position: relative;
  transition: color .2s;
  border: none;
  background: none;
  text-decoration: none;
}
.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { color: var(--primary); }
.nav-badge {
  position: absolute;
  top: 4px; right: 20%;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* ── Page Wrapper ────────────────────────────────── */
.page {
  padding-bottom: 80px;
  min-height: 100vh;
}
.page-content {
  padding: 16px;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 12px;
}

/* ── KYB Alert Banner ────────────────────────────── */
#kyb-alert-banner {
  display: none;
  background: var(--warning-light);
  border-bottom: 1px solid #FDE68A;
  padding: 10px 16px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #78350F;
}
#kyb-alert-banner a {
  color: var(--primary);
  font-weight: 700;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-secondary{ background: #F3F4F6; color: var(--text-1); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-sm       { padding: 8px 14px; font-size: 12px; border-radius: 8px; }
.btn-block    { width: 100%; }
.btn-icon     { padding: 10px; border-radius: 10px; }

/* ── Forms ───────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}
.form-label span { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-1);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary-mid); }
.form-control::placeholder { color: var(--text-3); }
.form-control.error { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.form-hint  { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger);  margin-top: 4px; }

/* ── Toggle Switch ───────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.toggle-label { font-size: 14px; color: var(--text-1); }
.toggle {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
  border: none;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { transform: translateX(20px); }

/* ── Stepper ─────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 0;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.step-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--border); color: var(--text-3);
}
.step.active .step-circle  { background: var(--primary); color: #fff; }
.step.done   .step-circle  { background: var(--success); color: #fff; }
.step-label  { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.step.active .step-label   { color: var(--primary); font-weight: 600; }
.step-line   { flex: 1; height: 2px; background: var(--border); margin-top: -16px; }
.step-line.done { background: var(--success); }

/* ── Status Tracker (order timeline) ────────────── */
.status-tracker {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 12px 0;
  gap: 0;
  scrollbar-width: none;
}
.status-tracker::-webkit-scrollbar { display: none; }
.tracker-step { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 60px; }
.tracker-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-3);
  border: 2px solid var(--border);
  position: relative; z-index: 1;
}
.tracker-step.done   .tracker-dot { background: var(--success); border-color: var(--success); color: #fff; }
.tracker-step.active .tracker-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.tracker-label { font-size: 10px; color: var(--text-3); text-align: center; margin-top: 4px; line-height: 1.3; }
.tracker-date  { font-size: 9px; color: var(--text-3); text-align: center; margin-top: 2px; }
.tracker-step.done   .tracker-label { color: var(--success); }
.tracker-step.active .tracker-label { color: var(--primary); font-weight: 700; }
.tracker-line  { flex: 1; height: 2px; background: var(--border); margin-top: 12px; min-width: 20px; }
.tracker-line.done { background: var(--success); }

/* ── Alert Banner ────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.alert-warning { background: var(--warning-light); color: #78350F; border: 1px solid #FDE68A; }
.alert-success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-info    { background: var(--info-light);    color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-danger  { background: var(--danger-light);  color: #991B1B; border: 1px solid #FCA5A5; }
.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* ── Stats Strip ─────────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 10px; color: var(--text-2); margin-top: 4px; line-height: 1.2; }

/* ── Section Header ──────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

/* ── List Item ───────────────────────────────────── */
.list-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.list-item:active { box-shadow: var(--shadow-md); }

/* ── Chips / Tags ────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-purple  { background: var(--primary-light); color: var(--primary); }
.chip-green   { background: var(--success-light); color: var(--success); }
.chip-orange  { background: var(--warning-light); color: var(--warning); }
.chip-red     { background: var(--danger-light);  color: var(--danger); }
.chip-gray    { background: #F3F4F6; color: var(--text-2); }
.chip-blue    { background: var(--info-light); color: var(--info); }

/* ── Divider ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-2);
}
.empty-state i { font-size: 48px; color: var(--text-3); margin-bottom: 12px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ── Bottom Sheet ────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
  z-index: 300;
  animation: fadeIn .2s;
}
.sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  animation: slideUp .25s;
  max-height: 90vh;
  overflow-y: auto;
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 20px;
}

/* ── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  background: #F3F4F6;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 9px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.tab-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ── Pill Filter ─────────────────────────────────── */
.pill-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  margin-bottom: 12px;
}
.pill-filters::-webkit-scrollbar { display: none; }
.pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Upload Card ─────────────────────────────────── */
.upload-card {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
  overflow: hidden;
}
.upload-card:hover, .upload-card.drag { border-color: var(--primary-mid); background: var(--primary-light); }
.upload-card input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-card i { font-size: 32px; color: var(--text-3); display: block; margin-bottom: 8px; }
.upload-card-text { font-size: 13px; color: var(--text-2); }
.upload-card-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── Food Grid ───────────────────────────────────── */
.food-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.food-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.food-card-img {
  width: 100%; height: 80px;
  object-fit: cover;
  background: #F3F4F6;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  color: var(--text-3);
}
.food-card-body { padding: 8px 10px; }
.food-card-name { font-size: 12px; font-weight: 600; color: var(--text-1); }

/* ── Timeline ────────────────────────────────────── */
.timeline { padding: 4px 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px; top: 22px;
  width: 2px;
  bottom: 0;
  background: var(--border);
}
.timeline-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.timeline-dot i { font-size: 12px; color: var(--primary); }
.timeline-body { flex: 1; padding-top: 2px; }
.timeline-text { font-size: 13px; color: var(--text-1); font-weight: 600; }
.timeline-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Summary Table ───────────────────────────────── */
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td { padding: 6px 0; font-size: 13px; vertical-align: top; }
.summary-table td:last-child { text-align: right; font-weight: 600; }
.summary-table .total-row td { font-weight: 700; font-size: 14px; border-top: 1.5px solid var(--border); padding-top: 10px; }
.summary-table .net-row td { font-weight: 800; font-size: 15px; color: var(--primary); }

/* ── Checklist ───────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checkbox {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.checkbox.checked { background: var(--success); border-color: var(--success); }
.checkbox.checked::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 700; }

/* ── Price Badge ─────────────────────────────────── */
.price-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-block;
}

/* ── Sticky Bottom Action Bar ────────────────────── */
.action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  max-width: 390px;
  margin: 0 auto;
  z-index: 100;
  display: flex;
  gap: 10px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* ── Animations ──────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Skeleton Loading ────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Utility Classes ─────────────────────────────── */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger);  }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-2);  }
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg   { font-size: 17px; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
