/**
 * Custom Auth Digits Frontend Styles
 */

:root {
  --cad-primary: #2563eb;
  --cad-primary-hover: #1d4ed8;
  --cad-border: #d1d5db;
  --cad-text: #1f2937;
  --cad-bg: #ffffff;
  --cad-error: #dc2626;
  --cad-success: #16a34a;
  --cad-radius: 8px;
}

.cad-auth-box {
  color: var(--cad-text);
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  box-sizing: border-box;
}

.cad-auth-box * {
  box-sizing: border-box;
}

.cad-form-group {
  margin-bottom: 18px;
}

.cad-form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--cad-text);
}

.cad-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.cad-input-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.6;
}

[dir="rtl"] .cad-input-icon {
  left: auto;
  right: 12px;
}

.cad-input {
  width: 100%;
  height: 44px;
  padding: 8px 14px;
  padding-left: 38px;
  font-size: 15px;
  border: 1px solid var(--cad-border);
  border-radius: var(--cad-radius);
  outline: none;
  background: #f9fafb;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background-color 0.2s;
}

[dir="rtl"] .cad-input {
  padding-left: 14px;
  padding-right: 38px;
}

.cad-input:focus {
  border-color: var(--cad-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.cad-input-otp {
  font-size: 22px;
  letter-spacing: 6px;
  text-align: center;
  font-weight: 700;
  padding: 8px 12px !important;
}

.cad-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--cad-primary);
  border: none;
  border-radius: var(--cad-radius);
  cursor: pointer;
  transition:
    background-color 0.2s,
    opacity 0.2s;
  text-decoration: none;
}

.cad-button:hover:not(:disabled) {
  background-color: var(--cad-primary-hover);
}

.cad-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.cad-btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: cad-spin 0.6s linear infinite;
}

.cad-button.loading .cad-btn-spinner {
  display: inline-block;
}

.cad-link-button {
  background: none;
  border: none;
  color: var(--cad-primary);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin: 0;
}

.cad-link-button:disabled {
  color: #9ca3af;
  cursor: not-allowed;
  text-decoration: none;
}

.cad-countdown-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
  color: #6b7280;
}

.cad-notice {
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: var(--cad-radius);
  font-size: 14px;
  line-height: 1.4;
  width: 100%;
  text-align: center;
}

.cad-notice-container:empty {
  display: none !important;
}

.cad-notice-error {
  background-color: #fee2e2;
  color: var(--cad-error);
  border: 1px solid #fca5a5;
}

.cad-notice-success {
  background-color: #dcfce7;
  color: var(--cad-success);
  border: 1px solid #86efac;
}

/* Modal Overlay & Dialog */
.cad-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cad-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.cad-modal-dialog {
  position: relative;
  z-index: 2;
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 12px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.2),
    0 10px 10px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: cad-scale-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.cad-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--cad-text);
}

.cad-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.2s;
}

.cad-modal-close:hover {
  color: var(--cad-text);
}

.cad-modal-body {
  padding: 24px;
}

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

@keyframes cad-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* کانتینر اطلاعات ارسال کد - تنظیم فاصله مناسب میان باکس سبز و فیلد ورودی */
.cad-otp-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 14px 0;
  font-size: 0.875rem; /* 14px */
  color: #64748b; /* خاکستری ملایم و هماهنگ با بقیه متون مدال */
  line-height: 1.6;
}

/* شماره موبایل - برجسته، خوانا و بدون لرزش ارقام */
.cad-otp-info strong,
#cad-display-phone {
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  margin: 0 2px;
}

/* دکمه ویرایش - طراحی کپسولی مایکرو (جایگزین لینک خط‌دار معمولی) */
.cad-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 9px;
  font-size: 0.75rem; /* 12px */
  font-weight: 600;
  color: #2563eb;
  background-color: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease-in-out;
}

.cad-link-button:hover {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transform: translateY(-1px);
}

.cad-link-button:active {
  transform: translateY(0);
}

/* ==============================================
   حالت دارک مود (با کلاس .dark روی روت / مدال)
   ============================================== */
.dark .cad-otp-info {
  color: #94a3b8;
}

.dark .cad-otp-info strong,
.dark #cad-display-phone {
  color: #ffffff;
}

.dark .cad-link-button {
  background-color: rgba(37, 99, 235, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.dark .cad-link-button:hover {
  background-color: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* دارک مود خودکار سیستم (در صورت فعال بودن تم تیره مرورگر) */
@media (prefers-color-scheme: dark) {
  :root:not(.light) .cad-otp-info {
    color: #94a3b8;
  }
  :root:not(.light) .cad-otp-info strong,
  :root:not(.light) #cad-display-phone {
    color: #ffffff;
  }
  :root:not(.light) .cad-link-button {
    background-color: rgba(37, 99, 235, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
  }
  :root:not(.light) .cad-link-button:hover {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
  }
}
