/* ============================================
   购物车产品列表页 - 全宽布局（参考 idctree.com）
   左侧分类栏 + 右侧内容区
   ============================================ */

/* ---- 隐藏父主题的"购物车"页面标题栏（page-title-box），让我们的"商品分类"占顶部 ---- */
body.cart-page-fullwidth .page-title-box,
body.cart-page-fullwidth .page-title-right,
body.cart-page-fullwidth .page-title,
body.cart-page-fullwidth [class*="page-title"],
body.cart-page-fullwidth .breadcrumb,
body.cart-page-fullwidth .backBtn {
  display: none !important;
}

/* 兜底隐藏任何残留的抽屉按钮（防服务器缓存） */
.cart-sidebar-toggle { display: none !important; }

/* 让"产品选择"成为右侧顶部主标题，无按钮 */
.cart-main-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e8ecf1;
  margin-bottom: 16px;
  background: #fff;
  border-radius: 8px 8px 0 0;
}

.cart-main-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
  text-align: left;
}


/* ---- 隐藏父主题(clientarea)的左侧导航栏，让购物车占满整个页面 ----
   仅在桌面端生效；移动端父主题侧栏由顶栏"≡"按钮控制（off-canvas），不能隐藏 */
@media (min-width: 901px) {
body.cart-page-fullwidth aside,
body.cart-page-fullwidth .sidebar,
body.cart-page-fullwidth .left-sidebar,
body.cart-page-fullwidth #sidebar,
body.cart-page-fullwidth [class*="sidebar"][class*="left"],
body.cart-page-fullwidth [class*="SideBar"],
body.cart-page-fullwidth [class*="left-menu"],
body.cart-page-fullwidth [class*="nav-sidebar"],
body.cart-page-fullwidth .app-sidebar,
body.cart-page-fullwidth .vertical-menu {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}
}

/* 父主题主内容区撑满 */
body.cart-page-fullwidth main,
body.cart-page-fullwidth .main-content,
body.cart-page-fullwidth .content-area,
body.cart-page-fullwidth [class*="main-content"],
body.cart-page-fullwidth [class*="page-content"],
body.cart-page-fullwidth [class*="content-wrapper"] {
  margin-left: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ---- 全局：购物车页容器铺满 ---- */
.cart-page-fullwidth .container,
.cart-page-fullwidth .container-fluid,
.cart-page-fullwidth .container-lg,
.cart-page-fullwidth .container-xl,
.cart-page-fullwidth .container-xxl {
  max-width: 100% !important;
  width: 100% !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

/* ---- 页面主体布局 ---- */
.cart-layout {
  display: block;
  min-height: 100vh;
  background: #f7f7f9;
}

/* ---- 左侧分类栏（position:fixed，始终固定在视口左侧） ----
   宽度由 CSS 变量 --cart-sidebar-width 控制（不与父主题 --sidebar-width 冲突），
   右侧主内容区用 margin-left 避开。 */
.cart-sidebar {
  position: fixed;
  left: 0;
  top: var(--cart-header-h, 60px);
  width: 240px;
  height: calc(100vh - var(--cart-header-h, 60px));
  background: #fff;
  border-right: 1px solid #f1f1f1;
  z-index: 998;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 5px 10px;
  scrollbar-width: thin;
  scrollbar-color: #e6e6e6 #f5f5f5;
}

/* 自定义滚动条样式（Webkit） */
.cart-sidebar::-webkit-scrollbar { width: 6px; }
.cart-sidebar::-webkit-scrollbar-track { background: #f5f5f5; }
.cart-sidebar::-webkit-scrollbar-thumb {
  background: #e6e6e6;
  border-radius: 3px;
}
.cart-sidebar::-webkit-scrollbar-thumb:hover { background: #c0c8d4; }

/* ---- 侧栏头部：分类标题（sticky 吸顶） ---- */
.cart-sidebar-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  padding: 15px 5px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f1f1;
  margin-bottom: 5px;
}

/* ---- 分类树（参考 server 主题风格） ---- */
.cat-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cat-tree-item {
  border-bottom: 1px solid #f1f1f1;
}

/* 一级菜单 */
.cat-tree-item > .cat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px;
  font-size: 13px;
  color: #181818;
  font-weight: normal;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.cat-tree-item > .cat-label:hover {
  background: rgba(0,100,255,0.04);
}

.cat-tree-item.active > .cat-label,
.cat-tree-item.expanded > .cat-label {
  background: rgba(0,100,255,0.06);
}

.cat-tree-item > .cat-label .cat-name-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-tree-item > .cat-label .cat-arrow {
  font-size: 11px;
  color: #999;
  transition: transform 0.3s ease;
  flex-shrink: 0;
  margin-left: 8px;
}

.cat-tree-item > .cat-label:hover .cat-arrow,
.cat-tree-item.active > .cat-label .cat-arrow {
  color: #0064ff;
}

.cat-tree-item.expanded > .cat-label .cat-arrow {
  transform: rotate(90deg);
}

/* 隐藏旧的 icon-box */
.cat-tree-item > .cat-label .cat-icon-box {
  display: none;
}

/* 二级菜单（max-height 动效）
   注意：JS（topbar-categories.tpl 的 toggleCatItem）会在展开时
   动态设置 inline max-height = scrollHeight，突破此处 600px 限制。
   这里写死 600px 只是 transition 起点的兜底（防止首次展开瞬间内容外溢）。 */
.cat-sub-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #f9f9f9;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.cat-tree-item.expanded .cat-sub-list {
  max-height: 600px;
}

/* 当 JS 设了 inline max-height 时，移除 transition 避免动画跳变 */
.cat-sub-list[style*="max-height"] {
  transition: max-height 0.2s ease-out;
}

.cat-sub-item a,
.cat-sub-item .cat-sub-link {
  display: flex;
  align-items: center;
  padding: 10px 10px 10px 24px;
  font-size: 12px;
  color: #181818;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.cat-sub-item a:hover,
.cat-sub-item .cat-sub-link:hover {
  background: rgba(0,100,255,0.04);
  color: #181818;
  text-decoration: none;
}

.cat-sub-item.active a,
.cat-sub-item.active .cat-sub-link {
  background: rgba(0,100,255,0.06);
  border-left-color: #0064ff;
  font-weight: 500;
}

/* 二级菜单内容行（国旗+名称+徽章） */
.cat-sub-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.cat-sub-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-sub-badge {
  background: rgba(252,241,235,1);
  color: rgba(254,95,71,1);
  padding: 0 8px;
  height: 20px;
  line-height: 20px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 国旗图标 */
.cat-flag {
  width: 26px;
  height: 18px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  flex-shrink: 0;
  vertical-align: middle;
}

.cat-country-code {
  display: none !important;
}

/* ---- 右侧主内容区 ---- */
.cart-main {
  margin-left: var(--cart-sidebar-width, 240px);
  min-height: calc(100vh - var(--cart-header-h, 60px));
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 顶部标题栏 */
.cart-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  background: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cart-main-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
}

.cart-search-box {
  position: relative;
  width: 260px;
}

.cart-search-box input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 14px;
  border: 1px solid #dfe3ea;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.cart-search-box input:focus {
  border-color: #0064ff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,100,255,0.08);
}

.cart-search-box input::placeholder {
  color: #a0aec0;
}

.cart-search-box .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #a0aec0;
  font-size: 14px;
  pointer-events: none;
}

/* 产品选择标签栏 */
.product-tabs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.product-tabs-bar .tab-label {
  font-size: 13px;
  color: #6b7785;
  white-space: nowrap;
  flex-shrink: 0;
}

.product-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid #dfe3ea;
  border-radius: 6px;
  font-size: 13px;
  color: #4a5568;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.product-tab-btn:hover {
  border-color: #0064ff;
  color: #0064ff;
}

.product-tab-btn.active {
  background: #0064ff;
  border-color: #0064ff;
  color: #fff;
}

.product-tab-btn .tab-flag {
  width: 28px;
  height: 20px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
  vertical-align: middle;
}

/* 商品标语行 */
.product-headline {
  font-size: 13px;
  color: #0064ff;
  margin-bottom: 20px;
  padding: 10px 4px;
}
.product-headline:empty { display: none; }

/* 无 tab 按钮时整条 tab bar 隐藏，避免出现只有「选择产品」标签的尴尬空间 */
.product-tabs-bar:not(:has(.product-tab-btn)) { display: none; }

/* 商品组标题+标语（在产品选择下方） */
.cart-group-meta {
  margin-top: 8px;
  padding: 0 4px;
  text-align: center;
}
.cart-group-title-label {
  font-size: 15px;
  font-weight: 600;
  color: #37404d;
  margin-bottom: 4px;
  line-height: 1.5;
}
.cart-group-slogan-label {
  font-size: 14px;
  font-weight: 700;
  color: #333;
  margin-bottom: 0;
  line-height: 1.5;
}

/* ---- 产品卡片网格（旧版风格，不变） ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.product-card-new {
  background: #fff;
  border: 1px solid #e8ecf1;
  border-radius: 10px;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.product-card-new:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,50,150,0.1);
  border-color: #c0d0ff;
}

.product-card-new::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0064ff, #3860f4);
  opacity: 0;
  transition: opacity 0.25s;
}

.product-card-new:hover::before {
  opacity: 1;
}

.product-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
  line-height: 1.4;
}

.product-card-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.product-card-price {
  font-size: 26px;
  font-weight: 800;
  color: #0064ff;
  line-height: 1;
  font-family: 'DIN Alternate', 'Helvetica Neue', Arial, sans-serif;
}

.product-card-price .currency-symbol {
  font-size: 15px;
  font-weight: 600;
  margin-right: 2px;
}

.product-card-period {
  font-size: 13px;
  color: #8892a4;
}

.product-card-original {
  font-size: 12px;
  color: #b0b8c9;
  text-decoration: line-through;
}

.product-card-specs {
  list-style: none;
  padding: 0;
  margin: 14px 0 20px;
  flex: 1;
}

.product-card-specs li {
  font-size: 12px;
  color: #6b7785;
  line-height: 26px;
  display: flex;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-specs li .spec-label {
  color: #8892a4;
  flex-shrink: 0;
  margin-right: 4px;
}

.product-card-specs li .spec-value {
  color: #4a5568;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-buy-btn {
  display: block;
  width: 100%;
  padding: 10px 0;
  background: linear-gradient(135deg, #0064ff, #3860f4);
  color: #fff;
  text-align: center;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.product-card-buy-btn:hover {
  background: linear-gradient(135deg, #0052cc, #2850de);
  box-shadow: 0 4px 12px rgba(0,100,255,0.3);
  color: #fff;
}

.product-card-buy-btn.disabled,
.product-card-buy-btn[disabled] {
  background: #e2e6ef;
  color: #a0aab8;
  cursor: not-allowed;
  box-shadow: none;
}

/* 库存标签 */
.product-stock-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #fef3cd, #ffeeba);
  color: #856404;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 1;
}

/* 空状态 */
.cart-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  background: #fff;
  border-radius: 10px;
  border: 1px dashed #d0d5dd;
}

.cart-empty-state img {
  width: 140px;
  opacity: 0.5;
  margin-bottom: 16px;
}

.cart-empty-state p {
  color: #8892a4;
  font-size: 14px;
}

/* ---- 响应式适配 ---- */
@media (max-width: 1200px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1100px) {
  :root { --cart-sidebar-width: 220px; }
}

@media (max-width: 900px) {
  :root { --cart-sidebar-width: 0px; }

  /* 移动端恢复父主题侧栏，让顶栏"≡"可以正常打开通用导航 */
  body.cart-page-fullwidth .vertical-menu,
  body.cart-page-fullwidth aside,
  body.cart-page-fullwidth .sidebar,
  body.cart-page-fullwidth .left-sidebar,
  body.cart-page-fullwidth #sidebar,
  body.cart-page-fullwidth [class*="sidebar"][class*="left"],
  body.cart-page-fullwidth [class*="nav-sidebar"],
  body.cart-page-fullwidth .app-sidebar {
    display: block !important;
    width: var(--sidebar-width, 250px) !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    visibility: visible !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  body.cart-page-fullwidth.sidebar-enable .vertical-menu,
  body.sidebar-enable .vertical-menu {
    transform: translateX(0);
  }

  .cart-sidebar {
    width: 240px;
    transform: translateX(-240px);
    transition: transform 0.3s ease;
  }

  .cart-sidebar.sidebar-show {
    transform: translateX(0);
  }

  .cart-main {
    margin-left: 0;
    padding: 16px;
    width: 100%;
  }

  .cart-main-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .cart-search-box { width: 100%; }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  /* 移动端侧栏展开按钮 */
  .sidebar-toggle-btn {
    display: flex;
    position: fixed;
    left: 15px;
    bottom: 90px;
    width: 40px;
    height: 40px;
    background: #0064ff;
    color: #fff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,100,255,0.3);
    border: none;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    padding: 0;
    text-align: center;
    overflow: hidden;
  }
  .sidebar-toggle-btn .sidebar-toggle-text {
    display: block;
    letter-spacing: 0;
  }
}

@media (max-width: 576px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-tabs-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .product-card-new {
    padding: 18px 16px 16px;
  }
}
