/*
 * Design system compartilhado da suíte. Tokens + componentes base (campo, botão, cartão,
 * aviso). Cada módulo importa este arquivo e acrescenta o mínimo próprio.
 * Claro/escuro automático via prefers-color-scheme. Sem fontes externas: a fonte do sistema
 * carrega instantaneamente e respeita o aparelho.
 */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --space: clamp(1rem, 4vw, 1.5rem);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15181d;
  --muted: #5b6472;
  --border: #d9dde4;
  --brand: #d9480f;
  --brand-hover: #c2410c;
  --brand-ink: #ffffff;
  --focus: #1c7ed6;
  --ok: #2b8a3e;
  --ok-bg: #ebfbee;
  --danger: #c92a2a;
  --danger-bg: #fff5f5;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a1f;
    --surface-2: #1f232a;
    --text: #eef1f5;
    --muted: #9aa3b2;
    --border: #2b3038;
    --brand: #f76707;
    --brand-hover: #fd7e14;
    --focus: #4dabf7;
    --ok: #51cf66;
    --ok-bg: #12261a;
    --danger: #ff8787;
    --danger-bg: #2a1416;
    --shadow: none;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(100% - 2 * var(--space), 30rem);
  margin-inline: auto;
  padding-block: var(--space) calc(var(--space) * 2);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

h1,
h2 {
  line-height: 1.2;
  margin: 0 0 0.25rem;
}

/* Campos */
.field {
  display: grid;
  gap: 0.375rem;
  margin-block-end: 1.125rem;
}

.field label,
.label {
  font-weight: 600;
  font-size: 0.95rem;
}

.input {
  width: 100%;
  font: inherit;
  font-size: 1.0625rem; /* >= 16px evita zoom automático no iOS */
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  min-height: 3rem;
  transition: border-color 0.15s;
}

textarea.input {
  min-height: 6rem;
  resize: vertical;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.error-text {
  font-size: 0.875rem;
  color: var(--danger);
  font-weight: 500;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.5rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 1.4rem;
  height: 1.4rem;
  accent-color: var(--brand);
}

/* Botão */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3.25rem;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background 0.15s,
    transform 0.05s;
}

.btn:hover {
  background: var(--brand-hover);
}

.btn:active {
  transform: scale(0.99);
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn-ghost {
  color: var(--text);
  background: var(--surface-2);
}

.btn-ghost:hover {
  background: var(--border);
}

/* Foco visível para teclado e leitores de tela (no fim: precisa vencer os estados acima). */
.input:focus-visible,
.btn:focus-visible,
.check input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Avisos */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  margin-block-end: 1rem;
  font-weight: 500;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}
