/* Docraft — componentes base (usam apenas os tokens de tokens.css) */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--body-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  line-height: 1.2;
  margin: 0 0 calc(var(--space) * 1.5);
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 calc(var(--space) * 2); }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--code-bg); border: var(--border-width) solid var(--border); border-radius: var(--radius-sm); padding: .1em .35em; }
pre { background: var(--code-bg); border: var(--border-width) solid var(--border); border-radius: var(--radius); padding: calc(var(--space) * 2); overflow-x: auto; margin: 0 0 calc(var(--space) * 2); }
pre code { background: none; border: 0; padding: 0; }
.muted { color: var(--text-muted); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1;
  padding: 11px 18px; border-radius: var(--btn-radius);
  border: var(--border-width) solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: var(--surface); }
.btn-danger:hover { filter: brightness(.92); color: var(--surface); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-icon { padding: 7px; color: var(--text-muted); }
.btn-icon:hover { color: var(--text); }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Formulários */
.field { display: grid; gap: 6px; margin-bottom: calc(var(--space) * 2); }
.label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .82rem; color: var(--text-muted); }
.input, .select {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
  border: var(--border-width) solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.is-invalid { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input { accent-color: var(--primary); width: 18px; height: 18px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .95rem; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* Badges de status */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--surface-2);    color: var(--text-muted); }

/* Alertas / callouts */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: var(--border-width) solid; font-size: .95rem; margin-bottom: calc(var(--space) * 2); }
.alert strong { display: block; margin-bottom: 2px; }
.alert-info    { background: var(--info-soft);    border-color: color-mix(in srgb, var(--info) 30%, transparent);    }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-danger  { background: var(--danger-soft);  border-color: color-mix(in srgb, var(--danger) 30%, transparent);  }
.alert .icon { flex: none; width: 20px; height: 20px; }
.alert-info .icon { color: var(--info); } .alert-success .icon { color: var(--success); }
.alert-warning .icon { color: var(--warning); } .alert-danger .icon { color: var(--danger); }

/* Cartões e tabela */
.card { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); padding: var(--card-padding); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--text-muted); background: var(--surface-2); padding: 10px 16px; white-space: nowrap; }
.table td { padding: 12px 16px; border-top: var(--border-width) solid var(--border); white-space: nowrap; }
.table .mono { font-family: var(--font-mono); font-size: .85rem; }

/* Código em destaque (ex.: .docraft.yml) */
.code-card { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.code-card-title {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-family: var(--font-mono); font-size: .82rem;
  color: var(--text-muted); background: var(--surface-2); border-bottom: var(--border-width) solid var(--border);
}
.code-card pre { margin: 0; border: 0; border-radius: 0; background: var(--code-bg); font-size: .95rem; line-height: 1.8; }
.tok-key { color: var(--primary); }
.tok-comment { color: var(--text-muted); }

/* Botão com aparência de texto (abre um detalhe, como o modal da branch) */
.link-button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }
.link-button code { text-decoration: underline dotted; text-underline-offset: 3px; }
.link-button:hover { color: var(--primary); }
.link-button:focus-visible { outline: none; box-shadow: var(--focus); }

/* Modal (<dialog> aberto com showModal pelo controller Stimulus "dialog") */
.modal {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font-size: 1rem; line-height: 1.5; text-align: left; white-space: normal;
}
.modal::backdrop { background: var(--overlay); }
.modal-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--space) * 1.5); padding: var(--card-padding); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--space) * 1); }
.modal-header h2 { font-size: 1.15rem; margin: 0; }
.modal p { margin: 0; }
.modal-footer { display: flex; justify-content: flex-end; }
.modal-wide { width: min(720px, calc(100vw - 32px)); }
.modal-body-footer { padding-top: 0; justify-items: start; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: calc(var(--space) * 1.5); }
.modal .field { margin: 0; }
.modal-footer { flex-wrap: wrap; gap: calc(var(--space) * 1); }
.code-card-action { margin-left: auto; font-family: var(--font-sans); }
.code-card pre code { white-space: pre; }
.code-card pre { overflow-x: auto; }

/* Cores encontradas no repositório (amostras de dados do cliente, não do tema) */
.swatches { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; list-style: none; font-size: .88rem; color: var(--text-muted); }
.swatches li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 18px; height: 18px; border-radius: var(--radius-sm); border: var(--border-width) solid var(--border); }
