/* ===========================================================================
   Conversor — componentes fiéis ao Claude Design (screen_conversor.jsx + lib.jsx)
   Aplicado por cima do markup; preserva todos os ids/names/hooks do JS.
   Tokens herdados do app.css (--primary #9C0F24, Space Grotesk, etc.).
   =========================================================================== */

/* CRÍTICO: garante que o atributo [hidden] esconda de verdade, mesmo quando o
   elemento tem uma classe com display:flex/grid (ex.: .cv-flash, .cv-summary-strip,
   .quick-card-fields). Sem isso, alertas e resumos aparecem na hora errada
   (ex.: "Acesso bloqueado" para quem tem assinatura). */
[hidden] { display: none !important; }

/* ---- Stepper (círculos conectados por linha) ---- */
.cv-stepper { display: flex; align-items: center; gap: 0; width: 100%; }
.cv-stepper .cv-step { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.cv-stepper .cv-step-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: #fff; color: var(--ap-ink4, #bbb); border: 1.5px solid #e2e2e2;
}
.cv-stepper .cv-step.is-current .cv-step-dot { background: var(--primary); color: #fff; border: none; }
.cv-stepper .cv-step.is-done .cv-step-dot { background: rgba(156,15,36,0.12); color: var(--primary); border: none; }
.cv-stepper .cv-step-label { font-size: 13px; font-weight: 500; color: var(--ap-ink4, #bbb); white-space: nowrap; }
.cv-stepper .cv-step.is-current .cv-step-label { font-weight: 700; color: var(--text, #111); }
.cv-stepper .cv-step.is-done .cv-step-label { color: var(--ap-ink2, #555); }
.cv-stepper .cv-step-line { flex: 1; height: 1.5px; margin: 0 14px; background: #e8e8e8; min-width: 16px; }
.cv-stepper .cv-step.is-done + .cv-step-line { background: rgba(156,15,36,0.3); }

/* ---- Card + CardHead (barra-accent maroon à esquerda) ---- */
.cv-card { background: #fff; border: 1px solid var(--line, rgba(0,0,0,0.06)); border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); overflow: hidden; }
.cv-card-head { padding: 16px 22px; border-bottom: 1px solid var(--ap-line2, #f3f3f3); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cv-card-head .cv-card-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cv-card-head .cv-card-title::before { content: ""; width: 4px; height: 20px; background: var(--primary); border-radius: 2px; flex-shrink: 0; }
.cv-card-head h2, .cv-card-head h3 { font-size: 15px; font-weight: 700; color: var(--text, #111); letter-spacing: -0.2px; margin: 0; }
.cv-card-head .cv-card-sub { font-size: 12.5px; color: var(--ap-ink4, #bbb); font-weight: 500; }
.cv-card-body { padding: 20px 22px; }

/* ---- Dropzone ---- */
.cv-dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px dashed #dcdcdc; border-radius: 13px;
  padding: 30px 20px; text-align: center; background: #fafafa; transition: all .15s; cursor: pointer;
}
.cv-dropzone:hover, .cv-dropzone.is-drag { border-color: var(--primary); background: rgba(156,15,36,0.04); }
/* input vira overlay transparente e clicável (sem mostrar o texto nativo "Nenhum arquivo...") */
.cv-dropzone input[type="file"] {
  position: absolute !important; inset: 0; width: 100%; height: 100%;
  opacity: 0 !important; cursor: pointer;
  padding: 0 !important; margin: 0 !important; border: none !important; background: transparent !important;
  font-size: 0 !important; color: transparent !important;
}
.cv-dropzone-icon {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 0 12px;
  background: rgba(156,15,36,0.09); color: var(--primary); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.cv-dropzone-title { display: block; font-size: 14.5px; font-weight: 600; color: var(--text, #111); }
.cv-dropzone-hint { display: block; font-size: 12.5px; color: var(--ap-ink3, #999); margin-top: 4px; }
.cv-dropzone-hint .cv-accent { color: var(--primary); font-weight: 600; }

/* ---- Lista de arquivos (preview rows) ---- */
.cv-files-label { font-size: 11.5px; font-weight: 700; color: var(--ap-ink3, #999); text-transform: uppercase; letter-spacing: 0.6px; margin: 18px 0 8px; }
.cv-file-list { border: 1px solid #eee; border-radius: 11px; overflow: hidden; list-style: none; padding: 0; margin: 0; }
.cv-file-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: #fff; border-bottom: 1px solid #f3f3f3; transition: background .12s; }
.cv-file-row:last-child { border-bottom: none; }
.cv-file-row:hover { background: #fafafa; }
.cv-file-icon { width: 38px; height: 38px; border-radius: 9px; background: #f5f3f1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--ap-ink3, #999); }
.cv-file-main { flex: 1; min-width: 0; }
.cv-file-name { display: flex; align-items: center; gap: 8px; }
.cv-file-name strong { font-size: 13.5px; font-weight: 600; color: var(--text, #111); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-file-meta { display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap; font-size: 11.5px; color: var(--ap-ink3, #999); }
.cv-file-meta strong { color: var(--ap-ink2, #555); font-weight: 600; }
.cv-file-meta .cv-warn { color: var(--ap-amber, #d97706); }
.cv-type-tag { padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }
.cv-type-tag.csv { background: rgba(22,163,74,0.1); color: var(--ap-green, #16a34a); }
.cv-type-tag.pdf { background: rgba(220,38,38,0.1); color: var(--ap-red, #dc2626); }
.cv-type-tag.xlt, .cv-type-tag.civ { background: rgba(37,99,235,0.1); color: var(--ap-blue, #2563eb); }
.cv-type-tag.other { background: rgba(0,0,0,0.06); color: #666; }
/* li simples gerado pelo JS (upload: arquivos selecionados) */
.cv-file-list li { display: block; padding: 10px 14px; border-bottom: 1px solid #f3f3f3; font-size: 13px; color: var(--ap-ink2, #555); }
.cv-file-list li:last-child { border-bottom: none; }
.cv-file-list li strong { color: var(--text, #111); }
/* botão desbloquear (CTA primário pequeno) */
.cv-unlock-btn { background: var(--primary) !important; color: #fff !important; border: none !important; border-radius: 9px !important; padding: 7px 16px !important; font-size: 12.5px !important; box-shadow: 0 2px 10px rgba(156,15,36,0.3); cursor: pointer; font-family: var(--ap-font); font-weight: 600; }

/* ---- Chips (checkboxes de filtro) ---- */
.cv-chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cv-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
  border: 1.5px solid #e6e6e6; border-radius: 9px; padding: 9px 12px; transition: border-color .15s, background .15s;
}
.cv-chip:hover { border-color: rgba(156,15,36,0.3); }
.cv-chip:has(input:checked) { border-color: var(--primary); background: rgba(156,15,36,0.05); }
.cv-chip input { accent-color: var(--primary); flex-shrink: 0; }
.cv-chip .cv-chip-label { font-size: 13px; font-weight: 500; color: var(--text, #111); }
.cv-chip .cv-chip-label small { color: var(--ap-ink3, #999); font-weight: 500; }

/* ---- Select-all bar ---- */
.cv-selectall { display: flex; align-items: center; gap: 6px; }
.cv-selectall button { background: none !important; border: none !important; box-shadow: none !important; cursor: pointer; font-family: var(--ap-font); font-weight: 600; font-size: 11.5px; padding: 0 !important; }
.cv-selectall .cv-link-all { color: var(--primary) !important; }
.cv-selectall .cv-link-clear { color: var(--ap-ink3, #999) !important; }
.cv-selectall .cv-sep { color: #ddd; }

/* ---- Radio-cards (formato de saída, modo de cálculo) ---- */
.cv-radio-cards { display: grid; gap: 8px; }
.cv-radio-cards.cols-2 { grid-template-columns: 1fr 1fr; }
.cv-radio-card {
  display: block; cursor: pointer; background: #fff; border: 1.5px solid #e6e6e6; border-radius: 10px;
  padding: 12px 14px; transition: border-color .15s, background .15s;
}
.cv-radio-card:hover { border-color: rgba(156,15,36,0.3); }
.cv-radio-card:has(input:checked) { border-color: var(--primary); background: rgba(156,15,36,0.05); }
.cv-radio-card-top { display: flex; align-items: center; gap: 9px; }
.cv-radio-card input { accent-color: var(--primary); flex-shrink: 0; }
.cv-radio-card .cv-radio-title { font-size: 13.5px; font-weight: 600; color: var(--text, #111); }
.cv-radio-card .cv-radio-sub { font-size: 11.5px; color: var(--ap-ink3, #999); margin-top: 4px; padding-left: 25px; }

/* ---- Collapse (seções de filtro recolhíveis — <details> nativo) ---- */
.cv-collapse { border: 1px solid #ededed; border-radius: 11px; overflow: hidden; background: #fff; }
.cv-collapse-head { padding: 13px 16px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--ap-font); list-style: none; }
.cv-collapse-head::-webkit-details-marker { display: none; }
.cv-collapse[open] > .cv-collapse-head { background: #fafafa; }
.cv-collapse-title { display: flex; align-items: center; gap: 9px; }
.cv-collapse-title .cv-caret { transition: transform .2s; color: var(--ap-ink3, #999); display: inline-flex; }
.cv-collapse[open] > .cv-collapse-head .cv-caret { transform: rotate(90deg); }
.cv-collapse-title > span:not(.cv-caret):not(.cv-count) { font-size: 13.5px; font-weight: 600; color: var(--text, #111); }
.cv-count { padding: 3px 9px; border-radius: 5px; font-size: 10.5px; font-weight: 700; background: rgba(156,15,36,0.1); color: var(--primary); }
.cv-count.zero { background: rgba(0,0,0,0.05); color: #888; }
.cv-collapse-body { padding: 14px 16px; border-top: 1px solid #f0f0f0; }

/* ---- Stat (resumo) ---- */
.cv-stat { display: inline-flex; flex-direction: column; }
.cv-stat-k { font-size: 10.5px; color: var(--ap-ink4, #bbb); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.cv-stat-v { font-size: 14px; font-weight: 700; color: var(--text, #111); }
.cv-summary-strip { background: #fafafa; border: 1px solid #eee; border-radius: 11px; padding: 12px 16px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }

/* ---- Página do conversor ---- */
.cv-stack { max-width: 920px; margin: 0 auto; padding: 0 4px 60px; display: flex; flex-direction: column; gap: 16px; background: transparent; border: none; box-shadow: none; }
.cv-page { max-width: 920px; margin: 0 auto; padding: 24px 20px 80px; display: flex; flex-direction: column; gap: 16px; }
/* flash de acesso bloqueado (estilo do design) */
.cv-flash { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 11px; background: rgba(217,119,6,0.09); border: 1px solid rgba(217,119,6,0.2); }
.cv-flash-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--ap-amber, #d97706); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cv-flash-body { flex: 1; }
.cv-flash-title { font-size: 13.5px; font-weight: 700; color: var(--ap-amber, #d97706); }
.cv-flash-text { font-size: 12.5px; color: var(--ap-ink2, #555); margin-top: 2px; line-height: 1.45; }
.cv-actions-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.cv-grid-2 { display: grid; grid-template-columns: 1.9fr 1fr; gap: 16px; align-items: start; }
.cv-page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.cv-page-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin: 0; color: var(--text, #111); }
@media (max-width: 820px) { .cv-grid-2 { grid-template-columns: 1fr; } }

/* ---- Conta: seções <section class="card"><h2> ganham o card-head do design ----
   (barra-accent maroon + borda; preserva todos os forms/ids dentro). */
.page-shell-account section.card { padding: 0 !important; overflow: hidden; }
.page-shell-account section.card > h2:first-child {
  display: flex; align-items: center; gap: 11px;
  font-size: 15px; font-weight: 700; color: var(--text, #111); margin: 0 !important;
  padding: 16px 22px; border-bottom: 1px solid var(--ap-line2, #f3f3f3); letter-spacing: -0.2px;
}
.page-shell-account section.card > h2:first-child::before {
  content: ""; width: 4px; height: 20px; background: var(--primary); border-radius: 2px; flex-shrink: 0;
}
.page-shell-account section.card > *:not(h2:first-child) { padding-left: 22px; padding-right: 22px; }
.page-shell-account section.card > h2:first-child { padding-left: 22px; padding-right: 22px; }
.page-shell-account section.card { padding-bottom: 18px !important; }
.page-shell-account section.card > .stats { margin-top: 16px; }
/* steppers do design na conta */
.page-shell-account .flow-step { border-radius: 12px !important; }
.cv-field-label { font-size: 12px; font-weight: 600; color: var(--ap-ink2, #555); margin-bottom: 6px; display: block; }
.cv-hint { font-size: 11.5px; color: var(--ap-ink3, #999); margin-top: 5px; }

@media (max-width: 640px) {
  .cv-radio-cards.cols-2 { grid-template-columns: 1fr; }
}
