/* Standalone login page — scoped; does not affect the rest of the app. */
:root {
  --login-bg: #090b07;
  --login-card: #10140d;
  --login-card-elevated: #141a11;
  --login-imperial: #075b43;
  --login-gold-hi: #ffe08a;
  --login-gold: #d9ae36;
  --login-gold-mid: #c9a227;
  --login-gold-deep: #916a0a;
  --login-ink: #f5e7bf;
  --login-muted: #b8ae91;
  --login-line: rgba(217, 174, 54, 0.45);
  --login-line-soft: rgba(217, 174, 54, 0.22);
  --login-input-bg: #0c100a;
  --login-input-focus: #12180f;
  --login-danger: #f2b8b5;
  --login-danger-bg: rgba(180, 35, 24, 0.16);
  --login-danger-border: rgba(242, 184, 181, 0.28);
  --login-radius: 22px;
  --login-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --login-font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --login-submit-text: #1a1408;
  --login-hover: rgba(217, 174, 54, 0.1);
  --login-menu-bg: #161c12;
  --login-placeholder: #8a8168;
  --login-atm:
    radial-gradient(ellipse 70% 60% at 12% 8%, rgba(217, 174, 54, 0.14), transparent 58%),
    radial-gradient(ellipse 65% 55% at 92% 96%, rgba(201, 162, 39, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(12, 10, 7, 0.65), transparent 70%),
    linear-gradient(180deg, #0a0907 0%, #080706 45%, #060504 100%);
  --login-orb-a-opacity: 0.72;
  --login-orb-b-opacity: 0.68;
  --login-orb-c-opacity: 0.18;
  --login-grid-opacity: 0.032;
  --login-panel-shadow:
    0 1px 0 rgba(255, 224, 138, 0.08) inset,
    0 0 0 1px rgba(7, 91, 67, 0.25),
    0 24px 56px rgba(0, 0, 0, 0.55),
    0 0 48px rgba(217, 174, 54, 0.08);
  --login-logo-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 14px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(217, 174, 54, 0.28);
  --login-title-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  --login-alert-info-color: var(--login-gold-hi);
  --login-pref-bg: rgba(16, 20, 13, 0.82);
  --login-menu-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--login-line-soft);
}

/* Light theme — warm champagne luxury (login only) */
html[data-theme="light"],
html[data-theme="system"][data-resolved="light"] {
  --login-bg: #f4efe4;
  --login-card: #fffcf5;
  --login-card-elevated: #fffaf0;
  --login-ink: #1c160c;
  --login-muted: #6b5c45;
  --login-line: rgba(145, 106, 10, 0.35);
  --login-line-soft: rgba(145, 106, 10, 0.2);
  --login-input-bg: #fff;
  --login-input-focus: #fffef8;
  --login-gold-hi: #8b6914;
  --login-gold: #c9a227;
  --login-gold-deep: #916a0a;
  --login-danger: #b42318;
  --login-danger-bg: #fef3f2;
  --login-danger-border: rgba(180, 35, 24, 0.18);
  --login-hover: rgba(201, 162, 39, 0.12);
  --login-menu-bg: #fffcf5;
  --login-placeholder: #a3947c;
  --login-submit-text: #1a1408;
  --login-atm:
    radial-gradient(ellipse 70% 60% at 12% 8%, rgba(217, 174, 54, 0.28), transparent 58%),
    radial-gradient(ellipse 65% 55% at 92% 96%, rgba(201, 162, 39, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(255, 252, 246, 0.55), transparent 70%),
    linear-gradient(180deg, #f8f2e6 0%, #f0e8d6 48%, #e8dcc4 100%);
  --login-orb-a-opacity: 0.55;
  --login-orb-b-opacity: 0.5;
  --login-orb-c-opacity: 0.22;
  --login-grid-opacity: 0.055;
  --login-panel-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 18px 48px rgba(92, 74, 42, 0.12),
    0 0 0 1px rgba(201, 162, 39, 0.18);
  --login-logo-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 12px 28px rgba(11, 61, 46, 0.28),
    0 0 0 1px rgba(201, 162, 39, 0.28);
  --login-title-shadow: none;
  --login-alert-info-color: var(--login-gold-deep);
  --login-pref-bg: rgba(255, 252, 245, 0.88);
  --login-menu-shadow: 0 18px 40px rgba(92, 74, 42, 0.14), 0 0 0 1px var(--login-line-soft);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.login-body {
  margin: 0;
  min-height: 100%;
  font-family: var(--login-font);
  color: var(--login-ink);
  background: var(--login-bg);
  -webkit-font-smoothing: antialiased;
}

.login-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 4vw, 2.75rem);
  overflow: hidden;
}

/* —— Atmosphere —— */
.login-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--login-atm);
}

/* Mesh: same spacing; bend around card; very faint */
.login-atm-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 45%;
  opacity: var(--login-grid-opacity);
  pointer-events: none;
  user-select: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}

/* Large soft gold blob — upper-left (like reference magenta) */
.login-orb--a {
  width: min(72vw, 640px);
  height: min(72vw, 640px);
  top: -28%;
  inset-inline-start: -18%;
  opacity: var(--login-orb-a-opacity);
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255, 224, 138, 0.55) 0%,
      rgba(217, 174, 54, 0.32) 32%,
      rgba(166, 124, 40, 0.12) 58%,
      transparent 76%);
}

/* Large soft gold blob — lower-right */
.login-orb--b {
  width: min(78vw, 700px);
  height: min(78vw, 700px);
  bottom: -32%;
  inset-inline-end: -22%;
  opacity: var(--login-orb-b-opacity);
  background:
    radial-gradient(circle at 50% 50%,
      rgba(240, 215, 138, 0.48) 0%,
      rgba(201, 162, 39, 0.28) 34%,
      rgba(145, 106, 10, 0.1) 60%,
      transparent 76%);
}

/* Soft bridge wash — keeps harmony between the two corner lights */
.login-orb--c {
  width: min(50vw, 420px);
  height: min(50vw, 420px);
  top: 48%;
  left: 50%;
  transform: translate(-50%, -40%);
  inset-inline-start: auto;
  opacity: var(--login-orb-c-opacity);
  background:
    radial-gradient(circle at 50% 50%,
      rgba(217, 174, 54, 0.2) 0%,
      rgba(145, 106, 10, 0.06) 50%,
      transparent 72%);
  filter: blur(100px);
}

/* —— Toolbar —— */
.login-toolbar {
  position: absolute;
  z-index: 5;
  top: clamp(0.85rem, 2.5vw, 1.25rem);
  inset-inline-end: clamp(0.85rem, 2.5vw, 1.25rem);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.login-pref {
  position: relative;
}

.login-pref-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--login-line-soft);
  border-radius: 12px;
  background: var(--login-pref-bg);
  color: var(--login-ink);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  padding: 0;
  font: inherit;
  transition:
    background-color 0.18s var(--login-ease),
    border-color 0.18s var(--login-ease);
}

.login-pref-btn:hover {
  background: var(--login-hover);
  border-color: var(--login-line);
}

.login-pref-btn:focus-visible {
  outline: 2px solid var(--login-gold);
  outline-offset: 2px;
}

.login-lang-code {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--login-gold-hi);
}

.login-pref--theme .icon-sun,
.login-pref--theme .icon-moon,
.login-pref--theme .icon-system {
  display: none;
}

html[data-theme="light"] .login-pref--theme .icon-sun { display: block; }
html[data-theme="dark"] .login-pref--theme .icon-moon { display: block; }
html[data-theme="system"] .login-pref--theme .icon-system { display: block; }

.login-pref-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 172px;
  padding: 0.4rem;
  background: var(--login-menu-bg);
  border-radius: 14px;
  box-shadow: var(--login-menu-shadow);
  border: 1px solid var(--login-line-soft);
  display: none;
  z-index: 60;
}

.login-pref-menu.open {
  display: block;
}

.login-pref-menu form {
  margin: 0;
}

.login-pref-menu button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--login-ink);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: start;
}

.login-pref-menu button:hover {
  background: var(--login-hover);
}

.login-pref-menu button.active {
  background: rgba(217, 174, 54, 0.14);
  color: var(--login-gold-hi);
}

.login-pref-menu button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.login-lang-flag {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--login-hover);
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--login-gold);
}

/* —— Stage: card + tagline —— */
.login-stage {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.35rem;
}

.login-panel {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: clamp(1.75rem, 4vw, 2.4rem);
  border-radius: var(--login-radius);
  background:
    linear-gradient(165deg, rgba(217, 174, 54, 0.06) 0%, transparent 42%),
    var(--login-card);
  border: 1px solid var(--login-line);
  box-shadow: var(--login-panel-shadow);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset-inline: 1.5rem;
  top: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--login-gold-hi) 22%,
    var(--login-gold) 50%,
    var(--login-gold-hi) 78%,
    transparent
  );
  opacity: 0.75;
  pointer-events: none;
}

/* —— Brand —— */
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.9rem;
  margin-bottom: 1.55rem;
  width: 100%;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-align: center;
}

.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  overflow: hidden;
  background: var(--login-imperial);
  box-shadow: var(--login-logo-shadow);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-inline: auto;
}

.login-logo-mark {
  width: 76px;
  height: 76px;
  display: block;
  object-fit: cover;
}

.login-brand h1 {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  width: 100%;
  font-size: clamp(1.5rem, 3.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-align: center;
  color: var(--login-gold-hi);
  text-shadow: var(--login-title-shadow);
}

/* Keep Latin title optically centered in both RTL and LTR pages */
.login-brand-title {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}

.login-brand p {
  margin: 0.2rem 0 0;
  color: var(--login-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 30ch;
  text-align: center;
}

/* —— Alerts —— */
.login-alerts {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.login-alerts:empty {
  display: none;
  margin: 0;
}

.login-alert {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.45;
  border: 1px solid transparent;
}

.login-alert--error {
  background: var(--login-danger-bg);
  color: var(--login-danger);
  border-color: var(--login-danger-border);
}

.login-alert--info {
  background: rgba(217, 174, 54, 0.12);
  color: var(--login-alert-info-color);
  border-color: var(--login-line-soft);
}

/* —— Form —— */
.login-form {
  display: grid;
  gap: 1rem;
}

.login-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  max-width: 100%;
}

.login-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--login-muted);
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  inset-inline-start: 0.9rem;
  width: 18px;
  height: 18px;
  color: var(--login-gold);
  opacity: 0.72;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.login-input-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-field input {
  width: 100%;
  height: 48px;
  padding: 0 0.95rem;
  padding-inline-start: 2.65rem;
  border-radius: 12px;
  border: 1px solid var(--login-line-soft);
  background: var(--login-input-bg);
  color: var(--login-ink);
  font: inherit;
  font-size: 0.98rem;
  outline: none;
  transition:
    border-color 0.2s var(--login-ease),
    box-shadow 0.2s var(--login-ease),
    background-color 0.2s var(--login-ease);
}

.login-field input::placeholder {
  color: var(--login-placeholder);
}

.login-field input:hover {
  border-color: var(--login-line);
}

.login-field input:focus {
  border-color: var(--login-gold);
  box-shadow: 0 0 0 3px rgba(217, 174, 54, 0.18);
  background: var(--login-input-focus);
}

.login-field .errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--login-danger);
  font-size: 0.8rem;
}

.login-captcha {
  min-width: 0;
  max-width: 100%;
}

/* Image on its own row (keeps captcha aspect); digits input + refresh below */
.login-captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem 0.5rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.login-captcha-row input[type="hidden"] {
  display: none;
}

.login-captcha-row img.captcha {
  grid-column: 1 / -1;
  justify-self: start;
  display: block;
  width: 150px;
  max-width: 100%;
  height: 48px;
  aspect-ratio: 150 / 48;
  object-fit: cover;
  object-position: center;
  border: 0;
  outline: 0;
  box-shadow: none;
  border-radius: 10px;
  background: #fff;
  /* Crop the 1px raster edge baked into django-simple-captcha PNGs */
  clip-path: inset(1.5px round 9px);
}

.login-captcha-row input[type="text"] {
  grid-column: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-align: start;
  letter-spacing: 0.06em;
  font-size: 0.9rem;
  padding-inline: 0.85rem !important;
}

.login-captcha-row input[type="text"]::placeholder {
  letter-spacing: 0;
  font-size: 0.82rem;
  opacity: 0.85;
}

.login-captcha-refresh {
  grid-column: 2;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--login-line-soft);
  border-radius: 12px;
  background: var(--login-input-bg);
  color: var(--login-muted);
  cursor: pointer;
}

.login-captcha-refresh:hover {
  background: var(--login-hover);
  color: var(--login-gold-hi);
  border-color: var(--login-line);
}

.login-captcha-refresh:focus-visible {
  outline: 2px solid var(--login-gold);
  outline-offset: 2px;
}

.login-captcha-hint {
  margin: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--login-muted);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  white-space: normal;
}

.login-submit {
  margin-top: 0.4rem;
  height: 50px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe08a 0%, #d9ae36 48%, #916a0a 100%);
  color: var(--login-submit-text);
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 10px 24px rgba(145, 106, 10, 0.35);
  transition:
    transform 0.18s var(--login-ease),
    box-shadow 0.18s var(--login-ease),
    filter 0.18s var(--login-ease);
}

.login-submit:hover {
  filter: brightness(1.04);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 12px 28px rgba(145, 106, 10, 0.42);
}

.login-submit:active {
  transform: translateY(1px) scale(0.99);
}

.login-submit.is-waiting {
  cursor: progress;
  opacity: 0.8;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.login-submit.is-waiting::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-wait-spin 0.7s linear infinite;
}

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

.login-submit:focus-visible {
  outline: 2px solid var(--login-gold-hi);
  outline-offset: 3px;
}

.login-foot {
  margin: 1.4rem 0 0;
  padding-top: 1.1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--login-muted);
  letter-spacing: 0.02em;
  border-top: 1px solid transparent;
  border-image: linear-gradient(
    90deg,
    transparent,
    rgba(217, 174, 54, 0.35) 30%,
    rgba(217, 174, 54, 0.35) 70%,
    transparent
  ) 1;
}

/* —— Tagline under card —— */
.login-tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  margin: 0;
  padding: 0 0.25rem;
  color: var(--login-gold);
  font-size: clamp(0.68rem, 2.2vw, 0.78rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
  text-shadow: 0 0 18px rgba(217, 174, 54, 0.25);
  opacity: 0.88;
}

.login-tagline::before,
.login-tagline::after {
  content: "";
  flex: 1;
  max-width: 72px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 174, 54, 0.55));
}

.login-tagline::after {
  background: linear-gradient(90deg, rgba(217, 174, 54, 0.55), transparent);
}

/* —— Responsive —— */
@media (max-width: 480px) {
  .login-shell {
    padding: 1rem 0.9rem 1.5rem;
    align-items: start;
    padding-top: max(4.5rem, 12vh);
  }

  .login-panel {
    padding: 1.45rem 1.2rem 1.55rem;
  }

  .login-logo,
  .login-logo-mark {
    width: 68px;
    height: 68px;
    border-radius: 18px;
  }

  .login-atm-grid {
    opacity: calc(var(--login-grid-opacity) * 0.7);
  }

  .login-orb--a {
    opacity: calc(var(--login-orb-a-opacity) * 0.78);
  }

  .login-orb--b {
    opacity: calc(var(--login-orb-b-opacity) * 0.78);
  }

  .login-orb--c {
    opacity: calc(var(--login-orb-c-opacity) * 0.7);
  }

  .login-captcha-row img.captcha {
    width: 140px;
    height: 45px;
  }

  .login-tagline {
    letter-spacing: 0.14em;
    gap: 0.55rem;
  }

  .login-tagline::before,
  .login-tagline::after {
    max-width: 40px;
  }
}

@media (max-height: 720px) {
  .login-shell {
    align-items: start;
    padding-top: max(3.5rem, 6vh);
    padding-bottom: 1.5rem;
  }

  .login-brand {
    margin-bottom: 1.1rem;
    gap: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-submit.is-waiting::before {
    animation: none !important;
  }

  .login-submit,
  .login-pref-btn,
  .login-field input {
    transition: none !important;
  }
}
