/* forms.css — componentes de formulário (SmartBox).
   Cobre TODOS os controles do guideline: inputs (text/número/url/tel/date),
   textarea, select nativo dark, checkbox/radio custom e switch. */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.field .error { font-size: 12px; color: var(--danger); display: flex; align-items: center; gap: 5px; }
.field .error svg { width: 14px; height: 14px; flex-shrink: 0; }
.req { color: var(--danger); }

/* Inputs e textarea: mesmo visual base para todos os tipos */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
textarea {
  width: 100%; font: inherit; color: var(--text-primary);
  background: var(--bg-surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); height: var(--control-h); padding: 0 12px; line-height: normal; box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 90px; height: auto; padding: 10px 12px; line-height: inherit; box-sizing: border-box; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
input:disabled, textarea:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Number: esconde spinners p/ consistência visual no dark */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Select nativo: mesmo visual dos inputs + chevron custom + popup dark */
select {
  width: 100%; font: inherit; color: var(--text-primary);
  background: var(--bg-surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C8FAB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); height: var(--control-h); padding: 0 36px 0 12px; line-height: normal; box-sizing: border-box;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer; color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select option {
  color: var(--text-primary);
  background: var(--bg-surface-2);
}

/* Input-wrap: ícone à esquerda / toggle à direita (senha, busca) */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap.with-icon input { padding-left: 38px; }
.input-wrap.with-toggle input { padding-right: 44px; }
.input-wrap > svg.lead { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.input-wrap .toggle-pw {
  position: absolute; right: 6px; width: 32px; height: 32px; display: grid; place-items: center;
  border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer;
}
.input-wrap .toggle-pw:hover { color: var(--text-primary); background: var(--bg-surface-3); }
.input-wrap .toggle-pw svg { width: 17px; height: 17px; }

/* Estados invalid/valid (no wrapper e direto no controle) */
.input-wrap.is-invalid input { border-color: var(--danger); }
.input-wrap.is-invalid input:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.input-wrap.is-valid input { border-color: var(--success); }
.input-wrap.is-valid input:focus { box-shadow: 0 0 0 3px var(--success-soft); }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); }
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
input.is-valid, select.is-valid, textarea.is-valid { border-color: var(--success); }
input.is-valid:focus, select.is-valid:focus, textarea.is-valid:focus { box-shadow: 0 0 0 3px var(--success-soft); }

/* Autofill: mantém o tema escuro quando o navegador preenche */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-surface-2) inset;
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
  transition: background-color 9999s ease-in-out 0s;
}

/* Checkbox custom (.check) — lista de opções em grade */
.check-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
label.check {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-primary); font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
label.check:hover { border-color: var(--border-strong); background: var(--bg-surface-2); }
label.check input { position: absolute; opacity: 0; pointer-events: none; }
label.check .box {
  width: 18px; height: 18px; flex-shrink: 0; display: grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: 5px; background: var(--bg-surface-2);
  transition: background 0.15s, border-color 0.15s;
}
label.check .box::after {
  content: ''; width: 10px; height: 6px; margin-top: -2px;
  border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg); opacity: 0; transition: opacity 0.15s;
}
label.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
label.check input:checked + .box::after { opacity: 1; }
label.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Radio custom (.radio) */
label.radio { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-primary); font-size: 14px; }
label.radio input { position: absolute; opacity: 0; pointer-events: none; }
label.radio .box {
  width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-surface-2);
  display: grid; place-items: center; transition: border-color 0.15s;
}
label.radio .box::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); transform: scale(0); transition: transform 0.15s;
}
label.radio input:checked + .box { border-color: var(--accent); }
label.radio input:checked + .box::after { transform: scale(1); }

/* Switch (.switch) — track 42x24 */
label.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-primary); font-size: 14px; }
label.switch input { position: absolute; opacity: 0; pointer-events: none; }
label.switch .track {
  width: 42px; height: 24px; flex-shrink: 0; border-radius: 999px;
  background: var(--bg-surface-3); border: 1px solid var(--border-strong);
  position: relative; transition: background 0.15s, border-color 0.15s;
}
label.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-secondary);
  transition: transform 0.15s, background 0.15s;
}
label.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
label.switch input:checked + .track::after { transform: translateX(18px); background: var(--on-accent); }
label.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
