/* JIG OTP — world-class public shell (mobile-first, perfectly centered) */
:root {
  --jig-font: "Vazirmatn", Tahoma, sans-serif;
  --jig-font-heading: var(--jig-font);
  --jig-radius: 18px;
  --jig-glass-blur: 22px;
  --jig-page-bg: #0a0d12;
  --jig-overlay: rgba(6, 8, 12, 0.62);
  --jig-btn-text: #061012;
  --jig-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --jig-bg: #0c1016;
  --jig-surface: rgba(18, 24, 32, 0.92);
  --jig-surface-2: rgba(255, 255, 255, 0.05);
  --jig-text: #f5f8fa;
  --jig-muted: #a7b1bc;
  --jig-accent: #1fa7a0;
  --jig-accent-2: #3bd4cb;
  --jig-danger: #e35d6a;
  --jig-ok: #3ecf8e;
  --jig-border: rgba(255, 255, 255, 0.12);
  --jig-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  --jig-safe-t: env(safe-area-inset-top, 0px);
  --jig-safe-r: env(safe-area-inset-right, 0px);
  --jig-safe-b: env(safe-area-inset-bottom, 0px);
  --jig-safe-l: env(safe-area-inset-left, 0px);
}

.jig-otp,
.jig-otp * {
  box-sizing: border-box;
}

/* ===== Login stage / atmospheric background ===== */
.jig-otp-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.jig-otp-stage--css {
  background:
    radial-gradient(1200px 700px at 85% -10%, color-mix(in srgb, var(--jig-accent) 28%, transparent), transparent 55%),
    radial-gradient(900px 600px at 0% 100%, color-mix(in srgb, var(--jig-accent-2) 16%, transparent), transparent 50%),
    linear-gradient(160deg, #07090d 0%, #10161f 48%, #0b1016 100%);
}

.jig-otp-stage--css::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 75%);
  opacity: 0.45;
}

.jig-otp-stage__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.06);
}

.jig-otp-stage__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 30%, transparent 0%, rgba(0, 0, 0, 0.35) 70%),
    var(--jig-overlay);
}

/* ===== Modal overlay shell — always centered ===== */
.jig-otp {
  font-family: var(--jig-font);
  color: var(--jig-text);
  direction: rtl;
}

.jig-otp[hidden] {
  display: none !important;
}

#jig-otp-root.jig-otp:not([hidden]),
.jig-otp.jig-otp--overlay:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(12px, var(--jig-safe-t))
    max(12px, var(--jig-safe-r))
    max(12px, var(--jig-safe-b))
    max(12px, var(--jig-safe-l));
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

html.jig-otp-open,
html.jig-otp-open body {
  overflow: hidden;
}

.jig-otp__backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--jig-accent) 18%, transparent), transparent 55%),
    rgba(5, 7, 10, 0.78);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  opacity: 0;
  animation: jig-fade 0.35s var(--jig-ease) forwards;
  cursor: pointer;
}

.jig-otp__modal {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 24px));
  max-width: 100%;
  max-height: none;
  margin: auto;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--jig-accent) 10%, transparent), transparent 42%),
    var(--jig-surface);
  border: 1px solid var(--jig-border);
  border-radius: calc(var(--jig-radius) + 4px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--jig-accent) 12%, transparent),
    var(--jig-shadow);
  overflow: visible;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  animation: jig-rise 0.48s var(--jig-ease) forwards;
  isolation: isolate;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.jig-otp__modal,
.jig-otp__panel,
.jig-otp-inline,
#jig-otp-root.jig-otp:not([hidden]) {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.jig-otp__modal::-webkit-scrollbar,
.jig-otp__panel::-webkit-scrollbar,
#jig-otp-root::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.jig-otp__modal::before {
  content: "";
  position: absolute;
  inset-inline: 18%;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--jig-accent), var(--jig-accent-2), transparent);
  z-index: 2;
}

.jig-otp__modal::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--jig-accent) 22%, transparent), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

.jig-otp__panel {
  position: relative;
  z-index: 1;
  padding: clamp(16px, 2.8vw, 22px) clamp(14px, 3vw, 22px) clamp(12px, 2.2vw, 18px);
  overflow: visible;
  max-height: none;
}

.jig-otp__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: clamp(10px, 2vw, 16px);
  text-align: center;
}

.jig-otp__eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--jig-accent);
  text-transform: uppercase;
  font-weight: 700;
}

.jig-otp__brand h2 {
  margin: 0;
  font-family: var(--jig-font-heading);
  font-size: clamp(1.28rem, 3.6vw, 1.65rem);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.jig-otp__brand p {
  margin: 0;
  color: var(--jig-muted);
  font-size: clamp(0.88rem, 2.6vw, 0.95rem);
  line-height: 1.75;
  max-width: 32ch;
}

.jig-otp__logo {
  height: 52px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  display: block;
  margin-inline: auto;
}

.jig-otp__mark {
  width: 52px;
  height: 52px;
  max-width: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--jig-accent-2), var(--jig-accent));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 12px 32px color-mix(in srgb, var(--jig-accent) 40%, transparent);
  display: block;
  margin-inline: auto;
}

.jig-otp__subtitle {
  margin: 0;
  color: var(--jig-muted);
  font-size: clamp(0.88rem, 2.6vw, 0.95rem);
  line-height: 1.75;
  max-width: 32ch;
}

.jig-otp__brand .screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}

.jig-otp__close {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border: 1px solid var(--jig-border);
  background: color-mix(in srgb, var(--jig-bg) 70%, transparent);
  color: var(--jig-muted);
  border-radius: 12px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: 0.2s var(--jig-ease);
}

.jig-otp__close:hover,
.jig-otp__close:focus-visible {
  color: var(--jig-text);
  border-color: var(--jig-accent);
  outline: none;
}

.jig-otp__channels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.jig-otp__channel {
  border: 1px solid var(--jig-border);
  background: var(--jig-surface-2);
  color: var(--jig-muted);
  border-radius: calc(var(--jig-radius) - 4px);
  padding: 12px 8px;
  min-height: 64px;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: center;
  transition: border-color 0.2s var(--jig-ease), color 0.2s, background 0.2s, transform 0.2s;
}

.jig-otp__channel-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
}

.jig-otp__channel--whatsapp .jig-otp__channel-icon { color: #25d366; }
.jig-otp__channel--telegram .jig-otp__channel-icon { color: #2aabee; }
.jig-otp__channel--bale .jig-otp__channel-icon { color: #00a3e0; }
.jig-otp__channel--sms .jig-otp__channel-icon { color: var(--jig-accent); }
.jig-otp__channel--email .jig-otp__channel-icon { color: #f0c674; }

.jig-otp__channel.is-active {
  color: var(--jig-text);
  border-color: color-mix(in srgb, var(--jig-accent) 70%, transparent);
  background: color-mix(in srgb, var(--jig-accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--jig-accent) 25%, transparent);
  transform: translateY(-1px);
}

.jig-otp__field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.jig-otp__field label {
  font-size: 0.92rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--jig-text) 82%, var(--jig-muted));
}

.jig-otp__field input {
  width: 100%;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--jig-accent) 34%, var(--jig-border));
  background: color-mix(in srgb, var(--jig-bg) 82%, #000);
  color: #f7fbfc;
  border-radius: calc(var(--jig-radius) - 6px);
  padding: clamp(12px, 2.8vw, 16px) clamp(12px, 3vw, 18px);
  min-height: clamp(46px, 12vw, 56px);
  font: inherit;
  font-size: clamp(1rem, 3.6vw, 1.18rem);
  font-weight: 650;
  letter-spacing: 0.03em;
  outline: none;
  transition: border-color 0.2s var(--jig-ease), box-shadow 0.2s, background 0.2s;
  -webkit-text-fill-color: #f7fbfc;
  box-sizing: border-box;
}

.jig-otp__field input::placeholder {
  color: color-mix(in srgb, #9eb0bf 88%, var(--jig-accent));
  opacity: 1;
  font-weight: 550;
  font-size: clamp(0.95rem, 3.2vw, 1.08rem);
  letter-spacing: 0.05em;
  -webkit-text-fill-color: color-mix(in srgb, #9eb0bf 88%, var(--jig-accent));
}

.jig-otp__field input:focus {
  border-color: var(--jig-accent);
  background: color-mix(in srgb, var(--jig-bg) 70%, #000);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--jig-accent) 22%, transparent);
}

.jig-otp__hp {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  height: 0 !important;
  width: 0 !important;
  pointer-events: none !important;
}

.jig-otp__digits {
  --jig-otp-len: 6;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--jig-otp-len), minmax(0, 1fr));
  justify-content: center;
  align-items: stretch;
  gap: clamp(4px, 1.6vw, 10px);
  width: 100%;
  max-width: 100%;
  direction: ltr;
  margin: 8px 0 18px;
  box-sizing: border-box;
}

.jig-otp__sms-autofill {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
}

.jig-otp__digit {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 3 / 3.6;
  height: auto;
  min-height: 40px;
  max-height: 54px;
  flex: none;
  text-align: center;
  font-size: clamp(0.95rem, 3.8vw, 1.28rem);
  font-weight: 800;
  border: 1px solid var(--jig-border);
  background: color-mix(in srgb, var(--jig-bg) 88%, #000);
  color: var(--jig-text);
  border-radius: calc(var(--jig-radius) - 6px);
  outline: none;
  padding: 0;
  box-sizing: border-box;
  transition: border-color 0.2s, transform 0.15s var(--jig-ease), box-shadow 0.2s;
}

.jig-otp__digit:focus {
  border-color: var(--jig-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--jig-accent) 22%, transparent);
  transform: translateY(-1px);
}

.jig-otp__btn {
  width: 100%;
  border: 0;
  border-radius: calc(var(--jig-radius) - 4px);
  padding: 14px 16px;
  min-height: 50px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, var(--jig-accent), var(--jig-accent-2));
  color: var(--jig-btn-text);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--jig-accent) 32%, transparent);
  transition: transform 0.2s var(--jig-ease), filter 0.2s, box-shadow 0.2s;
}

.jig-otp__btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.jig-otp__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.jig-otp__btn--ghost {
  background: transparent;
  color: var(--jig-muted);
  border: 1px solid var(--jig-border);
  box-shadow: none;
}

.jig-otp__actions {
  display: grid;
  gap: 8px;
}

.jig-otp__error {
  margin: 0 0 12px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--jig-danger) 45%, transparent);
  background: color-mix(in srgb, var(--jig-danger) 12%, transparent);
  color: #ffd0d5;
  border-radius: calc(var(--jig-radius) - 6px);
  font-size: 0.88rem;
}

.jig-otp__debug-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: calc(var(--jig-radius) - 6px);
  border: 1px dashed #e3b341;
  background: linear-gradient(90deg, rgba(227, 179, 65, 0.18), rgba(31, 167, 160, 0.12));
  color: #ffe9a8;
  font-size: 0.88rem;
}

.jig-otp__debug-code {
  font-size: 1.3rem;
  letter-spacing: 0.28em;
  color: #fff6d0;
  font-variant-numeric: tabular-nums;
}

.jig-otp__debug-fill {
  border: 1px solid rgba(227, 179, 65, 0.55);
  background: rgba(0, 0, 0, 0.25);
  color: #ffe9a8;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 40px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}

.jig-otp__success {
  text-align: center;
  padding: 18px 8px 8px;
}

.jig-otp__success-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--jig-ok) 18%, transparent);
  color: var(--jig-ok);
  font-size: 1.5rem;
  animation: jig-pop 0.5s var(--jig-ease);
}

.jig-otp__foot {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--jig-muted);
}

.jig-otp__foot a {
  color: var(--jig-accent);
  text-decoration: none;
}

.jig-otp-trigger,
.jig-otp-fab,
.jig-otp__fab {
  font-family: var(--jig-font);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--jig-accent) 50%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--jig-accent) 88%, #0e1116), var(--jig-accent-2));
  color: var(--jig-btn-text);
  padding: 12px 18px;
  min-height: 46px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 34px color-mix(in srgb, var(--jig-accent) 35%, transparent);
}

.jig-otp-fab,
.jig-otp__fab {
  position: fixed;
  bottom: max(18px, var(--jig-safe-b));
  inset-inline-start: max(18px, var(--jig-safe-l));
  z-index: 99970;
}

/* ===== Inline / wp-login surface ===== */
.jig-otp-inline {
  width: min(440px, 100%);
  margin-inline: auto;
}

.jig-otp-inline.jig-otp,
.jig-otp.jig-otp-inline:not([hidden]) {
  position: relative;
  inset: auto;
  display: block;
  padding: 0;
  overflow: visible;
  max-height: none;
}

.jig-otp-inline .jig-otp__modal {
  position: relative;
  width: 100%;
  max-height: none;
  margin: 0;
  opacity: 1;
  transform: none;
  animation: none;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--jig-accent) 14%, transparent),
    0 24px 60px rgba(0, 0, 0, 0.35);
}

.jig-otp-inline .jig-otp__backdrop,
.jig-otp-inline .jig-otp__close {
  display: none !important;
}

/* Login page composition */
body.login.jig-otp-body,
body.jig-otp-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0 !important;
  padding:
    max(16px, var(--jig-safe-t))
    max(16px, var(--jig-safe-r))
    max(16px, var(--jig-safe-b))
    max(16px, var(--jig-safe-l)) !important;
}

body.login #login {
  width: min(440px, 100%) !important;
  padding: 0 !important;
  margin: 0 auto !important;
  position: relative;
  z-index: 2;
}

.jig-otp-login-shell {
  width: 100%;
  margin: 0;
}

@keyframes jig-fade {
  to { opacity: 1; }
}

@keyframes jig-rise {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes jig-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
  #jig-otp-root.jig-otp:not([hidden]) {
    align-items: center;
    padding:
      max(10px, var(--jig-safe-t))
      max(10px, var(--jig-safe-r))
      max(10px, var(--jig-safe-b))
      max(10px, var(--jig-safe-l));
  }

  .jig-otp__modal {
    width: min(100%, calc(100vw - 16px));
    max-height: none;
    border-radius: 20px;
    overflow: visible;
  }

  .jig-otp__panel {
    padding: 14px 12px 12px;
    overflow: visible;
  }

  .jig-otp__digits {
    gap: clamp(3px, 1.4vw, 8px);
  }

  .jig-otp__digit {
    min-height: 38px;
    max-height: 48px;
    font-size: clamp(0.9rem, 4.2vw, 1.15rem);
  }

  .jig-otp__field input {
    font-size: clamp(1rem, 3.8vw, 1.12rem);
    min-height: 48px;
  }

  .jig-otp__field input::placeholder {
    font-size: clamp(0.92rem, 3.4vw, 1.02rem);
  }

  .jig-otp__brand h2 {
    font-size: 1.2rem;
  }

  .jig-otp__brand p {
    font-size: 0.84rem;
    max-width: 28ch;
  }

  .jig-otp__channels {
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    margin-bottom: 12px;
  }

  .jig-otp__channel {
    min-height: 54px;
    padding: 8px 6px;
    font-size: 0.8rem;
  }

  .jig-otp__field input {
    font-size: 1.06rem;
    min-height: 52px;
  }

  .jig-otp__foot {
    margin-top: 12px;
  }
}

@media (min-width: 481px) {
  #jig-otp-root.jig-otp:not([hidden]) {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jig-otp__backdrop,
  .jig-otp__modal,
  .jig-otp__success-icon,
  .jig-otp__btn,
  .jig-otp__digit {
    animation: none !important;
    transition: none !important;
  }

  .jig-otp__modal {
    opacity: 1;
    transform: none;
  }

  .jig-otp__backdrop {
    opacity: 1;
  }
}
