/**
 * ZSX Header 集成式页眉小部件样式
 * 桌面：Logo + 横向菜单 + 搜索图标；窄屏：折叠为汉堡 + 整屏抽屉树状菜单
 * 模式切换由 JS 在根元素加 .zsx-header--mobile 控制
 */

.zsx-header {
    --zsx-hd-accent: #0073b8;
    position: relative;
    width: 100%;
}

.zsx-header *,
.zsx-header *::before,
.zsx-header *::after {
    box-sizing: border-box;
}

.zsx-header__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* ===== Logo ===== */
.zsx-header__logo {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

.zsx-header__logo img {
    display: block;
    width: 180px;
    height: auto;
}

.zsx-header__site-name {
    font-size: 20px;
    font-weight: 700;
    color: #222;
    line-height: 1.2;
}

/* ===== 导航（桌面） ===== */
.zsx-header__nav {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.zsx-header__menu {
    display: flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
    /* 中等宽度放不下时优雅换行，而不是收成汉堡；汉堡只在断点以下出现 */
    flex-wrap: wrap;
    row-gap: 0;
    max-width: 100%;
    overflow: visible;
}

.zsx-header__menu > .zsx-hd-item {
    position: relative;
    margin: 0;
    flex: 0 0 auto;
}

.zsx-header__menu > .zsx-hd-item > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px;
    color: var(--zsx-hd-menu-color, #333);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: color .2s ease, border-color .2s ease;
}

.zsx-header__menu > .zsx-hd-item:hover > a {
    color: var(--zsx-hd-accent);
    border-bottom-color: var(--zsx-hd-accent);
    background: rgba(0, 115, 184, .07);
    background: color-mix(in srgb, var(--zsx-hd-accent) 8%, transparent);
}

.zsx-hd-caret {
    flex: 0 0 auto;
    transition: transform .2s ease;
}

.zsx-header__menu > .zsx-hd-item:hover > a .zsx-hd-caret {
    transform: rotate(180deg);
}

/* ===== 下拉面板（桌面，悬停显示） ===== */
.zsx-hd-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100000;
    display: none;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    overflow: hidden;
}

.zsx-header__menu > .zsx-hd-item:hover > .zsx-hd-panel {
    display: flex;
}

.zsx-hd-panel.align-right {
    left: auto;
    right: 0;
}

/* 简单下拉（无孙级） */
.zsx-hd-panel--simple {
    min-width: 220px;
}

.zsx-hd-panel--simple ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    width: 100%;
}

/* 与产品面板左栏保持一致的视觉规范：同样的行高、左边条与选中态 */
.zsx-hd-panel--simple li a {
    display: block;
    padding: 11px 16px;
    color: var(--zsx-hd-panel-link, #444);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}

.zsx-hd-panel--simple li a:hover {
    background: var(--zsx-hd-accent);
    color: #fff;
    border-left-color: rgba(255, 255, 255, .9);
    font-weight: 600;
}

/* 双栏面板（有孙级） */
.zsx-hd-panel--columns {
    width: 640px;
    max-width: calc(100vw - 24px);
}

.zsx-hd-col-left {
    flex: 0 0 220px;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background: #f7f8fa;
    border-right: 1px solid #e7eaee;
    max-height: 70vh;
    overflow-y: auto;
}

.zsx-hd-col-left li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 16px;
    color: var(--zsx-hd-panel-link, #444);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}

/* 选中/悬停的分类：主题色整块高亮，白色文字，一目了然 */
.zsx-hd-col-left li.active a,
.zsx-hd-col-left li a:hover {
    background: var(--zsx-hd-accent);
    color: #fff;
    border-left-color: rgba(255, 255, 255, .9);
    font-weight: 600;
}

.zsx-hd-caret--right {
    opacity: .45;
}

.zsx-hd-col-left li.active a .zsx-hd-caret--right,
.zsx-hd-col-left li a:hover .zsx-hd-caret--right {
    opacity: 1;
    transform: translateX(2px);
}

.zsx-hd-col-right {
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 18px;
    max-height: 70vh;
    overflow-y: auto;
}

.zsx-hd-group {
    display: none;
}

.zsx-hd-group.active {
    display: block;
}

.zsx-hd-link {
    display: block;
    padding: 7px 10px;
    margin: 0 -10px;
    border-radius: 6px;
    color: var(--zsx-hd-panel-link, #444);
    font-size: 14px;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.zsx-hd-link:hover {
    color: var(--zsx-hd-accent);
    background: rgba(0, 115, 184, .09);
    background: color-mix(in srgb, var(--zsx-hd-accent) 9%, #fff);
    border-left-color: var(--zsx-hd-accent);
    transform: translateX(3px);
    font-weight: 600;
}

.zsx-hd-sub {
    margin-bottom: 10px;
}

.zsx-hd-sub-title {
    display: block;
    padding: 6px 0 4px;
    color: #222;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.zsx-hd-sub-title:hover {
    color: var(--zsx-hd-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zsx-hd-link--sub {
    padding-left: 14px;
    font-size: 13px;
    color: #666;
}

/* ===== 右侧动作区 ===== */
.zsx-header__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 搜索弹层右对齐（结构样式在 frontend.css，这里只调整对齐） */
.zsx-header__actions .zsx-global-search.zsx-collapsible .zsx-search-panel {
    right: 0;
    left: auto;
}

/* ===== 汉堡按钮（桌面隐藏） ===== */
.zsx-header__burger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
}

.zsx-header__burger:hover {
    background: rgba(0, 0, 0, .05);
}

.zsx-header__burger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    transition: transform .25s ease, opacity .25s ease;
}

.zsx-header.is-drawer-open .zsx-header__burger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.zsx-header.is-drawer-open .zsx-header__burger span:nth-child(2) {
    opacity: 0;
}

.zsx-header.is-drawer-open .zsx-header__burger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ===== 抽屉（默认隐藏） ===== */
.zsx-header__drawer {
    display: none;
}

/* ===== 移动模式（JS 切换 .zsx-header--mobile） ===== */
.zsx-header--mobile .zsx-header__nav {
    display: none;
}

.zsx-header--mobile .zsx-header__burger {
    display: flex;
}

.zsx-header--mobile.is-drawer-open .zsx-header__drawer {
    display: block;
    position: fixed;
    top: var(--zsx-hd-drawer-top, 60px);
    left: 0;
    right: 0;
    width: 100vw;
    max-height: calc(100vh - var(--zsx-hd-drawer-top, 60px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border-top: 1px solid #e3e6ea;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .15);
    z-index: 100001;
}

/* ===== 抽屉树状手风琴 ===== */
.zsx-hd-tree,
.zsx-hd-tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.zsx-hd-tree-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f0f2f4;
}

.zsx-hd-tree-row a {
    flex: 1 1 auto;
    min-width: 0;
    padding: 13px 16px;
    color: var(--zsx-hd-menu-color, #333);
    font-size: 15px;
    text-decoration: none;
}

.zsx-hd-tree-row a:hover,
.zsx-hd-tree-row a:active {
    color: var(--zsx-hd-accent);
    background: rgba(0, 115, 184, .07);
    background: color-mix(in srgb, var(--zsx-hd-accent) 7%, transparent);
}

.zsx-hd-tree-toggle {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-left: 1px solid #f0f2f4;
    background: transparent;
    color: #888;
    cursor: pointer;
}

.zsx-hd-tree-toggle svg {
    transition: transform .2s ease;
}

.zsx-hd-tree li.is-open > .zsx-hd-tree-row .zsx-hd-tree-toggle svg {
    transform: rotate(180deg);
}

.zsx-hd-tree li.is-open > .zsx-hd-tree-row .zsx-hd-tree-toggle {
    color: var(--zsx-hd-accent);
}

/* 展开后的第一行：进入该分类页的明确入口（强调色 + 右箭头） */
.zsx-hd-tree-overview .zsx-hd-tree-row a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--zsx-hd-accent);
    font-weight: 600;
}

/* 子级默认收起，展开时显示并缩进 */
.zsx-hd-tree-children {
    display: none;
    background: #fafbfc;
}

.zsx-hd-tree li.is-open > .zsx-hd-tree-children {
    display: block;
}

.zsx-hd-tree-children .zsx-hd-tree-row a {
    padding-left: 32px;
    font-size: 14px;
}

.zsx-hd-tree-children .zsx-hd-tree-children .zsx-hd-tree-row a {
    padding-left: 48px;
    font-size: 13px;
    color: #555;
}

.zsx-hd-tree-children .zsx-hd-tree-children .zsx-hd-tree-children .zsx-hd-tree-row a {
    padding-left: 64px;
}
