/* ============================================
   LOGIN OVERLAY - NATIONAL TRAINING PROGRAM
   Ultra-premium authentication layer
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&display=swap');

/* ── Overlay Container ── */
#authOverlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  overflow: hidden;
}

/* ── Animated Gradient Background ── */
#authOverlay .auth-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0d1b2a 0%, #1a3c6e 35%, #14532d 70%, #0d1b2a 100%);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Floating Particles ── */
#authOverlay .particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#authOverlay .particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(100vh) scale(0); }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.2; }
  100% { opacity: 0; transform: translateY(-20vh) scale(1.5); }
}

/* ── Geometric Mesh Lines ── */
#authOverlay .mesh {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(46,139,87,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46,139,87,0.06) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: meshMove 20s linear infinite;
}

@keyframes meshMove {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

/* ── Glowing Orbs ── */
#authOverlay .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orbPulse 8s ease-in-out infinite alternate;
}

#authOverlay .orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(46,139,87,0.25) 0%, transparent 70%);
  top: -100px; right: -100px;
  animation-duration: 8s;
}

#authOverlay .orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(26,60,110,0.35) 0%, transparent 70%);
  bottom: -80px; left: -80px;
  animation-duration: 11s;
  animation-delay: -3s;
}

#authOverlay .orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(46,139,87,0.15) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  animation-duration: 14s;
  animation-delay: -6s;
}

@keyframes orbPulse {
  0%   { transform: scale(1) translate(0, 0); opacity: 0.6; }
  100% { transform: scale(1.3) translate(30px, -30px); opacity: 1; }
}

/* ── Main Auth Card ── */
#authOverlay .auth-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 460px;
  margin: 20px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 44px 40px;
  box-shadow:
    0 40px 80px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 1px 0 rgba(255,255,255,0.15) inset;
  animation: cardEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Logo Area ── */
#authOverlay .auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

#authOverlay .auth-logo img {
  height: 70px;
  width: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 20px rgba(46,139,87,0.4));
  animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

#authOverlay .auth-logo h1 {
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
}

#authOverlay .auth-logo p {
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ── Tab Switcher ── */
#authOverlay .auth-tabs {
  display: flex;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid rgba(255,255,255,0.08);
}

#authOverlay .auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

#authOverlay .auth-tab.active {
  background: linear-gradient(135deg, #2E8B57, #1a3c6e);
  color: #fff;
  box-shadow: 0 4px 15px rgba(46,139,87,0.4);
}

/* ── Form Fields ── */
#authOverlay .field-group {
  margin-bottom: 18px;
  position: relative;
}

#authOverlay .field-label {
  display: block;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

#authOverlay .field-input {
  width: 100%;
  padding: 13px 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: #fff;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  outline: none;
  direction: ltr;
  text-align: right;
}

#authOverlay .field-input::placeholder {
  color: rgba(255,255,255,0.25);
}

#authOverlay .field-input:focus {
  border-color: rgba(46,139,87,0.6);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(46,139,87,0.15), 0 4px 20px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

/* Password Toggle */
#authOverlay .field-wrapper {
  position: relative;
}

#authOverlay .pw-toggle {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 1rem;
  transition: color 0.2s;
  padding: 4px;
}

#authOverlay .pw-toggle:hover {
  color: rgba(255,255,255,0.8);
}

/* ── Remember & Forgot ── */
#authOverlay .auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

#authOverlay .remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  cursor: pointer;
}

#authOverlay .remember-label input[type="checkbox"] {
  accent-color: #2E8B57;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#authOverlay .forgot-link {
  color: #5adb8f;
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
}

#authOverlay .forgot-link:hover {
  color: #2E8B57;
  text-decoration: underline;
}

/* ── Primary Button ── */
#authOverlay .btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2E8B57 0%, #1a6b42 50%, #2E8B57 100%);
  background-size: 200% auto;
  color: #fff;
  border: none;
  border-radius: 13px;
  font-family: 'Tajawal', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(46,139,87,0.4);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

#authOverlay .btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s ease;
}

#authOverlay .btn-primary:hover::before {
  left: 100%;
}

#authOverlay .btn-primary:hover {
  background-position: right center;
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(46,139,87,0.55);
}

#authOverlay .btn-primary:active {
  transform: translateY(0);
}

/* ── Full Access Button ── */
#authOverlay .btn-full-access {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #1a3c6e 0%, #0f2449 50%, #1a3c6e 100%);
  background-size: 200% auto;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 13px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
  margin-top: 10px;
}

#authOverlay .btn-full-access:hover {
  background-position: right center;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(26,60,110,0.5);
  border-color: rgba(255,255,255,0.2);
}

/* ── Divider ── */
#authOverlay .divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

#authOverlay .divider-line {
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

#authOverlay .divider-text {
  color: rgba(255,255,255,0.35);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── Microsoft Sign-In Button ── */
#authOverlay .btn-microsoft {
  width: 100%;
  padding: 13px 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 13px;
  color: #fff;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.3s ease;
}

#authOverlay .btn-microsoft:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#authOverlay .ms-logo {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  width: 20px;
  height: 20px;
}

#authOverlay .ms-logo span {
  width: 9px;
  height: 9px;
  display: block;
}

#authOverlay .ms-logo .ms-r { background: #f25022; }
#authOverlay .ms-logo .ms-g { background: #7fba00; }
#authOverlay .ms-logo .ms-b { background: #00a4ef; }
#authOverlay .ms-logo .ms-y { background: #ffb900; }

/* ── Microsoft Inline Form ── */
#authOverlay .ms-inline-form {
  display: none;
  animation: slideDown 0.3s ease forwards;
}

#authOverlay .ms-inline-form.active {
  display: block;
}

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

/* ── Toast Notifications ── */
#authOverlay .auth-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(20,20,30,0.95);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 14px 24px;
  border-radius: 14px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 999999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  justify-content: center;
  white-space: nowrap;
}

#authOverlay .auth-toast.show {
  transform: translateX(-50%) translateY(0);
}

#authOverlay .auth-toast.success { border-color: rgba(46,139,87,0.5); }
#authOverlay .auth-toast.error   { border-color: rgba(231,76,60,0.5); }
#authOverlay .auth-toast.info    { border-color: rgba(52,152,219,0.5); }

#authOverlay .auth-toast .toast-icon {
  font-size: 1.2rem;
}

/* ── Loading Spinner ── */
#authOverlay .auth-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

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

/* ── User Status Bar (after login) ── */
#userStatusBar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, rgba(46,139,87,0.95), rgba(26,60,110,0.95));
  backdrop-filter: blur(20px);
  color: #fff;
  padding: 8px 24px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.875rem;
  direction: rtl;
  display: none;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

#userStatusBar.visible {
  display: flex;
}

#userStatusBar .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#userStatusBar .user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  border: 2px solid rgba(255,255,255,0.3);
}

#userStatusBar .logout-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 5px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.85rem;
  transition: all 0.2s;
}

#userStatusBar .logout-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* ── Guest Badge ── */
#authOverlay .guest-note {
  text-align: center;
  color: rgba(255,255,255,0.35);
  font-size: 0.8rem;
  margin-top: 16px;
}

/* ── Password strength indicator ── */
#authOverlay .pw-strength {
  height: 3px;
  border-radius: 3px;
  margin-top: 6px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

#authOverlay .pw-strength-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.3s ease, background 0.3s ease;
}

/* ── Exit Overlay Animation ── */
#authOverlay.closing {
  animation: overlayClose 0.6s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes overlayClose {
  0%   { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

#authOverlay .auth-card.closing {
  animation: cardClose 0.6s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes cardClose {
  0%   { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.9) translateY(-30px); opacity: 0; }
}

/* ── Scrollbar hidden on overlay ── */
#authOverlay { scrollbar-width: none; }
#authOverlay::-webkit-scrollbar { display: none; }

/* ── Responsive ── */
@media (max-width: 480px) {
  #authOverlay .auth-card {
    padding: 32px 24px;
    margin: 12px;
    border-radius: 22px;
  }
  #authOverlay .auth-logo img {
    height: 55px;
  }
}

/* ── Inject standalone toast styles (used outside overlay) ── */
.auth-toast-standalone {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(15,20,30,0.97);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 14px 24px;
  border-radius: 14px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 999999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  justify-content: center;
  direction: rtl;
  pointer-events: none;
}
.auth-toast-standalone.show {
  transform: translateX(-50%) translateY(0);
}
.auth-toast-standalone.success { border-color: rgba(46,139,87,0.6); }
.auth-toast-standalone.error   { border-color: rgba(231,76,60,0.6); }
.auth-toast-standalone.info    { border-color: rgba(52,152,219,0.6); }
