/**
 * Área do Afiliado — mini painel (afiliado/painel.php).
 *
 * Documento à parte, fora da casca da loja, no idioma do /painel da equipe: lateral
 * escura, conteúdo em cartões sobre cinza claro, Montserrat. Escopado em `body.afp`
 * (a tela de login usa o CSS do /painel/entrar e não pode herdar nada daqui).
 * Cores da marca vêm de --marca-* (Brand::css_root). Sobre o fundo QUASE PRETO da
 * lateral, o destaque é o ACENTO (sálvia), não a primária — mesma regra do /painel.
 */

body.afp {
  --bg: #f7f7f8;
  --card: #fff;
  --border: #ececef;
  --border-forte: #e2e2e6;
  --fg: #101012;
  --muted: #71717a;
  --muted-2: #9a9aa3;
  --side: #101012;
  --side-hover: #1c1c20;
  --side-fg: #e6e6e9;
  --side-muted: #8e8e98;
  --side-border: #26262b;
  --verde: #16a34a;
  --ambar: #b45309;
  --vermelho: #dc2626;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sombra: 0 1px 2px rgba(16, 16, 18, 0.04), 0 1px 3px rgba(16, 16, 18, 0.06);
  --sombra-lg: 0 8px 30px rgba(16, 16, 18, 0.08);
  --vermelho-bg: #fdecec;
  --lado: 256px;

  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

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

/* `:where` zera a especificidade: com `body.afp a` (0,0,1,2) a regra vencia as cores
   dos próprios links (.afp-nav__item, .afp-cab__link, o Sair vermelho do menu). */
:where(body.afp) a {
  color: inherit;
  text-decoration: none;
}

body.afp svg {
  display: block;
}

/* ---------- Lateral: cópia fiel do /painel ----------
   Mesmos valores do style.scss do loja-admin (.side, .brand, .nav__item, .badge-n):
   no desktop a lateral é SÓ marca + navegação, e a conta vai pro cabeçalho. Se o
   /painel mudar, mudar aqui também — a ideia é o afiliado reconhecer o "painel". */

.afp-side {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: var(--lado);
  height: 100vh;
  padding: 20px 16px;
  background: var(--side);
  color: var(--side-fg);
  border-right: 1px solid var(--side-border);
}

.afp-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 18px;
}

body.afp .afp-brand__icon img {
  display: block;
  width: auto;
  height: 36px;
  border-radius: 9px;
}

.afp-brand__txt {
  line-height: 1.15;
}

.afp-brand__txt b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
}

.afp-brand__tag {
  display: block;
  margin-top: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--side-muted);
}

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

.afp-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--side-muted);
  transition: background 0.15s ease, color 0.15s ease;
  transform: translateZ(0); /* mesmo antídoto de jitter de subpixel do /painel */
  backface-visibility: hidden;
}

body.afp .afp-nav__item svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.afp-nav__item:hover {
  background: var(--side-hover);
  color: var(--side-fg);
}

.afp-nav__item.is-active {
  background: var(--side-hover);
  color: #fff;
}

.afp-nav__item.is-active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -16px;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--marca-acento, #fff);
  transform: translateY(-50%);
}

.afp-nav__item.is-active svg {
  color: var(--marca-acento, #fff);
}

.afp-badge-n {
  min-width: 22px;
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--marca-acento, #fff);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: var(--marca-primaria-escura, #0b0b0c);
}

/* "Sair" na lateral só existe no celular (no desktop está no menu da conta). */
.afp-side__sair {
  display: none;
}

/* ---------- Cabeçalho da conta: cópia do .cab do /painel ---------- */

.afp-col {
  min-width: 0;
  margin-left: var(--lado);
}

.afp-cab {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px 0 34px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.afp-cab__dir {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.afp-cab__link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.afp-cab__link:hover {
  background: #f4f4f5;
  color: var(--fg);
}

body.afp .afp-cab__link svg {
  width: 15px;
  height: 15px;
}

.afp-cab__sep {
  flex: none;
  width: 1px;
  height: 24px;
  margin: 0 4px;
  background: var(--border);
}

.afp-cab__conta {
  position: relative;
}

.afp-cab__user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.afp-cab__user:hover,
.afp-cab__user.is-open {
  background: #f4f4f5;
  border-color: var(--border-forte);
}

.afp-cab__user b {
  font-size: 12.5px;
  font-weight: 600;
}

.afp-avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--marca-primaria, #111), color-mix(in srgb, var(--marca-primaria, #111) 72%, #fff));
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--marca-sobre-primaria, #fff);
}

.afp-cab__user-ic {
  display: flex;
  color: var(--muted-2);
}

body.afp .afp-cab__user-ic svg {
  width: 14px;
  height: 14px;
  transition: transform 0.18s ease;
}

.afp-cab__user.is-open .afp-cab__user-ic svg {
  transform: rotate(180deg);
}

.afp-contamenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 232px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border-forte);
  border-radius: var(--r);
  box-shadow: var(--sombra-lg);
}

.afp-contamenu[hidden] {
  display: none;
}

.afp-contamenu__head {
  margin-bottom: 6px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
}

.afp-contamenu__head b {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.afp-contamenu__head span {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.afp-contamenu__head .afp-contamenu__papel {
  font-weight: 600;
  color: var(--muted-2);
}

.afp-contamenu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease;
}

body.afp .afp-contamenu__item svg {
  flex: none;
  width: 17px;
  height: 17px;
}

.afp-contamenu__item--sair {
  color: var(--vermelho);
}

.afp-contamenu__item--sair:hover {
  background: var(--vermelho-bg);
}

/* ---------- Conteúdo ---------- */

.afp-main {
  display: grid;
  gap: 20px;
  align-content: start;
  max-width: 1100px;
  padding: 22px 34px 48px;
}


.afp-top {
  display: grid;
  gap: 3px;
  margin-bottom: 6px;
}

.afp-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.afp-top h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.afp-top p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* Resumo: três cartões de número (mesma anatomia dos KPIs do /painel). */
.afp-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.afp-kpi {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 18px 18px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sombra);
}

.afp-kpi__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.afp-kpi__top i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #f4f4f5;
  color: #52525b;
}

.afp-kpi__top svg {
  width: 17px;
  height: 17px;
}

.afp-kpi b {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.afp-kpi small {
  font-size: 12px;
  color: var(--muted);
}

/* O número que ele veio ver: ícone na cor da marca. */
.afp-kpi--destaque .afp-kpi__top i {
  background: var(--marca-primaria, #111);
  color: var(--marca-acento, #fff);
}

/* ---------- Cartões ---------- */

.afp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.afp-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra);
}

.afp-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.afp-card__sub {
  margin: -6px 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.afp-card__nota {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.afp-card--lista {
  padding: 6px 0;
}

.afp-card--lista .afp-vazio {
  margin: 14px 20px;
}

.afp-card--lista .afp-card__nota {
  padding: 4px 20px 10px;
}

/* Link / cupom + botão de copiar. */
.afp-copia {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 5px 5px 14px;
  background: var(--bg);
  border-radius: var(--r-sm);
}

.afp-copia code,
.afp-copia__cupom {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.afp-copia code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.afp-copia__cupom {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.afp-copia__cupom em {
  margin-left: 6px;
  font-size: 12.5px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

.afp-btn {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--marca-primaria, #111);
  color: var(--marca-sobre-primaria, #fff);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.afp-btn:hover {
  background: var(--marca-primaria-escura, #000);
}

.afp-btn.is-ok {
  background: var(--marca-acento, #16a34a);
  color: var(--marca-primaria, #111);
}

.afp-vazio {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
}

/* Como funciona: três passos numerados. */
.afp-passos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: passo;
}

.afp-passos li {
  display: grid;
  gap: 4px;
  align-content: start;
  counter-increment: passo;
}

.afp-passos li::before {
  content: counter(passo);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-forte);
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.afp-passos b {
  font-size: 13.5px;
}

.afp-passos span {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Listas (vendas, pagamentos) ---------- */

.afp-lista {
  margin: 0;
  padding: 0;
  list-style: none;
}

.afp-linha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 128px;
  align-items: center;
  gap: 16px;
  padding: 13px 20px;
}

.afp-linha--pag {
  grid-template-columns: minmax(0, 1fr) auto;
}

.afp-linha + .afp-linha {
  border-top: 1px solid var(--border);
}

.afp-linha.is-off {
  opacity: 0.55;
}

.afp-linha__info {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.afp-linha__info b {
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: break-word;
}

.afp-linha__info small {
  font-size: 12px;
  color: var(--muted);
}

.afp-linha__valor {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Situação: ponto + texto. */
.afp-st {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.afp-st::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.afp-st--espera { color: var(--ambar); }
.afp-st--receber { color: var(--fg); }
.afp-st--paga { color: var(--verde); }
.afp-st--cancelada { color: var(--vermelho); }

/* ---------- Celular: a lateral vira barra no topo, o menu vira abas ----------
   O cabeçalho da conta some e a barra ganha um "Sair". Medido em 390px: abas só com
   texto dividindo a largura (com ícone, "Pagamentos" cortava) e os números em faixa
   compacta (em cartão cheio, os três ocupavam meia tela antes do conteúdo). */

@media (max-width: 900px) {
  .afp-side {
    position: sticky;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
    width: auto;
    height: auto;
    padding: 12px 16px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--side-border);
  }

  .afp-brand {
    padding: 0;
  }

  body.afp .afp-brand__icon img {
    height: 30px;
  }

  .afp-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .afp-nav::-webkit-scrollbar {
    display: none;
  }

  .afp-nav__item {
    flex: 1 1 0;
    justify-content: center;
    gap: 8px;
    min-width: max-content;
    padding: 8px 10px;
  }

  body.afp .afp-nav__item svg {
    display: none;
  }

  .afp-nav__item.is-active::before {
    display: none;
  }

  .afp-side__sair {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--side-fg);
  }

  body.afp .afp-side__sair svg {
    width: 16px;
    height: 16px;
  }

  .afp-col {
    margin-left: 0;
  }

  .afp-cab {
    display: none;
  }

  .afp-main {
    gap: 16px;
    padding: 22px 16px 48px;
  }

  .afp-top h1 {
    font-size: 22px;
  }

  .afp-kpis,
  .afp-grid,
  .afp-passos {
    grid-template-columns: minmax(0, 1fr);
  }

  .afp-kpis {
    gap: 10px;
  }

  .afp-kpi {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "rotulo valor"
      "nota nota";
    align-items: baseline;
    gap: 2px 12px;
    padding: 13px 16px;
  }

  .afp-kpi__top {
    grid-area: rotulo;
    margin: 0;
  }

  .afp-kpi__top i {
    display: none;
  }

  .afp-kpi b {
    grid-area: valor;
    font-size: 19px;
  }

  .afp-kpi small {
    grid-area: nota;
  }

  .afp-kpi--destaque {
    box-shadow: var(--sombra), inset 3px 0 0 var(--marca-acento, #111);
  }

  .afp-linha {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
    padding: 12px 16px;
  }

  .afp-st {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* Dica do link de produto na aba Divulgar (23/11/2026). */
.afp-dica { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.5; color: var(--muted); }
.afp-dica b { color: var(--fg); }
.afp-dica a { color: inherit; font-weight: 600; text-decoration: underline; white-space: nowrap; }
