/*
 * Design system: telas de acesso (login, cadastro, recuperar e redefinir senha, 2 etapas).
 * Tudo escopado em .ds-auth; só tokens. Mobile-first: cartão centralizado, 1 coluna.
 * Inputs com 16px (iOS não dá zoom) e alvos >= 44px (--target-min).
 */

.ds-auth {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  padding: var(--space-6) var(--page-gutter) var(--space-12);
  overflow-x: clip;
}

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

.ds-auth-card {
  width: 100%;
  min-width: 0;
  max-width: 420px;
  padding: var(--space-6) var(--space-5) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
}

@media (min-width: 480px) {
  .ds-auth { padding-block-start: var(--space-10); }
  .ds-auth-card { padding: var(--space-8); }
}

.ds-auth a:focus-visible,
.ds-auth button:focus-visible,
.ds-auth input:focus-visible,
.ds-auth select:focus-visible,
.ds-auth textarea:focus-visible,
.ds-auth-alert:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* ---------- Cabeçalho do cartão ---------- */

.ds-auth-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 var(--space-4);
}

.ds-auth-logo img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.ds-auth-title {
  margin: 0 0 var(--space-2);
  color: var(--foreground);
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-align: center;
  overflow-wrap: anywhere;
}

.ds-auth-sub {
  margin: 0 0 var(--space-6);
  color: var(--muted-foreground);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- Campos ---------- */

.ds-field {
  margin: 0 0 var(--space-4);
}

.ds-label {
  display: block;
  margin: 0 0 var(--space-2);
  color: var(--foreground);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: var(--leading-tight);
}

.ds-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.ds-label-row .ds-label {
  margin: 0 0 var(--space-2);
}

.ds-input {
  display: block;
  width: 100%;
  min-height: var(--target-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: 16px;               /* >= 16px: o iOS não dá zoom ao focar */
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.ds-input:hover {
  border-color: color-mix(in oklch, var(--foreground) 30%, var(--input));
}

.ds-input:focus {
  border-color: var(--ring);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent);
}

.ds-input:focus-visible {
  outline: none;
}

.ds-input::placeholder {
  color: var(--muted-foreground);
}

.ds-textarea {
  min-height: 96px;
  padding-block: var(--space-3);
}

.ds-select {
  padding-inline-end: var(--space-10);
  background-image: 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='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

[dir="rtl"] .ds-select { background-position: left 12px center; }

.ds-auth .ds-input[aria-invalid="true"] {
  border-color: var(--destructive) !important;   /* vence regras legadas de input (night-mode.css) */
}

.ds-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--destructive) 25%, transparent);
}

/* Senha + botão mostrar/ocultar */
.ds-input-wrap {
  position: relative;
}

.ds-input-wrap .ds-input {
  padding-inline-end: var(--space-12);
}

.ds-reveal {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--target-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

.ds-reveal:hover {
  color: var(--foreground);
}

.ds-reveal svg {
  width: 20px;
  height: 20px;
}

.ds-reveal .ds-reveal-off,
.ds-reveal[aria-pressed="true"] .ds-reveal-on {
  display: none;
}

.ds-reveal[aria-pressed="true"] .ds-reveal-off {
  display: block;
}

.ds-reveal[aria-pressed="true"] {
  color: var(--brand-text);
}

.ds-field-hint {
  margin: var(--space-2) 0 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.ds-field-error {
  margin: 0;
  color: var(--destructive);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-normal);
}

.ds-field-error:not(:empty) {
  margin-block-start: var(--space-2);
}

html.dark .ds-field-error,
html.dark .ds-auth-alert {
  --destructive: #f87171;
}

/* Regras de complexidade da senha (quando habilitadas no painel) */
.ds-auth .helper-text {
  display: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.ds-auth .helper-text li {
  background: transparent !important;
}

.ds-auth .helper-text li.valid {
  color: var(--success);
}

/* ---------- Alertas do servidor ---------- */

.ds-auth-alert {
  display: block;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in oklch, var(--destructive) 40%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in oklch, var(--destructive) 8%, var(--card));
  color: var(--foreground);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
}

.ds-auth-alert:empty {
  display: none;
}

.ds-auth-alert .ds-icon,
.ds-auth-alert svg {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-inline-end: var(--space-2);
  vertical-align: -3px;
  color: var(--destructive);
}

.ds-auth-alert a {
  color: var(--foreground);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ds-auth-alert.is-success {
  border-color: color-mix(in oklch, var(--success) 40%, transparent);
  background: color-mix(in oklch, var(--success) 8%, var(--card));
}

.ds-auth-alert.is-success .ds-icon,
.ds-auth-alert.is-success svg {
  color: var(--success);
}

/* ---------- Checkbox ---------- */

.ds-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--target-min);
  margin: 0 0 var(--space-2);
}

.ds-check input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: var(--space-3) 0 0;               /* label tem 44px de altura mínima: alvo de toque */
  accent-color: var(--primary);
  cursor: pointer;
}

.ds-check label {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-block: 10px;
  color: var(--foreground);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: var(--leading-normal);
  cursor: pointer;
}

.ds-check label a {
  color: var(--brand-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ds-terms .ds-check {
  margin-block-end: 0;
}

.ds-recaptcha:not(:empty) {
  display: flex;
  justify-content: center;
  max-width: 100%;
  margin: 0 0 var(--space-4);
  overflow-x: auto;
}

/* ---------- Botão e links ---------- */

.ds-auth-submit {
  display: inline-flex;
  width: 100%;
  min-height: var(--target-min);
  margin-block-start: var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
}

.ds-link-quiet,
.ds-auth-switch a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--brand-text);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ds-link-quiet {
  font-size: var(--text-sm);
}

.ds-link-quiet:hover,
.ds-auth-switch a:hover {
  color: var(--foreground);
}

.ds-auth-switch {
  margin: var(--space-6) 0 0;
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: var(--text-md);
  text-align: center;
}

/* ---------- Login social (só aparece se habilitado no painel) ---------- */

.ds-auth .login-icons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-block-start: var(--space-4);
}

.ds-auth .login-icons > div {
  margin: 0;
}

.ds-auth .login-icons > div:last-child:nth-child(even) {
  grid-column: 1 / -1;
}

.ds-auth .pt-auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  grid-column: 1 / -1;
  margin: var(--space-2) 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

.ds-auth .pt-auth-divider::before,
.ds-auth .pt-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.ds-auth a.pt-auth-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--target-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
}

.ds-auth a.pt-auth-social:hover {
  background: var(--accent);
}

.ds-auth a.pt-auth-social svg,
.ds-auth a.pt-auth-social img {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.ds-auth #buttonDiv {
  display: flex;
  justify-content: center;
  margin-block-start: var(--space-3);
}

/* Movimento reduzido: sem transições nem giro do spinner além do necessário */
@media (prefers-reduced-motion: reduce) {
  .ds-input { transition: none; }
}

/* Abas Entrar / Criar conta (mesma tela, dois modos) */
.ds-auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-block: var(--space-4);
  border-block-end: 1px solid var(--border);
}

.ds-auth-tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target-min);
  margin-block-end: -1px;
  border-block-end: 2px solid transparent;
  color: var(--muted-foreground);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
}

.ds-auth-tabs a:hover {
  color: var(--foreground);
}

.ds-auth-tabs a[aria-current="page"] {
  border-block-end-color: var(--brand-text);
  color: var(--foreground);
}
