/* =============================================================================
   RX TECH / B-TEK · Dashboard v2 · DESIGN TOKENS
   =============================================================================
   Sistema de tokens baseado em Apple HIG Dark + tempero aprovado por Kawe.
   - Nunca hardcode cor em components.css — SEMPRE usar var(--token).
   - Breakpoint principal: 768px (tablet/mobile).
   - Respeita prefers-reduced-motion (animações desligam).
   - Contraste testado WCAG AA em fundo #08080a.
   ============================================================================= */

:root {
  /* ══════════════════════════════════════════════════════════════
     BRAND · RX TECH (institucional)
     ══════════════════════════════════════════════════════════════ */
  --brand-color-primary: #F57920;     /* laranja institucional RX TECH */
  --brand-color-primary-hover: #FF8A3D;
  --brand-color-primary-deep: #D4691C;
  --brand-logo-url: url('/app/shared/brand-assets/logo-rxtech-mark.svg');
  --brand-logo-horizontal-url: url('/app/shared/brand-assets/logo-rxtech-horizontal.svg');
  --brand-logo-square-url: url('/app/shared/brand-assets/logo-rxtech-square-transparent.svg');
  --brand-favicon-url: url('/app/shared/brand-assets/favicon.svg');
  --brand-tint: rgba(245, 121, 32, 0.18);
  --brand-glow: 0 0 24px rgba(245, 121, 32, 0.35);

  /* ══════════════════════════════════════════════════════════════
     BACKGROUNDS
     ══════════════════════════════════════════════════════════════ */
  --bg-app: #08080a;              /* fundo da página (quase preto) */
  --bg-card: #1c1c1e;             /* shell principal, cards padrão */
  --bg-card-hover: #242426;       /* hover em card, header interno */
  --bg-elevated: #2c2c2e;         /* chips, KPIs strip, inputs */
  --bg-elevated-2: #3a3a3c;       /* botões secundários */
  --bg-sunken: #1a1a1c;           /* regiões mais escuras que card */
  --bg-ticker: #0a0a0c;           /* ticker inferior */
  --bg-subnav: #1e1e20;           /* sub-nav background + timeline */
  --bg-kpi-gradient-end: #232325; /* final do gradiente de KPI card */
  --bg-ads-border-deep: #4a2f1a;  /* borda especial de KPI ads-highlight */

  /* Tints aplicados em hero-cards (brilham com glow) */
  --bg-hero-fat-a: #1a2e22;       /* verde escuro · topo */
  --bg-hero-fat-b: #0f1f16;       /* verde escuro · base */
  --bg-hero-lucro-a: #1a2642;     /* azul escuro · topo */
  --bg-hero-lucro-b: #0f1528;     /* azul escuro · base */
  --bg-hero-proj-a: #2a1a3f;      /* roxo escuro · topo */
  --bg-hero-proj-b: #1a0f28;      /* roxo escuro · base */
  --bg-hero-ads-a: #2a1f1a;       /* laranja escuro · topo */
  --bg-hero-ads-b: #1f1614;       /* laranja escuro · base */
  --bg-hero-defeito-a: #2e1a1a;   /* vermelho escuro · topo */
  --bg-hero-defeito-b: #1f0f0f;   /* vermelho escuro · base */
  --bg-hero-transito-a: #2e251a;  /* amarelo escuro · topo */
  --bg-hero-transito-b: #1f180f;  /* amarelo escuro · base */

  /* ══════════════════════════════════════════════════════════════
     BORDERS
     ══════════════════════════════════════════════════════════════ */
  --border: #3a3a3c;              /* borda padrão */
  --border-hover: #48484a;        /* hover padrão */
  --border-subtle: #2a2a2c;       /* borda timeline/nested */
  --border-blue-soft: rgba(10, 132, 255, 0.3);
  --border-green-soft: rgba(48, 209, 88, 0.3);
  --border-red-soft: rgba(255, 69, 58, 0.3);
  --border-orange-soft: rgba(255, 159, 10, 0.3);
  --border-purple-soft: rgba(191, 90, 242, 0.3);

  /* ══════════════════════════════════════════════════════════════
     TEXTS
     ══════════════════════════════════════════════════════════════ */
  --text-primary: #f2f2f7;        /* branco principal (WCAG AA em todos os bg) */
  --text-secondary: #a8a8ad;      /* cinza claro · metadata */
  --text-tertiary: #8e8e93;       /* cinza médio · labels */
  --text-muted: #636366;          /* cinza escuro · hints */
  --text-on-card-subtle: #e8e8e8; /* em cards mais claros */

  /* ══════════════════════════════════════════════════════════════
     ACCENTS · APPLE SYSTEM COLORS
     ══════════════════════════════════════════════════════════════ */
  --blue: #0a84ff;
  --blue-light: #64b5ff;
  --blue-deep: #0057b7;

  --green: #30d158;
  --green-light: #64e3a0;
  --green-deep: #007a2f;

  --red: #ff453a;
  --red-light: #ff7b72;

  --yellow: #ffd60a;
  --orange: #ff9f0a;

  --purple: #bf5af2;
  --purple-light: #d8a8ff;

  /* Cinzas Apple extras */
  --gray-1: #8e8e93;
  --gray-2: #636366;
  --gray-3: #48484a;

  /* Tonalidades adicionais pra gradientes / rankings */
  --white: #fff;
  --white-tint: #a8d8ff;           /* usado em heading shine */
  --silver: #c0c0c0;               /* 2º lugar ranking */
  --bronze: #cd7f32;               /* 3º lugar ranking */
  --red-deep: #c02e25;             /* botão danger deep */
  --purple-deep: #7c2acc;          /* botão purple deep */

  /* Accents transparentes (tints pra pills, backgrounds suaves) */
  --blue-tint: rgba(10, 132, 255, 0.15);
  --blue-tint-strong: rgba(10, 132, 255, 0.25);
  --green-tint: rgba(48, 209, 88, 0.2);
  --red-tint: rgba(255, 69, 58, 0.2);
  --orange-tint: rgba(255, 159, 10, 0.15);
  --yellow-tint: rgba(255, 214, 10, 0.15);
  --purple-tint: rgba(191, 90, 242, 0.2);

  /* ══════════════════════════════════════════════════════════════
     SEMANTIC ALIASES
     ══════════════════════════════════════════════════════════════ */
  --success: var(--green);
  --success-light: var(--green-light);
  --warn: var(--orange);
  --warn-light: var(--yellow);
  --danger: var(--red);
  --danger-light: var(--red-light);
  --info: var(--blue);
  --info-light: var(--blue-light);

  /* ══════════════════════════════════════════════════════════════
     SPACING · múltiplos de 4
     ══════════════════════════════════════════════════════════════ */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ══════════════════════════════════════════════════════════════
     RADII
     ══════════════════════════════════════════════════════════════ */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 22px;
  --radius-full: 999px;

  /* ══════════════════════════════════════════════════════════════
     TYPOGRAPHY
     ══════════════════════════════════════════════════════════════ */
  --font-family: -apple-system, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Escala tipográfica */
  --text-xs: 10px;     /* micro labels, legendas */
  --text-sm: 11px;     /* pills, chips, metadata */
  --text-md: 12px;     /* body default em cards densos */
  --text-lg: 14px;     /* body, nomes de produto */
  --text-xl: 18px;     /* KPI mini */
  --text-2xl: 24px;    /* KPI padrão */
  --text-3xl: 32px;    /* hero numbers */
  --text-4xl: 42px;    /* hero destaque (faturamento) */

  /* Pesos */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-heavy: 800;

  /* Letter spacing */
  --tracking-tight: -0.03em;
  --tracking-normal: 0;
  --tracking-wide: 0.06em;
  --tracking-wider: 0.08em;
  --tracking-widest: 0.15em;

  /* Line heights */
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.4;
  --leading-relaxed: 1.6;

  /* ══════════════════════════════════════════════════════════════
     SHADOWS & GLOWS
     ══════════════════════════════════════════════════════════════ */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);

  --shadow-glow-blue: 0 0 20px rgba(10, 132, 255, 0.3);
  --shadow-glow-green: 0 0 20px rgba(48, 209, 88, 0.3);
  --shadow-glow-red: 0 0 20px rgba(255, 69, 58, 0.3);
  --shadow-glow-orange: 0 0 20px rgba(255, 159, 10, 0.3);
  --shadow-glow-yellow: 0 0 20px rgba(255, 214, 10, 0.3);
  --shadow-glow-purple: 0 0 20px rgba(191, 90, 242, 0.3);

  --shadow-hero-fat: 0 10px 40px rgba(48, 209, 88, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-hero-lucro: 0 10px 40px rgba(10, 132, 255, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-hero-proj: 0 10px 40px rgba(191, 90, 242, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-hero-ads: 0 10px 40px rgba(255, 159, 10, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Focus ring (a11y) */
  --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.4);

  /* ══════════════════════════════════════════════════════════════
     EASING & TIMING
     ══════════════════════════════════════════════════════════════ */
  --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);           /* ease-out-quart (hero) */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-linear: linear;

  --duration-instant: 0.1s;
  --duration-fast: 0.15s;
  --duration-normal: 0.3s;
  --duration-slow: 0.8s;       /* count-up padrão */
  --duration-slower: 2s;       /* draw polyline */
  --duration-ambient: 8s;      /* glow line, shine */
  --duration-bg: 20s;          /* bg mesh */

  /* ══════════════════════════════════════════════════════════════
     Z-INDEX (escala)
     ══════════════════════════════════════════════════════════════ */
  --z-base: 0;
  --z-card-overlay: 1;
  --z-glow-line: 2;
  --z-header: 10;
  --z-dropdown: 50;
  --z-modal: 100;
  --z-toast: 1000;
  --z-confetti: 9999;

  /* ══════════════════════════════════════════════════════════════
     LAYOUT (max-widths, breakpoints as vars)
     ══════════════════════════════════════════════════════════════ */
  --container-max: 1400px;
  --container-wide: 1280px;
  --container-narrow: 1200px;
  --bp-mobile: 768px;
  --bp-tablet: 1024px;
  --bp-desktop: 1280px;
}

/* =============================================================================
   RESET MÍNIMO
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

html {
  background-color: #08080a;  /* fallback hard-coded pra evitar flash branco */
}
body {
  margin: 0;
  background: var(--bg-app, #08080a);
  background-color: #08080a;
  color: var(--text-primary, #f2f2f7);
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, "Helvetica Neue", Arial, sans-serif);
  font-feature-settings: "ss01", "ss02", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: var(--text-lg, 14px);
  line-height: var(--leading-normal, 1.4);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

/* BG mesh animado (aprovado por Kawe) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 10%, rgba(10, 132, 255, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 50%, rgba(48, 209, 88, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(191, 90, 242, 0.14) 0%, transparent 50%);
  animation: bgShift var(--duration-bg) ease-in-out infinite;
  pointer-events: none;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

/* =============================================================================
   A11Y · FOCUS VISIBLE
   ============================================================================= */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =============================================================================
   KEYFRAMES REUTILIZÁVEIS
   Declarados aqui (tokens) pra serem usados por qualquer component.css.
   ============================================================================= */

/* pulse · live indicator verde */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.5; }
}

/* pulse laranja · current step em timeline */
@keyframes pulseOrange {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}

/* shine · gradient animado em headings */
@keyframes shine {
  0%   { background-position: 0 0; }
  100% { background-position: 200% 0; }
}

/* topLine · glow line animada no topo do shell */
@keyframes topLine {
  0%   { background-position: 0 0; }
  100% { background-position: 200% 0; }
}

/* alias compat */
@keyframes topLineSweep {
  0%   { background-position: 0 0; }
  100% { background-position: 200% 0; }
}

/* bgShift · fundo mesh */
@keyframes bgShift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-15px, -25px) scale(1.08); }
}

/* orb · radial gradient flutuante nos hero-cards */
@keyframes orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(20px, -10px) scale(1.1); }
  66%      { transform: translate(-10px, 20px) scale(0.95); }
}
@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(20px, -10px) scale(1.1); }
  66%      { transform: translate(-10px, 20px) scale(0.95); }
}

/* ring · anel expandindo em status-dot ok */
@keyframes ring {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* blink · status-dot bad */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* blinkTag · count badges urgentes */
@keyframes blinkTag {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* fadeIn · reveal suave */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* fadeUp · reveal com translate */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* rollUp · KPI count-up */
@keyframes rollUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* dashDraw · polyline sparkline draw */
@keyframes dashDraw {
  from { stroke-dashoffset: 300; }
  to   { stroke-dashoffset: 0; }
}

/* drawIn · fill de sparkline */
@keyframes drawIn {
  from { opacity: 0; transform: scaleY(0); transform-origin: bottom; }
  to   { opacity: 1; transform: scaleY(1); }
}

/* peakPulse · ponto pulsante no final da sparkline */
@keyframes peakPulse {
  0%, 100% { r: 3; }
  50%      { r: 5; }
}

/* fillBar · progress bar animada */
@keyframes fillBar {
  from { width: 0; }
}

/* arrowPulse · seta ativa em fluxograma */
@keyframes arrowPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* shimmer · barras over >100% */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* tMove · ticker rolando */
@keyframes tMove {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* fall · confetti */
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* dashMove · linha ativa em timeline */
@keyframes dashMove {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* =============================================================================
   UTILITIES · animações baseadas em classe
   ============================================================================= */

/* Reveal on scroll (IntersectionObserver adiciona .in) */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--duration-slow) var(--ease-apple),
    transform var(--duration-slow) var(--ease-apple);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal + scale (mais suave pra cards de destaque) */
.reveal-scale {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  transition:
    opacity var(--duration-slow) var(--ease-apple),
    transform var(--duration-slow) var(--ease-apple);
}
.reveal-scale.in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Count-up trigger (JS preenche data-count="N") */
.count-up {
  font-variant-numeric: tabular-nums;
  animation: rollUp var(--duration-slow) var(--ease-apple);
}

/* Utils comuns */
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Gradient text (headings) */
.gradient-text {
  background: linear-gradient(90deg, #fff 0%, #a8d8ff 50%, #fff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  animation: shine var(--duration-ambient) linear infinite;
}

/* =============================================================================
   PREFERS-REDUCED-MOTION · desliga animações não-essenciais
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  body::before {
    animation: none;
  }

  .reveal,
  .reveal-scale {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =============================================================================
   RESPONSIVE · container fluido
   ============================================================================= */
@media (max-width: 768px) {
  body {
    padding: var(--space-3);
    font-size: var(--text-md);
  }
}
