:root {
  --auth-grad-start: var(--color-primary-300, #99A0DA);
  --auth-grad-end: var(--color-primary-600, #2f348e);
  --auth-surface: rgba(255, 255, 255, 0.9);
  --auth-shadow: 0 18px 45px rgba(29, 41, 63, 0.2);
  --auth-border: rgba(255, 255, 255, 0.5);
  --auth-muted: #6b7280;
  --auth-text: #0f172a;
  --auth-focus: rgba(99, 102, 241, 0.35);

  --fab-option-radius: 120px;
  --fab-safe-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  --fab-safe-right: calc(env(safe-area-inset-right, 0px) + 24px);

  /* Variáveis reutilizáveis */
  --radius-lg: 14px;
  --radius-xl: 30px;
  --shadow-soft: 0 12px 26px rgba(72, 83, 191, 0.35);
  --shadow-strong: 0 18px 45px rgba(29, 41, 63, 0.2);
}

body.auth-account header.site-header,
body.auth-account header.navbar,
body.auth-account footer.site-footer {
  display: none !important;
}

.auth-scope {
  min-height: 100vh;
  background: linear-gradient(135deg, #cfd5ff, #bcc4f4);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: clamp(20px, 3vw, 40px);
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.auth-scope,
.auth-scope * {
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

.auth-wrapper {
  width: min(1220px, 100%);
  margin: 0 auto;
  display: flex;
}

.auth-container {
  position: relative;
  width: 100%;
  background: var(--auth-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--auth-border);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  grid-template-areas: "toggle form";
  align-items: stretch;
  gap: 0;
}

.form-box {
  grid-area: form;
  display: none;
  align-items: flex-start;
  justify-content: stretch;
  padding: clamp(28px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.96);
}

/* Login padrão / cadastro quando .active */
.auth-container .form-box.login {
  display: flex;
}
.auth-container.active .form-box.login {
  display: none;
}
.auth-container.active .form-box.register {
  display: flex;
}

.auth-form {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--auth-text);
}

.auth-form--signup {
  gap: 16px;
}

.auth-form--signup form {
  gap: 12px;
}

.auth-form__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.auth-form__top > * {
  flex: 1 1 240px;
  min-width: 0;
}

.auth-kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
  color: var(--auth-grad-end);
}

.auth-form h1 {
  margin: 0 0 6px;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.15;
  color: var(--auth-text);
}

.auth-form p,
.auth-subtitle,
.auth-helper,
.auth-info-list li {
  font-size: clamp(13px, 1.6vw, 15px);
  line-height: 1.35;
  color: var(--auth-muted);
}

.auth-subtitle {
  margin: 2px 0 12px;
  word-break: break-word;
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.auth-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--auth-border);
  background: rgba(72, 83, 191, 0.08);
  color: var(--auth-grad-end);
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 6px 14px rgba(72, 83, 191, 0.12);
  word-break: break-word;
}

.auth-header-with-pet {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.pet-mascot {
  display: block;
}

.pet-mascot.pet-inline {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.social-icons {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  margin: 6px 0 4px;
}

.social-icons a {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(226, 232, 240, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #475569;
  background: #fff;
  transition: 0.25s ease;
}

.social-icons a:hover {
  border-color: var(--auth-grad-end);
  color: #fff;
  background: var(--auth-grad-end);
  transform: translateY(-3px);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.form-grid__item.full {
  grid-column: span 2;
}

.input-box {
  position: relative;
}

.input-box input,
.input-box select,
.input-box textarea {
  width: 100%;
  padding: 15px 52px 15px 16px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(226, 232, 240, 0.85);
  background: rgba(255, 255, 255, 0.96);
  font-size: 15px;
  color: var(--auth-text);
  transition: all 0.25s ease;
  outline: none;
}

.input-box input:focus,
.input-box select:focus,
.input-box textarea:focus {
  border-color: var(--auth-grad-end);
  box-shadow: 0 10px 22px rgba(72, 83, 191, 0.2);
  background: #fff;
}

.input-box i {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: #9ca3af;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--auth-text);
  margin: 6px 0 4px;
}

.auth-checkbox input {
  width: 16px;
  height: 16px;
}

.forgot-link {
  text-align: right;
  margin: 0;
}

.forgot-link a {
  font-size: 13px;
  color: var(--auth-muted);
  text-decoration: none;
}

.forgot-link a:hover {
  color: var(--auth-grad-end);
}

.btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--auth-grad-start), var(--auth-grad-end));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition:
    transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.25s ease,
    background 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(72, 83, 191, 0.45);
}

.btn.outline {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

.btn.outline:hover {
  background: rgba(255, 255, 255, 0.12);
}

.auth-helper {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--auth-muted);
}

.auth-link {
  color: var(--auth-grad-end);
  font-weight: 700;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-alert {
  font-size: 14px;
  color: #b91c1c;
  background: rgba(248, 113, 113, 0.15);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.auth-error {
  font-size: 13px;
  color: #b91c1c;
  margin: 6px 0 0;
}

.auth-info-list {
  list-style: none;
  padding: 12px 14px;
  margin: 6px 0 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--auth-border);
  border-radius: 14px;
}

.auth-info-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.85);
}

.auth-info-list li::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--auth-muted);
}

.auth-info-list li.is-valid {
  color: var(--auth-grad-end);
  font-weight: 600;
  background: rgba(72, 83, 191, 0.12);
}

.auth-info-list li.is-valid::before {
  background: var(--auth-grad-end);
}

.captcha-box,
.input-box.captcha-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.captcha-box img.captcha {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 12px;
  border: 2px solid rgba(226, 232, 240, 0.65);
  background: #f8f9fa;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.captcha-box input[type="text"] {
  width: 100%;
  max-width: 280px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(226, 232, 240, 0.65);
  background: rgba(255, 255, 255, 0.94);
  font-size: 16px;
  text-align: center;
  letter-spacing: 2px;
  font-weight: 600;
}

.captcha-box input[type="text"]:focus {
  border-color: var(--auth-grad-end);
}

button[data-reset-captcha] {
  width: auto;
  padding: 0 16px;
  height: 42px;
  font-size: 14px;
  border: 2px solid var(--auth-grad-end);
  color: var(--auth-grad-end);
  background: transparent;
  border-radius: 12px;
  align-self: flex-start;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

button[data-reset-captcha]:hover {
  background: var(--auth-grad-end);
  color: #fff;
  transform: translateY(-1px);
}

.toggle-box {
  grid-area: toggle;
  position: relative;
  background: linear-gradient(135deg, var(--auth-grad-end), #4c51bf);
  background-image: var(--bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: #fff;
  padding: clamp(28px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 0;
}

.toggle-panel {
  width: 100%;
  max-width: 340px;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.toggle-panel h1 {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 30px);
  font-weight: 800;
  color: #fff;
}

.toggle-panel p {
  margin: 0;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
}

.auth-container:not(.active) .toggle-panel.toggle-left {
  display: flex;
}

.auth-container.active .toggle-panel.toggle-right {
  display: flex;
}

.toggle-panel .btn {
  width: 150px;
  height: 46px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  position: relative;
  z-index: 1;
}

/* Floating FAB */
.fab-container {
  position: fixed;
  bottom: calc(var(--fab-safe-bottom) + var(--fab-option-radius));
  right: calc(var(--fab-safe-right) + var(--fab-option-radius));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fab-button {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, var(--auth-grad-end), #6f79cd);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  z-index: 2;
}

.fab-button:hover {
  transform: scale(1.05);
}

.fab-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 4px;
}

.fab-icon {
  position: relative;
  width: 28px;
  height: 28px;
}

.fab-icon::before,
.fab-icon::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 4px;
  background: #fff;
  top: 50%;
  left: 50%;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: transform 0.25s ease;
}

.fab-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.fab-container.active .fab-icon::after {
  transform: translate(-50%, -50%) rotate(0deg);
}

.fab-container.active .fab-icon::before {
  transform: translate(-50%, -50%) rotate(90deg);
}

.fab-options {
  position: absolute;
  inset: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.fab-option {
  --offset-x: 0px;
  --offset-y: 0px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  color: var(--auth-grad-end);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35);
  transition:
    opacity 0.25s ease,
    transform 0.25s cubic-bezier(.175,.885,.32,1.275);
  pointer-events: none;
}

.fab-container.active .fab-option {
  opacity: 1;
  pointer-events: auto;
  transform: translate(
      calc(-50% + var(--offset-x)),
      calc(-50% + var(--offset-y))
    )
    scale(1);
}

.fab-option:hover {
  background: linear-gradient(45deg, var(--auth-grad-end), #6f79cd);
  color: #fff;
}

.fab-options .fab-option:nth-child(1) {
  --offset-x: 0px;
  --offset-y: calc(var(--fab-option-radius) * -1);
}
.fab-options .fab-option:nth-child(2) {
  --offset-x: calc(var(--fab-option-radius) * -0.7);
  --offset-y: calc(var(--fab-option-radius) * -0.7);
}
.fab-options .fab-option:nth-child(3) {
  --offset-x: calc(var(--fab-option-radius) * -1);
  --offset-y: 0px;
}
.fab-options .fab-option:nth-child(4) {
  --offset-x: calc(var(--fab-option-radius) * -0.7);
  --offset-y: calc(var(--fab-option-radius) * 0.7);
}
.fab-options .fab-option:nth-child(5) {
  --offset-x: 0px;
  --offset-y: calc(var(--fab-option-radius) * 1);
}
.fab-options .fab-option:nth-child(6) {
  --offset-x: calc(var(--fab-option-radius) * 0.7);
  --offset-y: calc(var(--fab-option-radius) * 0.7);
}
.fab-options .fab-option:nth-child(7) {
  --offset-x: calc(var(--fab-option-radius) * 1);
  --offset-y: 0px;
}
.fab-options .fab-option:nth-child(8) {
  --offset-x: calc(var(--fab-option-radius) * 0.7);
  --offset-y: calc(var(--fab-option-radius) * -0.7);
}

/* Foco visível */
.btn:focus-visible,
.auth-link:focus-visible,
.social-icons a:focus-visible,
button[data-reset-captcha]:focus-visible {
  outline: 3px solid var(--auth-focus);
  outline-offset: 3px;
}

/* Responsivo */
@media (max-width: 1080px) {
  :root {
    --fab-option-radius: 104px;
  }

  .auth-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toggle"
      "form";
  }

  .toggle-box {
    min-height: 220px;
    border-bottom: 1px solid var(--auth-border);
  }

  .toggle-panel {
    max-width: 480px;
  }
}

@media (max-width: 780px) {
  :root {
    --fab-option-radius: 90px;
  }

  .auth-wrapper {
    width: 100%;
  }

  .auth-container {
    border-radius: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid__item.full {
    grid-column: span 1;
  }

  .auth-form {
    width: 100%;
  }
}

@media (max-width: 540px) {
  :root {
    --fab-option-radius: 72px;
  }

  .auth-scope {
    padding: 16px 12px;
  }

  .form-box {
    padding: 22px 18px;
  }

  .toggle-box {
    padding: 24px 18px;
  }

  .btn {
    height: 50px;
  }

  .toggle-panel .btn {
    width: 140px;
    height: 44px;
  }

  .fab-button {
    width: 60px;
    height: 60px;
  }

  .fab-option {
    width: 46px;
    height: 46px;
  }
}

/* Respeitar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
