/* ============================================
   FONTS — AmpleSoft Pro (local) + Roboto (Google)
   ============================================ */
@font-face {
  font-family: 'AmpleSoft';
  src: url('fonts/AmpleSoftPro-Bold.woff2') format('woff2'),
    url('fonts/AmpleSoftPro-Bold.woff') format('woff'),
    url('fonts/AmpleSoftPro-Bold.ttf') format('truetype');
  font-weight: 700;
}

@font-face {
  font-family: 'AmpleSoft';
  src: url('fonts/AmpleSoftPro-Medium.woff2') format('woff2'),
    url('fonts/AmpleSoftPro-Medium.woff') format('woff'),
    url('fonts/AmpleSoftPro-Medium.ttf') format('truetype');
  font-weight: 500;
}

@font-face {
  font-family: 'AmpleSoft';
  src: url('fonts/AmpleSoftPro-Regular.woff2') format('woff2'),
    url('fonts/AmpleSoftPro-Regular.woff') format('woff'),
    url('fonts/AmpleSoftPro-Regular.ttf') format('truetype');
  font-weight: 400;
}

@font-face {
  font-family: 'AmpleSoft';
  src: url('fonts/AmpleSoftPro-Light.woff2') format('woff2'),
    url('fonts/AmpleSoftPro-Light.woff') format('woff'),
    url('fonts/AmpleSoftPro-Light.ttf') format('truetype');
  font-weight: 300;
}

@font-face {
  font-family: 'AmpleSoft';
  src: url('fonts/AmpleSoftPro-ExtraLight.woff2') format('woff2'),
    url('fonts/AmpleSoftPro-ExtraLight.woff') format('woff'),
    url('fonts/AmpleSoftPro-ExtraLight.ttf') format('truetype');
  font-weight: 200;
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Cores exatas do Photoshop */
  --orange: #F26725;
  /* laranja principal do fundo */
  --orange-dark: #E05518;
  --white: #ffffff;
  --cream: #FFF5EE;
  /* fundo dos cards KPI e ranking */
  --cream-border: #F0D5C2;
  --text-dark: #1A1A1A;
  --text-mid: #3D3D3D;
  --text-on-orange: rgba(255, 255, 255, 0.90);
  --text-sub-orange: rgba(255, 255, 255, 0.75);
  --shadow-card: 0 6px 32px rgba(0, 0, 0, 0.13);
  --radius-card: 20px;
  --font-amp: 'AmpleSoft', 'Roboto', sans-serif;
  --font-rob: 'Roboto', sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-rob);
  /* Fundo laranja sólido — exato do Photoshop */
  background: var(--orange);
}

/* ============================================
   DASHBOARD WRAPPER
   ============================================ */
.dashboard-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 18px 28px;
  gap: 12px;
  /* Sutil degradê radial que escurece a borda, exatamente como no PDF */
  background: radial-gradient(ellipse at 50% 50%, #F7721A 0%, #E86018 55%, #D04D0C 100%);
}

/* ============================================
   HEADER
   ============================================ */
.header {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  padding-bottom: 15px;
}

.logo-img {
  height: clamp(54px, 6.5vh, 80px);
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.20));
  animation: fadeInDown 0.5s ease;
}

.header-title {
  animation: fadeInDown 0.5s ease 0.08s both;
}

/* "Corrida Comercial | Resultado do Dia" – AmpleSoft Bold, branco */
.title-main {
  font-family: var(--font-amp);
  font-size: clamp(24px, 2.7vw, 40px);
  font-weight: 700;
  color: var(--white);
  line-height: 1.05;
  letter-spacing: -0.2px;
}

.title-sep {
  color: rgba(255, 255, 255, 0.55);
  margin: 0 8px;
}

/* "Última atualização ..." – AmpleSoft Regular, branco 75% */
.title-sub {
  font-family: var(--font-amp);
  font-size: clamp(11px, 1vw, 16px);
  font-weight: 400;
  color: var(--text-sub-orange);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.content-area {
  display: flex;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

/* ============================================
   LEFT PANEL
   ============================================ */
.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* ============================================
   KPI CARDS — fundo branco/creme sobre laranja
   Conforme o design original do Photoshop/PDF
   ============================================ */
.kpi-row {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}

.kpi-card {
  flex: 1;
  background: var(--cream);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: fadeInUp 0.45s ease both;
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  height: clamp(90px, 16vh, 140px);
  /* altura fixa proporcional à tela */
}

.kpi-card:hover {
  transform: translateY(-3px);
}

.kpi-card:nth-child(1) {
  animation-delay: 0.08s;
}

.kpi-card:nth-child(2) {
  animation-delay: 0.16s;
}

.kpi-card:nth-child(3) {
  animation-delay: 0.24s;
}

.kpi-card-inner {
  padding: 14px 20px 12px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

/* Título do KPI — ex: "Fechamento do dia" */
.kpi-label {
  font-family: var(--font-amp);
  font-size: clamp(14px, 1.4vw, 24px);
  /* Título aumentado por volta de 18px */
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.15px;
  margin-bottom: 4px;
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

/* Número grande — ex: "12", "136", "42" */
.kpi-number {
  font-family: var(--font-rob);
  font-size: clamp(44px, 5.2vw, 74px);
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
  transition: color 0.35s;
}

/* "associados" — Roboto Regular pequeno */
.kpi-unit {
  font-family: var(--font-rob);
  font-size: clamp(12px, 1.05vw, 16px);
  font-weight: 400;
  color: #666;
  align-self: flex-end;
  margin-bottom: 10px;
}

/* "%" — mesmo peso que o número */
.kpi-unit-pct {
  font-family: var(--font-rob);
  font-size: clamp(26px, 2.8vw, 38px);
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0;
  align-self: baseline;
}

/* Barra de meta — card especial */
.kpi-card-meta .kpi-value-row {
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.meta-bar-wrap {
  flex: 1;
  min-width: 50px;
  max-width: 130px;
  align-self: center;
  margin-bottom: 3px;
}

.meta-bar-bg {
  width: 100%;
  height: 11px;
  background: #E8C9B4;
  border-radius: 99px;
  overflow: hidden;
}

.meta-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #D04A0A 0%, #F26725 60%, #FF8C40 100%);
  border-radius: 99px;
  transition: width 1.1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 6px rgba(226, 85, 24, 0.40);
}

/* ============================================
   RACE TRACK AREA
   ============================================ */
.race-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* SEM overflow:hidden — o carro precisa sair pela esquerda sem ser cortado */
  padding: 6px 10px 6px 4px;
  margin-top: 30px;
  animation: fadeInUp 0.5s ease 0.3s both;
}

/* Header com labels das vendas */
.checkpoints-header {
  position: relative;
  height: 24px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.cp-label {
  position: absolute;
  font-family: var(--font-rob);
  font-size: clamp(14px, 1.2vw, 17px);
  /* Texto das vendas aumentado */
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  transform: translateX(-50%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.2px;
}

/* Posições dos checkpoints — alinhadas com as cp-dot nas pistas */
.cp-2v {
  left: 21%;
}

.cp-5v {
  left: 50%;
}

.cp-10v {
  left: 82%;
  transform: translateX(-50%);
}

/* Container das pistas — clipa verticalmente (remove pistas extras)
   mas deixa 120px de espaço livre à esquerda para o carro não ser cortado */
.tracks-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  clip-path: inset(0 0 0 -120px);
}

/* PISTA INDIVIDUAL — ocupa exatamente 1/4 do container = 4 visíveis */
.track {
  flex: 0 0 25%;
  position: relative;
  display: flex;
  align-items: center;
  max-height: none;  /* remove o antigo 25% max-height que conflitava */
}

.track-road {
  position: absolute;
  left: 0;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 3px;
}

/* Linha branca da pista (dentro do track-road) */
.track-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 2px;
}

/* Dots de checkpoint — wrapper posicionado na pista */
.checkpoint {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.checkpoint.cp1 {
  left: 21%;
}

.checkpoint.cp2 {
  left: 50%;
}

.checkpoint.cp3 {
  left: 82%;
}

.cp-dot {
  display: block;
  width: clamp(12px, 1.4vw, 18px);
  height: clamp(12px, 1.4vw, 18px);
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.20);
}

/* CARRO */
.car-wrapper {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  bottom: 50%;
  left: 2%;
  transform: translateX(-50%) translateY(53%);
  transition: left 1.3s cubic-bezier(0.34, 1.08, 0.64, 1);
  z-index: 5;
}

.car-img {
  height: clamp(45px, 7.2vh, 90px);
  /* Aumentado de 5.2vh para 7.2vh */
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.28));
}

/* Nome do vendedor sob o carro — branco */
.car-name {
  font-family: var(--font-rob);
  font-size: clamp(12px, 1vw, 15px);
  /* Aumentado para volta de 15px */
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  margin-top: 2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.40);
  letter-spacing: 0.15px;
}

/* ============================================
   RIGHT PANEL — RANKING
   ============================================ */
.right-panel {
  width: clamp(210px, 23vw, 295px);
  flex-shrink: 0;
  animation: fadeInRight 0.5s ease 0.18s both;
}

.ranking-box {
  background: var(--cream);
  border-radius: var(--radius-card);
  padding: 14px 12px 14px 12px;
  height: 100%;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* "Ranking do dia" */
.ranking-title {
  font-family: var(--font-amp);
  font-size: clamp(15px, 1.4vw, 22px);
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cream-border);
  letter-spacing: 0.1px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
  min-height: 0;        /* essencial para overflow funcionar dentro de flex */
  overflow-y: auto;
  overflow-x: hidden;
}

/* ITEM DO RANKING */
.ranking-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #FFF0E6;
  border-radius: 14px;
  padding: 10px 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
  animation: fadeInRight 0.35s ease both;
  transition: transform 0.2s ease;
  flex-shrink: 0;  /* não encolhe — mantém altura natural, extra rola */
}

.ranking-item:hover {
  transform: translateX(-2px);
}

/* Tarja laranja lateral */
.ranking-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: 14px 0 0 14px;
  background: var(--orange);
}

.ranking-item.rank-2::before {
  background: #AAAAAA;
}

.ranking-item.rank-3::before {
  background: #C8832A;
}

.ranking-item.rank-4::before {
  background: #BBBBBB;
}

/* Badge com o número */
.rank-badge {
  width: 28px;
  height: 28px;
  background: var(--orange);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-amp);
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(242, 103, 37, 0.35);
}

.rank-badge.rank-2 {
  background: #AAAAAA;
  box-shadow: none;
}

.rank-badge.rank-3 {
  background: #C8832A;
  box-shadow: none;
}

.rank-badge.rank-4 {
  background: #BBBBBB;
  box-shadow: none;
}

/* Foto do vendedor —
   mix-blend-mode: multiply remove o fundo branco das imagens PSD */
.rank-photo {
  width: clamp(34px, 3.5vw, 46px);
  height: clamp(34px, 3.5vw, 46px);
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(242, 103, 37, 0.20);
  mix-blend-mode: multiply;
  background: transparent;
}

/* Informações do vendedor */
.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-family: var(--font-amp);
  font-size: clamp(12px, 1.15vw, 20px);
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-details {
  font-family: var(--font-rob);
  font-size: clamp(9px, 0.78vw, 16px);
  color: #666666;
  margin-top: 2px;
  line-height: 1.45;
}

.rank-details span {
  display: block;
}

/* ============================================
   LIVE DOT
   ============================================ */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #7CE87C;
  border-radius: 50%;
  animation: pulseDot 1.6s infinite;
  flex-shrink: 0;
}

@keyframes pulseDot {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.35;
    transform: scale(0.65);
  }
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes numberPop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.18);
    color: var(--orange);
  }

  100% {
    transform: scale(1);
  }
}

.number-pop {
  animation: numberPop 0.5s ease;
}

/* Scrollbar ranking — invisível mas funcional */
.ranking-list { scrollbar-width: none; }
.ranking-list::-webkit-scrollbar { display: none; }

/* ============================================
   RESPONSIVIDADE MOBILE
   ============================================ */

@media (max-width: 768px) {

  /* Permite scroll na página em vez de travar no 100vh */
  html, body {
    overflow: auto;
    height: auto;
  }

  .dashboard-wrapper {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 14px 10px 24px;
    gap: 10px;
  }

  /* ── HEADER ── */
  .header { gap: 10px; flex-wrap: wrap; }
  .logo-img { height: clamp(36px, 8vw, 52px); }
  .title-main { font-size: clamp(15px, 4.8vw, 22px); line-height: 1.1; }
  .title-sep { margin: 0 5px; }
  .title-sub { font-size: clamp(10px, 2.8vw, 13px); margin-top: 3px; }

  /* ── KPI CARDS — 2 colunas no mobile ── */
  .kpi-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex-shrink: 0;
  }
  .kpi-card { height: clamp(72px, 17vw, 100px); border-radius: 14px; }
  /* Meta (3º card) ocupa a largura toda */
  .kpi-card:nth-child(3) { grid-column: 1 / -1; height: clamp(60px,14vw,88px); }
  .kpi-label   { font-size: clamp(10px, 2.8vw, 14px); margin-bottom: 2px; }
  .kpi-number  { font-size: clamp(28px, 7.5vw, 44px); }
  .kpi-unit    { font-size: clamp(10px, 2.5vw, 13px); margin-bottom: 6px; }
  .kpi-unit-pct { font-size: clamp(18px, 4.5vw, 28px); }
  .kpi-card-inner { padding: 10px 14px 8px; }

  /* Meta bar */
  .meta-bar-bg  { height: 8px; }
  .meta-bar-wrap { max-width: 90px; }

  /* ── CONTENT AREA — empilhado verticalmente ── */
  .content-area {
    flex-direction: column;
    gap: 12px;
    overflow: visible;
    height: auto;
    flex: none;
  }

  /* Left panel ocupa largura total */
  .left-panel { flex: none; width: 100%; min-width: 0; }

  /* ── RACE AREA ── */
  .race-area {
    flex: none;
    height: 52vw;          /* aprox 4 pistas visíveis no mobile */
    max-height: 320px;
    margin-top: 12px;
    padding: 4px 6px 4px 2px;
  }

  /* Checkpoints labels */
  .checkpoints-header { height: 18px; margin-bottom: 1px; }
  .cp-label { font-size: clamp(9px, 2.5vw, 12px); }

  /* Tracks — 3 visíveis no mobile (33.33%) */
  .track { flex: 0 0 33.333%; }

  /* Carro menor */
  .car-img { height: clamp(28px, 6.5vw, 46px); }
  .car-name { font-size: clamp(9px, 2.2vw, 12px); margin-top: 1px; }
  .track-road { right: 14px; }
  .cp-dot { width: clamp(8px, 2vw, 12px); height: clamp(8px, 2vw, 12px); }

  /* ── RIGHT PANEL — ranking abaixo das pistas ── */
  .right-panel {
    width: 100%;
    flex-shrink: 0;
  }

  .ranking-box {
    height: auto;
    max-height: 60vw;
    border-radius: 16px;
    padding: 12px 10px;
  }

  .ranking-title { font-size: clamp(13px, 3.5vw, 17px); padding-bottom: 8px; }

  .ranking-item {
    padding: 8px 8px;
    border-radius: 11px;
    gap: 7px;
  }

  .rank-badge { width: 22px; height: 22px; font-size: 12px; border-radius: 6px; }
  .rank-photo { width: clamp(28px, 6.5vw, 38px); height: clamp(28px, 6.5vw, 38px); border-radius: 7px; }
  .rank-name   { font-size: clamp(11px, 3vw, 15px); }
  .rank-details { font-size: clamp(8px, 2vw, 11px); }
}

/* Telas muito pequenas (< 400px) */
@media (max-width: 400px) {
  .dashboard-wrapper { padding: 10px 8px 20px; }
  .title-main { font-size: 18px; }
  .kpi-number { font-size: 28px; }
  .race-area  { height: 58vw; max-height: 280px; }
  .ranking-box { max-height: 65vw; }
  .cp-label { display: none; }
}

/* ============================================
   SAMSUNG TV / TIZEN BROWSER
   Target: 1920x1080, sem suporte a clamp(),
   backdrop-filter ou mix-blend-mode
   ============================================ */
@media screen and (min-width: 1280px) and (min-height: 700px) {

  /* Garante fundo sólido sem radial-gradient problemático */
  html, body {
    background: #F26725;
    overflow: hidden;
  }

  .dashboard-wrapper {
    padding: 28px 36px 22px 36px;
    gap: 14px;
  }

  /* Header — tamanhos fixos para TV */
  .logo-img    { height: 72px; }
  .title-main  { font-size: 36px; }
  .title-sub   { font-size: 15px; }

  /* KPI Cards */
  .kpi-card        { height: 120px; border-radius: 20px; }
  .kpi-label       { font-size: 20px; }
  .kpi-number      { font-size: 68px; }
  .kpi-unit        { font-size: 15px; margin-bottom: 10px; }
  .kpi-unit-pct    { font-size: 36px; }

  /* Pistas */
  .cp-label        { font-size: 16px; }
  .car-img         { height: 76px; }
  .car-name        { font-size: 14px; }
  .cp-dot          { width: 16px; height: 16px; }

  /* Ranking */
  .right-panel     { width: 280px; }
  .ranking-title   { font-size: 20px; }
  .rank-name       { font-size: 18px; }
  .rank-details    { font-size: 13px; }
  .rank-photo      { width: 42px; height: 42px; }
  .rank-badge      { width: 30px; height: 30px; font-size: 15px; }

  /* Remove mix-blend-mode — pode causar tela branca em TVs */
  .rank-photo      { mix-blend-mode: normal; background: #f5e8de; }

  /* Scrollbar sempre oculta */
  .ranking-list    { overflow-y: hidden; }
}