/* 基础重置 */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

/* 头部容器:固定顶栏+阴影 */
.site-header {
    background-color: #ffffff;
    display: flex;
    /* 1. 设置主轴对齐方式：居中 */
    justify-content: center; 
    /* 2. 可选：如果希望内部容器在垂直方向也居中，则添加： */
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* 头部内容布局:Flex排版,左右中三列 */
.header-container {
    max-width: 1200px;
    width: 100%;
    margin: 0;
    padding: 0 0px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    min-height: 120px; /* 基础最小高度 */
    height: auto; /* 根据导航换行自动增高 */
    position: relative;
    /* 三栏布局可调变量：侧栏最小宽 + 中栏最大宽占比 */
    --header-side-min: 140px; /* 左/右区域的最小合理宽度 */
    --header-center-max: 9999px; /* 中间导航理论最大宽度（可用 max-width 约束） */
    gap: 32px; /* 统一间距，替代之前的大量 margin 空白 */
}
/* 三栏宽度分配：中间主导航扩展，左右收缩 */
.header-container > .site-branding { flex:0 0 var(--header-side-min); margin-right:0; }
.header-container > .header-actions { flex:0 0 var(--header-side-min); }
/* 中间导航（.main-navigation）获得剩余空间 */
.header-container > .main-navigation { flex:1 1 auto; max-width: var(--header-center-max); }
/* 避免导航受内部 max-width 限制（原有 600px 太窄） */
@media (min-width: 769px){
    .main-navigation { max-width: none; }
}

/* 左侧:店铺标识(图标+名称) */
.site-branding {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333333;
    transition: color 0.3s ease;
}
.site-branding:hover { 
    color: #007bff; 
}
.icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: inline-block;
}
.brand-logo {
    margin-right: 12px;
    color: #007bff;
    width: 48px;
    height: 48px;
}
.brand-logo-img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    background-color: transparent;
}
.brand-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap; /* 防止品牌名换行 */
}


/* 右侧:购物车图标+角标 */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}
.cart-icon {
    position: relative;
}
.cart-button {
    background: none;
    border: none;
    color: #333333;
    font-size: 22px;
    cursor: default;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
}
.cart-button:hover {
    color: #007bff;
}

/* 搜索框样式 */
.search-form {
    position: relative;
}
.search-input {
    padding: 10px 15px 10px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 30px;
    font-size: 14px;
    width: 200px;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
}
.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    background-color: #fff;
    width: 250px;
}
.search-button {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
}

/* 移动端菜单按钮 */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    margin-right: 15px;
}
.mobile-menu-toggle svg {
    pointer-events: none;
}
.submenu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0;
}

/* 响应式设计 */
@media (max-width: 992px) { .header-container { height:105px; } }

@media (max-width: 768px) {
    .header-container {
        padding: 6px 10px;
        height: auto;
        flex-wrap: wrap; /* 允许子元素换行 */
        align-items: stretch;
        gap: 4px;
        /* 如果父级之前被其他样式限制成 nowrap，可用以下提高优先级 */
        display: flex;
    }
    /* 明确指向直接子元素，强制占满一行 */
    .header-container > .site-branding,
    .header-container > .header-actions,
    .header-container > .main-navigation { flex: 0 0 100%; max-width:100%; }
    /* 避免之前的侧栏固定宽度规则在移动端残留 */
    .header-container > .site-branding { margin-right:0 !important; }
    /* 第一行：店铺 Logo + 名称 居中 */
    .site-branding {
        order: 1;
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 4px 0 2px;
    }
    .site-branding .brand-logo-img, .site-branding .brand-logo { 
        flex-shrink: 0; 
    }
    .site-branding .brand-logo { margin-right: 8px; }

    /* 第二行：搜索框（自适应）+ 购物车 + 汉堡菜单 */
    .header-actions {
        order: 2;
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        gap: 12px;
        flex-wrap: nowrap;
        align-items: center;
    }
    .header-actions .search-form { flex: 1 1 auto; max-width: 100%; }
    .header-actions .search-input, .header-actions .search-input:focus { width: 100%; }
    .cart-icon { flex: 0 0 auto; }
    .mobile-menu-toggle { 
        display: flex; 
        align-items: center; 
        justify-content: center; 
        flex: 0 0 auto; 
        margin-right: 0; 
    }

    /* 第三行（如需显示导航）：让导航占满整行，排在最下 */
    .main-navigation { 
        order: 3; 
        width: 100%; 
        margin-top: 2px; 
    }
    /* 展开状态左侧间距 */
    .main-navigation.is-open { padding-left: 10px; }
    .main-navigation .nav-menu { 
        display: flex; 
        flex-wrap: wrap; 
        justify-content: center; 
        gap: 6px; 
        padding: 4px 0 8px; 
    }
    .main-navigation .nav-menu > li { flex: 0 0 auto; }

    /* 搜索框收缩时维持圆角与内边距 */
    .search-input { min-width: 0; }
}
