/* =============================
 Version 3
 ============================= */

:root {
  /* Основные цвета */
  --form-primary: #1fa038;
  --form-primary-dark: #008018;
  --form-success: #28a745;
  --form-danger: #dc3545;
  --form-warning: #ffc107;
  --form-info: #17a2b8;
  --form-white: #ffffff;
  --form-black: #111111;
  --form-gray-light: #f8f9fa;
  --form-gray: #6c757d;
  
  /* Эффекты и тени */
  --form-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --form-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.25);
  --form-radius: 20px;
  --form-radius-small: 10px;
  
  /* Анимации */
  --form-anim-fast: 200ms ease;
  --form-anim-medium: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Фокусы */
  --form-focus-ring: 0 0 0 3px rgba(31, 160, 56, 0.35);
  --form-focus-gray: 0 0 0 3px rgba(108, 117, 125, 0.25);
  --form-focus-success: 0 0 0 3px rgba(40, 167, 69, 0.25);
  --form-focus-danger: 0 0 0 3px rgba(220, 53, 69, 0.25);
  --form-focus-warning: 0 0 0 3px rgba(255, 193, 7, 0.25);
  
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* =============================
   БАЗОВЫЕ КОНТЕЙНЕРЫ ФОРМ
   ============================= */

.registration-form,
.form-wrapper,
,
.register-form,
.modal-content,
.box-form,
.registrationFormdisplay {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 25px;
  background: var(--form-white);
  border: 1px solid #e0e0e0;
  border-radius: var(--form-radius-small);
  box-shadow: var(--form-shadow);
  text-align: center;
  box-sizing: border-box;
}

.form-header,
.form-wrapper h3,
.modal-content h3 {
  color: var(--form-black);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px 0;
  text-align: center;
  line-height: 1.3;
}

/* =============================
   ОСНОВНЫЕ ИНПУТЫ
   ============================= */

input[type="text"],
input[type="email"],
input[type="tel"],
.input,
.form-field {
  width: 100%;
  height: 52px;
  padding: 14px 18px;
  margin-bottom: 15px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--form-black);
  background: var(--form-white);
  border: 2px solid #d1d5db;
  border-radius: var(--form-radius);
  outline: none;
  box-sizing: border-box;
  transition: all var(--form-anim-fast);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Состояния фокуса - серая рамка по умолчанию */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
.input:focus,
.form-field:focus {
  border-color: var(--form-gray);
  box-shadow: var(--form-focus-gray);
  background: var(--form-white);
}

/* Плейсхолдеры */
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder,
.input::placeholder,
.form-field::placeholder {
  color: #9ca3af;
  opacity: 0.8;
  font-weight: 400;
}

/* =============================
   ВАЛИДАЦИОННЫЕ СОСТОЯНИЯ
   ============================= */

/* ВАЛИДНОЕ СОСТОЯНИЕ - зеленое */
.valid,
input.valid,
.form-field.valid,
input[type="text"].valid,
input[type="email"].valid,
input[type="tel"].valid {
  background: #ecfdf5 !important;
  border-color: var(--form-success) !important;
  box-shadow: var(--form-focus-success) !important;
}

/* НЕВАЛИДНОЕ СОСТОЯНИЕ - красное */
.invalid,
input.invalid,
.form-field.invalid,
input[type="text"].invalid,
input[type="email"].invalid,
input[type="tel"].invalid {
  background: #fef2f2 !important;
  border-color: var(--form-danger) !important;
  box-shadow: var(--form-focus-danger) !important;
}

/* СОСТОЯНИЕ ПРОВЕРКИ - желтое (для телефона) */
input[type="tel"][style*="border-color: #ffc107"],
input[type="tel"][style*="border-color: rgb(255, 193, 7)"],
.phone-checking {
  background: #fffef0 !important;
  border-color: var(--form-warning) !important;
  box-shadow: var(--form-focus-warning) !important;
}

/* =============================
   ИНТЕГРАЦИЯ С intl-tel-input
   ============================= */

.iti {
  width: 100% !important;
  display: block !important;
}

.iti__flag-container {
  border-top-left-radius: var(--form-radius) !important;
  border-bottom-left-radius: var(--form-radius) !important;
}

.iti__selected-flag {
  border-top-left-radius: var(--form-radius) !important;
  border-bottom-left-radius: var(--form-radius) !important;
}

.iti__selected-dial-code {
  color: var(--form-black) !important;
  font-weight: 500 !important;
}

/* Телефонный инпут с отступом для флага */
input[type="tel"].phone,
input[type="tel"].phonelist,
input[name="phone"] {
  padding-left: 95px !important;
  height: 52px !important;
}

/* Стили для строгого режима GEO (script.js PHONE_GEO_MODE === 'strict') */
.iti.iti--separate-dial-code .iti__flag-container {
  pointer-events: none;
  cursor: default;
}

.iti__arrow {
  display: none !important;
}

/* =============================
   АНИМАЦИЯ ЗАГРУЗКИ ТЕЛЕФОНА
   ============================= */

@keyframes phone-validation-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Индикатор проверки телефона из script.js */
input[type="tel"][style*="background-image"] {
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 20px 20px !important;
  animation: phone-validation-spin 1s linear infinite;
}

/* =============================
   КНОПКИ ОТПРАВКИ
   ============================= */

button[type="submit"],
.submit,
.register-btn,
.bazuka-btn,
.rf-form-button,
.dr-field-submit,
#rgbtm,
.btn-link {
  width: 100%;
  padding: 14px 20px;
  margin: 20px 0 10px 0;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: var(--form-white);
  background: linear-gradient(135deg, var(--form-primary) 0%, var(--form-primary-dark) 100%);
  border: 2px solid var(--form-primary);
  border-radius: var(--form-radius);
  cursor: pointer;
  outline: none;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all var(--form-anim-fast);
  box-shadow: 0 4px 12px rgba(31, 160, 56, 0.3);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* Анимация пульсации для активных кнопок (из script.js) */
@keyframes pulse-universal {
  0% { 
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(31, 160, 56, 0.3);
  }
  50% { 
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(31, 160, 56, 0.5);
  }
  100% { 
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(31, 160, 56, 0.3);
  }
}

button[type="submit"]:not(:disabled),
.submit:not(:disabled),
.register-btn:not(:disabled),
.bazuka-btn:not(:disabled),
.rf-form-button:not(:disabled),
#rgbtm:not(:disabled) {
  animation: pulse-universal 2s infinite;
}

/* Ховер эффекты */
button[type="submit"]:hover:not(:disabled),
.submit:hover:not(:disabled),
.register-btn:hover:not(:disabled),
.bazuka-btn:hover:not(:disabled),
.rf-form-button:hover:not(:disabled),
#rgbtm:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--form-shadow-hover);
  background: linear-gradient(135deg, #22a23a 0%, #0d5f28 100%);
}

/* Отключенное состояние */
button[type="submit"]:disabled,
.submit:disabled,
.register-btn:disabled,
.bazuka-btn:disabled,
.rf-form-button:disabled,
#rgbtm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
  background: #9ca3af;
  border-color: #9ca3af;
  transform: none;
  box-shadow: none;
}

/* =============================
   ЛОАДЕР СТРАНИЦЫ
   ============================= */

.pageloader {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: url("https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif") center no-repeat #f9f9f9;
  opacity: 0.8;
  display: none;
}

/* =============================
   E-DEVLET КОНТЕЙНЕР
   ============================= */

.form-group.devlet,
.devlet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 15px 0;
  padding: 10px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.devlet__logo {
  width: 42px;
  height: auto;
  padding: 0;
  margin: 0;
}

.devlet p {
  margin: 0;
  font-size: 13px;
  color: #495057;
  font-weight: 500;
}

/* =============================
   АВТОЗАПОЛНЕНИЕ И АВТОФИЛЛ
   ============================= */

/* CSS для обнаружения автозаполнения Chrome (из script.js) */
@keyframes onAutoFillStart {
  from {} 
  to {}
}

input:-webkit-autofill {
  animation-name: onAutoFillStart;
}

/* =============================
   TOAST УВЕДОМЛЕНИЯ
   ============================= */

#toast-container > .toast {
  z-index: 9999 !important;
}

/* =============================
   ПРЕДЛОЖЕНИЯ EMAIL (Mailcheck)
   ============================= */

.suggestion {
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--form-anim-fast);
  font-weight: 500;
}

.suggestion:hover,
.suggestion:focus-visible {
  background-color: #dbeafe;
  text-decoration: none;
  color: #1d4ed8;
}

/* =============================
   МОДАЛЬНЫЕ ОКНА
   ============================= */

.comment-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--form-white);
  max-width: 450px;
  margin: 8% auto;
  padding: 30px;
  border-radius: var(--form-radius-small);
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* =============================
   АДАПТИВНОСТЬ
   ============================= */

@media (max-width: 768px) {
  .form-wrapper,
  ,
  .registration-form,
  .register-form,
  .modal-content,
  .box-form {
    padding: 20px;
    margin: 10px auto;
  }
  
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  .input,
  .form-field {
    font-size: 16px; /* Предотвращает зум на iOS */
    padding: 12px 16px;
    height: 48px;
  }
  
  button[type="submit"],
  .submit,
  .register-btn,
  .bazuka-btn,
  .rf-form-button,
  #rgbtm {
    padding: 12px 18px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .form-wrapper,
  .modal-content {
    padding: 15px;
  }
  
  .form-header,
  .form-wrapper h3,
  .modal-content h3 {
    font-size: 16px;
  }
}

/* =============================
   LEGACY ПОДДЕРЖКА
   ============================= */

/* Поддержка множественных форм */
.registration-form {
  margin-bottom: 30px;
  border: 1px solid #e0e0e0;
  border-radius: var(--form-radius-small);
  background: var(--form-white);
}

.registration-form:nth-child(odd) {
  background: var(--form-white);
}

.registration-form:nth-child(even) {
  background: #f8f9fa;
}

/* Floating labels support */
input[type="text"]:focus + label,
input[type="email"]:focus + label,
input[type="tel"]:focus + label,
input[type="text"]:not(:placeholder-shown) + label,
input[type="email"]:not(:placeholder-shown) + label,
input[type="tel"]:not(:placeholder-shown) + label {
  top: -12px;
  color: var(--form-primary);
  font-size: 14px;
  font-weight: 600;
  background: var(--form-white);
  padding: 0 4px;
}

/* =============================
   ДОСТУПНОСТЬ
   ============================= */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Уменьшенная анимация для пользователей с настройками доступности */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================
   СПЕЦИФИЧНЫЕ СТИЛИ ДЛЯ SCRIPT.JS
   ============================= */

/* Стили для отображения прогресса ввода телефона */
input[type="tel"][title] {
  position: relative;
}

/* Отключенные инпуты */
input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="tel"]:disabled,
.input:disabled,
.form-field:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f3f4f6;
}

/* Фокус-видимость для кнопок */
button[type="submit"]:focus-visible,
.submit:focus-visible,
.register-btn:focus-visible,
.bazuka-btn:focus-visible,
.rf-form-button:focus-visible,
#rgbtm:focus-visible {
  outline: none;
  box-shadow: var(--form-focus-ring);
}

/* =============================
   ФИНАЛЬНЫЕ НАСТРОЙКИ
   ============================= */

/* Обеспечиваем правильное отображение форм */
form,
.registration-form,
.register-form {
  width: 100%;
  max-width: 100%;
}

/* Убираем дефолтные стили браузера */
input,
button,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Предотвращение нежелательного поведения */
* {
  box-sizing: border-box;
}

/* Последние штрихи для совместимости */
.iti__selected-dial-code {
  color: var(--form-black);
}

/* Z-index контроль */
.comment-modal,
.modal-content {
  z-index: 10000;
}

/* =============================
   ДЕБАГ И МОНИТОРИНГ
   ============================= */

/* Стили для отладки (если DEBUG_MODE включен в script.js) */
[data-debug="true"] {
  outline: 2px dashed #ff6b6b;
  outline-offset: 2px;
}

/* Индикатор для полей с ошибками валидации */
[data-validation-error="true"] {
  position: relative;
}

[data-validation-error="true"]::after {
  content: '!';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  background: var(--form-danger);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  z-index: 1;
}
