/**
 * TrendApp base — reset, tipografia, layout shell mobile
 */

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  color: var(--foreground);
  background: var(--muted);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 { margin: 0; letter-spacing: -0.02em; font-weight: 600; }
h1 { letter-spacing: -0.04em; }
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 8px;
}
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

.tabnum { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ─── Viewport mobile ─────────────────────────────────────── */
#root {
  width: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 0%, color-mix(in oklch, var(--primary) 4%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, color-mix(in oklch, var(--chart-2) 4%, transparent) 0%, transparent 50%),
    var(--muted);
}

.viewport {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--background);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), 0 12px 48px oklch(0 0 0 / 0.08);
  display: flex; flex-direction: column;
}

@media (min-width: 640px) {
  #root { padding: 24px 12px; }
  .viewport { border-radius: 32px; min-height: min(920px, calc(100svh - 48px)); max-height: calc(100svh - 48px); }
}

/* ─── Page shell ──────────────────────────────────────────── */
.page {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--background);
  will-change: transform, opacity;
}
.page.stacked { z-index: 5; box-shadow: -8px 0 24px oklch(0 0 0 / 0.08); }

.page-header {
  flex-shrink: 0;
  padding: 12px 20px;
  padding-top: calc(12px + var(--safe-top));
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  background: var(--background);
  border-bottom: 1px solid transparent;
  position: relative;
  z-index: 2;
}
.page-header.with-border { border-bottom-color: var(--border); }
.page-header .h-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; flex: 1; min-width: 0; }
.page-header .h-sub { font-size: 12px; color: var(--muted-foreground); font-weight: 400; }

.page-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
}
.page-body.no-nav { padding-bottom: calc(var(--safe-bottom) + 24px); }
.page-body .stack { display: flex; flex-direction: column; gap: 16px; padding: 8px 20px 24px; }

/* ─── Bottom nav ──────────────────────────────────────────── */
.bottom-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in oklch, var(--background) 92%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: 10;
}
.bottom-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--muted-foreground);
  font-size: 11px; font-weight: 500;
  transition: color 120ms ease;
  position: relative;
  padding-top: 6px;
}
.bottom-nav-item[data-active="true"] { color: var(--foreground); }
.bottom-nav-item[data-active="true"] svg { stroke-width: 2.2; }
.bottom-nav-item .indicator {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 160ms ease;
}
.bottom-nav-item[data-active="true"] .indicator { opacity: 1; }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.card.tight { padding: 12px 14px; }
.card.loose { padding: 20px; }

/* ─── Utility ─────────────────────────────────────────────── */
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted-foreground); }
.eyebrow { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); }
.section-title { font-size: 13px; font-weight: 600; color: var(--foreground); letter-spacing: -0.005em; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Pills / badges ──────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.pill.sm { padding: 2px 7px; font-size: 10px; }
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.farol-verde     { background: color-mix(in oklch, var(--farol-verde) 14%, transparent);    color: var(--farol-verde); }
.farol-amarelo   { background: color-mix(in oklch, var(--farol-amarelo) 16%, transparent);  color: var(--farol-amarelo); }
.farol-vermelho  { background: color-mix(in oklch, var(--farol-vermelho) 12%, transparent); color: var(--farol-vermelho); }

.status-neutral  { background: var(--muted); color: var(--muted-foreground); }
.status-info     { background: color-mix(in oklch, var(--info) 14%, transparent);        color: var(--info); }
.status-warning  { background: color-mix(in oklch, var(--warning) 16%, transparent);     color: var(--warning); }
.status-success  { background: color-mix(in oklch, var(--success) 14%, transparent);     color: var(--success); }
.status-danger   { background: color-mix(in oklch, var(--destructive) 12%, transparent); color: var(--destructive); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  min-height: 44px;
  transition: transform 100ms ease, background 120ms ease, opacity 120ms ease;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklch, var(--primary) 88%, black); }
.btn.secondary { background: var(--secondary); color: var(--secondary-foreground); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--foreground); }
.btn.ghost:hover:not(:disabled) { background: var(--muted); }
.btn.outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.btn.link { padding: 4px 0; min-height: 0; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; min-height: 36px; border-radius: 10px; }
.btn.icon { padding: 8px; min-height: 40px; min-width: 40px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--foreground);
  transition: background 120ms ease;
}
.icon-btn:hover { background: var(--muted); }
.icon-btn:active { background: color-mix(in oklch, var(--muted) 70%, var(--border)); }

/* ─── Inputs ──────────────────────────────────────────────── */
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field label { font-size: 13px; font-weight: 500; color: var(--foreground); }
.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  min-height: 48px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent); }
.input.with-toggle { padding-right: 44px; }
.input-wrap { position: relative; }
.input-wrap .input-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); border-radius: 8px;
}

/* ─── Skeleton ────────────────────────────────────────────── */
@keyframes sk-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } }
.skel {
  display: block;
  background: var(--muted);
  border-radius: 6px;
  animation: sk-pulse 1.4s ease-in-out infinite;
}

/* ─── Sheet (bottom sheet) ────────────────────────────────── */
.sheet-backdrop {
  position: absolute; inset: 0;
  background: oklch(0 0 0 / 0.4);
  z-index: 40;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.sheet-backdrop[data-open="true"] { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  background: var(--card);
  color: var(--card-foreground);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  max-height: 85%;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 -8px 32px oklch(0 0 0 / 0.15);
}
.sheet[data-open="true"] { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--border); margin: 6px auto 12px; }
.sheet-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }

/* ─── Page transitions ────────────────────────────────────── */
.page-enter { animation: page-slide-in 260ms cubic-bezier(.22,.61,.36,1) both; }
.page-exit  { animation: page-slide-out 200ms cubic-bezier(.22,.61,.36,1) both; }
@keyframes page-slide-in  { from { transform: translateX(30%); opacity: 0.4; } to { transform: translateX(0); opacity: 1; } }
@keyframes page-slide-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-15%); opacity: 0.6; } }

.tab-fade { animation: tab-fade 180ms ease; }
@keyframes tab-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Empty state ─────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  text-align: center; gap: 8px;
  color: var(--muted-foreground);
}
.empty .empty-icon {
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--muted);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  color: var(--muted-foreground);
}
.empty .empty-title { font-size: 15px; font-weight: 600; color: var(--foreground); }

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--muted);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.tabs .tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--muted-foreground);
  text-align: center;
  transition: color 120ms ease, background 120ms ease;
}
.tabs .tab[data-active="true"] {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-1);
}

/* ─── Chips (horizontal filter) ───────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: all 120ms ease;
}
.chip[data-active="true"] {
  background: var(--foreground);
  border-color: var(--foreground);
  color: var(--background);
}

/* ─── Tweaks panel ────────────────────────────────────────── */
.tweaks-toggle {
  position: fixed;
  right: 16px; top: 16px;
  z-index: 100;
  width: 44px; height: 44px;
  border-radius: 999px;
  background: var(--foreground);
  color: var(--background);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px oklch(0 0 0 / 0.15);
}
.tweaks-panel {
  position: fixed;
  right: 16px; top: 68px;
  z-index: 99;
  width: 320px;
  max-height: calc(100svh - 96px);
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  overflow-y: auto;
  box-shadow: 0 12px 40px oklch(0 0 0 / 0.15);
}
.tweaks-panel h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.005em; }
.tweaks-panel .tw-section { margin-bottom: 20px; }
.tweaks-panel .tw-section:last-child { margin-bottom: 0; }
.tweaks-panel .tw-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.tweaks-panel .tw-row .tw-label { font-size: 13px; color: var(--foreground); }
.tweaks-panel select, .tweaks-panel input[type="text"] {
  border: 1px solid var(--border); background: var(--background); color: var(--foreground);
  padding: 6px 10px; border-radius: 8px; font-size: 12px;
  min-width: 160px;
}
.tweaks-panel .tw-radio { display: flex; gap: 4px; flex-wrap: wrap; }
.tweaks-panel .tw-radio button {
  padding: 6px 10px; font-size: 12px; font-weight: 500;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--background); color: var(--muted-foreground);
}
.tweaks-panel .tw-radio button[data-on="true"] { background: var(--foreground); color: var(--background); border-color: var(--foreground); }

@media (max-width: 640px) {
  .tweaks-panel { right: 8px; left: 8px; width: auto; max-height: 70svh; }
}

/* ─── WhatsApp button styles ──────────────────────────────── */
.wa-btn {
  background: #25D366;
  color: #fff;
}
.wa-btn:hover:not(:disabled) { background: #1FB358; }
.wa-btn:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

/* ─── Divider spacer ──────────────────────────────────────── */
.section-spacer { height: 4px; }

/* ─── Small helpers ───────────────────────────────────────── */
.mono { font-variant-numeric: tabular-nums; }
.big-money {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.big-money .decimals { font-size: 24px; font-weight: 600; opacity: 0.8; }
.big-money .prefix { font-size: 20px; font-weight: 500; opacity: 0.7; margin-right: 6px; }
