/* public/css/products.css */

/* 商品頁面橫幅 */
.products-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 57vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  position: relative;
  background-image: url("/public/images/banner.png");
  background-size: cover;
  background-position: top center;
}

.products-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.banner-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  padding: 0 2rem;
}

.banner-content h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.banner-subtitle {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.banner-description {
  font-size: 1.2rem;
  opacity: 0.8;
  line-height: 1.6;
}

/* 商品頁面主容器 - 避免與 base.css 的 .container 衝突 */
.products-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 1rem 0; /* 頂部增加 padding 避免被 navbar 遮擋 */
  min-height: 100vh;
}

.products-container {
  width: 100%;
  /* 移除原本的 .container 樣式，避免與 base.css 衝突 */
}

/* 購物車通知 - 調整位置避免與 navbar 重疊 */
.cart-notification {
  position: fixed;
  top: 120px; /* 增加距離頂部的高度 */
  right: 20px;
  background-color: #37b24d;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 999; /* 降低 z-index，避免蓋過 navbar */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.cart-notification.show {
  transform: translateX(0);
}

.notification-text {
  font-weight: 600;
}

.check-icon {
  font-size: 1.2rem;
  font-weight: bold;
}

/* 分類區塊 - 調整 margin 和 scroll 位置 */
.category-section {
  margin-bottom: 4rem;
  width: 100%;
  scroll-margin-top: 120px; /* 增加 scroll margin 避免被 navbar 遮擋 */
}

/* 分類標題容器 */
.category-header {
  text-align: center;
  margin-bottom: 2rem;
}

/* 分類標題 - 對應 CategoryHeader */
.category-header h2 {
  font-size: 2rem;
  color: #b8272e;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* 分類描述 - 對應 CategoryDescription */
.category-description {
  color: #666;
  margin-bottom: 1.5rem;
  max-width: 800px;
  line-height: 1.6;
}

/* 產品網格 - 對應 ProductGrid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 1.5rem;
  justify-content: center;
  align-items: start; /* 確保卡片頂部對齊 */
}

/* 產品卡片 - 對應 ProductCard */
.product-card {
  border: 1px solid #b8272e;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  height: auto; /* 讓卡片高度自適應 */
}

/* 產品圖片容器 - 對應 ProductImageContainer */
.product-image-container {
  position: relative;
  height: 300px;
  overflow: hidden;
  flex-shrink: 0; /* 防止圖片容器被壓縮 */
}

/* 產品圖片 - 對應 ProductImage */
.product-image {
  height: 100%;
  width: 100%;
  background-size: contain;
  background-position: center;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  background-repeat: no-repeat;
  background-color: #f8f9fa; /* 添加背景色，以便看到容器 */
}

.product-image.active {
  opacity: 1;
}

/* 如果圖片載入失敗，顯示佔位符 */
.product-image:not([style*="background-image"]) {
  background-color: #e9ecef;
  border: 2px dashed #ced4da;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image:not([style*="background-image"])::after {
  content: "圖片載入中...";
  color: #6c757d;
  font-size: 0.9rem;
}

/* 圖片導航 - 對應 ImageNav */
.image-nav {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 3;
}

/* 圖片圓點 - 對應 ImageDot */
.image-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #c4c4c4;
  margin: 0 4px;
  border: none;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
  transition: background-color 0.3s ease;
}

.image-dot.active {
  background-color: #b8272e;
}

/* 加入詢價按鈕 - 對應 AddButtonContainer */
.add-button {
  background-color: #c72f2f;
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  margin-top: auto; /* 讓按鈕固定在底部 */
  flex-shrink: 0; /* 防止按鈕被壓縮 */
}

.add-button.adding {
  background-color: #37b24d;
}

.add-button:active {
  background-color: #b02727;
}

.add-button.adding:active {
  background-color: #2b9d41;
}

/* 按鈕文字 - 對應 AddButtonText */
.add-button-text {
  color: white;
  margin: 0.2rem;
  font-weight: bold;
  font-size: 1.4rem;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
}

.add-button:active .add-button-text {
  transform: scale(0.96);
}

.add-button-text .check-icon {
  display: inline-block;
  margin-left: 0;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
}

.add-button.adding .add-button-text .check-icon {
  margin-left: 8px;
  opacity: 1;
  transform: scale(1);
}

/* 波紋效果 - 對應 ripple keyframe */
.add-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%, -50%);
  transform-origin: 50% 50%;
}

.add-button.ripple::after {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  100% {
    transform: scale(100, 100);
    opacity: 0;
  }
}

/* 購物車圖標 */
.cart-icon-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.cart-icon-container:hover {
  transform: scale(1.1);
}

.cart-icon {
  background-color: #b8272e;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 1.5rem;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ff4757;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  min-width: 24px;
}

.cart-count.hidden {
  display: none;
}

/* 購物車側邊欄 */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: white;
  z-index: 1001;
  transition: right 0.3s ease;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.cart-sidebar.open {
  right: 0;
}

.cart-header {
  padding: 1.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f9fa;
}

.cart-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.3rem;
}

.close-cart {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-cart:hover {
  color: #b8272e;
}

.cart-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.empty-cart-message {
  text-align: center;
  color: #666;
  font-style: italic;
  margin-top: 2rem;
}

.cart-item {
  display: flex;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid #eee;
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-image {
  width: 60px;
  height: 60px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 8px;
  margin-right: 1rem;
  border: 1px solid #ddd;
}

.cart-item-info {
  flex: 1;
}

.cart-item-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.cart-item-category {
  color: #666;
  font-size: 0.85rem;
}

.cart-item-quantity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.quantity-btn {
  background-color: #f0f0f0;
  border: none;
  width: 25px;
  height: 25px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #666;
}

.quantity-btn:hover {
  background-color: #e0e0e0;
}

.quantity-display {
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  font-size: 0.9rem;
}

.remove-item {
  color: #dc3545;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  margin-left: 0.5rem;
}

.remove-item:hover {
  color: #c82333;
}

.cart-footer {
  padding: 1.5rem;
  border-top: 1px solid #eee;
  background-color: #f8f9fa;
  display: flex;
  gap: 1rem;
}

.clear-cart-btn,
.checkout-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.clear-cart-btn {
  background-color: #6c757d;
  color: white;
}

.clear-cart-btn:hover {
  background-color: #5a6268;
}

.checkout-btn {
  background-color: #b8272e;
  color: white;
}

.checkout-btn:hover {
  background-color: #a02323;
}

.checkout-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* 購物車遮罩 */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.cart-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .banner-content h1 {
    font-size: 2rem;
  }

  .banner-subtitle {
    font-size: 1.2rem;
  }

  .banner-description {
    font-size: 1rem;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
  }

  .category-header h2 {
    font-size: 2rem;
  }

  .cart-sidebar {
    width: 100%;
    right: -100%;
  }

  .cart-icon-container {
    bottom: 20px;
    right: 20px;
  }

  .cart-icon {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .cart-count {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    top: -6px;
    right: -6px;
  }
}

@media (max-width: 480px) {
  .banner-content h1 {
    font-size: 1.5rem;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .category-header h2 {
    font-size: 1.5rem;
  }

  .products-page {
    padding: 2rem 0;
  }

  .container {
    padding: 0 0.5rem;
  }
}
