/*
  Auth Module (Login / Forgot Password / Reset Password)
  Scope: only views whose <body> has `.auth-page`.
  One full-bleed dark scene (not a light-card-on-panel template): an animated
  "growth journey" line as the hero motif, a glass form panel, underline
  inputs. Shares the navy/teal palette from crm-ui.css so it still reads as
  the same product as the dashboard behind it.
*/

body.auth-page {
  --auth-navy: #0a1830;
  --auth-navy-2: #0e2340;
  --auth-teal: #14b8ad;
  --auth-teal-light: #6fe9dd;
  --auth-blue: #4f8fe0;
  --auth-green: #3ddc97;
  --auth-red: #ff6b7a;
  --auth-amber: #f2b84b;
  --auth-ink: #eaf2f7;
  --auth-muted: #9db0c4;
  --auth-line: rgba(255, 255, 255, 0.16);
  --auth-glass-bg: rgba(255, 255, 255, 0.055);
  --auth-glass-border: rgba(255, 255, 255, 0.14);

  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 82% 8%, #123554 0%, transparent 55%), linear-gradient(165deg, var(--auth-navy) 0%, #081422 100%);
  color: var(--auth-ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

body.auth-page * {
  box-sizing: border-box;
}

/* ---------- Ambient background: aurora glows + journey line ---------- */

.auth-aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-aurora__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.4;
  will-change: transform;
}

.auth-aurora__glow--1 {
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, var(--auth-teal) 0%, transparent 70%);
  top: -220px;
  right: -160px;
  animation: authGlowDrift1 24s ease-in-out infinite;
}

.auth-aurora__glow--2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, var(--auth-blue) 0%, transparent 70%);
  bottom: -220px;
  left: -140px;
  animation: authGlowDrift2 28s ease-in-out infinite;
}

.auth-aurora__glow--3 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, #7b5fe0 0%, transparent 70%);
  top: 38%;
  left: 8%;
  opacity: 0.22;
  animation: authGlowDrift3 20s ease-in-out infinite;
}

@keyframes authGlowDrift1 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-40px, 50px); } }
@keyframes authGlowDrift2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(35px, -35px); } }
@keyframes authGlowDrift3 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(20px, 25px) scale(1.1); } }

.auth-journey {
  position: absolute;
  top: 14%;
  left: 0;
  width: 100%;
  height: 46vh;
  min-height: 260px;
  max-height: 460px;
  overflow: visible;
  z-index: 0;
  pointer-events: none;
}

.auth-journey__path {
  fill: none;
  stroke: url(#authJourneyGradient);
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(20, 184, 173, 0.55));
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: authJourneyDraw 3.2s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

.auth-journey__dot {
  fill: var(--auth-teal-light);
  filter: drop-shadow(0 0 8px rgba(111, 233, 221, 0.85));
  opacity: 0;
  transform-origin: center;
  animation: authDotPop 0.6s ease-out forwards;
  animation-delay: var(--d, 0.6s);
}

@keyframes authJourneyDraw {
  to { stroke-dashoffset: 0; }
}

@keyframes authDotPop {
  0% { opacity: 0; transform: scale(0); }
  60% { opacity: 1; transform: scale(1.35); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes authDotPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(111, 233, 221, 0.6)); }
  50% { filter: drop-shadow(0 0 16px rgba(111, 233, 221, 1)); }
}

.auth-journey__dot {
  animation: authDotPop 0.6s ease-out forwards var(--d, 0.6s), authDotPulse 2.6s ease-in-out infinite 2s;
}

/* ---------- Scene layout ---------- */

.auth-scene {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 56px;
  padding: 48px 24px;
}

.auth-story {
  text-align: center;
  max-width: 640px;
}

.auth-story__word {
  margin: 0;
  font-size: clamp(42px, 8vw, 88px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  background: linear-gradient(90deg, #ffffff 15%, var(--auth-teal-light) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-story__rule {
  width: 84px;
  height: 3px;
  margin: 22px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--auth-teal), transparent);
}

.auth-story__tag {
  margin: 22px auto 0;
  max-width: 460px;
  color: var(--auth-muted);
  font-size: 17px;
  line-height: 1.95;
  font-weight: 300;
}

/* ---------- Glass card ---------- */

.auth-glass {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 40px 34px;
  border-radius: 22px;
  background: var(--auth-glass-bg);
  border: 1px solid var(--auth-glass-border);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 90px rgba(3, 10, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: authGlassIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .auth-glass {
    background: rgba(14, 30, 52, 0.92);
  }
}

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

.auth-glass__title {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 800;
  color: #ffffff;
}

.auth-glass__sub {
  margin: 0 0 26px;
  color: var(--auth-muted);
  font-size: 14px;
  line-height: 1.7;
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.7;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.auth-alert--error {
  background: rgba(255, 107, 122, 0.12);
  border-color: rgba(255, 107, 122, 0.3);
  color: #ffb3ba;
}

.auth-alert--success {
  background: rgba(61, 220, 151, 0.1);
  border-color: rgba(61, 220, 151, 0.3);
  color: #a3f0d1;
}

.auth-alert--info {
  background: rgba(79, 143, 224, 0.12);
  border-color: rgba(79, 143, 224, 0.3);
  color: #b7d3f7;
}

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

/* underline fields -- deliberately not boxed inputs */

.auth-line-field label {
  display: block;
  margin-bottom: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--auth-muted);
}

.auth-line-field input {
  width: 100%;
  padding: 8px 2px 12px;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--auth-line);
  color: #ffffff;
  font-size: 16px;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-line-field input::placeholder {
  color: rgba(234, 242, 247, 0.32);
}

.auth-line-field input:focus {
  outline: none;
  border-bottom-color: var(--auth-teal-light);
  box-shadow: 0 1px 0 0 var(--auth-teal-light);
}

.auth-line-field input.auth-input--error {
  border-bottom-color: var(--auth-red);
}

/* Neutralize the browser's forced light autofill background so fields stay
   dark/transparent even once the browser has remembered a value. */
.auth-line-field input:-webkit-autofill,
.auth-line-field input:-webkit-autofill:hover,
.auth-line-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: #ffffff;
  -webkit-box-shadow: 0 0 0 1000px #0e2038 inset;
  box-shadow: 0 0 0 1000px #0e2038 inset;
  caret-color: #ffffff;
  transition: background-color 9999s ease-in-out 0s;
}

.auth-field-error {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--auth-red);
}

.auth-line-field__pass {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1.5px solid var(--auth-line);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-line-field__pass:focus-within {
  border-bottom-color: var(--auth-teal-light);
  box-shadow: 0 1px 0 0 var(--auth-teal-light);
}

.auth-line-field__pass input {
  flex: 1;
  min-width: 0;
  border-bottom: none;
}

.auth-line-field__pass input:focus {
  box-shadow: none;
}

.auth-toggle-pass {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--auth-muted);
  cursor: pointer;
  padding: 4px;
  margin-bottom: 4px;
}

.auth-toggle-pass:hover {
  color: var(--auth-teal-light);
}

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

.auth-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px;
}

.auth-link {
  color: var(--auth-teal-light);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-cta {
  position: relative;
  height: 50px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--auth-teal) 0%, var(--auth-blue) 100%);
  background-size: 160% 160%;
  color: #06131f;
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(20, 184, 173, 0.28);
  transition: box-shadow 0.2s ease, transform 0.12s ease, background-position 0.4s ease;
  margin-top: 6px;
}

.auth-cta:hover {
  background-position: 100% 0;
  box-shadow: 0 22px 50px rgba(20, 184, 173, 0.4);
  transform: translateY(-1px);
}

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

.auth-cta:disabled {
  background: rgba(255, 255, 255, 0.12);
  color: var(--auth-muted);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.auth-foot {
  margin-top: 26px;
  text-align: center;
  font-size: 13px;
  color: var(--auth-muted);
}

.auth-status-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  background: rgba(242, 184, 75, 0.14);
  color: var(--auth-amber);
}

.auth-status-icon svg {
  width: 26px;
  height: 26px;
}

.auth-glass--center {
  text-align: center;
}

@media (min-width: 900px) {
  .auth-scene {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 96px;
    padding: 48px;
  }

  .auth-story {
    text-align: start;
  }

  .auth-story__rule {
    margin: 22px 0 0;
  }

  .auth-story__tag {
    margin: 22px 0 0;
  }
}

@media (max-width: 480px) {
  .auth-glass {
    padding: 30px 22px;
  }

  .auth-glass__title {
    font-size: 20px;
  }

  .auth-journey {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-aurora__glow,
  .auth-journey__path,
  .auth-journey__dot,
  .auth-glass {
    animation: none !important;
  }

  .auth-journey__path {
    stroke-dashoffset: 0;
  }

  .auth-journey__dot {
    opacity: 1;
    transform: scale(1);
  }
}

/* Language switch (Arabic / English) on the sign-in pages. */
.crm-lang-floating {
  position: fixed;
  top: 18px;
  inset-inline-end: 18px;
  z-index: 5;
}

body.auth-page .crm-lang-switch {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--auth-glass-border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.auth-page .crm-lang-switch__opt {
  color: var(--auth-muted);
  font-weight: 900;
}

body.auth-page .crm-lang-switch__opt.is-active {
  color: #ffffff;
}

body.auth-page .crm-lang-switch__thumb {
  background: linear-gradient(135deg, var(--auth-teal), var(--auth-blue));
  box-shadow: 0 8px 18px rgba(20, 184, 173, 0.3);
}
