/* WooCommerce Product Category Sidebar Styles */

.widget-area {
    padding: 0;
}

.widget_product_categories {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 4px;
}

.widget_product_categories h4 {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.product-categories-expandable {
    list-style: none;
    margin: 0;
    padding: 0;
}

.product-categories-expandable li {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;  /* 不换行，保持左右排列 */
}

.product-categories-expandable > li {
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;  /* 确保顶级项也不换行 */
}

.product-categories-expandable > li.cat-parent {
    flex-wrap: wrap;  /* 有子分类的顶级项允许换行 */
}

.product-categories-expandable > li:last-child {
    border-bottom: none;
}

/* 顶级分类链接 */
.product-categories-expandable > li > a {
    display: inline-block;
    flex: 1;
    padding: 12px 10px 12px 0;
    min-width: 0;
}

/* 顶级子列表占满整行 */
.product-categories-expandable > li > .children {
    width: 100%;
    flex-basis: 100%;
}

/* 顶级展开按钮 */
.product-categories-expandable > li > .category-toggle {
    display: inline-block;
    margin-right: 4px;
    flex-shrink: 0;
}

.product-categories-expandable li a {
    color: #555;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 14px;
    line-height: 1.4;
}

.product-categories-expandable li a:hover {
    color: #d35400;
}

.product-categories-expandable li.current-cat > a {
    color: #d35400;
    font-weight: 600;
}

/* 子分类样式 */
.product-categories-expandable ul.children {
    list-style: none;
    margin: 0;
    padding: 0 0 10px 20px;
    border-left: 2px solid #e0e0e0;
    display: block;  /* 确保子列表为块级元素 */
}

.product-categories-expandable ul.children li {
    padding-left: 10px;
    display: flex;  /* 子列表也使用 flex 布局 */
    align-items: center;
    flex-wrap: nowrap;  /* 默认不换行 */
}

/* 有子分类的子列表项允许换行 */
.product-categories-expandable ul.children li.cat-parent {
    flex-wrap: wrap;
}

.product-categories-expandable ul.children li a {
    font-size: 13px;
    flex: 1;
    padding: 8px 10px 8px 0;
    min-width: 0;  /* 允许文字被压缩 */
}

/* 第三级分类 */
.product-categories-expandable ul.children ul.children {
    padding-left: 15px;
    border-left-color: #efefef;
}

.product-categories-expandable ul.children ul.children li {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;  /* 第三级也不换行 */
}

.product-categories-expandable ul.children ul.children li.cat-parent {
    flex-wrap: wrap;  /* 有子分类时允许换行 */
}

.product-categories-expandable ul.children ul.children li a {
    font-size: 12px;
    flex: 1;
    min-width: 0;  /* 允许文字被压缩 */
}

.btLightSkin .btBox ul.product-categories-expandable li {
    display: flex;
}

/* 展开/折叠按钮 */
.category-toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 2px;
    transition: all 0.3s ease;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}

.category-toggle:before {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    line-height: 1;
    font-weight: 600;
    pointer-events: none;
}

.category-toggle:hover {
    background: #f0f0f0;
    border-color: #999;
}

.cat-parent.expanded > .category-toggle:before {
    content: '−';
}

/* 有子分类的项目布局 */
.cat-parent {
    flex-wrap: wrap;  /* 有子分类的项目允许换行，让子列表在下一行 */
}

/* 链接占满剩余空间 */
.product-categories-expandable li > a {
    display: inline-block;
    vertical-align: middle;
    flex: 1;
    padding: 12px 10px 12px 0;
    min-width: 0;  /* 允许文字被压缩 */
}

/* 子列表占满整行 */
.product-categories-expandable li > .children {
    width: 100%;
    flex-basis: 100%;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .widget_product_categories {
        margin-bottom: 30px;
    }

    .product-categories-expandable ul.children {
        padding-left: 15px;
    }
}

/* 动画效果 */
.product-categories-expandable ul.children {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.product-categories-expandable li.cat-parent > a {
    font-weight: 500;
}
