/* 修正表格版面問題 - 恢復正常table布局 */
.table {
  table-layout: auto;
  width: 100%;
  border-collapse: collapse;
}

/* 確保主表格容器正常顯示 */
.shop-cart {
  width: 100%;
}

/* 加價購區域 - 獨立於table之外，緊貼購物車下方 */
.addon-section {
  width: 100%;
  margin: 0 0 20px 0; /* 上邊距為0，緊貼購物車 */
  background: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
}

/* 當沒有加價購時的間隔 */
.addon-section-spacer {
  height: 0;
  margin: 0;
}

/* Addon Products - Toggle Button Styles */
.addon-toggle-container {
  padding: 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.addon-toggle-container:hover {
  background: #e9ecef;
}

.addon-toggle-button {
  display: flex;
  align-items: center;
  font-size: 16px;
  width: 100%;
}

.addon-chevron {
  transition: transform 0.3s ease;
}

.addon-chevron.expanded {
  transform: rotate(180deg);
}

/* 加價購商品容器 */
.addon-products-container {
  background: #EDF6F8;
  padding: 20px;
  border-radius: 0 0 8px 8px;
}

.addon-products-wrapper {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.addon-table-swiper {
  padding: 0 35px 15px 35px;
  margin: 0;
  overflow: hidden;
  position: relative;
}

/* 確保 swiper wrapper 能正常滾動 */
.addon-table-swiper .swiper-wrapper {
  align-items: stretch;
  display: flex;
}

.addon-card {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  height: 300px;
  width: 240px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.addon-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(30,133,69,0.15);
  border-color: #1e8545;
}

.addon-card-image {
  height: 160px;
  overflow: hidden;
  background: #f8f9fa;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.addon-card-image a {
  display: block;
  height: 100%;
  width: 100%;
}

.addon-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.addon-card-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
}

.addon-card-details {
  margin-bottom: 8px;
}

.addon-card-name {
  font-size: 15px;
  font-weight: 600;
  color: #323130;
  margin: 0 0 8px 0;
  line-height: 1.3;
  height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.addon-card-shop {
  font-size: 11px;
  color: #6c757d;
  margin-bottom: 6px;
}

.addon-card-price {
  margin-bottom: 8px;
}

.addon-card-price .original-price {
  font-size: 10px;
  color: #6c757d;
  text-decoration: line-through;
  margin-bottom: 2px;
  display: block;
}

.addon-card-price .current-price {
  font-size: 16px;
  font-weight: 700;
  color: #FF6543;
  margin: 0;
}

.addon-card-actions {
  margin-top: auto;
}

.addon-quantity-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: center;
  margin-bottom: 6px;
}

.addon-quantity-controls .btn-quantity-minus,
.addon-quantity-controls .btn-quantity-plus {
  width: 20px;
  height: 20px;
  border: 1px solid #dee2e6;
  background: white;
  cursor: pointer;
  border-radius: 2px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.addon-quantity-controls .btn-quantity-minus:hover,
.addon-quantity-controls .btn-quantity-plus:hover {
  background: #f8f9fa;
  border-color: #1e8545;
}

.addon-quantity-controls .addon-quantity {
  width: 30px;
  height: 20px;
  text-align: center;
  border: 1px solid #dee2e6;
  border-radius: 2px;
  font-size: 10px;
}

.btn-add-addon {
  width: 100%;
  background: #1e8545;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  min-height: 36px;
}

.btn-add-addon:hover {
  background: #186639;
  transform: translateY(-1px);
}

.btn-added-addon-card {
  width: 100%;
  background: #28a745;
  color: white;
  border: none;
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  min-height: 28px;
}

.btn-unavailable-card {
  width: 100%;
  background: #6c757d;
  color: white;
  border: none;
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 11px;
  cursor: not-allowed;
  min-height: 28px;
}

.addon-nav-next,
.addon-nav-prev {
  width: 32px;
  height: 32px;
  background: #1e8545;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(30,133,69,0.3);
  transition: all 0.2s ease;
  margin-top: -16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.addon-nav-next:hover,
.addon-nav-prev:hover {
  background: #186639;
  transform: scale(1.05);
}

.addon-nav-next::after,
.addon-nav-prev::after {
  color: white;
  font-size: 10px;
  font-weight: bold;
}

.addon-summary-row {
  background: #f1f8f5;
  border-radius: 4px;
  padding: 12px 15px;
  margin-top: 12px;
  border-left: 4px solid #1e8545;
}

.addon-summary-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

.addon-selected-info {
  color: #323130;
  font-size: 13px;
}

.addon-total-info {
  color: #FF6543;
  font-size: 14px;
  font-weight: 600;
}

.addon-count,
.addon-amount {
  font-weight: 700;
}

.addon-total-row {
  background: #f8f9fa !important;
  border-top: 2px solid #1e8545;
}

.addon-total-label {
  font-weight: 600;
  color: #1e8545;
  text-align: right;
  padding-right: 15px !important;
}

.addon-total-amount {
  font-weight: 600;
  color: #FF6543;
}

.grand-total-row {
  background: #EDF6F8 !important;
  border-top: 2px solid #1e8545;
}

.grand-total-label {
  font-weight: 700;
  font-size: 16px;
  text-align: right;
  padding-right: 15px !important;
}

.grand-total-amount {
  font-weight: 700;
  font-size: 16px;
}

/* 小計區域樣式 */
.cart-summary-section {
  width: 100%;
  margin: 15px 0;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  overflow: hidden;
}

.cart-summary-content {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);
}

.summary-left {
  flex: 1;
}

.summary-center {
  flex: 1;
  text-align: center;
}

.summary-right {
  flex: 1;
  text-align: right;
}

.summary-quantity {
  color: #323130;
  font-size: 14px;
  font-weight: 500;
}

.quantity-number {
  color: #1e8545;
  font-weight: 600;
  font-size: 16px;
  margin: 0 2px;
}

.summary-total {
  color: #FF6543;
  font-size: 16px;
  font-weight: 600;
}

.total-amount {
  font-weight: 700;
  font-size: 18px;
  color: #FF6543;
}

@media (max-width: 768px) {
  .addon-section {
    margin: 0 0 15px 0; /* 手機版也緊貼上方 */
  }
  
  .cart-summary-section {
    margin: 10px 0;
  }
  
  .cart-summary-content {
    flex-direction: column;
    gap: 8px;
    padding: 12px 15px;
    text-align: center;
  }
  
  .summary-left,
  .summary-center,
  .summary-right {
    flex: none;
    text-align: center;
  }
  
  .summary-quantity {
    font-size: 13px;
  }
  
  .quantity-number {
    font-size: 15px;
  }
  
  .summary-total {
    font-size: 15px;
  }
  
  .total-amount {
    font-size: 17px;
  }
  
  .addon-products-container {
    padding: 15px;
  }
  
  .addon-products-wrapper {
    padding: 15px;
  }
  
  .addon-table-swiper {
    padding: 0 20px 10px 20px;
  }
  
  .addon-nav-next,
  .addon-nav-prev {
    width: 28px;
    height: 28px;
    margin-top: -14px;
  }
  
  .addon-card {
    height: 260px;
    width: 200px;
  }
  
  .addon-card-image {
    height: 120px;
  }
  
  .addon-card-content {
    padding: 12px;
  }
  
  .addon-card-name {
    font-size: 13px;
    height: 34px;
  }
  
  .addon-card-price .current-price {
    font-size: 14px;
  }
  
  .btn-add-addon {
    padding: 8px 10px;
    font-size: 12px;
    min-height: 32px;
  }
  
  .addon-quantity-controls .btn-quantity-minus,
  .addon-quantity-controls .btn-quantity-plus {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }
  
  .addon-quantity-controls .addon-quantity {
    width: 25px;
    height: 18px;
    font-size: 9px;
  }
  
  .addon-summary-content {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }
  
  .addon-selected-info,
  .addon-total-info {
    font-size: 12px;
  }
}

/* 手機橫向模式優化 */
@media (max-width: 926px) and (orientation: landscape) {
  .addon-card {
    height: 240px;
    width: 180px;
  }
  
  .addon-card-image {
    height: 100px;
  }
  
  .addon-card-content {
    padding: 10px;
  }
  
  .addon-card-name {
    font-size: 12px;
    height: 30px;
    margin: 0 0 4px 0;
  }
  
  .addon-card-price .current-price {
    font-size: 13px;
  }
  
  .btn-add-addon {
    padding: 6px 8px;
    font-size: 11px;
    min-height: 28px;
  }
  
  .addon-table-swiper {
    padding: 0 15px 8px 15px;
  }
  
  .addon-products-container {
    padding: 12px;
  }
  
  .addon-products-wrapper {
    padding: 12px;
  }
}

/* 針對更小的手機橫向模式 */
@media (max-width: 667px) and (orientation: landscape) {
  .addon-card {
    height: 220px;
    width: 160px;
  }
  
  .addon-card-image {
    height: 90px;
  }
  
  .addon-card-content {
    padding: 8px;
  }
  
  .addon-card-name {
    font-size: 11px;
    height: 28px;
  }
  
  .addon-card-price .current-price {
    font-size: 12px;
  }
  
  .btn-add-addon {
    padding: 5px 6px;
    font-size: 10px;
    min-height: 24px;
  }
}

/* 平板橫向模式優化 */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  .addon-card {
    height: 280px;
    width: 200px;
  }
  
  .addon-card-image {
    height: 140px;
  }
  
  .addon-card-content {
    padding: 14px;
  }
  
  .addon-card-name {
    font-size: 14px;
    height: 36px;
  }
  
  .addon-card-price .current-price {
    font-size: 15px;
  }
  
  .btn-add-addon {
    padding: 8px 10px;
    font-size: 12px;
    min-height: 32px;
  }
}