/* ==========================================================================
   Painel animado do hero

   O dashboard da v2 do app (Sites/emito-app-v2, src/pages/Dashboard.jsx)
   redesenhado em HTML, no lugar do screenshot. Cores = tokens da v2
   (_tokens.scss), trocados junto com o tema do site.

   O canvas tem largura fixa de 1280px e e escalado para caber (--s, que o
   emito.js calcula). Sem JS: aparece o estado final, cortado pelo container.
   ========================================================================== */

/* Recorte do hero: mais alto que o do screenshot e com o desfoque de baixo
   mais curto, para o grafico (a parte que mais se mexe) aparecer. */
@media screen and (min-width: 992px) {
  .hero_image-wrapper.is-dash .hero_image-inner { height: 36rem; }
}

.hero_image-wrapper.is-dash .bottom-blur-wrapper { height: 26%; }

/* O .section.hero e flex centralizado e encolhia o conteudo ate a largura
   dele; o screenshot segurava a largura pelo tamanho natural da imagem.
   Aqui a coluna ocupa a largura toda e o .container-small limita. */
.section.hero > .padding-global { width: 100%; min-width: 0; }

.hero-dash {
  --em-bg: #eff1ea;
  --em-surface: #fff;
  --em-surface-2: #f8f9f5;
  --em-border: #e2e5da;
  --em-border-strong: #868d7b;
  --em-text: #171a12;
  --em-muted: #5b6152;
  --em-primary: #95c122;
  --em-on-primary: #12160a;
  --em-primary-text: #4c650c;
  --em-primary-soft: rgba(149, 193, 34, .14);
  --em-ink: #1b1f16;
  --em-on-ink: #f2f4ec;
  --em-on-ink-accent: #b5dd4a;
  --em-frame: #e4efc6;

  --s: .90625;
  position: relative;
  width: 100%;
  height: calc(760px * var(--s));
  font-family: Commissioner, system-ui, sans-serif;
  color: var(--em-text);
  user-select: none;
}

:root[data-theme="dark"] .hero-dash {
  --em-bg: #0e100c;
  --em-surface: #161913;
  --em-surface-2: #1d2119;
  --em-border: #2a2f24;
  --em-border-strong: #636b58;
  --em-text: #eceee6;
  --em-muted: #a0a795;
  --em-primary: #9fcc2a;
  --em-on-primary: #0e1208;
  --em-primary-text: #b5dd4a;
  --em-primary-soft: rgba(159, 204, 42, .14);
  --em-ink: #9fcc2a;
  --em-on-ink: #0e1208;
  --em-on-ink-accent: #0e1208;
  --em-frame: #23281d;
}

.hero-dash__canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 760px;
  transform: scale(var(--s));
  transform-origin: 0 0;
  display: flex;
  overflow: hidden;
  background: var(--em-bg);
  border: 10px solid var(--em-frame);
  border-radius: 28px;
  box-sizing: border-box;
}

.hero-dash svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Os titulos do site tem gradiente recortado no texto; aqui e cor solida. */
.hero-dash h3,
.hero-dash h4,
.hero-dash p {
  margin: 0;
  color: inherit;
  background: none;
  -webkit-text-fill-color: currentColor;
  font-family: inherit;
}

/* ---- Sidebar -------------------------------------------------------------- */
.hd-side {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 14px;
  background: var(--em-surface);
  border-right: 1px solid var(--em-border);
}

.hd-logo { width: 140px; max-width: none; height: auto; align-self: flex-start; margin-left: 8px; }

/* Mesmo esquema do logo do topo: as letras escuras somem no fundo escuro. */
:root[data-theme="dark"] .hd-logo { content: url("../emito-logo-horizontal-dark.svg"); }

.hd-empresa {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--em-surface-2);
  font-size: 14px;
}

.hd-empresa span { color: var(--em-muted); font-size: 12px; }

.hd-nav { display: flex; flex-direction: column; gap: 2px; }

.hd-nav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
}

.hd-nav__link.is-active {
  background: var(--em-primary-soft);
  color: var(--em-primary-text);
  font-weight: 600;
}

/* ---- Topbar --------------------------------------------------------------- */
.hd-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.hd-top {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--em-surface);
  border-bottom: 1px solid var(--em-border);
}

.hd-crumb { flex: 1; color: var(--em-muted); font-size: 15px; }

.hd-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 280px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--em-border);
  border-radius: 999px;
  color: var(--em-muted);
  font-size: 14px;
}

.hd-iconbtn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--em-border);
  border-radius: 12px;
}

.hd-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c8372b;
  border: 2px solid var(--em-surface);
}

.hd-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--em-border);
}

.hd-user strong { display: block; font-size: 14px; line-height: 1.2; }
.hd-user small { color: var(--em-muted); font-size: 12px; }

.hd-avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  background: var(--em-primary);
  color: var(--em-on-primary);
  font-size: 24px;
  font-weight: 800;
}

.hd-avatar.is-sm { width: 36px; height: 36px; font-size: 15px; }

/* ---- Conteudo ------------------------------------------------------------- */
.hd-content { display: flex; flex-direction: column; gap: 18px; padding: 24px; }

.hd-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hd-hello { display: flex; align-items: center; gap: 16px; }
.hd-hello h3 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.hd-hello p { color: var(--em-muted); font-size: 15px; }

.hd-periodos { display: flex; align-items: center; gap: 8px; }

.hd-pill,
.hd-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--em-border);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .35s ease, border-color .35s ease, color .35s ease;
}

.hd-pill.is-active {
  border-color: var(--em-primary);
  background: var(--em-primary-soft);
  color: var(--em-primary-text);
}

.hd-btn {
  border-color: var(--em-primary);
  background: var(--em-primary);
  color: var(--em-on-primary);
}

.hd-card {
  padding: 20px 22px;
  border: 1px solid var(--em-border);
  border-radius: 20px;
  background: var(--em-surface);
}

/* KPIs */
.hd-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.hd-kpi__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: var(--em-muted);
  font-size: 15px;
  font-weight: 500;
}

.hd-arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--em-border-strong);
  border-radius: 50%;
  color: var(--em-text);
}

.hd-arrow svg { width: 16px; height: 16px; }

.hd-kpi__valor {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.hd-kpi__sub { display: block; margin-top: 4px; color: var(--em-muted); font-size: 14px; }
.hd-kpi__delta { display: block; margin-top: 8px; color: var(--em-primary-text); font-size: 14px; font-weight: 600; }

.hd-card.is-ink { background: var(--em-ink); border-color: var(--em-ink); color: var(--em-on-ink); }
.hd-card.is-ink .hd-kpi__top,
.hd-card.is-ink .hd-kpi__sub { color: var(--em-on-ink); opacity: .8; }
.hd-card.is-ink .hd-kpi__delta { color: var(--em-on-ink-accent); }
.hd-card.is-ink .hd-arrow { background: var(--em-on-ink); border-color: var(--em-on-ink); color: var(--em-ink); }

/* Grafico */
.hd-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

.hd-card__head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hd-card h4 { font-size: 18px; font-weight: 700; }
.hd-card h4 + p,
.hd-card__head p { color: var(--em-muted); font-size: 14px; }

.hd-legenda { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.hd-legenda span { display: flex; align-items: center; gap: 8px; }
.hd-legenda i { width: 10px; height: 10px; border-radius: 3px; background: var(--em-primary); }
.hd-legenda i.is-rec { background: var(--em-border-strong); opacity: .5; }

.hd-plot { display: flex; gap: 14px; }

.hd-eixo {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 48px;
  height: 150px;
  color: var(--em-muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.hd-area { position: relative; flex: 1; height: 150px; }

.hd-area > i {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--em-border);
}

.hd-area > i:nth-child(1) { top: 0; }
.hd-area > i:nth-child(2) { top: 33.33%; }
.hd-area > i:nth-child(3) { top: 66.66%; }
.hd-area > i:nth-child(4) { top: 100%; }

.hd-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
}

.hd-bars__par { display: flex; align-items: flex-end; gap: 4px; height: 100%; }

.hd-bar {
  width: 22px;
  height: calc(var(--h) * 100%);
  border-radius: 4px 4px 0 0;
  background: var(--em-primary);
  transition: height .9s cubic-bezier(.22, .61, .36, 1) calc(var(--i) * 70ms);
}

.hd-bar.is-rec { background: var(--em-border-strong); opacity: .5; }

.hd-faixas {
  display: flex;
  justify-content: space-around;
  margin: 8px 0 0 62px;
  color: var(--em-muted);
  font-size: 13px;
}

/* Comparacao */
.hd-comp { display: flex; flex-direction: column; gap: 12px; }

.hd-comp__box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--em-primary-soft);
}

.hd-comp__box strong { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.hd-comp__box span { color: var(--em-primary-text); font-size: 14px; }

.hd-comp__meses,
.hd-comp__valores { display: flex; justify-content: space-between; font-size: 14px; }
.hd-comp__meses { color: var(--em-muted); }
.hd-comp__valores { font-weight: 600; }

.hd-progress { position: relative; height: 8px; border-radius: 999px; background: var(--em-surface-2); }

.hd-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--p) * 100%);
  border-radius: 999px;
  background: var(--em-primary);
  transition: width 1s cubic-bezier(.22, .61, .36, 1);
}

.hd-progress i::after {
  content: "";
  position: absolute;
  top: -6px;
  right: -2px;
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--em-text);
}

/* Aviso de nota autorizada */
.hd-toast {
  position: absolute;
  top: 80px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 12px 12px;
  border: 1px solid var(--em-border);
  border-radius: 16px;
  background: var(--em-surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
  font-size: 14px;
  opacity: 0;
  transform: translateY(-12px) scale(.98);
  transition: opacity .45s ease, transform .45s cubic-bezier(.22, .61, .36, 1);
}

.hd-toast.is-visible { opacity: 1; transform: none; }
.hd-toast strong { display: block; }
.hd-toast small { color: var(--em-muted); font-size: 13px; }

.hd-toast__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--em-primary);
  color: var(--em-on-primary);
}

.hd-toast__icon svg { stroke-width: 2.6; }

/* ---- Entrada -------------------------------------------------------------
   So com o script do painel rodando (.is-armed); sem ele, tudo ja aparece. */
.hero-dash.is-armed .hd-anim,
.hero-dash.is-armed .hd-nav__link { opacity: 0; transform: translateY(14px); }

.hero-dash.is-armed .hd-nav__link { transform: translateX(-10px); }

.hero-dash.is-armed:not(.is-playing) .hd-bar,
.hero-dash.is-armed:not(.is-playing) .hd-progress i { transition: none; }

.hero-dash.is-playing .hd-anim,
.hero-dash.is-playing .hd-nav__link {
  opacity: 1;
  transform: none;
  transition: opacity .6s ease calc(var(--d) * 90ms + 150ms),
              transform .6s cubic-bezier(.22, .61, .36, 1) calc(var(--d) * 90ms + 150ms);
}

.hero-dash.is-playing .hd-nav__link {
  transition-delay: calc(var(--d) * 45ms);
}

@media (prefers-reduced-motion: reduce) {
  .hero-dash *,
  .hero-dash.is-playing .hd-anim,
  .hero-dash.is-playing .hd-nav__link { transition: none !important; }
}
