/* ==========================================================================
   Termos de Uso — página pública (layout do site) e interna (layout do painel).
   Os dois layouts têm variáveis diferentes, por isso cada cor cai numa cadeia
   de fallback: painel → site → literal.
   ========================================================================== */

.terms-page {
  --t-txt: var(--txt, var(--text-main, #16302B));
  --t-muted: var(--txt-muted, var(--text-muted, #5C7770));
  --t-surface: var(--surface-1, var(--surface-white, #FFFFFF));
  --t-surface-alt: var(--surface-2, var(--bg-light, #F6FAF8));
  --t-border: var(--border-2, rgba(16, 185, 129, 0.18));
  --t-accent: var(--accent, var(--brand-accent, #10B981));
  --t-brand: var(--accent, var(--brand-primary, #0B3D2E));

  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(14px, 4vw, 32px) 64px;
  color: var(--t-txt);
}

/* Dentro do painel o layout já recua e limita a largura: não somar o nosso */
.app-view .terms-page {
  max-width: none;
  padding: 0 0 40px;
}

/* Cabeçalho */
.terms-hero {
  border-bottom: 1px solid var(--t-border);
  padding-bottom: 22px;
  margin-bottom: 28px;
}
.terms-hero h1 {
  font-size: clamp(1.5rem, 4.5vw, 2.2rem);
  letter-spacing: -0.6px;
  color: var(--t-brand);
  margin: 0 0 8px;
}
.terms-hero p {
  color: var(--t-muted);
  max-width: 72ch;
  line-height: 1.65;
  margin: 0;
}

.terms-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.terms-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 50px;
  font-size: 0.76rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--t-accent) 12%, transparent);
  color: var(--t-accent);
}
.terms-badge svg { width: 14px; height: 14px; }
.terms-badge-neutral {
  background: var(--t-surface-alt);
  color: var(--t-muted);
}

/* Layout: índice fixo + conteúdo */
.terms-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 44px);
  align-items: start;
}

.terms-toc {
  position: sticky;
  top: 20px;
  background: var(--t-surface);
  border: 1px solid var(--t-border);
  border-radius: 14px;
  padding: 16px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}
.terms-toc strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--t-muted);
  margin-bottom: 10px;
}
.terms-toc ol { list-style: none; margin: 0; padding: 0; }
.terms-toc a {
  display: block;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--t-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.terms-toc a:hover,
.terms-toc a.is-current {
  color: var(--t-accent);
  background: color-mix(in srgb, var(--t-accent) 8%, transparent);
  border-left-color: var(--t-accent);
}
.terms-toc a.is-current { font-weight: 700; }

/* Conteúdo */
.terms-content { min-width: 0; }

.terms-section { margin-bottom: 30px; scroll-margin-top: 20px; }
.terms-section h2 {
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  color: var(--t-brand);
  letter-spacing: -0.3px;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--t-border);
}
.terms-section p {
  margin: 0 0 11px;
  line-height: 1.7;
  font-size: 0.93rem;
  max-width: 78ch;
}
.terms-section ul {
  margin: 0 0 12px;
  padding-left: 20px;
  max-width: 78ch;
}
.terms-section li {
  margin-bottom: 7px;
  line-height: 1.62;
  font-size: 0.93rem;
}
.terms-section strong { color: var(--t-txt); }

.terms-alert {
  background: color-mix(in srgb, #F59E0B 11%, transparent);
  border-left: 3px solid #F59E0B;
  border-radius: 10px;
  padding: 12px 15px;
  margin: 0 0 13px;
  line-height: 1.62;
  font-size: 0.9rem;
  max-width: 78ch;
}

/* Rodapé: identificação da empresa e prova do aceite */
.terms-footer {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--t-border);
  font-size: 0.82rem;
  color: var(--t-muted);
  line-height: 1.7;
}
.terms-hash {
  font-family: 'Cascadia Mono', Consolas, monospace;
  font-size: 0.74rem;
  word-break: break-all;
  color: var(--t-muted);
}

.terms-receipt {
  background: var(--t-surface-alt);
  border: 1px solid var(--t-border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 26px;
}
.terms-receipt h3 {
  font-size: 0.86rem;
  color: var(--t-brand);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.terms-receipt h3 svg { width: 16px; height: 16px; color: var(--t-accent); }
.terms-receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 18px;
}
.terms-receipt-grid > div { display: flex; flex-direction: column; min-width: 0; }
.terms-receipt-grid small {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--t-muted);
}
.terms-receipt-grid span {
  font-size: 0.86rem;
  font-weight: 700;
  word-break: break-word;
}

/* Botão de imprimir/salvar */
.terms-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.terms-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 50px;
  border: 1.5px solid var(--t-accent);
  background: none;
  color: var(--t-accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.terms-btn:hover { background: color-mix(in srgb, var(--t-accent) 10%, transparent); }
.terms-btn svg { width: 15px; height: 15px; }

@media (max-width: 900px) {
  .terms-layout { grid-template-columns: 1fr; }
  .terms-toc {
    position: static;
    max-height: none;
    order: -1;
  }
  .terms-toc ol {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px;
  }
}

@media print {
  .terms-toc, .terms-actions, .sidebar, .topbar, .site-header, .site-footer { display: none !important; }
  .terms-layout { grid-template-columns: 1fr; }
  .terms-page { max-width: none; padding: 0; }
  .terms-section { break-inside: avoid; }
}
