/* ===== CSS Custom Properties (Design Tokens) ===== */
:root {
  /* 全局字體設定 (動森圓潤風格) */
  --bs-body-font-family: "Nunito", "GenJyuuGothic", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  /* 新色 */
  --color-brown: #794f27;
  --color-strong: #eb7373;
  --color-green: #82d7aa;
  --color-green-dark: #18ad61;
  --color-green-light: #d3e9dd;
  --color-green-guide: #a6e6c4;
  --color-blue: #5fa0d7;
  --color-blue-light: #dfeff1;
  --color-pink: #eb7373;
  --color-gray: #c8c8c3;
  --color-white: #f8f8f0;

  /* 品牌色 */
  --color-primary: rgba(25, 200, 185, 1);
  --color-primary-90: rgba(25, 200, 185, 0.9);
  --color-primary-20: rgba(25, 200, 185, 0.2);
  --color-primary-06: rgba(25, 200, 185, 0.06);

  /* 背景色 */
  --color-bg: #f8eebc;
  --color-bg-card: #fff;
  --color-bg-gray: #f8f9fa;

  /* 文字色 */
  --bs-body-font-size: 0.95rem;

  --color-text: #000;
  --color-text-muted: #adb5bd;

  /* 按鈕色 */
  --color-btn-cat: #a6e9d5;
  --color-btn-series: #9eeaf9;
  --color-btn-theme: #e2d9f3;
  --color-btn-other: #f7d6e6;

  /* Badge 色 */
  --color-danger: #dc3545;
  --color-success: #28a745;
  --color-warning: #ffc107;

  /* 間距 */
  --spacing-xs: 0.325rem;
  --spacing-sm: 0.475rem;
  --spacing-md: 0.5rem;
  --spacing-lg: 1rem;

  /* 圓角 */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  /* 陰影 */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.3);

  /* Grid 設定 */
  --grid-gap: var(--spacing-sm);
  --grid-item-min: 100px;
  --grid-item-max: 1fr;
}

html {
  text-rendering: optimizeLegibility !important;
  -moz-osx-font-smoothing: grayscale !important;
}

body {
  background-color: var(--color-bg) !important;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

nav.navbar {
  height: 50px;
  min-height: 50px;
  padding: 0;
}

nav.navbar,
footer a.btn {
  background-color: var(--color-primary-90);
  background-image: url(./images/pattern-dots.png);
  background-size: 10px 10px;
  background-position: 50% 50%;
  background-repeat: repeat;
}

/* ===== ACNH Style Category Buttons ===== */
.tag-container .btn-tag {
  border-radius: 99px !important;
  font-weight: 700 !important;
  padding: 0.35rem 0.6rem !important;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border-width: 2px !important;
  border-style: solid !important;
  margin: 0;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

/* 提高優先級，確保分類標籤內的圖標也套用 */
.tag-container .tag-icon,
.tag-icon {
  height: 26px !important;
  width: auto !important;
  margin-right: 1px !important;
  object-fit: contain;
  /* 使用負 margin 抵消高度，防止撐開按鈕 (Flexbox Hack) */
  margin-top: -8px !important;
  margin-bottom: -8px !important;
  /* 視覺微調 */
  transform: translateY(-0.5px);
}

.tag-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 1.1em;
  /* 稍微放大 Emoji */
  line-height: 1;
  /* Emoji 不使用負 margin，以自然大小呈現 */
}

/* Category: Green */
.tag-container .tag-category {
  background-color: var(--acnh-cream);
  border-color: var(--acnh-green);
  color: var(--acnh-brown);
}

.tag-container .tag-category:hover,
.tag-container .tag-category:focus,
.tag-container .tag-category:active,
.tag-container .tag-category.active {
  background-color: var(--acnh-green) !important;
  border-color: var(--acnh-green) !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(118, 197, 166, 0.3);
}

/* Series: Blue */
.tag-container .tag-series {
  background-color: var(--acnh-cream);
  border-color: var(--acnh-blue);
  color: var(--acnh-brown);
}

.tag-container .tag-series:hover,
.tag-container .tag-series:focus,
.tag-container .tag-series:active,
.tag-container .tag-series.active {
  background-color: var(--acnh-blue) !important;
  border-color: var(--acnh-blue) !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(95, 183, 229, 0.3);
}

/* Theme: Purple */
.tag-container .tag-theme {
  background-color: var(--acnh-cream);
  border-color: #ba68c8;
  color: var(--acnh-brown);
}

.tag-container .tag-theme:hover,
.tag-container .tag-theme:focus,
.tag-container .tag-theme:active,
.tag-container .tag-theme.active {
  background-color: #ba68c8 !important;
  border-color: #ba68c8 !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(186, 104, 200, 0.3);
}

/* Scene/Others: Red */
.tag-container .tag-scene,
.tag-container .tag-hot,
.tag-container .tag-new {
  background-color: var(--acnh-cream);
  border-color: var(--acnh-red);
  color: var(--acnh-brown);
}

.tag-container .tag-scene:hover,
.tag-container .tag-scene:focus,
.tag-container .tag-scene:active,
.tag-container .tag-scene.active,
.tag-container .tag-hot:hover,
.tag-container .tag-hot:focus,
.tag-container .tag-hot:active,
.tag-container .tag-hot.active,
.tag-container .tag-new:hover,
.tag-container .tag-new:focus,
.tag-container .tag-new:active,
.tag-container .tag-new.active {
  background-color: var(--acnh-red) !important;
  border-color: var(--acnh-red) !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

/* ===== 商品卡片 ===== */
.imgs {
  background-color: var(--color-bg-card) !important;
  border-radius: var(--radius-sm);
}

.main img {
  margin: var(--spacing-md) 0 0;
}

/* ===== 商品列表 Grid 佈局 ===== */
.article-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-item-min), var(--grid-item-max)));
  gap: var(--grid-gap);
  justify-content: center;
  padding-inline: 0.425rem;
}

.titles {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 1.2rem;
  /* 固定高度 */
  line-height: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.modal-dialog {
  max-width: 720px;
}

.pickamount {
  font-size: 1rem;
}

.clear-btn {
  margin-right: auto !important;
}

.count-badge {
  position: absolute;
  top: -0px;
  right: -0px;
  background: linear-gradient(180deg, #ff6b6b 0%, #e63946 100%);
  color: #fff;
  border-radius: 999px;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), 0 0 0 2px #fff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 10;
}

img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
select {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  -ms-user-select: text;
  user-select: text;
  touch-action: auto;
}

/* 加減按鈕立體回彈效果 */
.btn-increase,
.btn-decrease {
  transition: transform 80ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease;
  box-shadow: var(--shadow-sm);
  outline: none !important;
  background-color: var(--color-bg-gray);
  color: var(--color-text-muted);
  border-color: #dee2e6;
}

.btn-increase:active,
.btn-decrease:active,
.btn-increase.active,
.btn-decrease.active {
  transform: translateY(1px);
  background-color: var(--color-primary-90) !important;
  border-color: var(--color-primary-90) !important;
  color: #fff !important;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-increase:hover,
.btn-decrease:hover {
  background-color: var(--color-primary-06);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-increase:focus,
.btn-decrease:focus {
  background-color: var(--color-bg-gray);
  color: var(--color-text-muted);
  border-color: #dee2e6;
  box-shadow: var(--shadow-sm);
}

/* 手機等無 hover 裝置避免顏色卡住 */
@media (hover: none) {

  .btn-increase:hover,
  .btn-decrease:hover {
    background-color: var(--color-bg-gray);
    color: var(--color-text-muted);
    border-color: #dee2e6;
  }
}

/* 滾動至視窗時才淡入圖片，避免一次載入過多造成的突兀 */
.lazy-fade {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.lazy-fade.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Extracted Inline Styles */
.icon-cart {
  height: 1.25em;
  width: 1.25em;
  filter: brightness(0) invert(1);
}

.nav-icon-btn {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 0.375rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: background-color 0.2s;
  position: relative;
}

/* Ensure grid toggle button icon matches other nav icons */
#gridToggle .icon-cart {
  height: 1.25em;
  width: 1.25em;
  filter: brightness(0) invert(1);
}

.nav-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.nav-badge {
  position: absolute;
  top: 8px;
  right: 6px;
  transform: translate(50%, -50%);
  background: linear-gradient(180deg, #ffca2c 0%, #ffc107 100%);
  color: #000;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 0 0 2px #fff;
  pointer-events: none;
  z-index: 10;
}

/* 搜尋容器 */
.search-container {
  position: relative;
}

/* 桌面版搜尋框（直接顯示） */
@media (min-width: 768px) {
  .search-icon-trigger {
    display: none;
  }

  .search-form {
    display: flex;
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    padding: 0 0.5rem;
    margin: 0;
    box-shadow: none;
    backdrop-filter: none;
    height: 36px;
  }

  .search-form:hover,
  .search-form:focus-within {
    background: rgba(255, 255, 255, 0.3);
  }

  .search-input {
    width: 180px;
    padding: 0.3rem 0.5rem;
    border: none;
    background: transparent;
    color: #fff;
    border-radius: 0;
    font-size: 0.9rem;
    outline: none;
  }

  .search-input:focus {
    box-shadow: none;
    border: none;
  }

  .search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
  }
}

/* 手機版浮動搜尋框（獨立於導航欄） */
.search-form-mobile {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  z-index: 2001;
  width: 85vw;
  max-width: 400px;
  display: none;
}

.search-form-mobile.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.search-form-mobile .search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #dee2e6;
  border-radius: 0.5rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-form-mobile .search-input:focus {
  border-color: rgba(25, 200, 185, 0.8);
  box-shadow: 0 0 0 3px rgba(25, 200, 185, 0.2);
}

.search-form-mobile .search-input::placeholder {
  color: #adb5bd;
}

/* 手機版顯示浮動搜尋框，隱藏導航欄內的搜尋框 */
@media (max-width: 767px) {
  .search-icon-trigger {
    display: flex;
  }

  .search-form {
    display: none !important;
  }

  .search-form-mobile {
    display: block;
  }

  /* 浮動搜尋框的背景遮罩 */
  .search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
    z-index: 2000;
  }

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

/* 導航欄右側按鈕間隔 */
.ms-auto .nav-icon-btn {
  margin: 0;
}

.ms-auto .search-container+.nav-icon-btn {
  margin-left: 0.5rem;
}

.modal-body-centered {
  text-align: center;
}

/* Variant Text (Variation | Pattern) */
.variant-text {
  font-size: 0.775rem;
  color: #adb5bd;
  line-height: 1;
  height: 0.775rem;
  /* 固定高度 */
  padding-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Compact Mode Styles */
/* 使用 CSS 變數覆蓋 Grid 設定 */
:is(.compact-mode-loading, .compact-mode) {
  --grid-item-min: 71px;
  --grid-item-max: 1fr;
  --grid-gap: var(--spacing-xs);
}

:is(.compact-mode-loading, .compact-mode) .imgs .main {
  /* height: 100px !important;
  line-height: 100px !important; */
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

:is(.compact-mode-loading, .compact-mode) .imgs .main img {
  max-height: 100px !important;
  margin: 0 auto !important;
}

:is(.compact-mode-loading, .compact-mode) .titles {
  width: 100%;
  font-size: 0.7rem;
  height: 1.2rem;
  line-height: 1.2rem;
}

:is(.compact-mode-loading, .compact-mode) .variant-text {
  font-size: 0.65rem;
  height: 0.65rem;
  /* 保持與基礎高度一致 */
}

:is(.compact-mode-loading, .compact-mode) .btn-group {
  width: 100% !important;
}

:is(.compact-mode-loading, .compact-mode) .btn-increase,
:is(.compact-mode-loading, .compact-mode) .btn-decrease {
  font-size: 0.7rem !important;
  padding: 0.15rem 0.3rem !important;
  line-height: 1.5 !important;
  transition: transform 80ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease !important;
}

:is(.compact-mode-loading, .compact-mode) .btn-increase:hover,
:is(.compact-mode-loading, .compact-mode) .btn-decrease:hover {
  background-color: var(--color-primary-06) !important;
  color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

/* Preserve button effects in compact mode - Active state must come AFTER hover */
:is(.compact-mode-loading, .compact-mode) .btn-increase:active,
:is(.compact-mode-loading, .compact-mode) .btn-decrease:active,
:is(.compact-mode-loading, .compact-mode) .btn-increase.active,
:is(.compact-mode-loading, .compact-mode) .btn-decrease.active {
  transform: translateY(1px) !important;
  background-color: var(--color-primary-90) !important;
  border-color: var(--color-primary-90) !important;
  color: #fff !important;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.18) !important;
}

:is(.compact-mode-loading, .compact-mode) .d-grid {
  margin-bottom: 0 !important;
}

.feed-container {
  text-align: center;
}

/* Item Badges Container */
.item-badges-container {
  position: relative;
}

.item-image-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
}

/* Remove background when image is loaded */
.item-image-container.loaded {
  background-color: transparent;
}

/* 購物車中不需要載入底色 */
.cart-panel .item-image-container {
  background-color: transparent;
}

/* 購物車 modal 背景色 */
#shoplistModalCenter .modal-content {
  background-color: var(--color-blue-light);
}

/* 購物車尺寸為商品頁的 90% */
.cart-panel {
  --grid-item-min: 88px;
  --grid-item-max: 1fr;
  --grid-gap: 0.5rem;
}

/* 購物車 + compact mode（商品頁 compact 的 90%） */
.cart-panel:is(.compact-mode-loading, .compact-mode) {
  --grid-item-min: 70px;
  --grid-item-max: 1fr;
}

/* .cart-panel .imgs {
  border: 1px solid #dee2e6;
} */

/* 購物車文字和按鈕縮小 */
.cart-panel .titles {
  font-size: 0.8rem;
}

.cart-panel .variant-text {
  font-size: 0.75rem;
  height: 0.8rem;
  /* 保持一致高度 */
}

/* 購物車 + compact mode 文字按鈕更縮小 */
.cart-panel:is(.compact-mode-loading, .compact-mode) .titles {
  font-size: 0.7rem;
}

.cart-panel:is(.compact-mode-loading, .compact-mode) .variant-text {
  font-size: 0.6rem;
  height: 0.8rem;
  /* 保持一致高度 */
}

.item-image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
  z-index: 1;
}

/* Badge Corner Positioning */
.badge-corner {
  position: absolute;
  z-index: 1000;
  /* margin: 4px; */
}

.badge-top-left {
  top: 0;
  left: 0;
}

.badge-bottom-left {
  bottom: 0;
  left: 0;
}

.badge-top-right {
  top: 0;
  right: 0;
}

/* Badge Icon */
.badge-icon {
  object-fit: contain;
  display: block;
  opacity: 1;
}

/* Badge Text */
.badge-text {
  font-size: 0.6rem;
  padding: 1px 4px;
  border-radius: 0 8px 8px 0;
  display: inline-block;
  font-weight: 700;
}

.badge-danger {
  background: var(--color-danger);
  color: #fff;
}

/* ===== Specific Badge Type Adjustments ===== */
/* Uncomment and modify any of the following to fine-tune individual badge types */

/* Size Icon (furniture dimensions) */
.badge-size {
  margin-left: 4px;
  margin-top: 4px;
  width: 20px;
  height: 20px;
}

/* DIY Recipe Icon */
.badge-recipe {
  margin-left: 4px;
  margin-top: 4px;
  width: 24px;
  height: 24px;
}

/* Hybrid Flower Badge */
.badge-hybrid {
  color: #fff;
  background: var(--color-warning);
}

/* Stack Count Badge */
/* .badge-stack {
  margin-top: 4px;
} */

/* Saharah Series Badge */
/* .badge-saharah {
  font-size: 0.6rem;
} */

/* Genuine Art Badge */
.badge-genuine {
  color: #fff;
  background: var(--color-success);
  margin-bottom: 4px;
}

/* Catalog Icon */
.badge-catalog {
  margin-left: 4px;
  margin-bottom: 0px;
  width: 22px;
  height: 24px;
}

figure {
  margin: 0;
}

:is(.compact-mode-loading, .compact-mode) .badge-size {
  margin-top: 7px;
  width: 0.9rem;
  height: 0.9rem;
}

:is(.compact-mode-loading, .compact-mode) .badge-catalog {
  width: 1rem;
  height: 1.2rem;
}

:is(.compact-mode-loading, .compact-mode) .badge-recipe {
  width: 1.2rem;
  height: 1.2rem;
}

:is(.compact-mode-loading, .compact-mode) .badge-stack {
  margin-left: 0;
}

:is(.compact-mode-loading, .compact-mode) .badge-text {
  font-size: 0.55rem;
  padding: 1px 3px;
}

:is(.compact-mode-loading, .compact-mode) .count-badge {
  min-width: 18px;
  height: 18px;
  font-size: 0.7rem;
  line-height: 18px;
  padding: 0 3px;
}

:is(.compact-mode-loading, .compact-mode) .badge-top-left {
  top: -3px;
  left: 0;
}

:is(.compact-mode-loading, .compact-mode) .badge-top-right {
  top: 0;
  right: 0;
}

/* ===== 購物車分頁樣式 ===== */

.cart-tabs {
  display: flex;
  gap: 0;
}

.cart-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.2s, background 0.2s;
}

.cart-tab:hover {
  background: rgba(0, 0, 0, 0.03);
}

.cart-tab-count {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  background: #e9ecef;
  color: #666;
}

.cart-tab.active .cart-tab-count {
  background: var(--color-primary-20);
  color: var(--color-primary);
}

/* 可滑動面板容器 */
.cart-panels-wrapper {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.cart-panels {
  display: flex;
  align-items: stretch;
  width: 200%;
  height: 100%;
  transition: transform 0.3s ease;
}

.cart-panel {
  width: 50%;
  height: 100%;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--spacing-md);
  -webkit-overflow-scrolling: touch;
}

/* 防止 grid 子元素被 flex 拉伸 */
.cart-panel.article-feed {
  align-content: start;
}

/* 手機版：滑動切換 */
@media (max-width: 767.98px) {
  .cart-panels-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .cart-panels-wrapper::-webkit-scrollbar {
    display: none;
  }

  .cart-panels {
    transition: none;
  }

  .cart-panel {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    flex-shrink: 0;
  }
}

/* 電腦版：不滑動，靠 JS 切換 */
@media (min-width: 768px) {
  .cart-panels-wrapper {
    overflow: hidden;
  }

  .cart-panels[data-active="material"] {
    transform: translateX(-50%);
  }
}

/* Pagination Styles */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.5rem;
  border: 1px solid #dee2e6;
  background: #fff;
  border-radius: 4px;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.page-btn:hover:not(.disabled) {
  background: #f5f5f5;
  text-decoration: none;
  color: var(--color-text);
  border-color: #c1c1c1;
}

.page-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  pointer-events: none;
}

.page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f8f9fa;
}

.page-ellipsis {
  color: #6c757d;
  padding: 0 0.25rem;
}

/* 手機版分頁 */
@media (max-width: 576px) {
  .pagination-container {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
  }
}

/* Offcanvas Mobile Width */
@media (max-width: 576px) {
  .offcanvas-start {
    width: 95% !important;
    max-width: 95% !important;
  }
}

/* =========================================
   Menu Redesign (Tag-based) - Phase 3 (Refactored Structure)
   ========================================= */

/* 區塊標題 */
.section-title {
  font-size: 0.95rem;
  color: #8d6e63;
  margin-bottom: 0.6rem;
  padding-left: 0.5rem;
  border-left: 4px solid var(--section-color, #89E6C6);
  /* Use variable or default */
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* 區塊容器 */
.menu-section {
  margin-bottom: 1.8rem;
  --section-color: #89E6C6;
  /* Default fallback */
}

/* 標籤容器 */
/* 標籤容器 - Flexbox (Reverted due to low space efficiency of Grid) */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  /* 稍微增加一點間距讓視覺不那麼擠 */
}

/* 基礎標籤樣式 (統一結構) */
.btn-tag {
  /* Default Variables */
  --tag-bg: #e0e0e0;
  --tag-text: #5d4037;
  --tag-border: 2px solid transparent;
  /* Reserve space for border */
  --tag-shadow: 2px 3px 0px rgba(0, 0, 0, 0.08);

  appearance: none;
  border: var(--tag-border);
  background-color: var(--tag-bg);
  color: var(--tag-text);

  border-radius: 999px;
  /* Pill shape */

  /* 改用 Flexbox 修正對齊 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0px;

  /* 微調 Padding 以達視覺平衡 */
  padding: 0.4rem 1rem 0.35rem 1rem;

  font-size: 0.95rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;

  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  box-shadow: var(--tag-shadow);
  margin-bottom: 0.25rem;
}

/* 圖示與 Emoji 樣式 */
.tag-icon {
  width: 1.15em;
  height: 1.15em;
  object-fit: contain;
  display: block;
  /* 修正圖片本身的垂直偏差 */
  transform: translateY(-0.5px);
}

.tag-emoji {
  font-size: 1.1em;
  line-height: 1;
  /* Emoji 微調 */
  transform: translateY(-1px);
}

/* Hover/Active Effects - 支援 hover 變數 fallback 到一般狀態 */
.btn-tag:hover,
.btn-tag:focus {
  transform: translateY(-1px) scale(1.0);
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.08);

  /* 使用 hover 變數，fallback 到一般狀態 */
  background-color: var(--tag-bg-hover, var(--tag-bg)) !important;
  color: var(--tag-text-hover, var(--tag-text)) !important;
  border: var(--tag-border-hover, var(--tag-border)) !important;
  outline: none !important;
}

.btn-tag:active,
.btn-tag.active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.08);
}

/* --- 各類別配色定義 (只修改變數) --- */

/* 1. 精選 (熱門/最新) */
.menu-section:has(.tag-hot) {
  --section-color: #F5874F;
}

.tag-hot {
  --tag-bg: #F5874F;
  --tag-text: #fff;
}

.tag-new {
  --tag-bg: #F9E363;
  --tag-text: #5d4037;
}

/* 2. 物品分類 */
.menu-section:has(.tag-category) {
  --section-color: #89E6C6;
}

.tag-category {
  --tag-bg: #89E6C6;
  --tag-text: #00695C;
}

/* 3. 系列 */
.menu-section:has(.tag-series) {
  --section-color: #5DCDF0;
}

.tag-series {
  --tag-bg: #5DCDF0;
  --tag-text: #01579B;
}

/* 4. 主題 */
.menu-section:has(.tag-theme) {
  --section-color: #F4A6D5;
}

.tag-theme {
  --tag-bg: #F4A6D5;
  --tag-text: #880E4F;
}

/* 5. 場景 */
.menu-section:has(.tag-scene) {
  --section-color: #A4D59F;
}

.tag-scene {
  --tag-bg: #A4D59F;
  --tag-text: #33691E;
}

/* 6. 顏色 (有邊框) */
.menu-section:has(.tag-color) {
  --section-color: #D7CCC8;
}

.tag-color {
  --tag-bg: #FDFDF6;
  --tag-text: #795548;
  --tag-border: 2px solid #EFEBE9;
  --tag-shadow: 2px 3px 0px #D7CCC8;
}

/* 7. 版本 */
.menu-section:has(.tag-ver) {
  --section-color: #D7CCC8;
}

.tag-ver {
  --tag-bg: #D7CCC8;
  --tag-text: #4E342E;
}

/* ==========================================================================
   ACNH Shopping Cart Redesign
   ========================================================================== */
:root {
  --acnh-cream: #FFFDF0;
  --acnh-green: #76c5a6;
  --acnh-blue: #5FB7E5;
  --acnh-brown: #5d4037;
  --acnh-red: #ff6b6b;
  --acnh-border-radius: 20px;
}

/* Modal Content Override */
#shoplistModalCenter .modal-content {
  background-color: var(--acnh-cream);
  border-radius: var(--acnh-border-radius);
  border: none;
  box-shadow: 0 10px 30px rgba(93, 64, 55, 0.15);
  display: flex;
  flex-direction: column;
  height: 80vh;
  /* Set basic height base */
  min-height: 500px;
}

@media (max-width: 768px) {
  #shoplistModalCenter .modal-content {
    height: 100vh;
    border-radius: 0;
  }
}

/* Header */
#shoplistModalCenter .modal-header {
  border-bottom: none;
  padding: 1rem 1.5rem 0.5rem;
  background-color: var(--acnh-cream);
  flex-shrink: 0;
}

/* Tabs Redesign */
.acnh-tabs {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.acnh-tab-btn {
  flex: 1;
  background-color: #EFEBE9;
  border: none;
  border-radius: 99px;
  padding: 0.8rem 1rem;
  color: #a1887f;
  font-weight: 700;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 4px 0 #d7ccc8;
}

.acnh-tab-btn.active {
  background-color: var(--acnh-green);
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.acnh-tab-btn .badge-count {
  background: rgba(255, 255, 255, 0.9);
  color: var(--acnh-brown);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 0.9rem;
  font-weight: 900;
  margin-left: 6px;
}

/* Body */
#shoplistModalCenter .modal-body {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  /* Critical for flex child scrolling */
  position: relative;
}

@media (max-width: 768px) {
  #shoplistModalCenter .modal-body {
    background-color: var(--acnh-cream);
  }
}

/* Footer (Checkout) */
#shoplistModalCenter .modal-footer {
  border-top: none;
  background-color: var(--acnh-cream);
  padding: 0.8rem 1.5rem 1rem;
  flex-direction: column;
  gap: 0.8rem;
  flex-shrink: 0;
}

.checkout-details {
  background-color: #fff;
  border-radius: 16px;
  padding: 0.8rem 1rem;
  width: 100%;
  border: 2px dashed #E0E0E0;
}

.price-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
  color: #8d6e63;
}

.price-row.total {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 2px dashed #E0E0E0;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--acnh-brown);
  align-items: center;
}

.price-desc {
  font-size: 0.75rem;
  color: #a1887f;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.btn-acnh-clear {
  background-color: #FFE0E0;
  color: var(--acnh-red);
  border: none;
  border-radius: 99px;
  padding: 0.8rem 1.5rem;
  font-weight: 700;
  flex: 1;
}

.btn-acnh-clear:hover {
  background-color: #FFCDCD;
}

.btn-acnh-checkout {
  background-color: var(--acnh-green);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 0.8rem 1.5rem;
  font-weight: 900;
  flex: 2;
  box-shadow: 0 4px 0 #5aa388;
  position: relative;
  overflow: hidden;
}

.btn-acnh-checkout:active {
  transform: translateY(4px);
  box-shadow: none;
}

/* Empty State */
.empty-cart {
  display: none;
  /* hidden by default */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #a1887f;
}

.empty-cart img {
  width: 120px;
  opacity: 0.6;
  margin-bottom: 1.5rem;
}

.btn-go-shop {
  background-color: var(--acnh-blue);
  color: #fff;
  border-radius: 99px;
  padding: 0.8rem 2rem;
  font-weight: 700;
  border: none;
  margin-top: 1rem;
  box-shadow: 0 4px 0 #4da0c6;
}

.btn-go-shop:active {
  transform: translateY(4px);
  box-shadow: none;
}

.order-code {
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 2px;
  background: #f1f8e9;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: all;
  border: 1px solid #c5e1a5;
  color: #33691e;
  font-weight: bold;
}

/* Empty Cart Mode Styling */
#shoplistModalCenter .modal-content.empty-mode {
  height: auto !important;
  /* Override default height */
  min-height: 400px;
  /* PC Fixed Height */
}

#shoplistModalCenter .modal-content.empty-mode .modal-header {
  display: none !important;
  /* Hide header including close button */
}

#shoplistModalCenter .modal-content.empty-mode .modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border-radius: var(--acnh-border-radius);
}

@media (max-width: 768px) {
  #shoplistModalCenter .modal-content.empty-mode {
    height: 100vh !important;
    border-radius: 0;
  }

  #shoplistModalCenter .modal-content.empty-mode .modal-body {
    border-radius: 0;
  }
}

/* Empty Cart Dialog (Standalone) */
.empty-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-dialog-box {
  background: var(--acnh-cream);
  border-radius: 24px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(93, 64, 55, 0.2);
  max-width: 320px;
  width: 90%;
}

/* Collapsible Checkout Styles */
.checkout-details {
  transition: all 0.3s ease;
}

.checkout-details .toggle-icon {
  transition: transform 0.3s ease;
}

.checkout-details.collapsed .checkout-full-info {
  display: none;
}

.checkout-details:not(.collapsed) .toggle-icon {
  transform: rotate(180deg);
}

.dashed-line {
  border-top: 2px dashed #E0E0E0 !important;
}

/* Fix checkout details arrow rotation */
.checkout-details:not(.collapsed) .toggle-icon {
  transform: none;
}

.checkout-details:not(.collapsed) .toggle-icon .arrow {
  transform: rotate(180deg);
}

.toggle-icon .arrow {
  transition: transform 0.3s ease;
}

/* Fix cart item background color on desktop */
.cart-panel .figure {
  background-color: #fff !important;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
}

/* Ensure figure background is white in cart */
.cart-panel figure {
  background-color: #fff !important;
  border-radius: 12px;
}

/* =========================================
   Floating Action Button (Redesigned)
   ========================================= */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;

  /* Glassmorphism / ACNH Aesthetic */
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px rgba(93, 64, 55, 0.15);
  /* Warm shadow */

  color: var(--color-brown, #794f27);
  opacity: 0;
  /* Align with JS fade-in */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1040;
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Bouncy spring */
  outline: none;
  overflow: hidden;
}

/* Shine effect on hover */
.fab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transition: .5s;
  transform: skewX(-20deg);
}

.fab-btn:hover::before {
  left: 150%;
}

.fab-btn:hover {
  transform: translateY(-4px) scale(1.1);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 24px rgba(24, 173, 97, 0.25);
  /* Green glow */
  color: var(--color-green-dark, #18ad61);
  border-color: #fff;
}

.fab-btn:active {
  transform: scale(0.92);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fab-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  filter: drop-shadow(0 2px 2px rgba(121, 79, 39, 0.1));
  transition: transform 0.3s;
}

.fab-btn:hover svg {
  transform: rotate(90deg);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .fab-btn {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
  }
}