/* ==========================================================================
   Modex In-Page Authentication Modal
   Authentic Modex Design System | Consistent with Homepage & Contract
   ========================================================================== */

/* Backdrop Overlay */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 8, 14, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.auth-modal-backdrop[hidden] {
  display: none !important;
}

.auth-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Modal Dialog Frame */
.auth-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 410px;
  background: #0E121A;
  border: 1px solid #252A36;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal-backdrop.is-open .auth-modal-dialog {
  transform: translateY(0) scale(1);
}

/* 1. Modal Top Bar (Brand + Close) */
.auth-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  background: #0B0E15;
  border-bottom: 1px solid #1E2330;
}

.auth-modal-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.auth-brand-symbol {
  display: block;
}

.auth-modal-title {
  font-family: 'Acid Grotesk', 'Acid Grotesk Fallback', Inter, sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: #F4F6FB;
}

.auth-modal-title .brand-dot {
  color: #8B5CF6;
}

.auth-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #8F9AAF;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.auth-modal-close:hover {
  background: #1C2230;
  border-color: #353D50;
  color: #FFFFFF;
}

/* 2. Homepage Style Underline Tabs */
.auth-modal-tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: #0E121A;
  border-bottom: 1px solid #202636;
}

.auth-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 4px 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8F9AAF;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.auth-tab-btn svg {
  color: #64748B;
  transition: color 0.15s ease;
}

.auth-tab-btn:hover {
  color: #F4F6FB;
}

.auth-tab-btn:hover svg {
  color: #94A3B8;
}

.auth-tab-btn.is-active {
  color: #F4F6FB;
  border-bottom-color: #8B5CF6;
}

.auth-tab-btn.is-active svg {
  color: #A78BFA;
}

/* 3. Modal Card Content */
.auth-modal-card {
  padding: 20px 20px 22px;
}

/* Discord Dark Gaming Button */
.auth-modal-social {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
}

.auth-modal-social-btn,
.auth-modal-discord-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  background: #141824;
  border: 1px solid #272F42;
  border-radius: 6px;
  color: #F4F6FB !important;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  box-sizing: border-box;
}

.auth-modal-social-btn:hover,
.auth-modal-discord-btn:hover {
  background: #1A2030;
  color: #FFFFFF !important;
}

.auth-modal-google-btn:hover {
  border-color: #4285F4;
}

.auth-modal-discord-btn:hover {
  border-color: #5865F2;
}

.auth-modal-social-btn .google-svg-icon,
.auth-modal-social-btn .discord-svg-icon,
.auth-modal-discord-btn .discord-svg-icon {
  flex-shrink: 0;
}

.auth-modal-discord-btn .discord-svg-icon {
  color: #5865F2;
}

.auth-modal-social-btn span,
.auth-modal-discord-btn span {
  flex: 1;
  text-align: center;
}

.auth-modal-social-btn .auth-social-arrow,
.auth-modal-discord-btn .auth-social-arrow {
  color: #64748B;
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}

.auth-modal-google-btn:hover .auth-social-arrow {
  color: #4285F4;
}

.auth-modal-discord-btn:hover .auth-social-arrow {
  color: #5865F2;
}

[dir="rtl"] .auth-modal-social-btn .auth-social-arrow,
[dir="rtl"] .auth-modal-discord-btn .auth-social-arrow {
  transform: scaleX(-1);
}

/* Clean Divider */
.auth-modal-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: #64748B;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.auth-modal-divider::before,
.auth-modal-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #202636;
}

.auth-modal-divider span {
  padding: 0 10px;
}

/* Inline Alert Box */
.auth-modal-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #FCA5A5;
  font-size: 12px;
  line-height: 1.4;
}

.auth-modal-alert[hidden] {
  display: none !important;
}

.auth-modal-alert svg {
  flex-shrink: 0;
  color: #EF4444;
}

/* Forms */
.auth-modal-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-modal-form[hidden] {
  display: none !important;
}

.auth-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: #A5ADBE;
}

.auth-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Inputs (Matching Homepage Search & Card Form Inputs) */
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap .auth-input-icon {
  position: absolute;
  left: 11px;
  color: #64748B;
  pointer-events: none;
  transition: color 0.15s ease;
}

[dir="rtl"] .auth-input-wrap .auth-input-icon {
  left: auto;
  right: 11px;
}

.auth-input-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 34px;
  background: #141821;
  border: 1px solid #252A36;
  border-radius: 6px;
  color: #F4F6FB;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

[dir="rtl"] .auth-input-wrap input {
  padding: 0 34px 0 34px;
}

.auth-input-wrap input:focus {
  background: #161C26;
  border-color: #8B5CF6;
  box-shadow: none; /* No artificial AI glow */
}

.auth-input-wrap input:focus + .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon {
  color: #A78BFA;
}

.auth-input-wrap input::placeholder {
  color: #4B5569;
}

/* Password Toggle Eye Button */
.auth-pwd-toggle {
  position: absolute;
  right: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  color: #64748B;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

[dir="rtl"] .auth-pwd-toggle {
  right: auto;
  left: 7px;
}

.auth-pwd-toggle:hover {
  color: #F4F6FB;
  background: rgba(255, 255, 255, 0.05);
}

.auth-pwd-toggle svg {
  display: block;
}

.auth-pwd-toggle svg[hidden] {
  display: none !important;
}

/* Submit Button (Matching Homepage .auth-join & .button) */
.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 38px;
  margin-top: 3px;
  background: #8B5CF6;
  border: 1px solid #A78BFA;
  border-radius: 6px;
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.auth-submit-btn:hover {
  background: #9D74FF;
  border-color: #C4B5FD;
}

.auth-submit-btn:active {
  transform: translateY(1px);
}

.auth-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

.auth-submit-btn .btn-arrow {
  color: #E8DDFF;
  transition: transform 0.15s ease;
}

[dir="rtl"] .auth-submit-btn .btn-arrow {
  transform: scaleX(-1);
}

.auth-submit-btn:hover .btn-arrow {
  transform: translateX(2px);
}

[dir="rtl"] .auth-submit-btn:hover .btn-arrow {
  transform: scaleX(-1) translateX(2px);
}

/* Spinner */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
}

.btn-spinner[hidden] {
  display: none !important;
}

@keyframes authSpin {
  to { transform: rotate(360deg); }
}

/* Form Footer */
.auth-form-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  color: #7E8BA0;
  margin-top: 5px;
}

.auth-switch-link {
  background: transparent;
  border: none;
  padding: 0;
  color: #A78BFA;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-switch-link:hover {
  color: #C4B5FD;
  text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .auth-modal-backdrop {
    padding: 12px;
  }

  .auth-modal-dialog {
    max-width: 100%;
    border-radius: 8px;
  }

  .auth-modal-card {
    padding: 18px 16px 20px;
  }
}
