/* ============================================================================
   СОВРЕМЕННЫЕ СТИЛИ ДЛЯ КАРУСЕЛИ С ПОДДЕРЖКОЙ iOS
   ============================================================================ */

/* Базовые стили карусели */
.carousel {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  position: relative;
}

.carousel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.carousel ul li {
  text-align: center;
  position: relative;
  margin-right: 20px;
}

.carousel ul li:last-child {
  margin-right: 0;
}

.carousel ul li > span {
  display: block;
  margin: 0 auto 12px;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.2;
  height: 36px;
  overflow: hidden;
  padding: 0 5px;
}

.carousel ul li a {
  display: block;
  text-decoration: none;
  color: #333;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e0e0e0;
  margin-bottom: 8px;
}

.carousel ul li a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  border-color: #007cba;
}

.carousel ul li a img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
  background: #f8f8f8;
}

.carousel ul li a span {
  display: block;
  padding: 10px 8px;
  font-size: 13px;
  line-height: 1.3;
  background: rgba(255,255,255,0.95);
  margin-top: 0;
  border-top: 1px solid #f0f0f0;
}

/* ============================================================================
   АДАПТИВНЫЕ СТИЛИ
   ============================================================================ */

/* Планшеты */
@media (max-width: 1200px) {
  .carousel {
    max-width: 100%;
    padding: 8px 15px;
  }

  .carousel ul li > span {
    font-size: 13px;
    height: 32px;
  }
}

@media (max-width: 992px) {
  .carousel {
    padding: 6px 10px;
  }

  .carousel ul li > span {
    font-size: 12px;
    height: 30px;
  }

  .carousel ul li a span {
    font-size: 12px;
    padding: 6px 4px;
  }
}

/* Мобильные устройства */
@media (max-width: 768px) {
  .carousel {
    padding: 10px 15px;
  }

  .carousel ul li {
    margin-right: 0;
    margin-bottom: 15px;
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e8e8e8;
  }

  .carousel ul li:last-child {
    margin-bottom: 0;
  }

  .carousel ul li > span {
    font-size: 12px;
    height: auto;
    margin-bottom: 12px;
    line-height: 1.4;
    color: #333;
  }

  .carousel ul li a {
    margin: 0 auto;
    max-width: 160px;
    display: block;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
  }

  .carousel ul li a img {
    border-radius: 6px 6px 0 0;
    height: 95px;
    object-fit: cover;
  }

  .carousel ul li a span {
    font-size: 12px;
    padding: 8px 5px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
  }
}

/* Маленькие мобильные устройства */
@media (max-width: 480px) {
  .carousel {
    padding: 8px 12px;
  }

  .carousel ul li {
    margin-bottom: 12px;
    padding: 8px;
  }

  .carousel ul li > span {
    font-size: 11px;
    height: auto;
    margin-bottom: 10px;
    line-height: 1.3;
  }

  .carousel ul li a {
    max-width: 140px;
  }

  .carousel ul li a img {
    height: 85px !important;
    width: 140px !important;
  }

  .carousel ul li a span {
    font-size: 11px !important;
    padding: 6px 4px !important;
  }
}

/* ============================================================================
   СПЕЦИАЛЬНЫЕ ИСПРАВЛЕНИЯ ДЛЯ iOS
   ============================================================================ */

/* Определение iOS Safari */
@supports (-webkit-touch-callout: none) {
  .ios-carousel {
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
  }

  .ios-carousel .bx-wrapper {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  .ios-carousel .bx-viewport {
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
    position: relative;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .ios-carousel ul {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .ios-carousel ul li {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  /* Предотвращение зума на iOS */
  .ios-carousel img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
  }
}

/* Улучшение touch событий */
.ios-fix {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.ios-fix .bx-viewport {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.ios-fix .bx-controls-direction a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}

/* ============================================================================
   ИСПРАВЛЕНИЯ BxSlider ДЛЯ МОБИЛЬНЫХ
   ============================================================================ */

/* Переопределение inline стилей bxSlider для мобильных */
@media (max-width: 768px) {
  .bx-wrapper {
    width: 100% !important;
    max-width: 100%;
    margin: 0 auto;
  }

  .bx-wrapper .bx-viewport {
    width: 100% !important;
    height: auto !important;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  /* Улучшение для мобильных слайдеров */
  .bx-wrapper .bx-viewport ul {
    width: auto !important;
    display: flex;
    align-items: flex-start;
  }

  .bx-wrapper .bx-viewport ul li {
    flex: 0 0 auto;
    float: none !important;
  }
}

/* ============================================================================
   СТИЛИЗАЦИЯ КНОПОК УПРАВЛЕНИЯ
   ============================================================================ */

/* Убираем абсолютное позиционирование, чтобы кнопки были по центру */
.bx-controls {
  position: static;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  z-index: 100;
}

.bx-controls-direction {
  position: absolute;
  top: 50%;
  width: 100%;
  transform: translateY(-50%);
  z-index: 10;
  left: 0;
  pointer-events: none;
}

.bx-controls-direction a {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #ddd;
  border-radius: 50%;
  text-decoration: none;
  color: #666;
  font-size: 14px;
  font-weight: bold;
  pointer-events: all;
  transition: all 0.2s ease;
  cursor: pointer;
  z-index: 15;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.bx-prev {
  left: -45px;
}

.bx-next {
  right: -45px;
}

.bx-controls-direction a:hover {
  background: #fff;
  border-color: #007cba;
  color: #007cba;
  transform: scale(1.05);
  box-shadow: 0 3px 10px rgba(0,124,186,0.3);
}

.bx-controls-direction a:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
}

.bx-prev:before {
  border-width: 6px 8px 6px 0;
  border-color: transparent #666 transparent transparent;
  left: 52%;
}

.bx-next:before {
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #666;
  left: 48%;
}

.bx-prev:hover:before {
  border-color: transparent #007cba transparent transparent;
}

.bx-next:hover:before {
  border-color: transparent transparent transparent #007cba;
}

/* Мобильная адаптация кнопок */
@media (max-width: 768px) {
  .bx-prev {
    left: 5px;
  }

  .bx-next {
    right: 5px;
  }

  .bx-controls-direction a {
    width: 32px;
    height: 32px;
    font-size: 12px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
  }
}

@media (max-width: 480px) {
  .bx-prev {
    left: 2px;
  }

  .bx-next {
    right: 2px;
  }

  .bx-controls-direction a {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }
}

/* ============================================================================
   FALLBACK СТИЛИ ДЛЯ СТАТИЧЕСКОЙ КАРУСЕЛИ
   ============================================================================ */

.static-carousel {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 15px !important;
  overflow: visible !important;
  padding: 10px !important;
}

.static-carousel li {
  flex: 0 0 auto !important;
  float: none !important;
  display: block !important;
  text-align: center !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
}

.static-carousel li a {
  transform: none !important;
  transition: all 0.3s ease !important;
}

.static-carousel li a:hover {
  transform: translateY(-3px) !important;
}

/* ============================================================================
   ПРОИЗВОДИТЕЛЬНОСТЬ И ОПТИМИЗАЦИЯ
   ============================================================================ */

.carousel,
.carousel * {
  will-change: transform;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Улучшение производительности на мобильных */
@media (max-width: 768px) {
  .carousel,
  .carousel * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

/* ============================================================================
   ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ
   ============================================================================ */

/* Предотвращение мерцания */
.bx-wrapper .bx-viewport {
  -webkit-perspective: 1000;
  perspective: 1000;
}

/* Исправление z-index проблем */
.bx-wrapper {
  z-index: auto !important;
}

.bx-controls {
  z-index: 100 !important;
}

/* Улучшение доступности */
.bx-controls-direction a:focus {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .carousel ul li a:hover {
    transform: none;
  }

  .bx-controls-direction a {
    transition: none;
  }
}