/* OTP login / registration modal (RTL) */
.wm-otp-modal,
.wm-otp-modal * {
  box-sizing: border-box;
}

.wm-otp-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  direction: rtl;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.wm-otp-modal[hidden] {
  display: flex;
}

.wm-otp-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── Backdrop ── */
.wm-otp-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.55);
  backdrop-filter: blur(2px);
}

/* ── Panel ── */
.wm-otp-modal__panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--wm-color-surface, #ffffff);
  border-radius: var(--wm-radius-lg, 28px);
  box-shadow: var(--wm-shadow-md, 0 18px 45px rgba(17, 24, 39, 0.10));
  padding: var(--wm-space-8, 32px) var(--wm-space-6, 24px) var(--wm-space-6, 24px);
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.wm-otp-modal.is-open .wm-otp-modal__panel {
  transform: translateY(0) scale(1);
}

/* ── Accent stripe — matches product purchase block pattern ── */
.wm-otp-modal__accent {
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--wm-color-accent, #c89b3c), transparent);
}

/* ── Close button ── */
.wm-otp-modal--forced .wm-otp-modal__close {
  display: none;
}

.wm-otp-modal__close {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--wm-radius-pill, 999px);
  background: var(--wm-color-soft, #f9f8f5);
  color: var(--wm-color-muted, #6b7280);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.wm-otp-modal__close:hover {
  background: var(--wm-color-border, #e5e0d8);
  color: var(--wm-color-text, #1f2937);
}

/* ── Title / subtitle ── */
.wm-otp-modal__title {
  margin: 0 0 var(--wm-space-1, 4px);
  font-size: var(--wm-font-size-h3, 20px);
  font-weight: var(--wm-font-weight-heading, 800);
  color: var(--wm-color-primary, #111827);
  text-align: right;
}

.wm-otp-modal__subtitle {
  margin: 0 0 var(--wm-space-2, 8px);
  font-size: var(--wm-font-size-base, 15px);
  font-weight: 700;
  color: var(--wm-color-text, #1f2937);
  text-align: right;
}

/* ── Description ── */
.wm-otp-modal__desc {
  margin: 0 0 var(--wm-space-5, 20px);
  font-size: var(--wm-font-size-small, 13px);
  color: var(--wm-color-muted, #6b7280);
  line-height: var(--wm-line-height-body, 1.9);
  text-align: right;
}

/* ── Steps ── */
@keyframes wm-otp-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wm-otp-modal__step[hidden] {
  display: none;
}

.wm-otp-modal__step {
  animation: wm-otp-fade-in 200ms ease;
}

/* ── Forms — always vertical stack ── */
.wm-otp-modal__step form {
  display: flex;
  flex-direction: column;
  gap: var(--wm-space-3, 12px);
}

/* ── Inputs ── */
.wm-otp-modal__input {
  width: 100%;
  height: 48px;
  padding: 0 var(--wm-space-4, 16px);
  border: 1px solid var(--wm-color-border, #e5e0d8);
  border-radius: var(--wm-radius-md, 18px);
  background: var(--wm-color-soft, #f9f8f5);
  color: var(--wm-color-text, #1f2937);
  font-size: var(--wm-font-size-base, 15px);
  font-family: var(--wm-font-primary, 'Vazirmatn', system-ui, sans-serif);
  direction: ltr;
  text-align: center;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.wm-otp-modal__input:focus {
  outline: none;
  border-color: var(--wm-color-accent, #c89b3c);
  box-shadow: 0 0 0 3px rgba(200, 155, 60, 0.14);
}

.wm-otp-modal__input--code {
  letter-spacing: 8px;
  font-size: 20px;
  font-weight: 700;
}

/* ── Submit button ── */
.wm-otp-modal__submit {
  width: 100%;
  height: 48px;
  padding: 0 var(--wm-space-5, 20px);
  border: 0;
  border-radius: var(--wm-radius-md, 18px);
  background: linear-gradient(135deg, #111827, #243044);
  color: #fff;
  font-size: var(--wm-font-size-base, 15px);
  font-weight: 850;
  font-family: var(--wm-font-primary, 'Vazirmatn', system-ui, sans-serif);
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.wm-otp-modal__submit:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.28);
  transform: translateY(-1px);
}

.wm-otp-modal__submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Secondary actions (resend / back / login-with-code) ── */
.wm-otp-modal__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wm-space-2, 8px);
  margin-top: var(--wm-space-4, 16px);
  padding-top: var(--wm-space-4, 16px);
  border-top: 1px solid var(--wm-color-border, #e5e0d8);
}

.wm-otp-modal__resend,
.wm-otp-modal__back {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: var(--wm-font-size-small, 13px);
  font-weight: 700;
  font-family: var(--wm-font-primary, 'Vazirmatn', system-ui, sans-serif);
  color: var(--wm-color-accent-dark, #9f7425);
  cursor: pointer;
  transition: color 160ms ease;
}

.wm-otp-modal__resend:hover:not(:disabled),
.wm-otp-modal__back:hover {
  color: var(--wm-color-accent, #c89b3c);
}

.wm-otp-modal__resend:disabled {
  color: var(--wm-color-muted, #6b7280);
  cursor: not-allowed;
}

/* ── Error message ── */
.wm-otp-modal__error {
  margin: var(--wm-space-2, 8px) 0 0;
  font-size: var(--wm-font-size-small, 13px);
  color: var(--wm-color-danger-text, #b42318);
  text-align: right;
}

.wm-otp-modal__error[hidden] {
  display: none;
}

/* ── Body scroll lock ── */
body.wm-otp-modal-open {
  overflow: hidden;
}

/* ── Mobile: bottom-sheet above the mobile nav ── */
@media (max-width: 767px) {
  .wm-otp-modal {
    z-index: 1400; /* above mobile nav (1300) and sheets (1290) */
    align-items: flex-end;
    padding: 0;
  }

  .wm-otp-modal__panel {
    max-width: 100%;
    border-radius: var(--wm-radius-lg, 28px) var(--wm-radius-lg, 28px) 0 0;
    padding: var(--wm-space-8, 32px) var(--wm-space-5, 20px) calc(var(--wm-space-8, 32px) + env(safe-area-inset-bottom, 0px));
    transform: translateY(24px);
  }

  .wm-otp-modal.is-open .wm-otp-modal__panel {
    transform: translateY(0);
  }
}

/* ── Confirm-exit bar ── */
.wm-otp-modal__confirm-exit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wm-space-3, 12px);
  padding: var(--wm-space-3, 12px) var(--wm-space-4, 16px);
  margin-bottom: var(--wm-space-4, 16px);
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--wm-radius-md, 18px);
  font-size: var(--wm-font-size-small, 13px);
  color: var(--wm-color-text, #1f2937);
  animation: wm-otp-fade-in 200ms ease;
}

.wm-otp-modal__confirm-exit[hidden] {
  display: none;
}

.wm-otp-modal__confirm-exit-actions {
  display: flex;
  gap: var(--wm-space-2, 8px);
  flex-shrink: 0;
}

.wm-otp-modal__confirm-exit-btn {
  border: 0;
  border-radius: var(--wm-radius-sm, 10px);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--wm-font-primary, 'Vazirmatn', system-ui, sans-serif);
  cursor: pointer;
  transition: opacity 160ms ease;
}

.wm-otp-modal__confirm-exit-btn--cancel {
  background: var(--wm-color-primary, #111827);
  color: #fff;
}

.wm-otp-modal__confirm-exit-btn--confirm {
  background: transparent;
  color: var(--wm-color-danger-text, #b42318);
  border: 1px solid var(--wm-color-danger-text, #b42318);
}

.wm-otp-modal__confirm-exit-btn:hover {
  opacity: 0.85;
}

/* ── Resume banner ── */
.wm-otp-modal__resume-banner {
  padding: var(--wm-space-3, 12px) var(--wm-space-4, 16px);
  margin-bottom: var(--wm-space-4, 16px);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--wm-radius-md, 18px);
  font-size: var(--wm-font-size-small, 13px);
  animation: wm-otp-fade-in 200ms ease;
}

.wm-otp-modal__resume-banner[hidden] {
  display: none;
}

.wm-otp-modal__resume-text {
  color: #1e40af;
  font-weight: 600;
  margin-bottom: var(--wm-space-2, 8px);
  text-align: right;
}

.wm-otp-modal__resume-actions {
  display: flex;
  gap: var(--wm-space-2, 8px);
  justify-content: flex-end;
}

.wm-otp-modal__resume-btn {
  border: 0;
  border-radius: var(--wm-radius-sm, 10px);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--wm-font-primary, 'Vazirmatn', system-ui, sans-serif);
  cursor: pointer;
  transition: opacity 160ms ease;
}

.wm-otp-modal__resume-btn--continue {
  background: #1e40af;
  color: #fff;
}

.wm-otp-modal__resume-btn--reset {
  background: transparent;
  color: var(--wm-color-muted, #6b7280);
  border: 1px solid var(--wm-color-border, #e5e0d8);
}

.wm-otp-modal__resume-btn:hover {
  opacity: 0.85;
}
