/* ==========================================================================
   کلاغ (Kalagh) | استایل اختصاصی صفحات احراز هویت (ورود و تایید پیامک)
   ========================================================================== */

html, body.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--paper) !important;
  font-family: var(--font-sans) !important;
  color: var(--ink) !important;
  direction: rtl;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.auth-viewport {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 56px;
  box-sizing: border-box;
  position: relative;
}

/* توست و پاپ‌آپ زیبای پیام‌های سیستم */
.auth-toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 92vw;
  width: auto;
}

.auth-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: #251E1A;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  min-width: 280px;
  max-width: 440px;
  box-sizing: border-box;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.auth-toast-error {
  border-color: rgba(244, 63, 94, 0.45);
  background: #241618;
  color: #fda4af;
}

.auth-toast-success {
  border-color: rgba(16, 185, 129, 0.45);
  background: #14261d;
  color: #6ee7b7;
}

.auth-toast-info {
  border-color: rgba(224, 107, 85, 0.45);
  background: #261e1a;
  color: var(--ink);
}

.auth-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.auth-toast-msg {
  flex: 1;
  line-height: 1.5;
}

.auth-toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.65;
  font-size: 17px;
  cursor: pointer;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.15s ease;
}
.auth-toast-close:hover {
  opacity: 1;
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* کادر اصلی فرم - ابعاد یکپارچه و دقیق برای هر دو صفحه */
.auth-card-box {
  width: 100%;
  max-width: 440px;
  min-height: 480px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 38px 32px 30px;
  box-shadow: var(--shadow-md);
  text-align: center;
  position: relative;
  animation: fadeInCard 0.25s ease-out;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@keyframes fadeInCard {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card-header {
  flex-shrink: 0;
}

/* لوگوی کلاغ بدون کادر و حاشیه */
.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  transition: transform 0.25s ease;
}
.auth-logo-badge:hover {
  transform: scale(1.05);
}
.auth-logo-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  display: block;
}

/* تیتر و توضیحات */
.auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.4;
  margin: 0 0 4px;
}
.auth-title-sub {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
.auth-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.75;
  margin: 12px 0 24px;
}
.auth-target-mobile {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* فرم میانی */
.auth-form-wrap {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* اینپوت ورودی */
.auth-input-group {
  width: 100%;
  text-align: right;
}
.auth-input-wrapper {
  position: relative;
  width: 100%;
}
.auth-input {
  width: 100%;
  height: 52px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0 16px 0 48px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  direction: rtl;
  text-align: right;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}
.auth-input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.auth-input:focus {
  background: var(--white);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--peach);
}
.auth-input-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* اینپوت کد ۵ رقمی پیامک */
.auth-code-input {
  text-align: center !important;
  font-size: 24px !important;
  letter-spacing: 10px !important;
  font-weight: 800 !important;
  padding: 0 16px !important;
}

/* پیام خطای درون فرم */
.auth-error-hint {
  color: var(--accent);
  font-size: 11.5px;
  margin-top: 6px;
  text-align: right;
  line-height: 1.4;
  display: none;
}
.auth-error-hint.visible {
  display: block;
}

/* دکمه ارسال / ورود */
.auth-submit-btn {
  width: 100%;
  height: 50px;
  margin-top: 16px;
  background: #FAF8F5;
  color: #1F1A17;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 800;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-sm);
}
.auth-submit-btn:hover {
  background: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.auth-submit-btn:active {
  transform: scale(0.99);
}
.auth-submit-btn:disabled,
.auth-submit-btn.loading,
.auth-action-btn:disabled,
.auth-action-btn.loading {
  opacity: 0.65;
  cursor: not-allowed !important;
  pointer-events: none !important;
  transform: none !important;
}
.auth-btn-spinner {
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-left: 8px;
  border: 2.2px solid rgba(0, 0, 0, 0.22);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: authBtnSpin 0.65s linear infinite;
  vertical-align: middle;
}
@keyframes authBtnSpin {
  to { transform: rotate(360deg); }
}

/* پاورقی کارت */
.auth-card-footer {
  flex-shrink: 0;
  margin-top: 22px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}
.auth-card-footer a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.18s ease;
}
.auth-card-footer a.auth-action-btn,
.auth-card-footer a.auth-change-mobile-btn,
.auth-card-footer .auth-verify-actions a,
.auth-action-btn,
.auth-action-btn * {
  text-decoration: none !important;
}
.auth-card-footer a:hover {
  color: var(--accent);
}

/* بخش اعلان شمارنده زمان */
.auth-verify-timer-box {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-sizing: border-box;
}

.auth-timer-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

/* دکمه‌های زیبای تغییر شماره، ارسال مجدد کد و تماس صوتی */
.auth-verify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.auth-action-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  box-sizing: border-box;
  width: 100%;
}
.auth-action-btn:hover:not(:disabled):not(.disabled) {
  color: var(--ink);
  border-color: var(--muted);
  background: var(--white);
}

/* دکمه شمارنده دریافت مجدد کد و تماس صوتی */
.auth-resend-form,
.auth-voice-form {
  display: block;
  width: 100%;
}

.auth-action-resend,
.auth-action-voice {
  user-select: none;
}
.auth-action-resend.disabled,
.auth-action-resend:disabled,
.auth-action-voice.disabled,
.auth-action-voice:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--soft);
  color: var(--muted);
  border-color: var(--line);
}

.auth-action-resend.active {
  color: var(--accent);
  border-color: rgba(224, 107, 85, 0.4);
  background: var(--peach);
  cursor: pointer;
  font-weight: 700;
}
.auth-action-resend.active:hover {
  background: var(--accent);
  color: #FFFFFF;
}

.auth-action-voice.active {
  color: #10B981;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
  cursor: pointer;
  font-weight: 700;
}
.auth-action-voice.active:hover {
  background: #10B981;
  color: #FFFFFF;
}

.auth-countdown-timer {
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

/* فلش رو به پایین بازگشت به صفحه اصلی */
.auth-bottom-nav {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-bottom-nav a {
  color: var(--muted);
  display: inline-flex;
  padding: 8px;
  transition: all 0.2s ease;
}
.auth-bottom-nav a:hover {
  color: var(--accent);
  transform: translateY(2px);
}

@media (max-width: 480px) {
  .auth-card-box {
    padding: 30px 20px 24px;
    border-radius: var(--radius-lg);
    min-height: 460px;
  }
  .auth-title {
    font-size: 18px;
  }
  .auth-title-sub {
    font-size: 14px;
  }
  .auth-viewport {
    padding: 16px 12px 48px;
  }
  .auth-verify-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
