/* app-extras.css — complementos do design system para estados do app
   (spinner, alerts, upload zone, modais, tabelas). Carregar APÓS pages.css. */

/* ---------- SVG icon sizing (Safari iOS bulletproof) ----------
   Garante que SVGs inline dentro de botões/chips/links nunca explodam
   quando o <svg> outer não tem viewBox. Safari iOS, sem isso, renderiza
   no tamanho intrínseco do <symbol> (24x24) ou maior, ignorando width/height. */
.btn svg, .btn-ghost svg, .btn-text svg,
.trust-chip svg, .hero-pill svg,
.bullet-list .bi svg, .sb-item svg,
.alert svg, .pill svg, .status-badge svg,
.testi .stars svg, .badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.btn svg, .btn-ghost svg { width: 14px; height: 14px; }
.sb-item svg { width: 16px; height: 16px; }
.alert svg, .pill svg, .status-badge svg { width: 14px; height: 14px; }

/* Fallback ainda mais forte: qualquer SVG inline sem viewBox próprio E sem width definido */
svg:not([viewBox]):not([width]) { max-width: 24px; max-height: 24px; }

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loader-full {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 40px;
  gap: 16px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 14px 18px;
  border-radius: 12px;
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

.alert.alert-success {
  background: var(--ok-soft);
  border: 1px solid color-mix(in oklch, var(--ok) 30%, transparent);
  color: var(--ok);
}
.alert.alert-info {
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklch, var(--accent) 30%, transparent);
  color: var(--accent);
}
.alert.alert-warning {
  background: rgba(210,106,106,0.10);
  border: 1px solid color-mix(in oklch, var(--danger) 35%, transparent);
  color: var(--danger);
}
.alert.alert-warning strong { color: var(--ink); }

.hidden { display: none !important; }

/* ---------- Upload zone (dropzone) ---------- */
.upload-zone {
  border: 1.5px dashed var(--rule);
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--surface-3); }
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone input[type="file"] { display: none; }
.upload-zone .upload-icon {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
}
.upload-zone .upload-icon svg { width: 22px; height: 22px; }
.upload-zone h4 {
  font-family: var(--serif); font-size: 18px; color: var(--ink);
  font-weight: 400; margin-bottom: 6px;
}
.upload-zone p { font-size: 13px; color: var(--ink-muted); }

/* Preview de arquivo escolhido */
.file-preview {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 12px;
  display: flex; align-items: center; gap: 14px;
}
.file-preview .ic {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  color: var(--accent);
}
.file-preview .ic svg { width: 18px; height: 18px; }
.file-preview .info { flex: 1; line-height: 1.3; }
.file-preview .info b { display: block; color: var(--ink); font-size: 14px; font-weight: 500; }
.file-preview .info small { color: var(--ink-muted); font-size: 12px; font-family: var(--mono); }
.file-preview .x {
  background: none; border: none;
  color: var(--ink-muted); cursor: pointer;
  padding: 4px; line-height: 1;
}
.file-preview .x:hover { color: var(--danger); }

/* ---------- Tabela ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
}
.tbl th.num, .tbl td.num { text-align: right; font-family: var(--mono); }
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl tfoot td {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface-2);
  border-top: 1px solid var(--rule);
  font-weight: 500;
}
.tbl tfoot td.lbl {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.tbl .bad { color: var(--danger); }
.tbl .gold { color: var(--accent); }

/* ---------- Modal genérico ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.72);
  backdrop-filter: blur(8px);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 32px;
  max-width: 440px; width: 100%;
  box-shadow: var(--shadow);
}
.modal-card h3 {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: 400;
}
.modal-card .sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 22px;
}
.modal-actions {
  display: flex; gap: 10px; margin-top: 18px;
}
.modal-actions .btn, .modal-actions .btn-ghost { flex: 1; justify-content: center; }

/* ---------- Status pill compact ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid var(--rule);
  color: var(--ink-muted);
  font-family: var(--sans);
  font-weight: 500;
}
.status-badge.status-ok { background: var(--ok-soft); border-color: color-mix(in oklch, var(--ok) 30%, transparent); color: var(--ok); }
.status-badge.status-warn { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 30%, transparent); color: var(--accent); }
.status-badge.status-err { background: rgba(210,106,106,0.10); border-color: color-mix(in oklch, var(--danger) 30%, transparent); color: var(--danger); }
.status-badge.status-pending { background: var(--surface-2); }

/* ---------- Progress bar ---------- */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width .4s ease;
}

/* ---------- Form helpers (reuso de classes legadas em forms novos) ---------- */
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.form-error.show, .field-error-show .form-error { display: block; }
.input.error { border-color: var(--danger) !important; }

/* ---------- Hamburger menu (mobile) ---------- */
.hamburger {
  display: none;
  width: 28px; height: 22px;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  background: none; border: none; padding: 0;
}
.hamburger span {
  display: block; width: 100%; height: 1.5px;
  background: var(--ink);
  transition: transform .25s, opacity .25s;
}
.hamburger.active span:nth-child(1) { transform: translateY(10px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }

.mobile-menu {
  display: none;
  position: fixed; top: 72px; left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  padding: 20px var(--gutter);
  z-index: 49;
}
.mobile-menu ul { list-style: none; display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.mobile-menu a { color: var(--ink-soft); font-size: 15px; }
.mobile-menu .mobile-actions { display: flex; gap: 10px; }
/* Garante contraste correto dos botões dentro do menu mobile:
   - .btn (dourado): texto escuro var(--accent-ink) #160F03
   - .btn-ghost (transparente): texto branco --ink
   A regra .mobile-menu a (color: ink-soft) ganhava por especificidade. */
.mobile-menu .mobile-actions a.btn { color: var(--accent-ink); }
.mobile-menu .mobile-actions a.btn-ghost { color: var(--ink); }

@media (max-width: 960px) {
  .hamburger { display: flex; }
  .nav-cta > .btn, .nav-cta > .btn-text { display: none; }
  .mobile-menu.open { display: block; }
}

/* Em desktop, nunca mostra o menu mobile mesmo se .open for adicionada por engano */
@media (min-width: 961px) {
  .mobile-menu { display: none !important; }
}

/* ---------- Mobile drawer (sidebar do painel em telas pequenas) ----------
   Substitui o comportamento "chips horizontais" que vinha de pages.css por
   um drawer lateral clássico (hamburger → desliza pela esquerda). */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.mt-burger {
  width: 28px; height: 22px; padding: 0;
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
}
.mt-burger span {
  display: block; width: 100%; height: 1.5px;
  background: var(--ink);
  transition: transform .25s, opacity .25s;
}
.mt-burger.active span:nth-child(1) { transform: translateY(10px) rotate(45deg); }
.mt-burger.active span:nth-child(2) { opacity: 0; }
.mt-burger.active span:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }
.mt-brand {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.mt-brand em { color: var(--accent); font-style: italic; }

@media (max-width: 960px) {
  .mobile-topbar {
    display: flex;
    align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 99;
    background: var(--surface-2);
    border-bottom: 1px solid var(--rule);
    padding: 14px 20px;
    height: 56px;
    box-sizing: border-box;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  /* Override do pages.css: em vez de chips horizontais, drawer lateral */
  .app-shell > .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(82vw, 320px);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 22px;
    padding: 28px 20px;
    overflow-y: auto;
  }
  .app-shell > .sidebar.open { transform: translateX(0); }
  .app-shell > .sidebar .sb-group { flex-direction: column; gap: 2px; flex-wrap: nowrap; }
  .app-shell > .sidebar .sb-label { display: block; }
  .app-shell > .sidebar .sb-foot { display: flex; }
}

/* ---------- Justificação de blocos de texto longo ----------
   Aplica text-align: justify em parágrafos de cards, respostas de FAQ,
   depoimentos e labels de result-cards. hyphens: auto evita "rios" de
   espaço grande entre palavras. */
.card p,
.result-card .lbl,
.testi blockquote,
.why-aside p,
.security-note p,
.faq-a-inner,
.action-card p,
.section-head p {
  text-align: justify;
  hyphens: auto;
}

/* ---------- Util ---------- */
.text-soft { color: var(--ink-soft); }
.text-muted { color: var(--ink-muted); }
.text-gold { color: var(--accent); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.fw-100 { width: 100%; }
