
/*
  Products 前台商品樣式
*/
/* ========== 商品詳情頁圖片（取代 inline style） ========== */
.product-main-image {
  max-height: 500px;
  width: 100%;
  object-fit: contain;
}

.product-related-img {
  height: 200px;
  object-fit: cover;
  width: 100%;
}

.product-placeholder-img {
  background-color: var(--theme-section-alt-bg-color, #f8f9fa);
}

.qty-input-group {
  max-width: 150px;
}

.qty-number-input,
.product-model-selector input[type=number] {
  max-width: 60px;
  text-align: center !important;
  -moz-appearance: textfield;
}
.qty-number-input::-webkit-inner-spin-button, .qty-number-input::-webkit-outer-spin-button,
.product-model-selector input[type=number]::-webkit-inner-spin-button,
.product-model-selector input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field-label {
  font-size: 0.875rem;
  color: #495057;
}

.products-count-highlight {
  color: var(--theme-primary-color);
  font-weight: 700;
}

/* 側邊欄樣式：請見 application.scss 的「前台側邊欄」section（共用）*/
/* ========== 價格區間篩選 ========== */
.price-range-form .price-range-inputs {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.625rem;
}
.price-range-form .price-range-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  -moz-appearance: textfield;
}
.price-range-form .price-range-input::-webkit-inner-spin-button, .price-range-form .price-range-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.price-range-form .price-range-separator {
  flex-shrink: 0;
  color: #adb5bd;
  font-size: 0.875rem;
}
.price-range-form .price-range-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.price-range-form .price-range-submit {
  flex: 1;
}
.price-range-form .price-range-clear {
  font-size: 0.8125rem;
  color: #6c757d;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.price-range-form .price-range-clear:hover {
  color: #dc3545;
  text-decoration: none;
}

.btn-theme-outline {
  color: var(--theme-primary-color);
  border-color: var(--theme-primary-color);
  background: transparent;
}
.btn-theme-outline:hover, .btn-theme-outline:focus {
  background-color: var(--theme-primary-color);
  color: #fff;
}

/* ========== 商品列表頁工具列（數量 + 排序） ========== */
.products-toolbar {
  border-bottom: 1px solid var(--theme-border-color, #e9ecef);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.products-sort-form {
  gap: 0.5rem;
}

.products-sort-select {
  min-width: 130px;
}

/* 商品數量顯示 */
.products-count {
  font-size: 1rem;
}

/* 空商品狀態 */
.empty-products-state {
  padding: 4rem 2rem;
}
.empty-products-state .empty-products-icon svg {
  opacity: 0.3;
}
.empty-products-state .empty-products-title {
  font-weight: 600;
  color: #1e293b;
}
@media (max-width: 768px) {
  .empty-products-state {
    padding: 3rem 1rem;
  }
  .empty-products-state .empty-products-icon svg {
    width: 80px;
    height: 80px;
  }
}

/* ========== 商品詳情頁 ========== */
/* 右側商品資訊區塊：桌面版 sticky */
@media (min-width: 768px) {
  .product-info-section {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 transparent;
  }
  .product-info-section::-webkit-scrollbar {
    width: 4px;
  }
  .product-info-section::-webkit-scrollbar-track {
    background: transparent;
  }
  .product-info-section::-webkit-scrollbar-thumb {
    background: #dee2e6;
  }
}

/* 右側面板各節：以 border-top 分隔，取代巢狀 card wrapper */
.product-panel-section {
  border-top: 1px solid var(--theme-border-color, #dee2e6);
  padding: 1.25rem 0;
}
.product-panel-section:first-child {
  border-top: none;
  padding-top: 0;
}

/* 節標題（如「選擇規格」） */
.product-panel-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #495057;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* 標籤群組：溫層、門市限定、分類標籤集中同一行 */
.product-badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

/* 下方商品規格資訊表 */
.product-meta-card .product-meta-row {
  display: flex;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f3f5;
  font-size: 0.875rem;
}
.product-meta-card .product-meta-row:last-child {
  border-bottom: none;
}
.product-meta-card .product-meta-label {
  min-width: 130px;
  color: #6c757d;
  flex-shrink: 0;
}
.product-meta-card .product-meta-value {
  color: #212529;
  word-break: break-word;
}

.product-detail-title {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}
@media (max-width: 768px) {
  .product-detail-title {
    font-size: 1.25rem;
  }
}

.product-top-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.product-subtitle {
  font-size: 0.875rem;
  color: #6c757d;
  line-height: 1.5;
}

/* 商品標籤 */
.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.product-tags .product-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  background: #fff;
  border: 1px solid var(--theme-border-color, #dee2e6);
  color: #6c757d;
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s ease;
}
.product-tags .product-tag:hover {
  border-color: var(--theme-primary-color);
  color: var(--theme-primary-color);
  text-decoration: none;
}

/* 商品價格區塊（無背景，僅左側主題色細線） */
.product-price-section {
  border-left: 3px solid var(--theme-primary-color);
  padding-left: 0.75rem;
}
.product-price-section .product-price-current {
  font-size: 1.75rem;
  font-weight: 700;
  color: #dc3545;
}
@media (max-width: 768px) {
  .product-price-section .product-price-current {
    font-size: 1.5rem;
  }
}

/* React ProductModelSelector：選中規格後的價格/庫存行 */
.selected-model-info {
  border-top: 1px solid var(--theme-border-color, #dee2e6);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.product-description {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5em;
  max-height: 4.5em;
}

/* ========== 商品規格選擇樣式 ========== */
.product-model-options .custom-control {
  margin-bottom: 0;
}
.product-model-options .custom-control-label {
  cursor: pointer;
  padding: 0.75rem 1rem;
  border: 1px solid var(--theme-border-color, #dee2e6);
  margin-bottom: 0.75rem;
  transition: all 0.2s ease;
  background: #fff;
  width: 100%;
}
.product-model-options .custom-control-label:hover {
  background-color: var(--theme-section-alt-bg-color, #f8f9fa);
  border-color: var(--theme-primary-color);
}
.product-model-options .custom-control:last-child .custom-control-label {
  margin-bottom: 0;
}
.product-model-options .custom-control-input:checked ~ .custom-control-label {
  border-color: var(--theme-primary-color);
  border-width: 2px;
  background-color: #fff;
}
.product-model-options .custom-control-input:disabled ~ .custom-control-label {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--theme-section-alt-bg-color, #f8f9fa);
}
.product-model-options .custom-control-input:disabled ~ .custom-control-label:hover {
  transform: none;
}
.product-model-options .custom-control-input:disabled ~ .custom-control-label .model-name {
  text-decoration: line-through;
}
.product-model-options .model-name {
  font-weight: 600;
  color: #212529;
  transition: color 0.2s ease;
}
.product-model-options .model-price-info {
  white-space: nowrap;
  font-weight: 600;
}

/* ========== 加入購物車區塊樣式 ========== */
.selected-price {
  padding: 1rem 0;
  border-bottom: 2px dashed var(--theme-border-color, #dee2e6);
}

.qty-control .btn {
  transition: all 0.2s ease;
}
.add-to-cart-btn {
  font-weight: 700;
  transition: all 0.3s ease;
}
.add-to-cart-btn.adding {
  background-color: #6c757d;
  border-color: #6c757d;
  cursor: wait;
}
.add-to-cart-btn.added {
  background: #28a745;
  border-color: #28a745;
}

/* ========== 商品詳細資訊頁籤 ========== */
.nav-tabs {
  border-bottom: 2px solid var(--theme-border-color, #dee2e6);
}
.nav-tabs .nav-item {
  margin-bottom: -2px;
}
.nav-tabs .nav-link {
  font-weight: 500;
  color: #6c757d;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 1rem 1.5rem;
  transition: all 0.2s ease;
}
.nav-tabs .nav-link:hover {
  color: var(--theme-primary-color);
  background: var(--theme-section-alt-bg-color, #f8f9fa);
}
.nav-tabs .nav-link.active {
  color: var(--theme-primary-color);
  background: transparent;
  border-bottom-color: var(--theme-primary-color);
}

.tab-content {
  padding: 2rem;
  border: 1px solid var(--theme-border-color, #dee2e6);
  border-top: none;
  background: #fff;
}
.tab-content p {
  line-height: 1.8;
}

/* ========== 商品圖片放大 Lightbox ========== */
.product-lightbox-trigger {
  cursor: zoom-in;
  display: block;
}
@media (max-width: 767.98px) {
  .product-lightbox-trigger {
    cursor: default;
    pointer-events: none;
  }
}

/* ========== 行動版：carousel 下方水平縮圖列 ========== */
.product-mobile-img-strip {
  display: flex;
  flex-direction: row;
  gap: 6px;
  margin-top: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.product-mobile-img-strip::-webkit-scrollbar {
  display: none;
}
.product-mobile-img-strip .product-mobile-img-item {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 2px solid var(--theme-border-color, #dee2e6);
  overflow: hidden;
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.15s ease;
}
.product-mobile-img-strip .product-mobile-img-item picture {
  display: block;
  width: 100%;
  height: 100%;
}
.product-mobile-img-strip .product-mobile-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-mobile-img-strip .product-mobile-img-item.active {
  border-color: var(--theme-primary-color);
  border-width: 2px;
}

.product-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.82);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.product-lightbox.is-open {
  display: flex;
}
.product-lightbox .lightbox-inner {
  display: flex;
  background: #fff;
  overflow: hidden;
  max-width: 960px;
  width: 100%;
  max-height: 88vh;
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.product-lightbox .lightbox-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f4f4;
  position: relative;
}
.product-lightbox .lightbox-main .lightbox-img-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 2rem;
}
.product-lightbox .lightbox-main .lightbox-img-wrapper picture {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 80vh;
}
.product-lightbox .lightbox-main .lightbox-img-wrapper img {
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
}
.product-lightbox .lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease;
}
.product-lightbox .lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}
.product-lightbox .lightbox-nav.lightbox-prev {
  left: 0.875rem;
}
.product-lightbox .lightbox-nav.lightbox-next {
  right: 0.875rem;
}
.product-lightbox .lightbox-sidebar {
  width: 210px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--theme-border-color, #e9ecef);
  background: #fff;
  overflow: hidden;
}
.product-lightbox .lightbox-product-name {
  padding: 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #212529;
  border-bottom: 1px solid var(--theme-border-color, #e9ecef);
  line-height: 1.45;
  word-break: break-word;
  flex-shrink: 0;
}
.product-lightbox .lightbox-thumbnails {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.product-lightbox .lightbox-thumb {
  cursor: pointer;
  border: 2px solid transparent;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}
.product-lightbox .lightbox-thumb picture {
  display: block;
}
.product-lightbox .lightbox-thumb img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.product-lightbox .lightbox-thumb.active, .product-lightbox .lightbox-thumb:hover {
  border-color: var(--theme-primary-color);
}
.product-lightbox .lightbox-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease;
}
.product-lightbox .lightbox-close:hover {
  background: rgba(0, 0, 0, 0.85);
}
@media (max-width: 768px) {
  .product-lightbox {
    padding: 0;
  }
  .product-lightbox .lightbox-inner {
    flex-direction: column;
    max-height: 100dvh;
  }
  .product-lightbox .lightbox-main .lightbox-img-wrapper {
    padding: 1rem;
  }
  .product-lightbox .lightbox-main .lightbox-img-wrapper img {
    max-height: 52vh;
  }
  .product-lightbox .lightbox-sidebar {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--theme-border-color, #e9ecef);
    max-height: 32vh;
  }
  .product-lightbox .lightbox-thumbnails {
    flex-direction: row;
    overflow-y: hidden;
    overflow-x: auto;
  }
  .product-lightbox .lightbox-thumbnails .lightbox-thumb {
    min-width: 72px;
  }
  .product-lightbox .lightbox-thumbnails .lightbox-thumb img {
    height: 60px;
  }
  .product-lightbox .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
  }
}

/* ========== 桌面版：carousel 下方水平縮圖列（md+ 顯示） ========== */
.product-desktop-thumb-strip {
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.product-desktop-thumb-strip .product-desktop-thumb-item {
  width: 64px;
  height: 64px;
  border: 2px solid var(--theme-border-color, #dee2e6);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}
.product-desktop-thumb-strip .product-desktop-thumb-item picture {
  display: block;
  width: 100%;
  height: 100%;
}
.product-desktop-thumb-strip .product-desktop-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-desktop-thumb-strip .product-desktop-thumb-item.active, .product-desktop-thumb-strip .product-desktop-thumb-item:hover {
  border-color: var(--theme-primary-color);
}

/* ========== prefers-reduced-motion ========== */
@media (prefers-reduced-motion: reduce) {
  .product-tag,
.product-desktop-thumb-item,
.product-mobile-img-item,
.add-to-cart-btn,
.lightbox-nav,
.lightbox-close,
.category-tag-btn {
    transition: none;
  }
}
