/* ═══════════════════════════════════════════════════════════
   BASE.CSS — Design Tokens, Reset, Typography, Layout Shell
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ─── CSS Custom Properties ─────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary:      #0D0D0D;
  --bg-surface:      #1A1A1A;
  --bg-elevated:     #242424;
  --bg-input:        #242424;

  /* Orange Accent */
  --orange:          #FF6B00;
  --orange-hover:    #E55C00;
  --orange-glow:     rgba(255, 107, 0, 0.15);
  --orange-ring:     rgba(255, 107, 0, 0.30);
  --orange-shadow:   rgba(255, 107, 0, 0.50);

  /* Text */
  --text-primary:    #FFFFFF;
  --text-secondary:  #CCCCCC;
  --text-muted:      #888888;
  --text-disabled:   #555555;

  /* Borders */
  --border:          #2E2E2E;
  --border-active:   #FF6B00;

  /* Semantic */
  --success:         #00C896;
  --warning:         #FFB800;
  --error:           #FF4444;

  /* Cost Layer Colors */
  --color-food:      #FF6B00;
  --color-labor:     #4A9EFF;
  --color-overhead:  #A78BFA;
  --color-packaging: #34D399;
  --color-loss:      #FB923C;
  --color-fees:      #F472B6;

  /* Energy Tier Colors */
  --color-low:       #4A9EFF;
  --color-medium:    #FFB800;
  --color-high:      #FF4444;

  /* Radius */
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --radius-xl:       20px;
  --radius-pill:     100px;

  /* Spacing */
  --space-xs:        4px;
  --space-sm:        8px;
  --space-md:        12px;
  --space-lg:        16px;
  --space-xl:        20px;
  --space-2xl:       24px;
  --space-3xl:       32px;

  /* Typography */
  --font-display:    'Syne', sans-serif;
  --font-body:       'DM Sans', sans-serif;
  --font-mono:       'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-med:  200ms ease;
  --transition-slow: 350ms ease;

  /* Bottom Nav Height */
  --nav-height:      64px;

  /* Top Stripe */
  --stripe-height:   3px;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
}

a {
  color: var(--orange);
  text-decoration: none;
}

input, textarea, select, button {
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  border: none;
  background: none;
}

button {
  cursor: pointer;
  color: inherit;
}

ul, ol {
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ─── App Shell ─────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100svh;
  height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  /* Reserve space for fixed bottom nav + iOS safe area */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

/* Orange gradient stripe at top */
#top-stripe {
  flex-shrink: 0;
  height: var(--stripe-height);
  background: linear-gradient(90deg, var(--orange) 0%, #FF9500 50%, var(--orange) 100%);
  background-size: 200% 100%;
  animation: stripeFlow 4s linear infinite;
}

@keyframes stripeFlow {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* ─── Screen Container ──────────────────────────────────── */
#screens {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* Screen scrollable content area */
.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + 80px);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.screen-content::-webkit-scrollbar {
  display: none;
}

/* ─── Screen Header ─────────────────────────────────────── */
.screen-header {
  flex-shrink: 0;
  padding: var(--space-xl) var(--space-lg) var(--space-md);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.screen-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.screen-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Typography Utilities ──────────────────────────────── */
.font-display  { font-family: var(--font-display); }
.font-mono     { font-family: var(--font-mono); }

.text-xs    { font-size: 11px; }
.text-sm    { font-size: 12px; }
.text-base  { font-size: 14px; }
.text-md    { font-size: 15px; }
.text-lg    { font-size: 17px; }
.text-xl    { font-size: 20px; }
.text-2xl   { font-size: 24px; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-orange    { color: var(--orange); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-error     { color: var(--error); }

/* ─── Layout Utilities ──────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-xs   { gap: var(--space-xs); }
.gap-sm   { gap: var(--space-sm); }
.gap-md   { gap: var(--space-md); }
.gap-lg   { gap: var(--space-lg); }
.flex-1   { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full   { width: 100%; }
.overflow-hidden { overflow: hidden; }

.mt-xs  { margin-top: var(--space-xs); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }

/* ─── Scroll Utilities ──────────────────────────────────── */
.scroll-area {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.scroll-area::-webkit-scrollbar { display: none; }

/* ─── Empty State ───────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  gap: var(--space-md);
}

.empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 240px;
}

/* ─── Section Label ─────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-lg) 0 var(--space-sm);
}

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

/* ─── Scrollable Horizontal Chips ───────────────────────── */
.chips-row {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chips-row::-webkit-scrollbar { display: none; }

/* ─── Loading State ─────────────────────────────────────── */
.loading-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── Tooltip ───────────────────────────────────────────── */
.tooltip {
  position: relative;
}

.tooltip-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 100;
}

.tooltip:hover .tooltip-text {
  opacity: 1;
}

/* ─── Grid ──────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-sm);
}

/* ─── Summary Stat Block ────────────────────────────────── */
.stat-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-block .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-block .stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-block .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}
