/* Auth Modal — Fouad LMS */
body.auth-modal-open {
  overflow: hidden;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-modal-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(51, 122, 183, 0.22), transparent 55%),
    rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: authFadeIn 0.28s ease;
}

.auth-modal-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 42px 34px 32px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(51, 122, 183, 0.12);
  box-shadow:
    0 24px 64px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  animation: authSlideUp 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: var(--font-sans);
}

.auth-modal-accent {
  position: absolute;
  top: 0;
  inset-inline: 34px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, #337ab7, #7ec8ef);
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.auth-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: rgba(51, 122, 183, 0.2);
}

.auth-step {
  animation: authFadeIn 0.28s ease;
}

.auth-header {
  text-align: start;
  margin-bottom: 26px;
  padding-inline-end: 28px;
}

.auth-title {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 2.6vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
  font-family: var(--font-sans);
}

.auth-subtitle {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #64748b;
  font-family: inherit;
}

#otp-phone-display {
  color: #2a6599;
  font-weight: 650;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-modal .form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auth-modal .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-modal .form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  font-family: inherit;
}

.auth-modal .form-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid #dbe3ec;
  border-radius: 12px;
  font-size: 0.9375rem;
  color: #0f172a;
  background: #ffffff;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
}

.auth-modal .form-input:hover {
  border-color: #c5d4e4;
}

.auth-modal .form-input:focus {
  outline: none;
  border-color: #337ab7;
  box-shadow: 0 0 0 4px rgba(51, 122, 183, 0.12);
  background: #fff;
}

.auth-modal .form-input::placeholder {
  color: #94a3b8;
}

.auth-modal select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-inline-end: 36px;
}

html[dir="rtl"] .auth-modal select.form-input,
.dir-rtl .auth-modal select.form-input {
  background-position: left 12px center;
}

.form-input.field-error,
.otp-input.field-error {
  border-color: #dc2626;
  animation: authShake 0.45s;
}

.form-input.field-error:focus,
.otp-input.field-error:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.field-error-message {
  color: #dc2626;
  font-size: 0.75rem;
  margin-top: 2px;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-error-message::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dc2626;
  flex-shrink: 0;
}

.communication-toggle {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 12px;
}

.toggle-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.toggle-option svg {
  width: 18px;
  height: 18px;
}

.toggle-option.active {
  background: #ffffff;
  color: #2a6599;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.toggle-option:hover:not(.active) {
  color: #334155;
}

.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 4px;
}

.otp-input {
  width: 54px;
  height: 54px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  border: 1.5px solid #dbe3ec;
  border-radius: 12px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.otp-input:focus {
  outline: none;
  border-color: #337ab7;
  box-shadow: 0 0 0 4px rgba(51, 122, 183, 0.12);
}

.otp-timer {
  text-align: center;
  font-size: 0.8125rem;
  color: #64748b;
  margin: 0;
  font-family: inherit;
}

#otp-countdown {
  color: #2a6599;
  font-weight: 700;
  transition: color 0.2s ease;
}

#otp-countdown.resend-active {
  color: #1e5a94;
  cursor: pointer;
  text-decoration: underline;
}

#otp-countdown.resend-active:hover {
  color: #164876;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  cursor: pointer;
  accent-color: #337ab7;
  flex-shrink: 0;
}

.auth-button {
  width: 100%;
  min-height: 50px;
  padding: 13px 22px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    filter 0.2s ease;
  font-family: inherit;
}

.auth-button.primary {
  background: linear-gradient(135deg, #4696d4 0%, #2f74b0 48%, #1f5a8f 100%);
  color: #ffffff;
  box-shadow:
    0 10px 24px rgba(51, 122, 183, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.auth-button.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 14px 28px rgba(51, 122, 183, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.auth-button.primary:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.auth-button.ghost {
  width: 100%;
  background: transparent;
  color: #337ab7;
  border: 1px solid rgba(51, 122, 183, 0.28);
  box-shadow: none;
}

.auth-button.ghost:hover:not(:disabled) {
  background: rgba(51, 122, 183, 0.06);
  border-color: rgba(51, 122, 183, 0.45);
}

.auth-register-hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #64748b;
}

#step-signin[data-signin-mode="code"] [data-password-only] {
  display: none !important;
}

.auth-form-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: -0.25rem 0 1rem;
  flex-wrap: wrap;
}

.auth-remember {
  margin: 0;
  font-size: 0.82rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.85rem 0;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(15, 23, 42, 0.1);
}

.auth-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

.auth-button.rate-limited {
  opacity: 0.7;
  cursor: not-allowed;
  background: #94a3b8 !important;
  box-shadow: none !important;
}

.auth-button.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.auth-button.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: authSpin 0.6s linear infinite;
}

.auth-footer {
  text-align: center;
  font-size: 0.875rem;
  color: #64748b;
  margin: 4px 0 0;
  font-family: inherit;
}

.auth-footer--switch {
  margin-top: 2px;
  padding-top: 17px;
  border-top: 1px solid rgba(15, 23, 42, 0.07);
}

.auth-link {
  color: #2a6599;
  text-decoration: none;
  font-weight: 650;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}

.auth-link:hover {
  color: #1e5a94;
  text-decoration: underline;
}

@keyframes authFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes authSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

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

.custom-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  min-width: 280px;
  max-width: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  animation: authSlideInRight 0.28s ease;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.custom-notification-error {
  border-inline-start: 4px solid #dc2626;
}

.custom-notification-success {
  border-inline-start: 4px solid #059669;
}

.notification-content {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
}

.notification-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
}

.custom-notification-error .notification-icon {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.custom-notification-success .notification-icon {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
}

.notification-message {
  flex: 1;
  color: #0f172a;
  font-size: 0.875rem;
  line-height: 1.45;
}

.notification-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.notification-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.notification-fadeout {
  animation: authSlideOutRight 0.28s ease forwards;
}

@keyframes authSlideInRight {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes authSlideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(40px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-modal-overlay,
  .auth-modal-container,
  .auth-step,
  .auth-button.primary:hover {
    animation: none;
    transition: none;
    transform: none;
  }
}

@media (max-width: 768px) {
  .auth-modal-container {
    padding: 28px 22px 24px;
  }

  .auth-modal .form-row {
    grid-template-columns: 1fr;
  }

  .otp-input {
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
  }

  .otp-inputs {
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .auth-modal {
    padding: 12px;
  }

  .auth-modal-container {
    padding: 24px 18px 20px;
    border-radius: 16px;
  }

  .otp-input {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
  }

  .communication-toggle {
    flex-direction: column;
  }

  .toggle-option {
    width: 100%;
  }
}
