/* SGAU ? Autentica??o. Tokens: site.css + design-system.css */

body.auth-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

[data-theme="dark"] body.auth-body {
  color-scheme: dark;
}

.auth-body ::selection {
  background: var(--brand-mid);
}

/* ??? Shell ??? */

.auth-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.auth-back-link {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  transition: color 0.16s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease);
}

.auth-back-link:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border-3);
  text-decoration: none;
}

.auth-theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  border-radius: var(--r-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.16s var(--ease), background 0.16s var(--ease), border-color 0.16s var(--ease);
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-theme-toggle:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border-3);
}

.auth-theme-toggle .sun-icon,
.auth-theme-toggle .moon-icon {
  display: flex;
}

.auth-theme-toggle svg {
  width: 16px;
  height: 16px;
}

[data-theme="dark"] .auth-theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .auth-theme-toggle .moon-icon {
  display: flex;
}

.auth-theme-toggle .moon-icon {
  display: none;
}

/* ??? Formul?rio ??? */

.auth-form-section {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(72px, 8vw, 96px) clamp(20px, 4vw, 48px) clamp(32px, 5vw, 56px);
  background: var(--bg);
  min-width: 0;
  overflow-y: auto;
}

.auth-form-wrapper {
  width: 100%;
  max-width: 380px;
}

.auth-form-wrapper.auth-form-wide {
  max-width: 520px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  display: block;
}

.auth-brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-1);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.auth-title {
  font-size: clamp(22px, 3.5vw, 26px);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-1);
  margin: 0 0 8px;
  line-height: 1.15;
}

.auth-title strong {
  font-weight: 600;
  color: var(--text-1);
}

.auth-subtitle {
  color: var(--text-2);
  margin: 0 0 28px;
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 42ch;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0;
}

.auth-form.form-stack {
  gap: 4px;
}

.auth-form .form-group {
  margin-bottom: 14px;
  gap: 5px;
}

.auth-form .field-label,
.auth-form .form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 0;
}

.auth-form .form-control,
.auth-form .form-select {
  width: 100%;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 400;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background-color: var(--surface-1);
  color: var(--text-1);
  min-height: 36px;
  height: 36px;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.auth-form .form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236E6E6B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  cursor: pointer;
}

[data-theme="dark"] .auth-form .form-select,
[data-theme="dark"] .auth-form .form-select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238F8F8C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

.auth-form .form-control::placeholder {
  color: var(--text-3);
}

.auth-form .form-control:focus,
.auth-form .form-select:focus {
  border-color: var(--brand);
  background-color: var(--surface-1);
  box-shadow: 0 0 0 3px var(--brand-dim);
  color: var(--text-1);
  outline: none;
}

/* Chrome autofill no dark (evita fundo branco) */
.auth-form .form-control:-webkit-autofill,
.auth-form .form-control:-webkit-autofill:hover,
.auth-form .form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-1);
  caret-color: var(--text-1);
  box-shadow: 0 0 0 1000px var(--surface-1) inset;
  transition: background-color 99999s ease-in-out 0s;
}

.auth-form .form-control.is-invalid,
.auth-form .form-select.is-invalid {
  border-color: var(--red);
}

.auth-alert {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--red-mid);
  background: var(--red-dim);
  color: var(--red);
  font-size: 12px;
  line-height: 1.45;
}

.auth-alert.validation-summary-valid {
  display: none !important;
}

.auth-alert.validation-summary-errors,
.auth-alert.auth-alert-danger {
  display: block;
  border-color: var(--red-mid);
  background: var(--red-dim);
  color: var(--red);
}

.auth-alert.auth-alert-success {
  display: block;
  border-color: var(--green-mid);
  background: var(--green-dim);
  color: var(--green);
}

.auth-alert.auth-alert-info {
  display: block;
  border-color: var(--blue-mid);
  background: var(--blue-dim);
  color: var(--blue);
}

.auth-alert:not(:empty):not(.validation-summary-valid) {
  display: block;
}

.auth-alert ul {
  margin: 0;
  padding-left: 1.1rem;
}

.auth-alert li {
  margin: 0 0 2px;
}

.auth-form .field-hint {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.4;
}

.auth-form .api-message.alert {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  line-height: 1.45;
}

.auth-form .api-message.alert-danger {
  border: 1px solid var(--red-mid);
  background: var(--red-dim);
  color: var(--red);
}

.auth-form .api-message.alert-success {
  border: 1px solid var(--green-mid);
  background: var(--green-dim);
  color: var(--green);
}

.auth-form .api-message.alert-info {
  border: 1px solid var(--blue-mid);
  background: var(--blue-dim);
  color: var(--blue);
}

.auth-dev-link {
  margin: -8px 0 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.auth-dev-link a {
  color: var(--text-1);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Wizard (um bloco por vez, sem scroll longo) */
.auth-progress {
  margin: 0 0 22px;
}

.auth-progress-track {
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--border-1);
  overflow: hidden;
  margin-bottom: 8px;
}

.auth-progress-fill {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
  transition: width 0.28s var(--ease-out);
}

.auth-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--text-3);
}

.auth-progress-meta #authProgressHint {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 9px;
}

.auth-step.is-hidden,
.auth-subtitle-step.is-hidden,
.is-hidden {
  display: none !important;
}

.auth-step-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.auth-step-actions .auth-btn,
.auth-step-actions #authStepNext,
.auth-step-actions #registerSubmit {
  flex: 1;
}

.auth-btn-back {
  flex: 0 0 auto;
  min-width: 96px;
}

.field-optional {
  color: var(--text-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.auth-subtitle-step {
  margin-bottom: 20px;
}

/* Se??es do registro (legado) */
.auth-section {
  margin-bottom: 8px;
}

.auth-section-title {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 8px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border-1);
}

.auth-section:first-of-type .auth-section-title {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Grids do formul?rio (independentes do breakpoint Bootstrap) */
.auth-grid-2,
.auth-grid-3,
.auth-grid-address {
  display: grid;
  gap: 0 12px;
  margin-bottom: 0;
}

.auth-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.auth-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.auth-grid-address {
  grid-template-columns: minmax(100px, 0.9fr) minmax(0, 2fr) minmax(72px, 0.55fr);
}

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.auth-btn {
  width: 100%;
  margin-top: 4px;
  justify-content: center;
  min-height: 40px;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-row .auth-checkbox {
  margin-bottom: 0;
}

.auth-checkbox .form-check-input {
  margin: 0;
  flex-shrink: 0;
}

.auth-checkbox .form-check-label {
  font-size: 12px;
  color: var(--text-2);
  margin: 0;
  cursor: pointer;
}

.auth-form a,
.auth-row a {
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.16s var(--ease);
}

.auth-form a:hover,
.auth-row a:hover {
  color: var(--text-1);
}

.auth-links {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-1);
  text-align: center;
}

.auth-links p {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-3);
}

.auth-links a {
  color: var(--text-1);
  font-weight: 500;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-links a:hover {
  color: var(--text-1);
}

.auth-security {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.auth-security i {
  margin-right: 4px;
  opacity: 0.85;
}

.auth-form .text-danger {
  color: var(--red) !important;
  font-size: 10.5px;
  margin-top: 2px;
}

/* ??? Banner lateral ??? */

.auth-banner-section {
  position: relative;
  flex: 0 0 min(42vw, 460px);
  max-width: 460px;
  overflow: hidden;
  border-left: 1px solid var(--border-1);
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 4vw, 48px);
}

.auth-banner-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 80% 20%, var(--brand-dim), transparent 60%),
    radial-gradient(ellipse 50% 40% at 20% 80%, var(--blue-dim), transparent 55%);
  pointer-events: none;
}

.auth-banner-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-1) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-1) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 78% 68% at 72% 34%, #000 12%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 78% 68% at 72% 34%, #000 12%, transparent 76%);
  opacity: 0.55;
  pointer-events: none;
}

.auth-banner-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 320px;
}

.auth-banner-eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.auth-banner-title {
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 600;
  letter-spacing: -0.028em;
  margin: 0 0 10px;
  color: var(--text-1);
  line-height: 1.25;
}

.auth-banner-title strong {
  font-weight: 600;
  color: var(--text-1);
}

.auth-banner-description {
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 24px;
  color: var(--text-2);
}

.auth-banner-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-banner-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.auth-banner-feature > i {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-dim);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-size: 12px;
}

.auth-banner-feature-title {
  font-size: 12.5px;
  font-weight: 500;
  margin: 0;
  color: var(--text-1);
  line-height: 1.3;
}

.auth-banner-feature-desc {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.45;
}

/* ??? Responsivo ??? */

@media (max-width: 1024px) {
  .auth-banner-section {
    flex-basis: min(40vw, 400px);
    max-width: 400px;
  }

  .auth-form-wrapper.auth-form-wide {
    max-width: 460px;
  }
}

@media (max-width: 900px) {
  .auth-container {
    flex-direction: column;
  }

  .auth-form-section {
    flex: 1 1 auto;
    align-items: flex-start;
    padding: 72px 20px 28px;
  }

  .auth-form-wrapper,
  .auth-form-wrapper.auth-form-wide {
    max-width: 480px;
    margin: 0 auto;
  }

  /* Banner vira faixa inferior compacta ? n?o some no mobile */
  .auth-banner-section {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-1);
    align-items: stretch;
    justify-content: flex-start;
    padding: 24px 20px 28px;
  }

  .auth-banner-content {
    max-width: 480px;
    margin: 0 auto;
  }

  .auth-banner-description {
    margin-bottom: 16px;
  }

  .auth-banner-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .auth-banner-feature > i {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
}

@media (max-width: 640px) {
  .auth-grid-2,
  .auth-grid-3,
  .auth-grid-address {
    grid-template-columns: 1fr;
  }

  .auth-banner-features {
    grid-template-columns: 1fr;
  }

  .auth-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-form .form-control,
  .auth-form .form-select {
    min-height: 40px;
    height: 40px;
    font-size: 16px; /* evita zoom autom?tico no iOS */
  }

  .auth-btn {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .auth-back-link {
    top: 0.85rem;
    left: 0.85rem;
  }

  .auth-theme-toggle {
    top: 0.85rem;
    right: 0.85rem;
  }

  .auth-form-section {
    padding: 64px 16px 24px;
  }

  .auth-banner-section {
    padding: 20px 16px 24px;
  }

  .auth-brand {
    margin-bottom: 22px;
  }

  .auth-subtitle {
    margin-bottom: 22px;
  }

  .auth-security {
    gap: 12px;
    flex-direction: column;
    align-items: center;
  }
}

@media (max-height: 700px) and (min-width: 901px) {
  .auth-form-section {
    align-items: flex-start;
    padding-top: 72px;
    padding-bottom: 32px;
  }

  .auth-banner-section {
    align-items: flex-start;
    padding-top: 72px;
  }
}

/* --- Layout solo (confirma??o, acesso negado, etc.) --- */

.auth-container.auth-solo {
  justify-content: center;
}

.auth-container.auth-solo .auth-form-section {
  flex: 0 1 420px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.auth-status-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 16px;
  margin-bottom: 18px;
}

.auth-status-icon.is-success {
  background: var(--green-dim);
  border-color: var(--green-mid);
  color: var(--green);
}

.auth-status-icon.is-danger {
  background: var(--red-dim);
  border-color: var(--red-mid);
  color: var(--red);
}

.auth-status-icon.is-warning {
  background: var(--amber-dim);
  border-color: var(--amber-mid);
  color: var(--amber);
}

.auth-status-icon.is-info {
  background: var(--blue-dim);
  border-color: var(--blue-mid);
  color: var(--blue);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.auth-actions .btn {
  width: 100%;
  justify-content: center;
}
