/**
 * @file
 * Custom styles for AJAX loader.
 */

/* ========== ОСНОВНЫЕ СТИЛИ ========== */

/* Скрываем стандартные спиннеры Drupal */
.ajax-progress__throbber,
.views-ajax-progress__throbber {
  display: none !important;
}

/* Скрываем стандартные gif-спиннеры */
.ajax-progress-throbber .throbber,
.views-ajax-progress .throbber {
  display: none !important;
}

/* ========== КАСТОМНЫЙ СПИННЕР ДЛЯ ОБЩЕГО AJAX ========== */

.ajax-progress {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ajax-progress::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top: 2px solid #2563eb;
  border-radius: 50%;
  animation: custom-spin 1s linear infinite;
  flex-shrink: 0;
}

/* ========== КАСТОМНЫЙ СПИННЕР ДЛЯ VIEWS ========== */

.views-ajax-progress {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #2563eb;
}

.views-ajax-progress::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #d5dbdb;
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  animation: custom-spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ========== АНИМАЦИЯ ========== */

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

/* ========== СТИЛИ ДЛЯ СООБЩЕНИЙ ========== */

.ajax-progress__message {
  font-size: 14px;
  color: #2c3e50;
  font-weight: 500;
}

.views-ajax-progress__message {
  font-size: 14px;
  color: #2563eb;
  font-weight: 600;
}

/* ========== FULLSCREEN OVERLAY (для модальных окон) ========== */

.ajax-progress-fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(8px);
  background-color: hsla(0, 0%, 100%, .44);
  z-index: 9999;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.ajax-progress-fullscreen::before {
  width: 80px;
  height: 80px;
  border: 8px solid #1f2937;
  border-top: 8px solid #ea580c;
  animation: custom-spin 0.8s linear infinite;
}

.ajax-progress-fullscreen .ajax-progress__message {
  font-size: 18px;
  color: #2c3e50;
  font-weight: 600;
}

/* ========== СТИЛИ ДЛЯ КНОПОК ========== */

.form-submit .ajax-progress,
.button .ajax-progress {
  padding: 4px 8px;
  background: rgba(52, 152, 219, 0.1);
  border-radius: 3px;
}

.form-submit .ajax-progress::before,
.button .ajax-progress::before {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* ========== ТЕМНАЯ ТЕМА ========== */

@media (prefers-color-scheme: dark) {
  .ajax-progress {
    background: rgba(44, 62, 80, 0.9);
    color: #ecf0f1;
  }
  
  .ajax-progress::before {
    border: 2px solid #34495e;
    border-top: 2px solid #3498db;
  }
  
  .views-ajax-progress {
    background: rgba(44, 62, 80, 0.95);
    border-left-color: #2ecc71;
  }
  
  .views-ajax-progress::before {
    border: 3px solid #2c3e50;
    border-top: 3px solid #2ecc71;
  }
  
  .ajax-progress__message {
    color: #ecf0f1;
  }
  
  .views-ajax-progress__message {
    color: #2ecc71;
  }
  
  .ajax-progress-fullscreen {
    background: rgba(44, 62, 80, 0.98);
  }
  
  .ajax-progress-fullscreen::before {
    border: 4px solid #34495e;
    border-top: 4px solid #3498db;
  }
  
  .ajax-progress-fullscreen .ajax-progress__message {
    color: #ecf0f1;
  }
}

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

@media (max-width: 768px) {
  .ajax-progress {
    padding: 6px 10px;
    gap: 6px;
  }
  
  .ajax-progress::before {
    width: 18px;
    height: 18px;
  }
  
  .views-ajax-progress {
    padding: 8px 12px;
    gap: 8px;
  }
  
  .views-ajax-progress::before {
    width: 20px;
    height: 20px;
  }
  
  .ajax-progress__message,
  .views-ajax-progress__message {
    font-size: 13px;
  }
}

/* ========== АЛЬТЕРНАТИВНЫЕ ЦВЕТА ========== */

/* Синий вариант */
.ajax-progress--blue::before {
  border-top-color: #2563eb;
}

.views-ajax-progress--blue::before {
  border-top-color: #2563eb;
}

/* Красный вариант */
.ajax-progress--red::before {
  border-top-color: #e74c3c;
}

.views-ajax-progress--red::before {
  border-top-color: #c0392b;
}

/* Оранжевый вариант */
.ajax-progress--orange::before {
  border-top-color: #f39c12;
}

.views-ajax-progress--orange::before {
  border-top-color: #e67e22;
}

/* Фиолетовый вариант */
.ajax-progress--purple::before {
  border-top-color: #9b59b6;
}

.views-ajax-progress--purple::before {
  border-top-color: #8e44ad;
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ АНИМАЦИИ ========== */

/* Пульсирующая анимация */
@keyframes custom-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.ajax-progress--pulse::before {
  animation: custom-pulse 1.5s ease-in-out infinite;
}

/* Двойная анимация */
@keyframes custom-spin-pulse {
  0% {
    transform: rotate(0deg);
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    transform: rotate(360deg);
    opacity: 1;
  }
}

.ajax-progress--spin-pulse::before {
  animation: custom-spin-pulse 1.2s linear infinite;
}