/* 商城分类导航（首页侧栏 + 二级导航下拉） */
/* 首页商品分类：左侧一级 + 弹窗内竖列二级 + 商品网格 */
.mall-category-nav {
    position: relative;
    align-self: flex-start;
    flex: 0 0 var(--home-cat-width, 228px);
    width: var(--home-cat-width, 228px);
    z-index: 10;
}

/* 首页左侧分类：随页面滚动粘在顶栏下方 */
.mall-category-nav:not(.mall-category-nav--subnav) {
    position: sticky;
    top: calc(var(--site-nav-height, 114px) + 12px);
    max-height: calc(100vh - var(--site-nav-height, 114px) - 24px);
}

.mall-category-nav:not(.mall-category-nav--subnav) .mall-category-menu {
    max-height: inherit;
}

.mall-category-nav:not(.mall-category-nav--subnav) .mall-category-menu__list {
    flex: 1 1 auto;
    max-height: calc(100vh - var(--site-nav-height, 114px) - 24px - 44px);
    overflow-x: hidden;
    overflow-y: auto;
}

/* 详情页等非首页：二级导航内下拉分类 */
.mall-category-nav--subnav {
    flex: 0 0 auto;
    width: auto;
    z-index: 20;
}

.mall-category-nav--subnav .mall-category-menu {
    position: relative;
    width: auto;
    min-height: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.mall-category-nav--subnav .mall-category-menu__title {
    height: var(--sf-subnav-height, 44px);
    padding: 0 16px;
    border-radius: 0;
    cursor: pointer;
    white-space: nowrap;
}

.mall-category-nav--subnav .mall-category-menu__title-action {
    display: none;
}

.mall-category-nav--subnav .mall-category-menu__list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: var(--home-cat-width, 228px);
    max-height: min(70vh, 560px);
    overflow-x: hidden;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e8edf2;
    border-top: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 28px rgba(23, 105, 170, 0.12);
    z-index: 30;
}

.mall-category-nav--subnav:hover .mall-category-menu__list,
.mall-category-nav--subnav .mall-category-menu.is-panel-open .mall-category-menu__list {
    display: block;
}

.mall-category-nav--subnav .mall-category-menu.is-panel-open {
    border-radius: 0;
}

.mall-category-nav--subnav .mall-category-menu.is-panel-open .mall-category-menu__title {
    border-radius: 0;
}

.mall-category-nav--subnav .mall-category-panel {
    top: 100%;
    left: var(--home-cat-width, 228px);
    width: min(920px, calc(100vw - var(--home-cat-width, 228px) - 56px));
    height: min(560px, calc(100vh - var(--site-nav-height, 114px) - 20px));
    z-index: 31;
}

.mall-category-menu {
    position: relative;
    width: var(--home-cat-width, 228px);
    min-height: 0;
    height: auto;
    max-height: none;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e8edf2;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    overflow: visible;
}

.mall-category-menu.is-panel-open {
    border-right-color: transparent;
    border-radius: 12px 0 0 12px;
    box-shadow: none;
}

.mall-category-menu__title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 44px;
    padding: 0 14px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: #2e91f6;
    border-radius: 11px 11px 0 0;
}

.mall-category-menu.is-panel-open .mall-category-menu__title {
    border-radius: 11px 0 0 0;
}

.mall-category-menu__title-action {
    display: none;
    margin-left: auto;
    font-size: 14px;
    opacity: 0.9;
}

.mall-category-menu__list {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding: 4px 0;
}

.mall-category-menu__title-icon {
    font-size: 15px;
    line-height: 1;
    color: #fff;
}

.mall-category-menu__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 38px;
    padding: 0 14px;
    color: #334155;
    font-size: 14px;
    box-sizing: border-box;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.mall-category-menu__name {
    flex: 1 1 auto;
    min-width: 0;
}

.mall-category-menu__item:hover > .mall-category-menu__link,
.mall-category-menu__item.is-active > .mall-category-menu__link {
    background: #e8f4ff;
    color: #2e91f6;
}

.mall-category-menu__item:hover > .mall-category-menu__link::before,
.mall-category-menu__item.is-active > .mall-category-menu__link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #2e91f6;
    border-radius: 0 2px 2px 0;
}

.mall-category-menu__caret {
    flex: 0 0 auto;
    font-size: 12px;
    color: #c5cdd6;
    transition: color 0.15s ease;
}

.mall-category-menu__item:hover > .mall-category-menu__link .mall-category-menu__caret,
.mall-category-menu__item.is-active > .mall-category-menu__link .mall-category-menu__caret {
    color: #2e91f6;
}

.mall-category-panel {
    position: absolute;
    top: 0;
    left: calc(100% - 1px);
    display: flex;
    flex-direction: column;
    width: min(var(--home-content-width, 1200px), calc(100vw - var(--home-cat-width, 228px) - 48px));
    height: 560px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e8edf2;
    border-left: none;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 11;
    pointer-events: none;
}

.mall-category-panel::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 0;
    bottom: 0;
    width: 10px;
}

.mall-category-menu.is-panel-open > .mall-category-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.mall-cat-panel__body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.mall-cat-panel__chips {
    display: flex;
    flex-direction: column;
    flex: 0 0 168px;
    overflow-y: auto;
    padding: 8px 0;
    background: #f7f9fc;
    border-right: 1px solid #f1f5f9;
}

.mall-cat-chip {
    appearance: none;
    display: block;
    width: 100%;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    color: #475569;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mall-cat-chip:hover {
    color: #2e91f6;
    background: #eef6ff;
}

.mall-cat-chip.is-active,
.mall-cat-chip.is-active:hover {
    background: #fff;
    border-left-color: #2e91f6;
    color: #2e91f6;
    font-weight: 600;
}

.mall-cat-panel__grid {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, 112px);
    justify-content: start;
    align-content: start;
    gap: 16px 18px;
    padding: 16px 20px 20px;
}

.mall-cat-panel__grid.is-state {
    display: flex;
}

.mall-cat-state {
    width: 100%;
    padding: 48px 16px;
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
}

.mall-cat-state--error {
    color: #b45309;
}

.mall-cat-retry {
    margin-top: 12px;
    padding: 8px 18px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    cursor: pointer;
}

.mall-cat-retry:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.mall-prod-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 112px;
    text-decoration: none;
    color: #4a4f57;
}

.mall-prod-card__img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border: 1px solid #eef0f3;
    border-radius: 8px;
    overflow: hidden;
    background: #f7f8fa;
    transition: border-color 0.15s ease;
}

.mall-prod-card:hover .mall-prod-card__img {
    border-color: #91d5ff;
}

.mall-prod-card__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mall-prod-card__img--empty {
    background: #eef0f3;
}

.mall-prod-card__name {
    margin-top: 6px;
    width: 100%;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    color: #4a4f57;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mall-prod-card:hover .mall-prod-card__name {
    color: #2e91f6;
}

.mall-cat-panel__skeleton {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 20px;
}

.mall-cat-skel {
    background: #eef0f3;
    border-radius: 6px;
    animation: mall-skel 1.2s ease-in-out infinite;
}

@keyframes mall-skel {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.mall-cat-skel-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.mall-cat-skel-chips {
    display: flex;
    flex-direction: column;
    flex: 0 0 168px;
    gap: 8px;
    padding-right: 12px;
}

.mall-cat-skel--chip {
    width: 100%;
    height: 28px;
    border-radius: 4px;
}

.mall-cat-skel-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 10px;
}

.mall-cat-skel--card {
    height: 118px;
}

.mall-category-sheet {
    display: none;
}

@media (max-width: 768px) {
    .mall-category-nav {
        position: static;
        flex: 0 0 auto;
        width: 100%;
    }

    /* 首页：仅显示标题栏，点击展开全屏分类 sheet */
    .mall-category-nav:not(.mall-category-nav--subnav) .mall-category-menu__list {
        display: none;
    }

    .mall-category-nav:not(.mall-category-nav--subnav) .mall-category-menu {
        min-height: 0;
    }

    .mall-category-menu {
        width: 100%;
        min-height: 0;
    }

    .mall-category-menu__title {
        cursor: pointer;
    }

    .mall-category-menu__title-action {
        display: inline-flex;
    }

    .mall-category-menu__list {
        max-height: none;
        overflow: visible;
    }

    .mall-category-panel {
        display: none;
    }

    .mall-cat-panel__chips {
        flex: 0 0 92px;
        padding: 6px 0;
    }

    .mall-cat-chip {
        padding: 10px 8px;
        font-size: 12px;
        white-space: normal;
    }

    .mall-cat-panel__grid {
        grid-template-columns: repeat(auto-fill, 80px);
        gap: 10px 12px;
        padding: 12px;
    }

    .mall-cat-skel-chips {
        flex: 0 0 92px;
    }

    .mall-cat-skel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mall-prod-card {
        width: 80px;
    }

    .mall-prod-card__img {
        width: 72px;
        height: 72px;
    }

    .mall-category-sheet.is-open {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 1100;
        background: #fff;
    }

    .mall-category-sheet__bar {
        display: flex;
        align-items: center;
        flex: 0 0 44px;
        height: 44px;
        padding: 0 8px;
        border-bottom: 1px solid #eef0f3;
        font-size: 16px;
        font-weight: 700;
        color: #1e293b;
    }

    .mall-category-sheet__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-right: 4px;
        border: none;
        background: transparent;
        color: #334155;
        font-size: 18px;
        cursor: pointer;
    }

    .mall-category-sheet__body {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
    }

    .mall-category-sheet__rail {
        flex: 0 0 92px;
        overflow-y: auto;
        background: #f7f8fa;
    }

    .mall-category-sheet__rail-item {
        display: block;
        width: 100%;
        min-height: 44px;
        padding: 10px 8px;
        border: none;
        border-left: 3px solid transparent;
        background: transparent;
        color: #475569;
        font-size: 13px;
        line-height: 1.3;
        text-align: left;
        cursor: pointer;
        word-break: break-all;
    }

    .mall-category-sheet__rail-item.is-active {
        background: #fff;
        color: #2e91f6;
        border-left-color: #2e91f6;
        font-weight: 600;
    }

    .mall-category-sheet__main {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: #fff;
    }

    body.mall-sheet-open {
        overflow: hidden;
    }
}
