/* ============================================================================
   SENSETI Math Captcha Modal
   Стандартизовано відповідно до референсу: senseti.netlify.app/components/popups.html
   ============================================================================ */

/* Overlay з backdrop blur */
.captcha-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.captcha-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

/* Модальне вікно */
.captcha-modal {
  position: relative;
  max-width: 420px;
  width: 90vw;
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 24px;
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.captcha-overlay.active .captcha-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Кнопка закриття (X) */
.captcha-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #86868B;
  padding: 0;
}

.captcha-close:hover {
  color: #1D1D1F;
  transform: scale(1.1);
}

/* Body */
.captcha-body {
  text-align: center;
}

/* Заголовок */
.captcha-title {
  font-size: 20px;
  font-weight: 600;
  color: #1D1D1F;
  margin: 0 0 8px 0;
}

/* Інструкція */
.captcha-instruction {
  font-size: 14px;
  color: #86868B;
  margin: 0 0 24px 0;
}

/* Контейнер для питання */
.captcha-question {
  margin-bottom: 24px;
}

/* Візуальний блок з кружечками */
.captcha-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.captcha-dots-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 120px;
}

/* Синій кружечок */
.captcha-dot {
  width: 24px;
  height: 24px;
  background: #007AFF;
  border-radius: 50%;
  display: inline-block;
}

/* Оператор (+, -, =) */
.captcha-operator {
  font-size: 2rem;
  font-weight: 600;
  color: #1D1D1F;
}

/* Знак питання */
.captcha-question-mark {
  font-size: 2rem;
  font-weight: 600;
  color: #1D1D1F;
}

/* Поле вводу відповіді - відповідно до референсу */
.captcha-input-wrapper {
  margin-bottom: 16px;
}

.captcha-input {
  width: 190px;
  padding: 10px 16px;
  font-size: 18px;
  font-weight: 400;
  text-align: center;
  border: 1px solid #007AFF;
  border-radius: 8px;
  background: #FFFFFF;
  color: #1D1D1F;
  transition: all 0.2s ease;
  outline: none;
}

.captcha-input:focus {
  border-color: #007AFF;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.captcha-input.error {
  border-color: #FF3B30;
  animation: shake 0.4s ease;
}

.captcha-input.success {
  border-color: #34C759;
}

/* Приховуємо стрілки в input[type=number] */
.captcha-input::-webkit-outer-spin-button,
.captcha-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.captcha-input[type=number] {
  -moz-appearance: textfield;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Повідомлення про помилку */
.captcha-error {
  font-size: 13px;
  color: #FF3B30;
  margin-top: 8px;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.captcha-error.visible {
  opacity: 1;
}

/* Головна кнопка підтвердження - pill shape */
.captcha-btn-submit {
  display: block;
  width: auto;
  min-width: 160px;
  margin: 0 auto 16px auto;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #FFFFFF;
  background: #007AFF;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.captcha-btn-submit:hover {
  background: #0066CC;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.captcha-btn-submit:active {
  transform: scale(0.98);
}

/* Нижні посилання (НОВА ЗАДАЧА, СКАСУВАТИ) */
.captcha-footer-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* Кнопка НОВА ЗАДАЧА - тёмный текст с иконкой */
.captcha-link-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: #1C1F27;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.captcha-link-refresh:hover {
  color: #007AFF;
}

.captcha-link-refresh svg {
  width: 24px;
  height: 24px;
}

/* Кнопка СКАСУВАТИ - серый текст */
.captcha-link-cancel {
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: #808080;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.captcha-link-cancel:hover {
  color: #1D1D1F;
}

/* Success іконка */
.captcha-success-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  animation: successPulse 0.5s ease;
}

@keyframes successPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
   Адаптивність для мобільних
   ============================================================================ */

@media (max-width: 480px) {
  .captcha-modal {
    max-width: 95vw;
    padding: 20px;
  }

  .captcha-title {
    font-size: 18px;
  }

  .captcha-dot {
    width: 20px;
    height: 20px;
  }

  .captcha-operator,
  .captcha-question-mark {
    font-size: 20px;
  }

  .captcha-input {
    width: 140px;
    font-size: 16px;
    padding: 8px 12px;
  }

  .captcha-btn-submit {
    width: 100%;
    padding: 14px 24px;
  }

  .captcha-footer-links {
    flex-direction: column;
    gap: 8px;
  }

  .captcha-link-refresh,
  .captcha-link-cancel {
    font-size: 13px;
  }
}
