:root {
  --primary-blue: #003087;
  --azul-claro: #005aa7;
  --cinza-claro: #f4f7f8;
  --cinza-escuro: #1a2332;
  --branco: #ffffff;
  --borda: rgba(15, 40, 45, 0.1);
  --verde-carf: #067074;
  --verde-carf-escuro: #6cad17;
  --verde-carf-title: #067074;
  --carf-teal: #067074;
  --carf-lime: #6cad17;
  --glass: #f3f6f7;
  --text-muted: #64748b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
html {
  height: 100vh;
  font-family: 'Manrope', sans-serif;
  background-color: #060c10;
  background-image: url('../img/Fundo.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  /* Cobre a tela toda sem o zoom/crop agressivo do cover */
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  color: var(--cinza-escuro);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(6, 112, 116, 0.18), transparent 60%),
    rgba(0, 0, 0, 0.4);
  z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  max-width: 520px;
  max-height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108, 173, 23, 0.22), rgba(6, 112, 116, 0.08) 45%, transparent 70%);
  filter: blur(8px);
  z-index: 0;
  pointer-events: none;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.page-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  padding: 1rem 1.25rem 3.5rem;
  transform: translateY(-3vh);
}

.login-container {
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  width: min(400px, 92vw);
  max-width: 400px;
  min-width: 0;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.08),
    0 24px 48px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(6, 112, 116, 0.08);
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  z-index: 1;
  opacity: 0;
  animation: loginFallbackShow 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s forwards;
}

.login-container.motion-ready {
  animation: none;
}

@keyframes loginFallbackShow {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-accent {
  height: 4px;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--carf-teal) 0%, var(--carf-lime) 55%, #9fd84a 100%);
}

.login-header {
  padding: 1.6rem 2.75rem 1.15rem;
  text-align: center;
  position: relative;
}

.login-header::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  margin: 1rem auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--carf-teal), var(--carf-lime));
  opacity: 0.7;
}

.logo {
  width: 130px;
  height: auto;
  margin: 0 auto 0.85rem;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
  transition: filter 0.3s ease;
  opacity: 0;
  /* Só começa depois do card aparecer */
  animation: headerFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.55s forwards;
}

.logo.carf {
  width: 140px;
  max-width: 140px;
  margin-left: auto;
  margin-right: auto;
}

.logo:hover {
  filter: drop-shadow(0 4px 12px rgba(6, 112, 116, 0.35));
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.header-subtitle {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--carf-lime);
  margin: 0;
  line-height: 1.15;
  order: 1;
  opacity: 0;
  animation: headerFadeUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.75s forwards;
}

.header-subtitle.carf {
  color: var(--carf-lime);
}

.header-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.15rem 0 0;
  color: var(--carf-teal);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  order: 2;
  opacity: 0;
  animation: headerFadeUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.92s forwards;
}

.header-title.carf {
  color: var(--carf-teal);
}

@keyframes headerFadeUp {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-form,
#loginForm {
  display: block;
  width: 100%;
  max-width: none;
  padding: 0.35rem 2rem 1.85rem;
  box-sizing: border-box;
}

.form-group {
  position: relative;
  margin-bottom: 1.05rem;
}

.field-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 1rem;
  z-index: 2;
  pointer-events: none;
  transition: color 0.25s ease;
}

.form-group input {
  width: 100%;
  padding: 0.95rem 2.75rem 0.95rem 2.65rem;
  border: 1px solid rgba(15, 40, 45, 0.12);
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--cinza-escuro);
  background: rgba(248, 250, 252, 0.9);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  overflow-x: auto;
  text-overflow: clip;
  white-space: nowrap;
}

.form-group input:hover {
  border-color: rgba(6, 112, 116, 0.28);
}

.form-group input:focus {
  outline: none;
  border-color: var(--carf-teal);
  box-shadow: 0 0 0 4px rgba(6, 112, 116, 0.12);
  background: var(--branco);
}

.form-group input:focus ~ .field-icon,
.form-group input:not(:placeholder-shown) ~ .field-icon,
.form-group input.filled ~ .field-icon {
  color: var(--carf-teal);
}

/* ícone está antes do input no HTML — usar sibling anterior via :has */
.form-group:has(input:focus) .field-icon,
.form-group:has(input:not(:placeholder-shown)) .field-icon,
.form-group:has(input.filled) .field-icon {
  color: var(--carf-teal);
}

.form-group input::placeholder {
  color: transparent;
}

.form-group label {
  position: absolute;
  top: 0.95rem;
  left: 2.65rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
  transition: all 0.25s ease;
  background: transparent;
  padding: 0 0.2rem;
}

.form-group input:focus + label,
.form-group input:not(:placeholder-shown) + label,
.form-group input.filled + label {
  top: -0.55rem;
  left: 2.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--carf-teal);
  /* Mesmo tom do container (sem mancha branca) */
  background: var(--glass);
  letter-spacing: 0.02em;
}

.password-wrapper button#togglePassword {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 6px;
  transition: color 0.25s ease, background 0.25s ease;
}

.password-wrapper button#togglePassword:hover {
  color: var(--carf-teal);
  background: rgba(6, 112, 116, 0.08);
}

.btn-submit {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.95rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--branco);
  background: linear-gradient(115deg, var(--carf-teal) 0%, #0a8f86 45%, var(--carf-lime) 100%);
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(6, 112, 116, 0.32);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-submit i {
  font-size: 1.45rem;
  line-height: 1;
  transition: transform 0.25s ease;
}

.btn-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transition: left 0.55s ease;
}

.btn-submit:hover::before {
  left: 130%;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(6, 112, 116, 0.4);
  filter: brightness(1.03);
}

.btn-submit:hover i {
  transform: translateX(3px);
}

.btn-submit:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(6, 112, 116, 0.28);
}

.btn-submit.carf {
  background: linear-gradient(115deg, var(--carf-teal) 0%, #0a8f86 45%, var(--carf-lime) 100%);
  box-shadow: 0 8px 20px rgba(6, 112, 116, 0.32);
}

.btn-submit.carf:hover {
  background: linear-gradient(115deg, var(--carf-lime) 0%, #0a8f86 50%, var(--carf-teal) 100%);
}

.forgot-password-container {
  margin-top: 1.15rem;
  text-align: center;
}

.forgot-password-container a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--carf-teal);
  text-decoration: none;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.forgot-password-container a i {
  font-size: 0.95rem;
}

.forgot-password-container a:hover {
  color: var(--carf-lime);
  background: rgba(6, 112, 116, 0.06);
  border-color: rgba(6, 112, 116, 0.12);
}

.forgot-password-container a.carf {
  color: var(--carf-teal);
}

.forgot-password-container a.carf:hover {
  color: #558c12;
}

/* Modal */
.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  font-family: 'Manrope', sans-serif;
}

.modal-accent {
  height: 4px;
  background: linear-gradient(90deg, var(--carf-teal), var(--carf-lime));
}

.modal-header {
  border-bottom: 1px solid rgba(15, 40, 45, 0.08);
  padding: 1.15rem 1.4rem;
  background: #fbfcfd;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(6, 112, 116, 0.12), rgba(108, 173, 23, 0.18));
  color: var(--carf-teal);
  font-size: 1.1rem;
}

.modal-title {
  font-weight: 750;
  font-size: 1.05rem;
  color: var(--cinza-escuro);
  margin: 0;
}

body.theme-carf .modal-title {
  color: var(--carf-teal);
}

.modal-body {
  padding: 1.35rem 1.4rem 1.2rem;
}

.modal-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.05rem;
  line-height: 1.5;
}

.modal-body .form-label {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--cinza-escuro);
}

.modal-body .form-control {
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
  border-color: rgba(15, 40, 45, 0.12);
  font-size: 0.92rem;
  font-family: inherit;
}

.modal-body .form-control:focus {
  border-color: var(--carf-teal);
  box-shadow: 0 0 0 4px rgba(6, 112, 116, 0.12);
}

.modal-footer {
  border-top: 1px solid rgba(15, 40, 45, 0.08);
  padding: 1rem 1.4rem 1.2rem;
  gap: 0.55rem;
}

.modal-footer .btn {
  border-radius: 10px;
  font-weight: 700;
  font-family: inherit;
  padding: 0.58rem 1.2rem;
  min-width: 104px;
}

.modal-footer .btn-secondary {
  background: #eef2f6;
  border-color: transparent;
  color: #475569;
}

.modal-footer .btn-secondary:hover {
  background: #e2e8f0;
  color: #334155;
}

.modal-footer .btn-primary,
body.theme-carf .modal-footer .btn-primary {
  background: linear-gradient(115deg, var(--carf-teal), var(--carf-lime));
  border: none;
  box-shadow: 0 4px 12px rgba(6, 112, 116, 0.28);
}

.modal-footer .btn-primary:hover,
body.theme-carf .modal-footer .btn-primary:hover {
  background: linear-gradient(115deg, var(--carf-lime), var(--carf-teal));
  filter: brightness(1.02);
}

#toast-container > .toast {
  background-color: #fff !important;
  color: var(--carf-teal) !important;
  border-left: 6px solid var(--carf-teal) !important;
  font-weight: 600;
  font-family: 'Manrope', sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18) !important;
  border-radius: 10px !important;
}

#toast-container > .toast-success {
  background-color: #4CAF50 !important;
  color: #fff !important;
  border-left-color: #388E3C !important;
}

#toast-container > .toast-error {
  background-color: #F44336 !important;
  color: #fff !important;
  border-left-color: #D32F2F !important;
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  z-index: 10;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
  .page-wrapper {
    transform: translateY(-1vh);
    max-width: 100%;
  }

  .login-container {
    width: min(380px, 94vw);
    max-width: 380px;
    min-width: 0;
  }

  .login-header,
  .login-form,
  #loginForm {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
  }

  .logo,
  .logo.carf {
    width: 120px;
    max-width: 120px;
  }

  .header-subtitle {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .page-wrapper {
    transform: none;
    padding: 0.75rem 0.75rem 3rem;
    max-width: 100%;
  }

  .login-container {
    width: 94vw;
    max-width: 94%;
    min-width: 0;
    border-radius: 14px;
  }

  .login-header {
    padding: 1.25rem 1.25rem 0.9rem;
  }

  .login-form,
  #loginForm {
    padding: 0.2rem 1.25rem 1.4rem;
  }

  .logo,
  .logo.carf {
    width: 110px;
    max-width: 110px;
  }

  .header-subtitle {
    font-size: 1.1rem;
  }

  .header-title {
    font-size: 0.82rem;
  }

  .footer {
    font-size: 0.7rem;
  }
}
