/**
 * CSS for handling responsive product descriptions and embedded content
 * For EZP Store Bootstrap 5.3.3 integration
 */

/* 商品描述中的所有元素保持在容器內 */
.goods-description {
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 處理所有嵌入內容的響應式顯示 */
.goods-description iframe,
.goods-description embed,
.goods-description object,
.goods-description video,
.tab-content iframe,
.tab-content embed,
.tab-content object,
.tab-content video {
  max-width: 100%;
  height: auto;
}

/* 響應式圖片容器 */
.img-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

/* 處理超寬表格 */
.goods-description table {
  table-layout: auto;
  width: 100% !important;
}

/* 確保表格內的圖片不超出 */
.goods-description table img {
  max-width: 100% !important;
}

/* 處理用戶生成內容中的常見問題 */
.goods-description div[style*="width"],
.goods-description span[style*="width"],
.goods-description p[style*="width"] {
  max-width: 100% !important;
  width: auto !important;
}

/* ===========================
   Quantity Selector Styles
   =========================== */

/* Quantity Selector Container */
.quantity-wrapper {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  overflow: hidden;
  display: inline-flex;
  align-items: stretch;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease;
}

.quantity-wrapper:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.quantity-wrapper .btn {
  border: none;
  border-radius: 0;
  background: #f8f9fa;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  font-size: 1rem;
  color: #495057;
}

.quantity-wrapper .btn:hover:not(:disabled) {
  background: #e9ecef;
  color: var(--ezp-bright-blue, #0066cc);
}

.quantity-wrapper .btn:active:not(:disabled) {
  background: #dee2e6;
  transform: scale(0.95);
}

.quantity-wrapper .btn:disabled,
.quantity-wrapper .btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f8f9fa;
  color: #adb5bd;
}

.quantity-wrapper input {
  border: none;
  border-left: 1px solid #dee2e6;
  border-right: 1px solid #dee2e6;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  width: 60px;
  padding: 0.5rem 0.25rem;
  transition: all 0.15s ease;
  background: white;
  color: #212529;
}

.quantity-wrapper input:focus {
  outline: none;
  background: #f0f8ff;
  border-left-color: var(--ezp-bright-blue, #0066cc);
  border-right-color: var(--ezp-bright-blue, #0066cc);
}

/* Remove spinner buttons from number input */
.quantity-wrapper input[type="number"]::-webkit-inner-spin-button,
.quantity-wrapper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quantity-wrapper input[type="number"] {
  -moz-appearance: textfield;
}

/* Button Icons */
.quantity-wrapper .bi {
  font-size: 1rem;
  line-height: 1;
}

/* Shake animation for limits */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.quantity-wrapper input.shake {
  animation: shake 0.2s ease-in-out;
}

/* Mobile Responsive */
@media (max-width: 576px) {
  .quantity-wrapper {
    max-width: 140px;
  }
  
  .quantity-wrapper .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
  }
  
  .quantity-wrapper input {
    width: 50px;
    font-size: 0.9rem;
    padding: 0.4rem 0.2rem;
  }
}


/* 媒體查詢以處理不同螢幕大小 */
@media (max-width: 768px) {
  .goods-description img {
    height: auto !important;
  }

  /* 小螢幕下的表格滾動 */
  .goods-description .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 活動標籤手機版字體縮小 */
@media (max-width: 991.98px) {
  .activity-tags .badge {
    font-size: 0.75rem !important;
    margin-right: 0.25rem !important;
  }
  .activity-tags a {
    font-size: 0.8rem !important;
  }
  .activity-tags .text-danger.fw-bold {
    font-size: 0.8rem !important;
  }
}
