/* === УМНАЯ СИСТЕМА АДАПТИВНОСТИ ИЗОБРАЖЕНИЙ === */

/* Базовый класс для умных изображений */
.smart-image {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.smart-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

/* Состояния изображения */
.smart-image.mode-contain img {
  object-fit: contain !important;
}

.smart-image.mode-cover img {
  object-fit: cover !important;
}

.smart-image.mode-fill img {
  object-fit: fill !important;
}

/* Интерактивность */
.smart-image:hover img {
  transform: scale(1.03);
}

.smart-image.clickable:hover img {
  object-fit: cover;
  transform: scale(1.05);
}

/* Индикатор режима просмотра */
.smart-image::before {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.smart-image:hover::before {
  opacity: 1;
}

.smart-image.mode-contain::before {
  background: #28a745; /* Зеленый - полное изображение */
}

.smart-image.mode-cover::before {
  background: #ffc107; /* Желтый - обрезанное изображение */
}

/* Адаптивные контейнеры для автомобилей */
.car-image-container {
  position: relative;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  overflow: hidden;
}

.car-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: all 0.4s ease;
}

/* === АДАПТИВНЫЕ ПРАВИЛА ДЛЯ УМНЫХ ИЗОБРАЖЕНИЙ === */

/* Планшеты в альбомной ориентации */
@media (max-width: 1024px) and (min-width: 769px) {
  .car-image-container img,
  .smart-image img {
    object-fit: contain !important;
    background: #f8f9fa;
  }

  .smart-image:hover img {
    transform: scale(1.02);
    object-fit: contain !important;
  }
}

/* Планшеты в портретной ориентации */
@media (max-width: 768px) and (min-width: 481px) {
  .car-image-container img,
  .smart-image img {
    object-fit: contain !important;
    background: #f8f9fa;
  }

  /* Отключаем эффекты наведения на планшетах */
  .smart-image:hover img {
    transform: none;
    object-fit: contain !important;
  }
}

@media (min-width: 769px) {
  .car-image-container:hover img {
    object-fit: cover;
    transform: scale(1.02);
  }
}

/* Специальные правила для карточек автомобилей */
.car-card-smart {
  position: relative;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  overflow: hidden;
}

.car-card-smart img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: all 0.3s ease;
}

.car-card-smart:hover img {
  object-fit: cover;
  transform: scale(1.05);
}

/* Кнопка переключения режима просмотра */
.image-mode-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.smart-image:hover .image-mode-toggle {
  opacity: 1;
}

.image-mode-toggle:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Полноэкранный режим */
.image-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-fullscreen img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

/* Анимации загрузки */
.smart-image.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Улучшенная типографика для подписей */
.image-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 20px 15px 15px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.smart-image:hover .image-caption {
  opacity: 1;
}

/* Мобильные устройства - без обрезки */
@media (max-width: 480px) {
  .smart-image img,
  .car-card-smart img {
    object-fit: contain !important;
    background: #f8f9fa;
  }

  .smart-image:hover img,
  .car-card-smart:hover img {
    transform: none;
    object-fit: contain !important;
  }

  .image-mode-toggle {
    display: none;
  }
}

/* Высокие экраны */
@media (min-height: 800px) {
  .car-image-container {
    min-height: 300px;
  }
}

/* Широкие экраны */
@media (min-width: 1400px) {
  .car-image-container {
    min-height: 400px;
  }
  
  .smart-image img {
    object-fit: cover;
  }

  .smart-image:hover img {
    object-fit: cover;
  }
}
