/* ===========================
   Gosmooth - Building Materials Page
   搜尋建材頁外層排版
   黃色分類條 + 搜尋框 共用 main.css
   =========================== */

/* 黃色分隔線（已取消，與產品詳情頁一致） */
.bm-divider {
  display: none !important;
}

/* 優選品牌區域 */
.bm-brands-section {
  padding: 56px 0 72px;
  background: #ffffff;
}

.bm-brands-section__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 40px;
}

.bm-brands-section__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 0 0 24px;
  font-family: "Noto Serif TC", serif;
  font-size: 26px;
  font-weight: 700;
  color: #1F2D3D;
}

.bm-brands-section__title-line {
  display: inline-block;
  width: 82px;
  height: 2px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent 0%, #E8A900 50%, transparent 100%);
}

/* 搜尋框（放在優選品牌標題下方，水平置中） */
.bm-brand-search {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 26px auto 46px;
}

/* 品牌網格 */
.bm-brands-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 24px 20px;
  align-items: center;
  justify-items: center;
}

.bm-brand-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 130px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #ffffff;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.bm-brand-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  border-color: #EEB21B;
}

/* 改大品牌 Logo：外框不變，只把裡面的 Logo 圖片放大，不被裁切，完整置中 */
.bm-brand-item img {
  width: auto !important;
  height: auto !important;
  max-width: 76% !important;
  max-height: 68% !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block !important;
}

/* 品牌 hover 氣泡（僅桌面端，手機端隱藏） */
.bm-brand-bubble {
  display: none;
}

@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
  .bm-brand-bubble {
    display: block;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%) translateY(8px);
    min-width: 76px;
    padding: 9px 16px;
    border-radius: 9px;
    background: #ffffff;
    color: #E8A900;
    font-family: "Noto Serif TC", serif;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .24s ease, transform .24s ease, visibility .24s ease;
    z-index: 5;
  }

  .bm-brand-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.04);
  }

  .bm-brand-item:hover .bm-brand-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }

  .bm-brand-item:hover {
    border-color: #E8A900;
    box-shadow: 0 16px 36px rgba(232, 169, 0, 0.15);
  }
}

/* ===========================
   Responsive - Tablet (max-width: 1024px)
   =========================== */
@media (max-width: 1024px) {
  .bm-brands-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 20px 16px;
  }

  .bm-brands-section__inner {
    padding: 0 32px;
  }

  .bm-brand-search {
    margin: 22px auto 38px;
  }
}

/* ===========================
   Responsive - Mobile (max-width: 768px)
   =========================== */
@media (max-width: 768px) {
  .bm-brands-section {
    padding: 40px 0 56px;
  }

  .bm-brands-section__inner {
    padding: 0 20px;
  }

  .bm-brands-section__title {
    font-size: 22px;
    gap: 16px;
    margin-bottom: 20px;
  }

  .bm-brands-section__title-line {
    width: 48px;
  }

  .bm-brand-search {
    margin: 20px auto 32px;
  }

  .bm-brands-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 12px;
  }

  .bm-brand-item {
    max-width: none;
    padding: 12px;
  }

  .bm-brand-item img {
    width: auto !important;
    height: auto !important;
    max-width: 72% !important;
    max-height: 64% !important;
    object-fit: contain !important;
    object-position: center center !important;
    display: block !important;
  }

  /* 手機端完全隱藏氣泡 */
  .bm-brand-bubble {
    display: none !important;
  }
}

/* ===========================
   Responsive - Small Mobile (max-width: 480px)
   =========================== */
@media (max-width: 480px) {
  .bm-brands-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 10px;
  }

  .bm-brand-item {
    padding: 10px;
  }

  .bm-brand-item img {
    width: auto !important;
    height: auto !important;
    max-width: 68% !important;
    max-height: 60% !important;
    object-fit: contain !important;
    object-position: center center !important;
    display: block !important;
  }

  .bm-brands-section__title {
    font-size: 20px;
  }

  .bm-brand-search {
    margin: 18px auto 26px;
  }
}

/* ═══════════════════════════════════════════════════════════
   產品展示區（左側分類按鈕 + 右側產品 grid + 分頁）
   ═══════════════════════════════════════════════════════════ */
.materials-products-section {
  padding: 6px 32px 90px;
  background: #ffffff;
}

/* 左側欄改短：220px → 170px */
.materials-products-layout {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 38px;
  max-width: 1760px;
  margin: 0 auto;
}

/* ── 左側分類側邊欄（字體改為 Noto Sans TC）── */
.materials-category-sidebar {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.materials-category-sidebar a {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 6px;
  background: #f5f5f5;
  color: #4A4A4A;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  transition: transform .2s ease, background .2s ease, color .2s ease;
}

.materials-category-sidebar a:hover,
.materials-category-sidebar a.is-active {
  background: linear-gradient(180deg, #FDD24A 0%, #FCA428 100%);
  color: #ffffff;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════
   正序 / 倒序 切換按鈕（共用：building-materials、category-detail、brand-detail）
   ═══════════════════════════════════════════════════════════ */
.product-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 36px;
}

.product-list-toolbar .materials-products-tab {
  margin-bottom: 0;
  flex-shrink: 0;
}

.product-sort-control {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border: 1px solid rgba(252, 164, 40, 0.35);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.product-sort-btn {
  min-width: 64px;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: #333;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.product-sort-btn:hover,
.product-sort-btn.is-active {
  background: linear-gradient(180deg, #fdd24a 0%, #fca428 100%);
  color: #222;
  box-shadow: 0 6px 14px rgba(252, 164, 40, 0.28);
}

@media (max-width: 768px) {
  .product-list-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }

  .product-list-toolbar .materials-products-tab {
    flex: 0 1 auto;
    margin-bottom: 0;
  }

  .product-sort-control {
    flex: 0 0 auto;
    align-self: center;
    margin-left: auto;
  }

  .product-sort-btn {
    min-width: 54px;
    height: 32px;
    padding: 0 12px;
    font-size: 14px;
    white-space: nowrap;
  }
}

/* ── 灰色斜角 tab：底線改成黃色漸變（#FDD24A → #FCA428）── */
.materials-products-tab {
  position: relative;
  margin: 0 0 36px;
  border-bottom: 0;
}

.materials-products-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(180deg, #FDD24A 0%, #FCA428 100%);
}

/* 灰色斜角背景外層（保留形狀） */
.materials-products-tab-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 22px;
  background: #555555;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 100%, 0% 100%);
}

/* 金色漸變文字 */
.materials-products-tab-text {
  font-family: "Noto Serif TC", serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(180deg, #FDD24A 0%, #FCA428 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* ── 產品 grid：一行 4 個 ── */
.materials-products-grid.bm-four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 22px;
}

/* ── 空狀態 ── */
.materials-products-empty {
  text-align: center;
  padding: 64px 24px;
  color: #9A9A9A;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 17px;
  line-height: 2;
}

.materials-products-empty a {
  color: #E8A900;
  text-decoration: underline;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   RWD：產品展示區
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
  .materials-products-layout {
    grid-template-columns: 150px 1fr;
    gap: 28px;
  }

  .materials-products-grid.bm-four-col {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 768px) {
  .materials-products-section {
    padding: 38px 16px 64px;
  }

  .materials-products-layout {
    display: block;
  }

  .materials-category-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 30px;
  }

  .materials-category-sidebar a {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 15px;
  }

  .materials-products-tab {
    margin-bottom: 26px;
  }

  .materials-products-tab-label {
    min-height: 38px;
    padding: 0 18px;
  }

  .materials-products-tab-text {
    font-size: 15px;
  }

  /* ── 手機版產品 grid：一行 2 個，同首頁人氣建材 ── */
  .materials-products-grid.bm-four-col {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 18px;
  }

  /* 手機版隱藏原本左側分類按鈕（改用下拉選單） */
  .materials-category-sidebar {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Mobile category dropdown - building materials only
   僅新增手機版下拉選單，不影響電腦版分類按鈕
   ═══════════════════════════════════════════════════════════ */

/* 預設隱藏（電腦版不顯示） */
.materials-mobile-category-select {
  display: none;
}

@media (max-width: 768px) {
  .materials-mobile-category-select {
    display: block;
    width: 100%;
    margin: 0 0 24px;
  }

  .materials-mobile-category-label {
    display: block;
    margin: 0 0 8px;
    font-family: "Noto Sans TC", sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #3A3A3A;
  }

  .materials-mobile-category-select form {
    width: 100%;
  }

  .materials-mobile-category-select select {
    width: 100%;
    height: 48px;
    padding: 0 44px 0 16px;
    border: 1px solid rgba(232, 169, 0, 0.55);
    border-radius: 8px;
    background-color: #ffffff;
    color: #1F2D3D;
    font-family: "Noto Sans TC", sans-serif;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23E8A900' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px 8px;
  }

  .materials-mobile-category-select select:focus {
    border-color: #E8A900;
    box-shadow: 0 0 0 3px rgba(232, 169, 0, 0.16);
  }

  .materials-mobile-category-select select option:checked {
    background: linear-gradient(180deg, #FDD24A 0%, #FCA428 100%) !important;
    background-color: #FCA428 !important;
    color: #ffffff !important;
  }

  .materials-mobile-category-select select option:hover,
  .materials-mobile-category-select select option:focus {
    background: linear-gradient(180deg, #FDD24A 0%, #FCA428 100%) !important;
    background-color: #FCA428 !important;
    color: #ffffff !important;
  }
}