.login-screen {
  position: relative;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  padding: 24px;
  min-height: 100vh;
  background-color: var(--bg-primary); /* Static base white background */
}

/* Large, soft gold ambient glow orbiting the corners of the screen */
.login-screen::before {
  content: '';
  position: absolute;
  top: calc(50% - 80vmax);
  left: calc(50% - 80vmax);
  width: 160vmax;
  height: 160vmax;
  background-image: radial-gradient(circle at 18% 18%, rgba(255, 202, 40, 0.16) 0%, transparent 28%);
  animation: rotateGlow 40s linear infinite; /* Sped up to 40s for visibility, still very smooth */
  z-index: 1;
  pointer-events: none;
  transform-origin: center center;
}

@keyframes rotateGlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.login-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
}

.page-top-brand {
  position: absolute;
  top: -110px;
  left: 50%;
  width: 240px;
  height: 81px;
  z-index: 3;
  pointer-events: none;
  animation: loginBrandFadeIn 0.8s ease-out both;
}

.page-top-brand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.08));
}

@keyframes loginBrandFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.login-card {
  position: relative;
  z-index: 2; /* Floats card above the background rotation */
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 32px;
  padding: 0px 52px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
}

.login-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.04);
}

.login-card:active {
  transform: translateY(-1px) !important; /* Prevents card from snapping/reacting on click */
}

.brand-header {
  text-align: center;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.brand-logo-frame {
  width: 100%;
  height: 142px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo-img {
  width: 360px;
  max-width: 118%;
  height: auto;
  object-fit: contain;
  margin-top: 23px;
  margin-bottom: -62px;
  display: block;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: #2E7D32; /* Premium green text color */
  background-color: #E8F5E9; /* Soft green pill background */
  border: 1.5px solid rgba(46, 125, 50, 0.12);
  padding: 5px 16px;
  border-radius: 20px; /* Long pill shape */
  display: inline-block;
  margin: 10px 0 0;
  text-align: center;
  letter-spacing: 0.3px;
}

/* Custom Login Form Styling Override */
.login-card .form-group {
  margin-bottom: 18px;
}

.login-card .input-wrapper {
  position: relative;
  width: 100%;
}

.login-card .input-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: #8A94A6;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.login-card .form-input {
  width: 100%;
  height: 52px;
  padding: 0 20px 0 52px;
  font-size: 14px;
  background-color: #F8F9FA;
  border: 1px solid #EAEAEA;
  border-radius: 26px;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

.login-card .form-input:focus {
  background-color: #FFFFFF;
  border-color: #D4AF37;
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.08);
  outline: none;
}

.login-card .input-wrapper:focus-within .input-icon {
  color: var(--accent-gold);
}

.login-card .btn-primary {
  height: 52px;
  border-radius: 26px;
  background-color: #111111;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  border: none;
  margin-top: 10px;
  transition: var(--transition-smooth);
}

.login-card .btn-primary:hover {
  background-color: #222222;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.login-card .btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.forgot-password {
  text-align: center;
  margin-top: 31px;
  font-size: 14px;
  color: var(--text-secondary);
}

.forgot-password a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  transition: var(--transition-smooth);
}

.forgot-password a:hover {
  color: var(--accent-gold-dark);
}

/* Recupero password gratuito con codice personale */
.recovery-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.recovery-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.recovery-dialog {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 30px 34px 32px;
  border: 1px solid var(--border-color);
  border-radius: 28px;
  background: var(--bg-secondary);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.recovery-modal.active .recovery-dialog {
  transform: translateY(0) scale(1);
}

.recovery-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 21px;
  cursor: pointer;
}

.recovery-dialog-logo {
  display: block;
  width: 128px;
  height: 38px;
  object-fit: contain;
  margin-bottom: 18px;
}

.recovery-dialog-heading {
  padding-right: 42px;
}

.recovery-kicker {
  color: var(--accent-gold-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.recovery-dialog-heading h2 {
  margin: 5px 0 5px;
  color: var(--text-primary);
  font-size: 25px;
  line-height: 1.15;
}

.recovery-dialog-heading p {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

#password-recovery-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.recovery-form-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.recovery-input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.recovery-input:focus {
  border-color: var(--accent-gold);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.08);
}

.recovery-code-input {
  font-family: Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.recovery-primary-btn {
  grid-column: 1 / -1;
  height: 48px;
  margin-top: 2px;
  border-radius: 15px;
}

.recovery-message {
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 12.5px;
  line-height: 1.45;
}

.recovery-message.error {
  border-color: rgba(211, 47, 47, 0.2);
  background: #FFEBEE;
  color: #B42318;
}

.recovery-message.success {
  border-color: rgba(46, 125, 50, 0.2);
  background: #E8F5E9;
  color: #246B2B;
}

.recovery-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 18px;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
}

.recovery-divider::before,
.recovery-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.recovery-admin-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid rgba(212, 175, 55, 0.24);
  border-radius: 17px;
  background: var(--accent-gold-light);
}

.recovery-admin-help h3 {
  margin: 0 0 3px;
  color: #111111;
  font-size: 14px;
}

.recovery-admin-help p {
  margin: 0;
  color: #665D45;
  font-size: 11.5px;
  line-height: 1.4;
}

.recovery-admin-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 12px;
  background: #FFFFFF;
  color: #111111;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
}

.recovery-admin-btn:hover {
  border-color: #111111;
}

.recovery-admin-btn:disabled,
.recovery-primary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.alert {
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  
  /* Spring-bounce height expansion animation */
  animation: alertBounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  overflow: hidden;
  transform-origin: top center;
}

@keyframes alertBounceIn {
  0% {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-width: 0;
    transform: scaleY(0.85);
  }
  60% {
    max-height: 120px;
    opacity: 0.9;
    padding-top: 14px;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-width: 1px;
    transform: scaleY(1.02);
  }
  100% {
    max-height: 100px;
    opacity: 1;
    padding: 12px 16px;
    margin-bottom: 18px;
    border-width: 1px;
    transform: scaleY(1);
  }
}

.alert-danger {
  background-color: var(--danger-bg);
  border: 1px solid rgba(211, 47, 47, 0.15);
  color: var(--danger-color);
}

.alert-lockout {
  animation: pulseLock 1s infinite alternate;
  background-color: var(--text-primary);
  color: var(--bg-secondary);
  border: 1px solid var(--accent-gold);
}

.alert-lockout span.timer {
  color: var(--accent-gold);
  font-weight: 700;
}

@media (max-width: 520px) {
  .page-top-brand {
    top: -82px;
    width: 200px;
    height: 58px;
  }

  .login-card {
    padding: 24px;
    border-radius: 28px;
  }

  .brand-logo-frame {
    height: 126px;
  }

  .brand-logo-img {
    width: 320px;
  }

  .recovery-dialog {
    padding: 24px 20px;
    border-radius: 22px;
  }

  #password-recovery-form {
    grid-template-columns: 1fr;
  }

  .recovery-admin-help {
    align-items: stretch;
    flex-direction: column;
  }

  .recovery-admin-btn {
    width: 100%;
  }
}
