/**
 * Authentication Modal Styles
 *
 * Premium, high-end authentication modal with breathing animations
 */

/* Modal backdrop animation with breathing effect */
#auth-modal {
  /* Above tool TopupModal (9999) — do not rely on Tailwind z-[*] (may be purged). */
  z-index: 10050;
  animation: fadeInBackdrop 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Prevent scroll on body when modal is open */
body:has(#auth-modal:not(.hidden)) {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
}

html:has(#auth-modal:not(.hidden)) {
  overflow: hidden !important;
}

@keyframes fadeInBackdrop {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(12px);
  }
}

/* Modal container with elegant entrance */
.auth-modal-container {
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center;
  overflow-x: hidden;
  box-sizing: border-box;
  /* Remove vertical scrollbar by making content fit */
  max-height: fit-content;
}

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

/* Breathing animation for background gradient */
.auth-modal-container::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.1),
    rgba(20, 184, 166, 0.1)
  );
  border-radius: inherit;
  z-index: -1;
  animation: breathe 4s ease-in-out infinite;
  opacity: 0.5;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.02);
  }
}

/* Social login buttons with shimmer effect */
.social-login-btn {
  position: relative;
  overflow: hidden;
}

.social-login-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.5s;
}

.social-login-btn:hover::before {
  left: 100%;
}

.social-login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.1);
}

.social-login-btn:active {
  transform: translateY(0);
}

/* Form inputs with focus glow */
.form-input {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Password toggle button positioning */
.form-group .relative {
  position: relative;
}

.form-group button[aria-label="Toggle password visibility"] {
  position: absolute;
  right: 0.625rem; /* 10px */
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  pointer-events: auto;
}

.form-input:focus {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1),
    0 2px 8px rgba(16, 185, 129, 0.12);
  transform: translateY(-0.5px);
}

.form-input:hover:not(:focus) {
  border-color: rgba(148, 163, 184, 0.5);
  background-color: rgba(30, 41, 59, 0.8);
}

/* Form group animation */
.form-group {
  animation: fadeInUp 0.3s ease-out backwards;
}

.form-group:nth-child(1) {
  animation-delay: 0.05s;
}
.form-group:nth-child(2) {
  animation-delay: 0.1s;
}
.form-group:nth-child(3) {
  animation-delay: 0.15s;
}
.form-group:nth-child(4) {
  animation-delay: 0.2s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hide scrollbar but allow scrolling if needed */
#auth-modal .overflow-y-auto {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

#auth-modal .overflow-y-auto::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Tab switching animation */
#tab-signin,
#tab-signup {
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#tab-signin.bg-gradient-to-r,
#tab-signup.bg-gradient-to-r {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* Error and success messages with slide-in */
#auth-error,
#auth-success {
  animation: slideInFromTop 0.3s ease-out;
}

@keyframes slideInFromTop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading state animation */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Close button hover effect */
#auth-modal-close:hover {
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#auth-modal-close {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .auth-modal-container {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }
}

/* Smooth transitions for all interactive elements */
#auth-modal * {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

/* Ensure all inputs and buttons don't cause overflow */
#auth-modal input,
#auth-modal button,
#auth-modal form {
  max-width: 100%;
  box-sizing: border-box;
}

/* Preview conversion (Export / Adjust): Google + Microsoft only — no email signup. */
#auth-modal[data-entry="oauth-only"] #auth-divider,
#auth-modal[data-entry="oauth-only"] #email-auth-section,
#auth-modal[data-entry="oauth-only"] #signin-form,
#auth-modal[data-entry="oauth-only"] #signup-form {
  display: none !important;
}

/* Prevent any element from causing horizontal scroll */
#auth-modal {
  width: 100vw;
  max-width: 100vw;
}

#auth-modal > div {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
