/* ========================================
   輪播響應式樣式 - 圖片不放大、保持原比例
   ======================================== */

/* ========== 基礎輪播容器 ========== */
.banner {
  width: 100%;
  position: relative;
  overflow: hidden;
  background-color: #f0e5de;
}

.banner .carousel {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* 輪播容器 */
.carousel-inner {
  width: 100%;
  position: relative;
}

/* 輪播項目 - 使用固定寬高比 */
.carousel-item {
  width: 100%;
  position: relative;
  overflow: hidden;
  background-color: #f0e5de;
}

/* 確保連結包滿圖片 */
.carousel-item a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

/* ========== 圖片響應式處理 - 不放大 ========== */
.carousel-item img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
  margin: 0 auto;
}

/* ========== 桌面版設定 ========== */
@media (min-width: 1200px) {
  .carousel-item {
    height: auto;
    max-height: 550px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 550px;
    object-fit: contain;
  }
}

@media (min-width: 992px) and (max-width: 1199px) {
  .carousel-item {
    height: auto;
    max-height: 480px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: contain;
  }
}

/* ========== 平板版設定 ========== */
@media (min-width: 768px) and (max-width: 991px) {
  .carousel-item {
    height: auto;
    max-height: 380px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 380px;
    object-fit: contain;
  }
  
  .banner .carousel-control-prev,
  .banner .carousel-control-next {
    width: 50px;
  }
  
  .banner .carousel-control-prev-icon,
  .banner .carousel-control-next-icon {
    width: 35px;
    height: 35px;
  }
}

/* ========== 手機版設定 ========== */
@media (max-width: 767px) {
  .banner {
    margin-top: 10px !important;
  }
  
  .carousel-item {
    height: auto;
    min-height: 180px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }
  
  /* 輪播指示器調整 */
  .banner .carousel-indicators {
    bottom: 10px;
  }
  
  .banner .carousel-indicators li {
    width: 8px;
    height: 8px;
    margin: 0 4px;
  }
  
  .banner .carousel-indicators li.active {
    width: 24px;
    height: 8px;
  }
  
  /* 左右箭頭調整 */
  .banner .carousel-control-prev,
  .banner .carousel-control-next {
    width: 40px;
    opacity: 0.8;
  }
  
  .banner .carousel-control-prev-icon,
  .banner .carousel-control-next-icon {
    width: 30px;
    height: 30px;
    padding: 6px;
  }
  
  /* 圓角調整 */
  .banner .carousel {
    border-radius: 0 0 12px 12px;
  }
}

/* ========== 極小螢幕（小手機）========== */
@media (max-width: 576px) {
  .carousel-item {
    height: auto;
    min-height: 140px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }
  
  .banner .carousel-indicators {
    bottom: 8px;
  }
  
  .banner .carousel-indicators li {
    width: 6px;
    height: 6px;
    margin: 0 3px;
  }
  
  .banner .carousel-indicators li.active {
    width: 18px;
    height: 6px;
  }
  
  .banner .carousel-control-prev,
  .banner .carousel-control-next {
    width: 35px;
  }
  
  .banner .carousel-control-prev-icon,
  .banner .carousel-control-next-icon {
    width: 25px;
    height: 25px;
    padding: 5px;
  }
}

/* ========== 橫向模式處理 ========== */
@media (max-width: 768px) and (orientation: landscape) {
  .carousel-item {
    height: auto;
    max-height: 280px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: contain;
  }
}

/* ========== 載入動畫 ========== */
.carousel-item {
  transition: transform 0.6s ease-in-out;
}

/* ========== 觸控優化 ========== */
@media (hover: none) and (pointer: coarse) {
  .banner .carousel-control-prev,
  .banner .carousel-control-next {
    opacity: 0.7;
  }
  
  .banner .carousel-control-prev:active,
  .banner .carousel-control-next:active {
    opacity: 1;
  }
}

/* ========== 高解析度螢幕優化 ========== */
@media (min-width: 1400px) {
  .carousel-item {
    height: auto;
    max-height: 600px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
  }
}

@media (min-width: 1600px) {
  .carousel-item {
    height: auto;
    max-height: 650px;
  }
  
  .carousel-item img {
    width: 100%;
    height: auto;
    max-height: 650px;
    object-fit: contain;
  }
}

/* ========== 確保容器不會溢出 ========== */
.banner,
.banner .carousel,
.carousel-inner {
  max-width: 100vw;
  overflow-x: hidden;
}

/* ========== 載入時的佔位 ========== */
.carousel-item {
  background-color: #f0e5de;
}

/* ========== 確保第一張圖片快速載入 ========== */
.carousel-item.active img {
  will-change: transform;
}

/* ========== 過渡效果優化 ========== */
.carousel-item-next,
.carousel-item-prev,
.carousel-item.active {
  display: block;
}

/* ========== 性能優化 ========== */
.carousel-inner {
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}