/* ═══════════════════════════════════════════════════════════════════════════
   APP.CSS — Layout principal + toggle da sidebar
   Complementa design-system.css (que tem todos os componentes do mockup)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Skip link (a11y — aparece só no focus via teclado) ──────────────── */
.sp-skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  z-index: 10000;
  background: var(--d);
  color: #fff;
  padding: .5rem .9rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  transition: top .15s;
}
.sp-skip-link:focus {
  top: 6px;
  outline: 2px solid var(--gold);
}

/* Focus visível nos interativos (WCAG AA) */
*:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}

/* ── Main content area ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background: var(--c);
  position: relative;
}

.main-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 1.75rem) clamp(1rem, 2.5vw, 2.25rem);
}

/* ── Sidebar: transição suave pro toggle ──────────────────────────────── */
@media (min-width: 768px) {
  .sidebar {
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
}

/* Botão toggle: aba vertical no meio da borda direita da sidebar */
#sp-sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 56px;
  background: linear-gradient(135deg, #1B3A5C, #0C1929);
  border: 2px solid #0C1929;
  border-left: none;
  border-radius: 0 10px 10px 0;
  color: #fff;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 3px 2px 8px rgba(0,0,0,.18);
  transition: background .2s, box-shadow .2s;
}
#sp-sidebar-toggle:hover {
  background: linear-gradient(135deg, #2E6B9E, #1B3A5C);
  box-shadow: 4px 3px 12px rgba(0,0,0,.25);
}
#sp-sidebar-toggle svg {
  width: 13px;
  height: 13px;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

/* Estado colapsado: desliza a sidebar pra esquerda */
@media (min-width: 768px) {
  body.sp-sidebar-collapsed .sidebar {
    transform: translateX(calc(-100% + 38px));
  }
  body.sp-sidebar-collapsed #sp-sidebar-toggle svg {
    transform: rotate(180deg);
  }
  body.sp-sidebar-collapsed .sb-head,
  body.sp-sidebar-collapsed .sb-scroll,
  body.sp-sidebar-collapsed .sb-foot {
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
  }
}

/* ── Mobile antigo (empilhado) — neutralizado pelo LOTE 5E.              */
/* Agora mobile/tablet usam drawer overlay; regras novas vêm no bloco     */
/* "RESPONSIVIDADE — DRAWER" no final deste arquivo.                      */

/* ── Cards hover effect ───────────────────────────────────────────────── */
a.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(27,58,92,.08);
  border-color: var(--pl) !important;
}
a.card {
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

/* ── Footer disclaimer (tela /resultado) — estilo discreto alinhado QWEN ── */
/* Espelha app.py:3156 (#8a9ab0, 0.68rem, itálico, centralizado) */
.footer-disclaimer {
  text-align: center;
  color: #8a9ab0;
  font-style: italic;
  font-size: 0.68rem;
  line-height: 1.5;
  margin: 3rem auto 1.5rem;
  max-width: 720px;
  padding: 0 1rem;
}

/* ── Botão secundário sobre fundo escuro (hero da /resultado) ─────────── */
/* .btn-outline sobre navy fica quase invisível; esta variante usa tom    */
/* dourado translúcido (paleta da marca) com borda mais marcada e texto   */
/* branco-creme. Aplicar APENAS dentro do .result-hero.                    */
.btn-outline-on-dark {
  background: transparent;
  border: 1.5px solid rgba(212, 165, 116, 0.5);
  color: #f5f5f5;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline-on-dark:hover {
  background: rgba(212, 165, 116, 0.12);
  border-color: rgba(212, 165, 116, 0.9);
  color: #ffffff;
}

/* ── Caixa informativa "próxima etapa" no form /novo (LOTE 5H) ────────── */
.info-next-step {
  background: rgba(46, 107, 158, 0.06);
  border-left: 3px solid var(--p, #1B3A5C);
  border-radius: 0 8px 8px 0;
  padding: .75rem 1rem;
  font-size: .85rem;
  color: var(--ink2, #4A5568);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ── LOTE 7 — Rodapé global do app (links legais + contato) ──────────── */
.app-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid #e8e4dc;
  background: #fafbfd;
  margin-top: 3rem;
}
.app-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: .78rem;
  color: #7A8A9E;
}
.app-footer-links a {
  color: #4A5568;
  text-decoration: none;
  font-weight: 500;
}
.app-footer-links a:hover {
  color: #1B3A5C;
  text-decoration: underline;
}
.app-footer-links .sep {
  margin: 0 .5rem;
  opacity: .5;
}
@media (max-width: 767px) {
  .app-footer { padding: 1.25rem 1rem; }
  .app-footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* ── LOTE 6 — Olhinho mostrar/esconder senha ─────────────────────────── */
.pwd-wrap {
  position: relative;
  display: block;
}
.pwd-wrap input[type="password"],
.pwd-wrap input[type="text"] {
  padding-right: 42px;
  width: 100%;
}
.pwd-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--ink3, #7A8A9E);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.pwd-toggle:hover {
  color: var(--p, #1B3A5C);
  background: rgba(27, 58, 92, 0.06);
}
.pwd-toggle:focus-visible {
  outline: 2px solid var(--a, #0A6E5C);
  outline-offset: 2px;
}
.pwd-toggle.is-visible { color: var(--p, #1B3A5C); }

/* ── LOTE 6 — Hint discreto dentro dos modais ────────────────────────── */
.sp-dlg-hint {
  font-size: .72rem;
  color: var(--ink3, #7A8A9E);
  margin: .25rem 0 .7rem;
  line-height: 1.45;
}
.sp-dlg-label {
  display: block;
  font-weight: 600;
  font-size: .82rem;
  color: var(--ink2, #4A5568);
  margin: .55rem 0 .3rem;
}
.sp-dlg-input {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid var(--c3, #DDE5EF);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink, #1A1A1A);
}
.sp-dlg-input:focus {
  outline: none;
  border-color: var(--p, #1B3A5C);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, .15);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOTE 5E — RESPONSIVIDADE FASE 1
   Breakpoints: 480 · 768 · 1024 · 1440
   Desktop (>= 1024) permanece idêntico. Todas as regras novas vivem em
   @media queries, exceto os tokens e classes do hamburger/drawer/backdrop
   que começam escondidas por padrão (display:none).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bp-mobile: 480px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --bp-wide: 1440px;
  --sidebar-w: 272px;
  --topbar-h: 56px;
}

/* ── Botão hamburger (topbar) ──────────────────────────────────────────── */
.topbar-hamburger {
  display: none;
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--p, #1B3A5C);
  margin-right: 8px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}
.topbar-hamburger:hover { background: rgba(27, 58, 92, 0.08); }
.topbar-hamburger svg { display: block; }

/* ── Botão fechar (sidebar, canto sup. direito do drawer) ──────────────── */
.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.sidebar-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ── Backdrop escurecido (só visível com drawer aberto) ────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 25, 41, 0.5);
  z-index: 90;
  animation: sp-backdrop-in 0.2s ease-out;
}
.sidebar-backdrop.open { display: block; }
.sidebar-backdrop[hidden] { display: none; }
.sidebar-backdrop.open[hidden] { display: block; }

@keyframes sp-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Drawer em mobile + tablet (< 1024) ────────────────────────────────── */
@media (max-width: 1023px) {
  .topbar-hamburger { display: inline-flex; }
  .sidebar-close { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    width: 280px;
    min-width: 280px;
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    width: 100%;
    margin-left: 0;
  }

  /* Previne scroll do body quando drawer aberto (reforça overflow:hidden) */
  body.drawer-open { overflow: hidden; }

  /* Em < 1024 escondemos o toggle colapsável desktop pra não conflitar    */
  /* com o drawer. O toggle é reativado em >= 1024 (CSS base).             */
  #sp-sidebar-toggle { display: none !important; }

  /* Topbar mais compacta em mobile/tablet */
  .topbar { padding: 0.85rem 1rem; }
}

/* ── Ajustes finos em mobile (< 768) ───────────────────────────────────── */
@media (max-width: 767px) {
  .topbar { padding: 0.65rem 0.85rem; gap: 0.5rem; }
  .breadcrumb { font-size: 0.8rem; }
  .breadcrumb span:not(.current):not(.sep) { display: none; }
  .breadcrumb .sep { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOTE 5G — RESPONSIVIDADE FASE 2 (telas internas)
   Desktop >= 1024px permanece idêntico. Todas as mudanças vivem em
   @media (max-width: 1023px) [tablet] e (max-width: 767px) [mobile].
   ═══════════════════════════════════════════════════════════════════════════ */

/* === TABLET (768-1023px) === */
@media (max-width: 1023px) {
  .page {
    padding: 1.5rem 1.25rem 3rem;
  }

  /* Grids que têm 3+ colunas → 2 colunas em tablet */
  .quick-grid,
  .news-row,
  .tipos-grid-3,
  .plans-grid,
  .integ-grid,
  .sponsor-row,
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Grids 2 colunas dissimétricos → 1 coluna já em tablet */
  .hero-grid,
  .home-cols,
  .perfil-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Hero stats vira linha (se existir .hero-stat-stack) */
  .hero-stat-stack {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .5rem;
  }
  .hero-stat {
    flex: 1 1 calc(50% - .5rem);
    min-width: 0;
  }
}

/* === MOBILE (<= 767px) === */
@media (max-width: 767px) {
  .page {
    padding: 1rem .85rem 2rem;
  }

  /* Todos os grids comuns → 1 coluna */
  .grid-2,
  .grid-3,
  .grid-4,
  .quick-grid,
  .news-row,
  .tipos-grid-2,
  .tipos-grid-3,
  .plans-grid,
  .bonus-grid,
  .integ-grid,
  .sponsor-row,
  .books-grid,
  .hero-grid,
  .home-cols,
  .perfil-grid,
  .perfil-form-grid,
  .avulso-grid,
  .tipos-forms .grid-2,
  .tipos-forms .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Hero: título menor, stats em 1 coluna */
  .hero-banner {
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }
  .hero-title {
    font-size: 1.5rem;
  }
  .hero-sub {
    font-size: .88rem;
  }
  .hero-stat-stack {
    flex-direction: column;
    gap: .6rem;
  }
  .hero-stat {
    flex: 1;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .hero-actions .btn {
    width: 100%;
  }

  /* Page titles compactos */
  .page-title {
    font-size: 1.6rem;
  }
  .page-sub {
    font-size: .85rem;
  }

  /* Cards menos padding */
  .card,
  .card-soft,
  .card-dark,
  .previa-hero,
  .perfil-hero,
  .result-hero,
  .pipe-banner {
    padding: 1.25rem 1rem;
    border-radius: 12px;
  }

  /* Botões: wrap e full-width quando em grupo */
  .flex.gap-2,
  .flex.gap-3 {
    flex-wrap: wrap;
  }
  .btn-xl {
    padding: .8rem 1.1rem;
    font-size: .88rem;
  }

  /* ── Histórico: row vira card empilhado (cabeçalho some) ── */
  .hist-row {
    grid-template-columns: 44px 1fr auto;
    grid-template-areas:
      "ico title btn"
      "ico meta btn"
      "stat stat stat";
    gap: .35rem .7rem;
    padding: .85rem 1rem;
  }
  .hist-row.head { display: none; }
  .hist-row .hist-ico { grid-area: ico; }
  .hist-row > div:nth-child(2) { grid-area: title; }
  .hist-row > div:nth-child(3) { grid-area: meta; font-size: .72rem; }
  .hist-row > div:nth-child(4) { display: none; }
  .hist-row > div:nth-child(5) { grid-area: stat; }
  .hist-row > div:nth-child(6) { grid-area: btn; }

  /* ── Recomendador: journal card empilha ── */
  .journal-card {
    grid-template-columns: 1fr;
    gap: .6rem;
    padding: 1rem;
  }
  .journal-card > * {
    text-align: left !important;
  }
  .journal-score {
    font-size: 1.2rem;
    text-align: left;
  }
  .journal-score-lbl {
    text-align: left;
  }

  /* ── Comprar: avulso vira stack, featured sem lift ── */
  .avulso {
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
    text-align: left;
  }
  .avulso-body { width: 100%; }
  .avulso .btn { width: 100%; }
  .plan.featured { transform: none; }

  /* ── Perfil hero: stack vertical + ctas full-width ── */
  .perfil-hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1rem;
  }
  .perfil-cta { align-items: stretch; }
  .perfil-cta .btn-gold-line,
  .perfil-cta .btn-ghost-w { width: 100%; }

  /* ── Tabela de compras do perfil → scroll horizontal ── */
  .purch-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .purch-table { min-width: 640px; }

  /* ── Resultado: 2fr 1fr → 1 coluna; stats 1fr 1fr se mantém ── */
  .result-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .result-stats {
    grid-template-columns: 1fr 1fr;
  }

  /* ── Pipeline: chips wrap ── */
  .pipe-chips { flex-wrap: wrap; }

  /* ── Watermark suave ── */
  .wm {
    font-size: clamp(2rem, 10vw, 4rem);
    right: .5rem;
    top: .5rem;
  }

  /* ── Uploader mais compacto ── */
  .uploader {
    padding: 1.1rem .9rem;
  }
}

/* === MOBILE SMALL (<= 400px) — últimos ajustes para iPhone SE 1ª gen etc === */
@media (max-width: 400px) {
  .page-title { font-size: 1.4rem; }
  .hero-title { font-size: 1.35rem; }
  .card,
  .card-soft,
  .card-dark { padding: 1rem .85rem; }
  .result-stats { grid-template-columns: 1fr; }
}
