/* ═══════════════════════════════════════════════════════════
   auth.css — Login & Register Pages
   ═══════════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-primary);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
}

/* Background glow effect */
.auth-page::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-primary-glow) 0%, transparent 70%);
  top: -100px;
  left: -100px;
  animation: float 6s ease-in-out infinite;
}
.auth-page::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 38, 38, 0.1) 0%, transparent 70%);
  bottom: -80px;
  right: -80px;
  animation: float 8s ease-in-out infinite reverse;
}

.auth-container {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 920px;
  min-height: 560px;
  display: flex;
  flex-direction: row-reverse; /* Visual on right, form on left */
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--transition-base) ease;
  overflow: hidden;
}

/* Visual Panel */
.auth-visual-panel {
  flex: 1.1;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.auth-visual-bg {
  position: absolute;
  inset: -10px; /* Expand bounds to prevent blur-bleeding on container edges */
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
  filter: blur(2px); /* Premium blurring effect for text readability */
  z-index: 0;
}

.auth-visual-bg.active {
  opacity: 1;
}

.auth-visual-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(10, 10, 10, 0.3) 0%, rgba(10, 10, 10, 0.85) 100%);
  pointer-events: none;
}

.auth-visual-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.auth-visual-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-end; /* Align logo and app name to the left side in RTL column */
}

.auth-visual-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.auth-visual-logo span {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.auth-visual-slider {
  margin-top: auto;
}

.slider-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.slider-desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-4);
}

.slider-dots {
  display: flex;
  gap: 8px;
}

.slider-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  transition: all var(--transition-base);
  cursor: pointer;
}

.slider-dots .dot.active {
  width: 24px;
  background: var(--color-primary);
}

/* Form Panel */
.auth-form-panel {
  flex: 1;
  padding: var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrapper .form-input {
  padding-left: 45px; /* RTL layout: the field end is on the left side */
}

.password-toggle-btn {
  position: absolute;
  left: 14px;
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.password-toggle-btn:hover {
  color: var(--color-text-primary);
  transform: scale(1.1);
}

.password-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Password Strength Indicator */
.password-strength-container {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.password-strength-bar-wrapper {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.password-strength-bar {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* Strength levels classes */
.password-strength-bar.weak {
  width: 33%;
  background-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.password-strength-bar.medium {
  width: 66%;
  background-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.password-strength-bar.strong {
  width: 100%;
  background-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.password-strength-text {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  transition: color 0.2s ease;
}

.password-strength-text.weak { color: var(--color-primary); }
.password-strength-text.medium { color: var(--color-primary); }
.password-strength-text.strong { color: var(--color-primary); }

/* Password requirements details */
.password-requirements {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-3);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.requirement-item {
  font-size: var(--text-xs);
  color: var(--color-error); /* Red by default for unfulfilled requirements */
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--transition-fast);
}

.requirement-item.valid {
  color: var(--color-text-primary); /* White when met */
}

.requirement-item svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: inherit; /* Inherits the red/green color automatically */
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.requirement-item.valid svg {
  transform: scale(1.1);
}

.auth-form .form-input {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-switch {
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.auth-switch a {
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}
.auth-switch a:hover {
  color: var(--color-primary-light);
  text-decoration: underline;
}

.auth-error {
  padding: var(--space-3);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--color-error);
  font-size: var(--text-sm);
  text-align: center;
  animation: fadeSlideUp var(--transition-fast) ease;
}

/* Mobile Responsive styling matching the 3rd mockup */
@media (max-width: 768px) {
  .auth-container {
    flex-direction: column;
    max-width: 440px;
    min-height: auto;
    border-radius: var(--radius-xl);
  }

  .auth-visual-panel {
    height: 240px;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-6);
  }

  .auth-visual-bg::after {
    background: linear-gradient(rgba(10, 10, 10, 0.4), rgba(10, 10, 10, 0.85));
  }

  .auth-visual-content {
    justify-content: flex-end;
  }

  .auth-visual-logo {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4); /* Align to the left on mobile viewports */
  }

  .auth-visual-slider {
    margin-top: 0;
  }

  .slider-title {
    font-size: var(--text-lg);
  }

  .slider-desc {
    font-size: var(--text-xs);
    margin-bottom: var(--space-2);
  }

  .auth-form-panel {
    padding: var(--space-6) var(--space-6) var(--space-8);
  }
}


/* ═════════════ Two-factor: first-time setup, code inputs, 6-hour lock ═════════════ */
.auth-2fa-head { text-align: center; }
.auth-2fa-head .auth-subtitle { margin-bottom: var(--space-4); line-height: 1.7; }
.auth-2fa-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(220, 38, 38, 0.1);
  color: var(--color-primary);
  font-size: 1.35rem;
  margin-bottom: var(--space-2);
}
.auth-2fa-setup {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 14px);
  background: rgba(255, 255, 255, 0.02);
}
.auth-qr {
  width: 128px;
  height: 128px;
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.auth-qr-skeleton {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #eee 0%, #f7f7f7 50%, #eee 100%);
  background-size: 200% 100%;
  animation: authShimmer 1.2s linear infinite;
}
@keyframes authShimmer { to { background-position: -200% 0; } }
.auth-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.auth-steps li { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.auth-steps li > div { min-width: 0; }
.auth-steps strong { display: block; font-size: var(--text-sm); color: var(--color-text-primary); font-weight: var(--font-weight-semibold, 600); }
.auth-steps span { display: block; font-size: var(--text-xs); color: var(--color-text-secondary); line-height: 1.6; }
.auth-secret-row {
  grid-column: 1 / -1;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.auth-step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff !important;
  font-size: 0.72rem !important;
  font-weight: 700;
  margin-top: 1px;
}
.auth-secret {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 4px 4px 10px;
  border: 1px dashed var(--color-border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  max-width: 100%;
}
.auth-secret code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
  text-align: left;
}
.auth-secret-copy {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.auth-secret-copy:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--color-text-primary); }
.auth-code-input {
  text-align: center;
  font-size: 1.5rem !important;
  letter-spacing: 0.5em;
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.75rem calc(0.75rem + 0.5em) !important;
  font-variant-numeric: tabular-nums;
}
.auth-code-input.invalid { border-color: var(--color-error) !important; animation: authShake 0.32s ease; }
@keyframes authShake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* 6-hour lock screen — sits over the app; only the 2FA code is needed to continue */
.reauth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  animation: reauthIn 0.22s ease;
}
.reauth-overlay.closing { opacity: 0; transition: opacity 0.18s ease; }
@keyframes reauthIn { from { opacity: 0; } }
.reauth-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: var(--space-8, 2rem) var(--space-6, 1.5rem) var(--space-6, 1.5rem);
  border-radius: 20px;
  background: var(--color-bg-secondary, #141414);
  border: 1px solid var(--color-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: reauthCard 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes reauthCard { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
.reauth-title { font-size: var(--text-xl); font-weight: var(--font-weight-bold); color: var(--color-text-primary); margin: 0 0 6px; }
.reauth-desc { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.7; margin: 0 0 var(--space-4); }
.reauth-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: var(--space-4);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}
.reauth-user bdi { color: var(--color-text-muted); font-size: var(--text-xs); }
.reauth-card .auth-error { margin-bottom: var(--space-3); }
.reauth-card .auth-form { gap: var(--space-3); }
.reauth-logout {
  margin-top: var(--space-4);
  border: none;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.reauth-logout:hover { color: var(--color-text-primary); }
body.light-theme .reauth-overlay { background: rgba(240, 240, 244, 0.7); }
body.light-theme .reauth-card { background: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.15); }
body.light-theme .auth-secret { background: rgba(0, 0, 0, 0.03); }

@media (max-width: 520px) {
  .auth-2fa-setup { grid-template-columns: 112px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3); }
  .auth-qr { width: 112px; height: 112px; }
}
@media (prefers-reduced-motion: reduce) {
  .reauth-overlay, .reauth-card, .auth-code-input.invalid, .auth-qr-skeleton { animation: none !important; }
}
