/* ============================================
   AppTitude Fit — overrides sobre o Metronic (demo64)
   Marca (manual v1.0): Laranja Apptitude #F37021 + Chumbo #313131
   Regra 60-30-10: 60% branco/cinza claro, 30% chumbo, 10% laranja (CTAs)
   ============================================ */

:root,
[data-bs-theme="light"] {
  --bs-primary: #F37021;
  --bs-primary-active: #D05E17;
  --bs-primary-light: #FDE9DC;
  --bs-primary-inverse: #FFFFFF;
  /* Família completa do primary (Metronic 8 usa essas vars em .text-primary,
     .bg-primary, borders e subtles — sem elas sobra o azul #1B84FF do bundle) */
  --bs-primary-rgb: 243, 112, 33;
  --bs-primary-text-emphasis: #8A4A12;
  --bs-primary-bg-subtle: #FDE9DC;
  --bs-primary-border-subtle: #F5C9A8;
  --bs-text-primary: #F37021;
  --bs-danger: #D92D20;
  --bs-danger-active: #B42318;
  --bs-danger-light: #FDECEA;
  --bs-body-bg: #F8F9FA;
  --bs-gray-900: #313131;
  --bs-gray-600: #8C8C8C;
  /* Links: fora do azul padrão do Metronic (#1B84FF) — âncoras na cor da marca */
  --bs-link-color: #D05E17;
  --bs-link-color-rgb: 208, 94, 23;
  --bs-link-hover-color: #F37021;
  --bs-link-hover-color-rgb: 243, 112, 33;
  --af-accent: #F5A26B;
  --af-ink: #313131;
  --af-muted: #8C8C8C;
}

/* --- Paleta de status: vermelho forte e "info" na cor da marca --- */
/* Blindagem: o bundle do Metronic pinta .text-primary com --bs-primary-rgb azul
   (#1B84FF); garantimos a cor da marca na classe, além das variáveis */
.text-primary { color: #F37021 !important; }
a.text-primary:hover, a.text-primary:focus { color: #D05E17 !important; }
[data-bs-theme="dark"] .text-primary { color: #F58A47 !important; }
[data-bs-theme="dark"] a.text-primary:hover, [data-bs-theme="dark"] a.text-primary:focus { color: #F37021 !important; }
.text-danger { color: #D92D20 !important; }
.bg-danger { background-color: #D92D20 !important; }
.badge-light-danger { color: #D92D20 !important; background-color: #FDECEA !important; }
.btn-light-danger { color: #D92D20 !important; background-color: #FDECEA !important; border-color: transparent !important; }
.btn-light-danger:hover, .btn-light-danger:focus { color: #FFFFFF !important; background-color: #D92D20 !important; }
.alert-danger { background-color: #FDECEA !important; color: #7A1B14 !important; border-color: #D92D20 !important; }
.text-info { color: #D05E17 !important; }
.badge-light-info { color: #D05E17 !important; background-color: #FDE9DC !important; }
.btn-light-info { color: #D05E17 !important; background-color: #FDE9DC !important; border-color: transparent !important; }
.btn-light-info:hover, .btn-light-info:focus { color: #FFFFFF !important; background-color: #F37021 !important; }
.alert-info { background-color: #FDE9DC !important; color: #8A4A12 !important; border-color: #F37021 !important; }
.progress-bar.bg-danger { background-color: #D92D20 !important; }
/* Variantes sólidas (legenda de status, botões) */
.badge-danger { background-color: #D92D20 !important; }
.badge-info { background-color: #F37021 !important; }
.badge-success { background-color: #2D9D78 !important; }
.bg-info { background-color: #F37021 !important; }
.btn-danger { background-color: #D92D20 !important; border-color: #D92D20 !important; }
.btn-danger:hover, .btn-danger:focus { background-color: #B42318 !important; border-color: #B42318 !important; }

[data-bs-theme="dark"] {
  --bs-primary: #F37021;
  --bs-primary-active: #F58A47;
  --bs-primary-light: #3A2A1E;
  --bs-primary-inverse: #FFFFFF;
  --bs-primary-rgb: 243, 112, 33;
  --bs-primary-text-emphasis: #FFA978;
  --bs-primary-bg-subtle: #331606;
  --bs-primary-border-subtle: #7A3A10;
  --bs-text-primary: #F58A47;
  --bs-link-color: #F58A47;
  --bs-link-color-rgb: 245, 138, 71;
  --bs-link-hover-color: #F37021;
  --bs-link-hover-color-rgb: 243, 112, 33;
}

/* --- Wordmark --- */
.af-wordmark {
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--af-ink);
  text-decoration: none;
}
.af-wordmark .fit { color: var(--bs-primary); }
[data-bs-theme="dark"] .af-wordmark { color: #FFFFFF; }
.af-wordmark-lg { font-size: 2.2rem; }

/* --- Botões: feedback de pressão (emil-design-eng) --- */
.btn {
  transition: transform 160ms ease-out, background-color 160ms ease-out,
              border-color 160ms ease-out, color 160ms ease-out, box-shadow 160ms ease-out;
}
.btn:active { transform: scale(0.97); }
.btn-primary { --bs-btn-bg: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary-active); }

/* --- Login: painel lateral (chumbo + acento laranja) --- */
.af-login-aside {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(243, 112, 33, 0.28), transparent 60%),
    linear-gradient(160deg, #313131 0%, #1B1B1B 100%);
  color: #FFFFFF;
}
.af-login-aside .af-wordmark { color: #FFFFFF; }
.af-login-aside .af-wordmark .fit { color: var(--af-accent); }
.af-login-aside h1, .af-login-aside h2, .af-login-aside h3,
.af-login-aside .fw-bold, .af-login-aside .text-gray-900 { color: #FFFFFF !important; }
.af-proof-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  color: rgba(255, 255, 255, 0.85);
}
.af-proof-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--af-accent);
  margin-top: 0.45rem;
}

/* --- OTP: 6 caixas (assinatura do login) --- */
.af-otp {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.af-otp-input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border: 1px solid var(--bs-gray-300, #E1E3EA);
  border-radius: 0.625rem;
  background: transparent;
  color: inherit;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;
}
.af-otp-input:focus {
  outline: none;
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 4px rgba(243, 112, 33, 0.15);
}
.af-otp-input.af-filled { border-color: var(--bs-primary); }
.af-otp-input.af-error {
  border-color: var(--bs-danger, #D92D20);
  animation: af-shake 200ms ease-out;
}
@keyframes af-shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* --- Transição entre etapas do login --- */
.af-step {
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.af-step.af-hidden {
  display: none;
}
.af-step-enter {
  opacity: 0;
  transform: translateY(8px);
}

/* --- Sidebar do shell --- */
.af-sidebar {
  width: 265px;
  flex: none;
  border-right: 1px solid var(--bs-gray-200, #EFF2F5);
  background: var(--bs-body-bg);
  min-height: 100vh;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
[data-bs-theme="dark"] .af-sidebar { border-right-color: #2B2B40; }

/* --- Mobile: sidebar vira off-canvas com topbar + hambúrguer --- */
.af-topbar-mobile {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-gray-200, #EFF2F5);
  background: var(--bs-body-bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.af-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(49, 49, 49, 0.45);
  z-index: 39;
}
@media (max-width: 991.98px) {
  .af-topbar-mobile { display: flex; }
  .af-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
    overflow-y: auto;
  }
  body.af-nav-open .af-sidebar { transform: translateX(0); }
  body.af-nav-open .af-overlay { display: block; }
  main.flex-grow-1.p-10 { padding: 1.25rem !important; }
}
.af-menu-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.625rem;
  color: var(--af-muted);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}
.af-menu-link:hover { background: var(--bs-primary-light); color: var(--bs-primary); }
.af-menu-link.active { background: var(--bs-primary-light); color: var(--bs-primary); font-weight: 600; }
.af-menu-icon { width: 1.25rem; height: 1.25rem; flex: none; }

/* --- Empty state --- */
.af-empty {
  border: 2px dashed var(--bs-gray-300, #E1E3EA);
  border-radius: 0.75rem;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--af-muted);
}

/* --- Miolo centralizado em telas grandes --- */
main.flex-grow-1 {
  max-width: 1440px;
  width: 100%;
  margin-inline: auto;
}

/* --- Card de ficha clicável --- */
.ficha-card {
  transition: box-shadow 180ms ease-out, border-color 180ms ease-out;
}
.ficha-card:hover {
  box-shadow: 0 6px 20px rgba(49, 49, 49, 0.1);
}

/* --- Modal leve (duplicar ficha, confirmações) --- */
.af-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(49, 49, 49, 0.5);
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.af-modal.aberto { display: flex; }
.af-modal-card {
  background: var(--bs-body-bg, #fff);
  border-radius: 1rem;
  padding: 1.75rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: af-modal-in 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes af-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
[data-bs-theme="dark"] .af-modal-card { border: 1px solid #2B2B40; }

/* --- Popover de troca de perfil (rodapé da sidebar) --- */.af-perfil-pop {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-gray-200, #EFF2F5);
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(49, 49, 49, 0.16);
  padding: 0.5rem;
  z-index: 50;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: bottom center;
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}
.af-perfil-pop.aberto {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.af-perfil-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease-out;
}
.af-perfil-item:hover { background: var(--bs-primary-light); }
[data-bs-theme="dark"] .af-perfil-pop { border-color: #2B2B40; }

/* --- Acessibilidade / motion --- */
@media (prefers-reduced-motion: reduce) {
  .btn, .af-step, .af-otp-input, .af-menu-link, .af-perfil-pop, .ficha-card { transition-duration: 0ms; }
  .af-modal-card { animation: none; }
  .af-otp-input.af-error { animation: none; }
}
:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

/* --- Tema dark: overrides dos componentes customizados --- */
[data-bs-theme="dark"] {
  --bs-body-bg: #1B1B1F;
}
[data-bs-theme="dark"] .af-topbar-mobile { border-bottom-color: #2B2B35; }
[data-bs-theme="dark"] .mt-exercicio { background: #232328 !important; border-color: #34343C !important; }
[data-bs-theme="dark"] .mt-exercicio.done { background: #1E2A25 !important; border-color: #2D9D78 !important; }
[data-bs-theme="dark"] .mt-check { background: #2B2B32 !important; border-color: #4A4A55 !important; }
[data-bs-theme="dark"] .mt-exercicio.done .mt-check { background: #2D9D78 !important; border-color: #2D9D78 !important; }
[data-bs-theme="dark"] .mt-chip { background: #232328 !important; border-color: #34343C !important; color: #8C8C8C !important; }
[data-bs-theme="dark"] .mt-chip.completo { background: #2D9D78 !important; border-color: #2D9D78 !important; color: #fff !important; }
[data-bs-theme="dark"] .mt-chip.incompleto { background: #3A2F18 !important; border-color: #FFC700 !important; color: #FFC700 !important; }
[data-bs-theme="dark"] .mt-chip.falta { background: #3A1F27 !important; border-color: #D92D20 !important; color: #D92D20 !important; }
[data-bs-theme="dark"] .mt-chip.reposicao { background: #2A2118 !important; border-color: #F37021 !important; color: #F37021 !important; }
[data-bs-theme="dark"] .mt-chip.descanso { background: #232328 !important; }
[data-bs-theme="dark"] .fi-chip { background: #232328 !important; border-color: #34343C !important; }
[data-bs-theme="dark"] .fi-chip.completo { background: #2D9D78 !important; border-color: #2D9D78 !important; color: #fff !important; }
[data-bs-theme="dark"] .fi-chip.incompleto { background: #3A2F18 !important; border-color: #FFC700 !important; color: #FFC700 !important; }
[data-bs-theme="dark"] .fi-chip.falta { background: #3A1F27 !important; border-color: #D92D20 !important; color: #D92D20 !important; }
[data-bs-theme="dark"] .fi-chip.reposicao { background: #2A2118 !important; border-color: #F37021 !important; color: #F37021 !important; }
[data-bs-theme="dark"] .fi-chip.descanso { background: #232328 !important; }
[data-bs-theme="dark"] .pf-dia { background: #232328 !important; border-color: #34343C !important; color: #D5D5DC !important; }
[data-bs-theme="dark"] .pf-dia.completo { background: #2D9D78 !important; border-color: #2D9D78 !important; color: #fff !important; }
[data-bs-theme="dark"] .pf-dia.incompleto { background: #3A2F18 !important; border-color: #FFC700 !important; color: #FFC700 !important; }
[data-bs-theme="dark"] .pf-dia.falta { background: #3A1F27 !important; border-color: #D92D20 !important; color: #D92D20 !important; }
[data-bs-theme="dark"] .pf-dia.reposicao { background: #2A2118 !important; border-color: #F37021 !important; color: #F37021 !important; }
[data-bs-theme="dark"] .pf-dia.descanso { background: #1F1F24 !important; color: #8C8C8C !important; }
[data-bs-theme="dark"] .pf-dia.futuro { color: #55555F !important; }
[data-bs-theme="dark"] .pf-dia.hoje { outline-color: #D5D5DC !important; }
[data-bs-theme="dark"] .pf-login { background: #D5D5DC !important; }
[data-bs-theme="dark"] .pf-tl::before { background: #34343C !important; }
[data-bs-theme="dark"] .pf-tl-dot { background: #232328 !important; border-color: #34343C !important; }
[data-bs-theme="dark"] .pf-tl-dot.ficha { border-color: #F37021 !important; background: #2A2118 !important; }
[data-bs-theme="dark"] .pf-tl-dot.treino { border-color: #2D9D78 !important; background: #1E2A25 !important; }
[data-bs-theme="dark"] .pf-tl-dot.login { border-color: #55555F !important; background: #232328 !important; }
[data-bs-theme="dark"] .ff-grupo-card { border-color: #34343C !important; }
[data-bs-theme="dark"] .ff-grupo-card.ativo { border-color: #F37021 !important; }
[data-bs-theme="dark"] .ff-busca-resultados { background: #232328 !important; border-color: #34343C !important; }
[data-bs-theme="dark"] .ff-busca-item:hover { background: #2A2118 !important; }
[data-bs-theme="dark"] .db-bar.hoje { outline-color: #D5D5DC !important; }
[data-bs-theme="dark"] .af-empty { color: #8C8C8C; }
