/**
 * RachaPro — app shell (sidebar desktop + offcanvas mobile + topbar)
 * Usa a paleta existente do base: --navy-blue, --lime-green, --dark-navy, etc.
 */
:root {
  --racha-sidebar-w: 280px;
  --racha-topbar-h: 3.5rem;
  --racha-surface-nav: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  --racha-nav-radius: 10px;
  --racha-topbar-z: 1030;
  --racha-sidebar-z: 1020;
  --racha-offcanvas-surface: linear-gradient(180deg, #1a1a2e 0%, #152238 100%);
}

/* ——— Shell ——— */
.app-shell {
  display: flex;
  min-height: 100dvh;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Sidebar fixa: só visível a partir de lg */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--racha-sidebar-z);
  width: var(--racha-sidebar-w);
  height: 100dvh;
  height: 100vh;
  max-height: 100dvh;
  flex-direction: column;
  background: var(--racha-surface-nav);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  border-right: 1px solid rgba(205, 220, 57, 0.12);
  transition: transform 0.22s ease;
}

.app-sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
}

.app-sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}
.app-sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--lime-green);
  border-radius: 4px;
}

/* Coluna principal (direita da sidebar) */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  margin-left: 0;
}

@media (min-width: 992px) {
  .app-main {
    margin-left: var(--racha-sidebar-w);
    transition: margin-left 0.22s ease;
  }
}

/* Desktop: recolher / mostrar a sidebar (também guarda preferência em localStorage) */
@media (min-width: 992px) {
  .app-shell.racha-sidebar-hidden .app-sidebar {
    transform: translateX(-100%);
    pointer-events: none;
  }
  .app-shell.racha-sidebar-hidden .app-main {
    margin-left: 0;
  }
}
@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .app-main {
    transition: none;
  }
}
.racha-sidebar-toggler .racha-ico-when-nav-hidden {
  display: none;
}
.app-shell.racha-sidebar-hidden .racha-sidebar-toggler .racha-ico-when-nav-visible {
  display: none;
}
.app-shell.racha-sidebar-hidden .racha-sidebar-toggler .racha-ico-when-nav-hidden {
  display: inline-block;
}
.racha-topbar-start {
  min-width: 0;
}

/* ——— Offcanvas: mesmo “sheet” de nave; só em < lg ——— */
#rachaNavOffcanvas {
  z-index: 1050;
  background: var(--racha-offcanvas-surface);
  color: var(--white, #fff);
  width: min(20rem, 100vw) !important;
  border-right: 1px solid rgba(205, 220, 57, 0.15) !important;
}
#rachaNavOffcanvas .offcanvas-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark-navy) 0%, var(--navy-blue) 100%);
  border-bottom: 2px solid var(--lime-green);
  color: #fff;
}
#rachaNavOffcanvas .offcanvas-header .offcanvas-title {
  margin-bottom: 0;
}
#rachaNavOffcanvas .offcanvas-header .btn-close {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  filter: invert(1) grayscale(1);
  opacity: 0.85;
}
#rachaNavOffcanvas .offcanvas-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}

#rachaNavOffcanvas .app-offcanvas-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ——— Topbar ——— */
.racha-topbar {
  position: sticky;
  top: 0;
  z-index: var(--racha-topbar-z);
  min-height: var(--racha-topbar-h);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  background: linear-gradient(135deg, var(--dark-navy) 0%, var(--navy-blue) 100%);
  border-bottom: 3px solid var(--lime-green);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.racha-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: #fff !important;
  font-weight: 700;
  flex: 0 0 auto;
}
.racha-topbar-logo {
  height: 31px;
  width: auto;
  object-fit: contain;
}
.racha-topbar-mid {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}
.racha-topbar-title:empty {
  display: none;
}
h1.racha-topbar-title {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.racha-topbar-end {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Botão hamburger (só móvel) */
.racha-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.8rem;
  min-height: 2.8rem;
  border-radius: var(--racha-nav-radius);
  border: 2px solid var(--lime-green);
  background: rgba(205, 220, 57, 0.12);
  color: var(--lime-green);
  transition: background 0.2s ease, transform 0.2s ease;
}
.racha-burger:hover {
  background: rgba(205, 220, 57, 0.22);
  color: #f4ff81;
  transform: scale(1.03);
}

@media (min-width: 992px) {
  .racha-burger.d-lg-none {
    display: none !important;
  }
}

/* ——— Nav sheet (blocos + itens) ——— */
.racha-nav-sheet {
  padding: 0.5rem 0.65rem 0.75rem;
  flex: 1;
  min-width: 0;
}

/* Cada secção do menu = “bloquinho” (card) */
.racha-nav-block {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(205, 220, 57, 0.16);
  border-radius: 12px;
  padding: 0.4rem 0.45rem 0.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 10px rgba(0, 0, 0, 0.2);
}

.racha-nav-block + .racha-nav-block {
  margin-top: 0.65rem;
}

.racha-nav-block-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
  margin: 0.2rem 0.35rem 0.5rem 0.3rem;
  padding-bottom: 0.35rem;
  line-height: 1.2;
  border-bottom: 1px solid rgba(205, 220, 57, 0.1);
}

.racha-nav-block:first-child .racha-nav-block-title {
  margin-top: 0.05rem;
}

ul.racha-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.racha-nav-list > li {
  margin: 0.15rem 0;
}

/* Link linha (folha) */
a.racha-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.45rem 0.6rem 0.45rem 0.5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--racha-nav-radius);
  border-left: 3px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

a.racha-nav-item i:first-child,
button.racha-nav-item i:first-child {
  font-size: 1.1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.9;
}
/* Ícone custom (ex.: bola na Artilharia) — alinhado ao slot do <i> */
a.racha-nav-item > .racha-nav-ico-img {
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.6rem;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  opacity: 0.95;
  align-self: center;
}

a.racha-nav-item .racha-nav-chevron,
button.racha-nav-item .racha-nav-chevron-end {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.4;
  flex-shrink: 0;
}

a.racha-nav-item:hover,
a.racha-nav-item.active {
  background: rgba(205, 220, 57, 0.14);
  border-left-color: var(--lime-green);
  color: var(--lime-green);
  transform: translateX(2px);
}

a.racha-nav-item.active {
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(205, 220, 57, 0.1);
}

/* Subitens (collapsed) */
a.racha-nav-sub {
  font-size: 0.9rem;
  padding-left: 0.3rem;
}
a.racha-nav-sub i:first-child {
  font-size: 1rem;
  width: 1.4rem;
}

/* Parent (collapse) */
button.racha-nav-item {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.45rem 0.6rem 0.45rem 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--racha-nav-radius);
  border-left: 3px solid transparent;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}
button.racha-nav-item:hover,
button.racha-nav-item[aria-expanded='true'] {
  background: rgba(205, 220, 57, 0.1);
  border-left-color: rgba(205, 220, 57, 0.4);
  color: var(--lime-green);
}
button.racha-nav-item[aria-expanded='true'] .racha-nav-chevron-rot {
  transform: rotate(180deg);
}
.racha-nav-chevron-rot {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform 0.25s ease;
  opacity: 0.6;
  flex-shrink: 0;
}
.racha-nav-group .racha-nav-collapse {
  margin-left: 0.1rem;
  border-left: 1px solid rgba(205, 220, 57, 0.1);
  padding-left: 0.35rem;
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}

/* ——— Brand na sidebar (desktop) ——— */
.racha-side-brand {
  background: linear-gradient(135deg, var(--dark-navy) 0%, var(--navy-blue) 100%);
  padding: 1rem 1.1rem;
  border-bottom: 3px solid var(--lime-green);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
}
.racha-side-brand a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
}
.racha-side-brand img {
  height: 32px;
  width: auto;
  object-fit: contain;
}
.racha-topbar-ghost {
  /* placeholder direita quando offcanvas: logo centrado ainda funciona com flex 1 1 */
  width: 2.8rem;
  flex-shrink: 0;
  visibility: hidden;
}

/* ——— User strip (sidebar + offcanvas) ——— */
.racha-user-strip {
  margin-top: auto;
  padding: 0.65rem 0.75rem;
  background: rgba(205, 220, 57, 0.08);
  border-top: 1px solid rgba(205, 220, 57, 0.2);
  flex-shrink: 0;
}
.racha-user-strip-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.racha-user-avatar,
.racha-user-strip .racha-avatar,
.app-sidebar .sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lime-green);
  color: var(--dark-navy);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--lime-green);
  flex-shrink: 0;
}
.racha-user-strip .racha-avatar .avatar-initial,
.racha-user-avatar .avatar-initial {
  z-index: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--dark-navy);
}
.racha-user-strip .racha-avatar .avatar-photo,
.racha-user-avatar .avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  border-radius: 50%;
}
.racha-user-text {
  min-width: 0;
  flex: 1;
}
.racha-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1.2;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.racha-user-mail {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.72rem;
  margin: 0.1rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.racha-logout {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid rgba(244, 67, 54, 0.4);
  color: #ff8a80;
  white-space: nowrap;
  transition: background 0.2s;
}
a.racha-logout:hover {
  background: rgba(244, 67, 54, 0.3);
  color: #ffccc7;
}
.app-sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  flex: 1;
}

/* Conteúdo: scroll sob topbar; footer segue a coluna */
.app-content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.racha-guest-outer {
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Foco acessível */
a.racha-nav-item:focus-visible,
button.racha-nav-item:focus-visible,
.racha-burger:focus-visible,
.racha-burger.btn:focus {
  outline: 2px solid var(--lime-green);
  outline-offset: 2px;
}

/* ——— Barra inferior (atleta, mobile) — alinhada ao shell navy + ícones em cápsula ——— */
.racha-bottom-nav-atleta {
  --racha-bottom-fg: rgba(255, 255, 255, 0.78);
  --racha-bottom-muted: rgba(255, 255, 255, 0.45);
  /* Filho direto de <body> (base.html) para fixed não “herdar” de flex/transform em ancestrais (Safari/WebKit). */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  z-index: 1040;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 0.1rem;
  min-height: 3.75rem;
  padding: 0.35rem 0.2rem 0.3rem;
  padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 0px));
  /* Mesma família de cor da sidebar / cards (evita preto “chapado”) */
  background: linear-gradient(180deg, #1a237e 0%, #121a4a 45%, #0a0e28 100%);
  border-top: 1px solid rgba(205, 220, 57, 0.2);
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-tap-highlight-color: transparent;
}
.racha-bottom-nav-atleta__item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--racha-bottom-muted);
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.1rem 0.05rem;
  max-width: 5.75rem;
  margin: 0 auto;
  transition: color 0.2s ease, transform 0.12s ease;
  touch-action: manipulation;
}
.racha-bottom-nav-atleta__item:active {
  transform: scale(0.97);
}
/* Cápsula do ícone — leitura tipo app (iFood / Uber) */
.racha-bottom-nav-atleta__ico-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2);
  color: var(--racha-bottom-fg);
  transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.racha-bottom-nav-atleta__item.is-active .racha-bottom-nav-atleta__ico-wrap {
  background: linear-gradient(145deg, rgba(205, 220, 57, 0.28) 0%, rgba(205, 220, 57, 0.12) 100%);
  box-shadow: inset 0 0 0 1px rgba(205, 220, 57, 0.35), 0 2px 12px rgba(205, 220, 57, 0.12);
  color: var(--lime-green, #cddc39);
}
.racha-bottom-nav-atleta__ico {
  font-size: 1.5rem;
  line-height: 1;
  display: block;
}
/* Pagamentos: cifrão / moeda um pouco maior no mesmo slot */
.racha-bottom-nav-atleta__ico--pag {
  font-size: 1.58rem;
  margin-top: -0.04rem;
}
.racha-bottom-nav-atleta__item.is-active .racha-bottom-nav-atleta__ico--pag {
  filter: drop-shadow(0 0 6px rgba(205, 220, 57, 0.25));
}
.racha-bottom-nav-atleta__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.racha-bottom-nav-atleta__item.is-active {
  color: var(--lime-green, #cddc39);
}
.racha-bottom-nav-atleta__item:focus-visible {
  outline: 2px solid var(--lime-green, #cddc39);
  outline-offset: 2px;
  border-radius: 0.5rem;
}
@media (min-width: 992px) {
  .racha-bottom-nav-atleta.d-lg-none {
    display: none !important;
  }
}
@media (max-width: 991.98px) {
  body.racha-has-bottom-nav-atleta,
  body.racha-has-bottom-nav-diretoria {
    padding-bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ——— Subnav superior: desempenho (ícones + rótulo; no mobile, fila centralizada) ——— */
.racha-subnav-desempenho {
  width: 100%;
  border-bottom: 1px solid rgba(205, 220, 57, 0.12);
  padding: 0.2rem 0 0.45rem;
}
.racha-subnav-desempenho__row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.4rem 0.35rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 0.2rem;
}
.racha-subnav-desempenho__item {
  flex: 0 1 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 3.6rem;
  max-width: 5.1rem;
  width: min(5.1rem, calc(20% - 0.32rem));
  padding: 0.5rem 0.4rem 0.42rem;
  border-radius: 0.85rem;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.racha-subnav-desempenho__item:hover {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(205, 220, 57, 0.2);
}
.racha-subnav-desempenho__item.is-active {
  color: var(--lime-green, #cddc39);
  background: linear-gradient(180deg, rgba(205, 220, 57, 0.2) 0%, rgba(26, 26, 46, 0.4) 100%);
  border-color: rgba(205, 220, 57, 0.4);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.racha-subnav-desempenho__item:focus-visible {
  outline: 2px solid var(--lime-green, #cddc39);
  outline-offset: 2px;
}
.racha-subnav-desempenho__ico {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.4rem;
  font-size: 1.3rem;
  line-height: 1;
  opacity: 0.95;
}
.racha-subnav-desempenho__item.is-active .racha-subnav-desempenho__ico {
  filter: drop-shadow(0 0 6px rgba(205, 220, 57, 0.25));
}
.racha-subnav-desempenho__item.is-active .racha-subnav-desempenho__img-ico {
  filter: drop-shadow(0 0 6px rgba(205, 220, 57, 0.35)) brightness(1.15) saturate(1.1);
}
.racha-subnav-desempenho__img-ico {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  object-fit: contain;
  opacity: 0.9;
  flex-shrink: 0;
}
.racha-subnav-desempenho__item--artilharia .racha-subnav-desempenho__img-ico {
  width: 1.5rem;
  height: 1.5rem;
  opacity: 0.95;
}
.racha-subnav-desempenho__item.is-active .racha-subnav-desempenho__img-ico {
  opacity: 1;
}
.racha-subnav-desempenho__label {
  display: block;
  width: 100%;
  white-space: normal;
  text-align: center;
  letter-spacing: 0.02em;
  word-break: break-word;
  hyphens: auto;
}
/* Desktop: itens alinhados à esquerda (fluxo de leitura); mobile segue centralizado */
@media (min-width: 992px) {
  .racha-subnav-desempenho__row {
    justify-content: flex-start;
    padding-left: 0;
  }
  .racha-subnav-desempenho__item {
    width: auto;
    min-width: 4.4rem;
    max-width: 5.4rem;
  }
}
/* Telas muito estreitas: 5 cápsulas centralizados em 2 filas, sem corte */
@media (max-width: 380px) {
  .racha-subnav-desempenho__row {
    gap: 0.4rem 0.4rem;
  }
  .racha-subnav-desempenho__item {
    width: calc(33.333% - 0.35rem);
    min-width: 0;
    max-width: 6rem;
  }
}
