/* ============================================================
   CLICKFOOD — BASE STYLES: reset, tokens, typography, buttons, forms, cards, badges, skeletons
   ============================================================ */

:root {
  /* Brand: cream background, warm dark brown text, orange-red primary,
     forest green accent. Display type is Bricolage Grotesque, body DM Sans. */
  --color-primary: #E04A1F;
  --color-primary-rgb: 224,74,31;
  --color-primary-dark: #C23D16;
  --color-primary-light: #F2A58C;
  --color-green: #1B4D2E;
  --color-charcoal: #2A1A14;
  --color-offwhite: #F8F3EA;
  --color-yellow: #F2B33D;
  --color-success: #23864B;
  --color-error: #D83A2E;
  --color-gray: #6E6058;

  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Bricolage Grotesque", "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --bg-body: var(--color-offwhite);
  --bg-surface: #FFFCF7;
  --bg-surface-2: #F1EADF;
  --bg-elevated: #FFFFFF;
  --text-primary: #2A1A14;
  --text-secondary: #6E6058;
  --text-inverse: #FFFFFF;
  --text-accent: var(--color-green);
  --border-color: #EADFD1;
  --border-strong: #DACBB8;
  --shadow-sm: 0 1px 2px rgba(42,26,20,0.06);
  --shadow-md: 0 6px 18px rgba(42,26,20,0.08);
  --shadow-lg: 0 14px 36px rgba(42,26,20,0.14);
  --overlay: rgba(28,18,14,0.5);
  --media-bg: #EFE6D9;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --nav-h: 64px;
  --bottomnav-h: 64px;
  --sidebar-w: 220px;

  --transition-fast: 140ms ease;
  --transition-med: 220ms ease;

  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #F0603A;
  --color-primary-rgb: 240,96,58;
  --color-primary-dark: #E04A1F;
  --bg-body: #16110E;
  --bg-surface: #201915;
  --bg-surface-2: #2A221D;
  --bg-elevated: #2F2621;
  --text-primary: #F6EFE6;
  --text-secondary: #B5A89C;
  --text-inverse: #2A1A14;
  --text-accent: #7CC49A;
  --border-color: #3A2F28;
  --border-strong: #4A3D34;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
  --overlay: rgba(0,0,0,0.65);
  --media-bg: #2A221D;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #F0603A;
    --color-primary-rgb: 240,96,58;
    --color-primary-dark: #E04A1F;
    --bg-body: #16110E;
    --bg-surface: #201915;
    --bg-surface-2: #2A221D;
    --bg-elevated: #2F2621;
    --text-primary: #F6EFE6;
    --text-secondary: #B5A89C;
    --text-inverse: #2A1A14;
    --text-accent: #7CC49A;
    --border-color: #3A2F28;
    --border-strong: #4A3D34;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
    --overlay: rgba(0,0,0,0.65);
    --media-bg: #2A221D;
  }
}

* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
  padding-top: var(--nav-h);
}
/* Not on body: with html/body pinned to height:100%, a border-box body's own bottom padding doesn't extend real scroll height (confirmed quirk) — #app has no fixed height, so it does. */
#app { padding-bottom: var(--fixed-bottom-space, 0px); }
/* Public homepage supplies its own (sticky, in-flow) header instead of the
   fixed .app-nav, so no reserved top padding is needed for it. */
body.no-app-nav { padding-top: 0; }

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; }
h1,h2,h3,h4,p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* focus visibility for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Layout helpers ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.grid { display: grid; gap: 16px; }
.grid-menu { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1{margin-top:4px;} .mt-2{margin-top:8px;} .mt-3{margin-top:12px;} .mt-4{margin-top:16px;} .mt-6{margin-top:24px;}
.mb-1{margin-bottom:4px;} .mb-2{margin-bottom:8px;} .mb-3{margin-bottom:12px;} .mb-4{margin-bottom:16px;}
.text-sm { font-size: 13px; } .text-xs{font-size:11px;} .text-lg{font-size:18px;} .text-xl{font-size:22px;}
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-primary-c { color: var(--color-primary); }

.cf-logo-badge svg { display: block; }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.divider { height: 1px; background: var(--border-color); border: none; margin: 16px 0; }

/* ---------- Typography scale ---------- */
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-weight: 600; font-size: 14px;
  border-radius: var(--radius-md); padding: 12px 20px; min-height: 44px;
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--border-color); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover { background: var(--bg-surface-2); }
.btn-sm { padding: 8px 14px; min-height: 34px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 15px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; min-width: 40px; min-height: 40px; border-radius: var(--radius-pill); background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-icon:hover { background: var(--border-color); }
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn-secondary.btn-loading::after, .btn-ghost.btn-loading::after, .btn-google.btn-loading::after { border-color: rgba(30,30,36,0.25); border-top-color: #1f1f1f; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.input, .select, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-primary); font-size: 14px; min-height: 44px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb),0.15); outline: none;
}
.input.has-error { border-color: var(--color-error); }
.field-error { font-size: 12px; color: var(--color-error); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.input-group { display: flex; align-items: center; border: 1.5px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-surface); padding: 0 12px; }
.input-group input { border: none; background: transparent; min-height: 44px; flex: 1; }
.input-group input:focus { outline: none; box-shadow: none; }

/* ---------- Custom select (native <select> popups render inconsistently
   in some mobile browsers; this is a self-positioned replacement) ---------- */
.custom-select { position: relative; }
.custom-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-primary); font-size: 14px; min-height: 44px;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.custom-select-trigger .custom-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-trigger .custom-select-value.placeholder { color: var(--text-secondary); }
.custom-select-trigger:focus, .custom-select-trigger.open {
  border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb),0.15); outline: none;
}
.custom-select-trigger i { flex-shrink: 0; width: 16px; height: 16px; color: var(--text-secondary); transition: transform var(--transition-fast); }
.custom-select-trigger.open i { transform: rotate(180deg); }
.custom-select-panel {
  position: fixed; background: var(--bg-elevated); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); overflow-y: auto; padding: 4px; z-index: 2000;
}
.custom-select-option {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-primary);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.custom-select-option:hover { background: var(--bg-surface-2); }
.custom-select-option.selected { color: var(--color-primary); font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color); transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card-pad { padding: 18px; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-hover:active { transform: scale(0.98); }

/* ---------- Image fade-in (lazy-loaded photos) ---------- */
.fade-img { opacity: 0; transition: opacity 280ms ease; }
.fade-img.loaded { opacity: 1; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: var(--radius-pill); text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-primary { background: rgba(var(--color-primary-rgb),0.14); color: var(--color-primary-dark); }
.badge-yellow { background: rgba(255,193,7,0.22); color: #8a6400; }
.badge-success { background: rgba(34,197,94,0.15); color: #157a41; }
.badge-error { background: rgba(239,68,68,0.14); color: #b91c1c; }
.badge-gray { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border-color); }
:root[data-theme="dark"] .badge-yellow { color: #FFC107; }
:root[data-theme="dark"] .badge-success { color: #4ade80; }
:root[data-theme="dark"] .badge-error { color: #f87171; }

/* ---------- Skeletons ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--border-color) 37%, var(--bg-surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Empty states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 20px; color: var(--text-secondary); gap: 10px; }
.empty-state .icon-wrap { width: 64px; height: 64px; border-radius: 50%; background: var(--bg-surface-2); display: flex; align-items: center; justify-content: center; color: var(--color-primary); margin-bottom: 6px; }
.empty-state h3 { color: var(--text-primary); font-size: 16px; }

/* ---------- Scrollbars (light touch) ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

/* Utility for icon sizing via lucide */
[data-lucide] { width: 1em; height: 1em; }
svg.lucide { display: inline-block; vertical-align: -2px; }

/* ---------- Typography ----------
   Headings, shop and food names use the display face; everything else
   (body, inputs, buttons) uses the body face. */
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4,
.page-title, .section-title, .modal-title, .msection-title, .msection-title-sm, .shop-section-title,
.hero-title, .mhero-title, .mhero-title-lg, .mhow-title, .mfeature-title, .onboarding-headline, .campus-setup-title,
.brand, .home-brand, .store-card-name, .store-mini-name, .mshop-card-name, .shop-info-name, .shop-prod-name,
.menu-card-name, .hot-name, .deal-title, .promo-mini-title, .kanban-col-title, .stat-value, .empty-state h3 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}
h1, .page-title, .hero-title, .mhero-title, .mhero-title-lg, .onboarding-headline { font-weight: 800; letter-spacing: -0.025em; line-height: 1.08; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-primary); }
.text-accent { color: var(--text-accent); }

/* Shown only until the first session check finishes (js/app.js skeleton()).
   Same cream as manifest background_color; no logo. */
.boot-screen {
  position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 5000;
  background: #FDF3DF; display: flex; align-items: center; justify-content: center; padding: 40px 20px; text-align: center;
}
.boot-screen .text-muted { color: #6E6058; }
