:root {
  --login-accent: #2f6fb0;
  --login-accent-strong: #1d4f83;
  --login-accent-soft: rgba(47, 111, 176, 0.18);
  --login-text: #17324a;
  --login-muted: #5d7082;
  --login-bg-deep: #0e3048;
  --login-bg-mid: #0f5d84;
  --login-bg-light: #22acd8;
  --login-bg-glow: rgba(117, 214, 241, 0.32);
  --login-bg-glow-strong: rgba(47, 111, 176, 0.34);
  --login-card-bg: rgba(245, 250, 255, 0.56);
  --login-card-border: rgba(255, 255, 255, 0.52);
  --login-card-shadow: 0 30px 70px -36px rgba(17, 35, 52, 0.42);
  --login-card-overlay: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 251, 255, 0.76) 100%);
  --login-field-bg: rgba(255, 255, 255, 0.82);
  --login-field-bg-hover: rgba(255, 255, 255, 0.9);
  --login-field-bg-focus: rgba(255, 255, 255, 0.96);
  --login-field-border: rgba(73, 110, 142, 0.18);
  --login-field-border-focus: rgba(47, 111, 176, 0.52);
  --login-panel-bg: rgba(255, 255, 255, 0.48);
  --login-card-motion-opacity: 0.32;
}

/* Fundo com GIF original, preservando a identidade visual anterior. */
body {
  min-height: 100vh;
  background-color: #112334;
  background-image: url('/img/background/sigaa_login.gif');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.14) 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: none;
}

body > * {
  position: relative;
  z-index: 1;
}

/* Area principal: centralizacao real do card e respiro adequado em desktop/mobile. */
.catalyst-auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  position: relative;
}

.catalyst-auth::before {
  content: '';
  position: absolute;
  width: min(40rem, 82vw);
  height: min(40rem, 82vw);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(208, 226, 245, 0.08) 45%, rgba(208, 226, 245, 0) 75%);
  filter: blur(8px);
  pointer-events: none;
}

.catalyst-auth::after {
  content: none;
}

/* Card de login: translucidez leve, cantos amplos, sombra suave e acabamento premium. */
.auth-card {
  width: min(33.75rem, 100%);
  padding: 2.15rem 2.15rem 1.5rem;
  border-radius: 2rem;
  border: 1px solid var(--login-card-border);
  background: var(--login-card-bg);
  box-shadow: var(--login-card-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  animation: auth-card-enter 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/img/background/sigaa_login.gif');
  background-size: cover;
  background-position: center;
  opacity: var(--login-card-motion-opacity);
  transform: scale(1.08);
  pointer-events: none;
  z-index: 0;
}

.auth-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--login-card-overlay);
  pointer-events: none;
  z-index: 0;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

/* Cabecalho: logo central, destaque para SIGAA e subtitulo institucional discreto. */
.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.brand-mark {
  width: 16.5rem;
  height: auto;
  aspect-ratio: 1024 / 478;
  padding: 0;
  margin-block: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  overflow: visible;
  box-shadow: none;
}

.brand-logo {
  width: 100%;
  max-width: 100%;
  max-height: none;
  margin: 0 auto;
  display: block;
  object-fit: contain;
  object-position: center;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0.9rem;
  gap: 0.35rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--login-accent);
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw, 2.1rem);
  line-height: 1.12;
  font-weight: 800;
  color: var(--login-text);
}

.subtitle {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(23, 50, 74, 0.84);
}

.intro-copy {
  margin: 0.15rem 0 0;
  max-width: 24rem;
  font-size: 0.94rem;
  line-height: 1.6;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(93, 112, 130, 0.88);
}

/* Formularios: labels discretas, campos altos, foco moderno e espacamento consistente. */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field span {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(23, 50, 74, 0.62);
  padding-left: 0.15rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(47, 111, 176, 0.1);
  border: 1px solid rgba(47, 111, 176, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: rgba(29, 79, 131, 0.82);
  pointer-events: none;
  z-index: 2;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.field-icon svg {
  width: 0.95rem;
  height: 0.95rem;
}

.field input {
  width: 100%;
  min-height: 3.35rem;
  padding: 0.92rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--login-field-border);
  background: var(--login-field-bg);
  color: var(--login-text);
  font-size: 0.98rem;
  line-height: 1.2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 12px 28px -24px rgba(17, 35, 52, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.input-shell input {
  padding-left: 3.45rem;
}

.field input[readonly] {
  cursor: text;
}

.field input:hover {
  background: var(--login-field-bg-hover);
}

.field input:focus {
  outline: none;
  background: var(--login-field-bg-focus);
  border-color: var(--login-field-border-focus);
  box-shadow: 0 0 0 4px var(--login-accent-soft), 0 18px 30px -24px rgba(29, 79, 131, 0.42);
  transform: translateY(-1px);
}

.field:focus-within span {
  color: var(--login-accent-strong);
}

.field:focus-within .field-icon {
  color: var(--login-accent-strong);
  background: rgba(47, 111, 176, 0.16);
  border-color: rgba(47, 111, 176, 0.16);
}

.field input::placeholder {
  color: rgba(93, 112, 130, 0.78);
}

/* Evita o duplicado do Edge no campo de senha e mantem apenas o toggle customizado. */
.field input[type='password']::-ms-reveal,
.field input[type='password']::-ms-clear {
  display: none;
}

.field small {
  font-size: 0.8rem;
  color: #b42318;
  margin-top: 0.1rem;
}

/* Campo de senha: toggle visual para mostrar/ocultar sem alterar a logica do form. */
#password_display {
  padding-right: 7rem;
}

.password-toggle {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border: 0;
  border-radius: 999px;
  background: rgba(227, 239, 250, 0.96);
  color: var(--login-accent-strong);
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.password-toggle:hover {
  background: rgba(209, 227, 245, 0.98);
}

.password-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 111, 176, 0.16);
}

.password-toggle.is-visible {
  background: rgba(47, 111, 176, 0.12);
}

.password-toggle-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

/* Linha de opcoes: alinhamento horizontal, checkbox melhor resolvido e link discreto. */
.form-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.82rem 0.95rem;
  border-radius: 1rem;
  background: var(--login-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--login-muted);
  font-size: 0.9rem;
}

.remember {
  display: none;
  align-items: center;
  gap: 0.55rem;
  color: var(--login-text);
  font-size: 0.9rem;
}

.remember input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--login-accent);
}

.form-meta a {
  color: var(--login-accent-strong);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-meta a:hover {
  text-decoration: underline;
}

/* CTA principal: gradiente azul, hover suave e estado loading preparado. */
.auth-form > .submit-button {
  min-height: 3.35rem;
  border: 0;
  border-radius: 1.05rem;
  padding: 0.92rem 1rem;
  background: linear-gradient(135deg, #2f6fb0 0%, #21588f 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 20px 42px -26px rgba(33, 88, 143, 0.85);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}

.auth-form > .submit-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.04);
  box-shadow: 0 24px 50px -28px rgba(33, 88, 143, 0.92);
}

.auth-form > .submit-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(47, 111, 176, 0.18), 0 24px 50px -28px rgba(33, 88, 143, 0.92);
}

.auth-form > .submit-button:disabled,
.auth-form > .submit-button.is-loading {
  cursor: progress;
  opacity: 0.9;
}

.auth-form > .submit-button::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: calc(1.05rem - 1px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.04) 52%, rgba(255, 255, 255, 0.02) 100%);
  pointer-events: none;
}

.submit-button-inner {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.submit-button-icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.submit-button-icon svg {
  width: 100%;
  height: 100%;
}

.submit-button-label {
  display: inline-block;
}

.submit-button-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.96);
  display: none;
  flex: 0 0 auto;
  animation: login-button-spin 0.75s linear infinite;
}

.auth-form > .submit-button:hover:not(:disabled) .submit-button-icon {
  transform: translateX(2px);
}

.auth-form > .submit-button.is-loading .submit-button-icon {
  opacity: 0.72;
}

.auth-form > .submit-button.is-loading .submit-button-spinner {
  display: inline-flex;
}

/* Alertas e rodape: areas suaves e discretas para suporte e feedback. */
.alert {
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.92rem;
}

.alert strong,
.alert p {
  margin: 0;
}

.alert p {
  margin-top: 0.25rem;
}

.alert.error {
  background: rgba(255, 240, 241, 0.9);
  color: #a61b26;
}

.alert.success {
  background: rgba(234, 250, 238, 0.92);
  color: #166534;
}

.register-hint {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: rgba(23, 50, 74, 0.82);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}

.secondary-link {
  color: var(--login-accent-strong);
  text-decoration: none;
  font-weight: 700;
}

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

@keyframes auth-card-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Responsividade mobile: card compacto, toque confortavel e hierarquia preservada. */
@media (max-width: 640px) {
  body {
    background-attachment: scroll;
  }

  .catalyst-auth {
    padding: 0;
    align-items: stretch;
  }

  .auth-card {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem 1rem 1rem;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    gap: 0.95rem;
    justify-content: center;
  }

  .brand-mark {
    width: 10.5rem;
    height: auto;
    aspect-ratio: 1024 / 478;
    padding: 0;
    margin-block: 0;
    border-radius: 0;
  }

  .brand-logo {
    max-width: 100%;
    max-height: none;
  }

  .brand-copy h1 {
    font-size: 1.45rem;
  }

  .brand-copy {
    margin-top: 0.7rem;
  }

  .subtitle,
  .intro-copy,
  .register-hint,
  .form-meta,
  .form-meta a,
  .remember {
    font-size: 0.86rem;
  }

  .subtitle {
    font-size: 0.94rem;
  }

  .intro-copy {
    font-size: 0.88rem;
  }

  .field input,
  .auth-form > .submit-button {
    min-height: 3.1rem;
    font-size: 0.95rem;
  }

  #password_display {
    padding-right: 6.2rem;
  }

  .password-toggle {
    right: 0.55rem;
    min-height: 2.05rem;
    padding: 0 0.6rem;
    font-size: 0.74rem;
  }

  .form-meta {
    padding: 0.72rem 0.8rem;
  }
}

/* Mobile app: lighter login shell for faster first focus and keyboard open. */
body.is-capacitor-app {
  background-color: #eaf4fb;
  background-image:
    radial-gradient(circle at top right, rgba(34, 172, 216, 0.16), transparent 32%),
    linear-gradient(180deg, #eef7fc 0%, #e3f2fb 100%);
  background-attachment: scroll;
}

body.is-capacitor-app::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.12) 100%);
}

body.is-capacitor-app .catalyst-auth::before {
  display: none;
}

body.is-capacitor-app .auth-card {
  background: rgba(248, 252, 255, 0.94);
  border-color: rgba(210, 230, 244, 0.92);
  box-shadow: 0 18px 42px -28px rgba(17, 35, 52, 0.28);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.is-capacitor-app .auth-card::before {
  display: none;
}

body.is-capacitor-app .auth-card::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 250, 254, 0.94) 100%);
}

body.is-capacitor-app .field input,
body.is-capacitor-app .form-meta,
body.is-capacitor-app .register-hint,
body.is-capacitor-app .alert {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.is-capacitor-app .field input {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 10px 24px -24px rgba(17, 35, 52, 0.3);
}

body.is-capacitor-app .password-toggle {
  background: rgba(224, 237, 248, 0.98);
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .field input,
  .auth-form button,
  .password-toggle {
    animation: none;
    transition: none;
  }
}
