/* ===== Header 样式 ===== */

/* 顶部提示条 */
.top-bar { 
    background: #000; 
    color: #fff; 
    text-align: center; 
    padding: 8px 0; 
    font-size: 12px; 
    max-width: 100%; 
}

/* Header 导航 */
.header { 
    background: #fff; 
    border-bottom: 1px solid #e5e5e5; 
    position: relative;
    max-width: 100%; 
    overflow: visible;
    min-height: 72px;
    height: auto;
}

.header-inner { 
    max-width: 1400px; 
    width: 100%; 
    margin: 0 auto; 
    padding: 16px 24px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    position: relative; 
    overflow: visible;
    min-height: 72px;
    height: 72px;
    box-sizing: border-box;
}

.logo { 
    font-size: 24px; 
    font-weight: 700; 
    letter-spacing: -0.5px; 
    color: #000;
    text-decoration: none;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
    height: auto;
    margin: 0;
    padding: 0;
}

/* 移动端菜单按钮（默认隐藏，仅小屏显示；与右侧图标同尺寸） */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
}
.nav-toggle:hover { background: transparent; opacity: 0.8; }
.nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #111;
    border-radius: 1px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.header.nav-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.header.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
.header.nav-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav { 
    display: flex; 
    gap: 32px; 
    align-items: center; 
    position: relative; 
    z-index: 10001;
    height: 100%;
    flex-shrink: 0;
}

.header .nav-item { 
    position: relative; 
    z-index: 10002; 
}

/* 确保header的nav-item不受账户页面样式影响 */
.header .nav-item,
.header .nav-item.active {
    pointer-events: auto;
}

.nav-link { 
    font-size: 14px; 
    font-weight: 500; 
    color: #000; 
    padding: 8px 0; 
    display: block; 
    transition: color 0.3s; 
    text-decoration: none;
    line-height: 1.5;
    height: auto;
    white-space: nowrap;
}

.nav-link:hover { 
    color: #666; 
    text-decoration: none;
}

/* 下拉菜单 */
.dropdown { 
    position: absolute; 
    left: 0; 
    top: 100%; 
    padding-top: 8px; 
    opacity: 0; 
    visibility: hidden; 
    transition: all 0.3s; 
    z-index: 10003;
    pointer-events: none; /* 隐藏时不可点击 */
}

.header .nav-item:hover .dropdown {
    pointer-events: auto; /* 显示时可点击 */
}

.header .nav-item:hover .dropdown { 
    opacity: 1; 
    visibility: visible; 
    pointer-events: auto; /* 显示时可点击 */
}

.dropdown-container {
    display: flex;
    background: #fff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    z-index: 10005;
}

.dropdown-menu { 
    background: #fff; 
    padding: 8px 0; 
    min-width: 180px; 
    position: relative; 
    z-index: 10004; 
    border-right: 1px solid #e5e5e5;
}

.dropdown-item { 
    display: flex; 
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px; 
    font-size: 13px; 
    color: #333; 
    transition: background 0.2s; 
    text-decoration: none;
    pointer-events: auto !important;
    cursor: pointer;
    position: relative;
    z-index: 10006;
}

/* 确保header内的dropdown-item不受账户页面样式影响 */
.header .dropdown-item {
    background: transparent !important;
    border-left: none !important;
    border-bottom: none !important;
    font-weight: normal !important;
}

/* 确保链接可以点击 - 不受账户页面样式影响 */
.header .dropdown-item,
.header .dropdown-item[href],
.header .dropdown-item.active,
.header .dropdown-item.active[href] {
    pointer-events: auto !important;
    cursor: pointer !important;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.header .dropdown-item:hover,
.header .dropdown-item[href]:hover,
.header .dropdown-item.active:hover,
.header .dropdown-item.active[href]:hover {
    background: #f5f5f5 !important;
}

.dropdown-item:hover { 
    background: #f5f5f5; 
}

.dropdown-text {
    flex: 1;
    pointer-events: auto !important;
    position: relative;
    z-index: 10007;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    color: #999;
    margin-left: 8px;
    flex-shrink: 0;
    transition: color 0.2s, transform 0.2s;
    cursor: pointer;
    pointer-events: auto;
}

.dropdown-item:hover .dropdown-arrow {
    color: #333;
    transform: translateX(2px);
}

.dropdown-item:hover .dropdown-arrow:hover {
    color: #000;
    transform: translateX(4px);
}

.dropdown-preview {
    width: 300px;
    height: 300px;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.dropdown-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.dropdown-preview-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    box-sizing: border-box;
}

.dropdown-preview-placeholder.is-hidden,
.dropdown-preview-img.is-hidden {
    display: none;
}

/* 右侧图标 */
.header-icons { 
    display: flex; 
    gap: 20px; 
    align-items: center;
    height: 100%;
    flex-shrink: 0;
}

.icon-btn { 
    width: 20px; 
    height: 20px; 
    color: #000; 
    transition: color 0.3s, fill 0.3s; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.icon-btn:hover { 
    color: #666; 
}

.icon-btn svg { 
    width: 100%; 
    height: 100%; 
}

/* 带文字的图标按钮（PC端） */
.icon-btn-with-text {
    width: auto;
    height: auto;
    gap: 2px;
    padding: 0;
    position: relative;
}

.icon-btn-with-text svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon-text {
    font-size: 0.875rem;
    color: #000;
    white-space: nowrap;
    display: none; /* 默认隐藏，PC端显示 */
}

.header-count-badge {
    position: absolute;
    top: -8px;
    right: -14px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e60012;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .icon-text {
        display: inline-block;
    }
}

/* 图标选中状态 - 实心黑色 */
.icon-btn.active {
    color: #000;
}
.icon-btn.active svg {
    fill: #000;
    stroke: #000;
}

/* 搜索容器 */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-toggle {
    display: flex;
}

.search-box {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 10008;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    white-space: nowrap;
}

/* PC端搜索框保持原有样式 */
@media (min-width: 769px) {
    .search-box {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }
}

.search-box.active {
    opacity: 1;
    visibility: visible;
    width: 300px;
    padding: 6px 8px;
}

.search-container.search-active .search-toggle {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px 8px;
    color: #333;
    background: transparent;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: 4px;
    background: none;
    border: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.search-btn:hover {
    color: #000;
}

.search-btn svg {
    width: 16px;
    height: 16px;
}

.search-close {
    width: 20px;
    height: 20px;
    padding: 0;
    margin-left: 4px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.search-close:hover {
    color: #333;
}

.search-close svg {
    width: 16px;
    height: 16px;
}

/* ===== Header 响应式 ===== */

@media (max-width: 1024px) {
    .header {
        min-height: 64px;
    }
    .header-inner { 
        padding: 12px 20px;
        min-height: 64px;
        height: 64px;
    }
    .nav { gap: 24px; }
    .logo { font-size: 20px; line-height: 1; }
    .header-icons { gap: 16px; }
    .icon-btn { width: 18px; height: 18px; }
    .dropdown-preview {
        width: 250px;
        height: 250px;
    }
}

@media (max-width: 768px) {
    .top-bar { padding: 6px 10px; font-size: 11px; line-height: 1.4; }

    .header {
        min-height: 56px;
    }
    .header-inner { 
        padding: 10px 16px; 
        flex-wrap: nowrap; 
        gap: 12px; 
        overflow: visible; 
        min-width: 0;
        min-height: 56px;
        height: 56px;
    }
    .logo { 
        font-size: 18px; 
        flex-shrink: 0;
        line-height: 1;
    }
    .header-icons { 
        flex-shrink: 0; 
        gap: 2px;
        height: 100%;
    }

    /* 汉堡与右侧图标同尺寸、紧挨搜索 */
    .nav-toggle {
        display: flex;
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        align-items: center;
        justify-content: center;
    }
    .nav-toggle-bar { width: 20px; height: 2px; }

    /* 移动端导航：固定浮层，盖在页面最上层，不被 banner 遮挡；无需滑动 header */
    .nav {
        position: fixed;
        left: 0;
        right: 0;
        /* 使用 CSS 变量控制顶部距离，默认 56px，由 JS 根据 header 高度动态更新 */
        top: var(--mobile-nav-top, 56px);
        z-index: 9999;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        margin: 0;
        background: #fff;
        /* 移动端不再需要额外的白色横线边框 */
        border-top: none;
        box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        -webkit-overflow-scrolling: touch;
        display: flex;
    }
    .header.nav-open .nav {
        /* 视口高度减去 header 高度，保证不会超出屏幕 */
        max-height: calc(100vh - var(--mobile-nav-top, 56px));
        overflow-y: auto;
        overflow-x: hidden;
    }
    /* 打开菜单时锁定页面，弹窗不随滚动移动 */
    body.menu-open { overflow: hidden; position: fixed; width: 100%; left: 0; }
    /* 汉堡展开时隐藏页面主体，避免与导航菜单重叠（仅行为，不改变 header 外观） */
    body.menu-open main { visibility: hidden; pointer-events: none; }

    .nav .nav-item,
    .nav > .nav-link { border-bottom: 1px solid #f0f0f0; }
    .nav .nav-item:last-child,
    .nav > .nav-link:last-of-type { border-bottom: none; }

    .nav-link {
        display: block;
        padding: 14px 20px;
        font-size: 15px;
        font-weight: 500;
        white-space: nowrap;
        min-height: 48px;
        box-sizing: border-box;
        line-height: 1.4;
        text-decoration: none;
    }

    /* 移动端下拉项直接展开在「批量灯具」下方 */
    .nav-item .dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        padding: 0;
        box-shadow: none;
        border: none;
        max-height: none;
    }
    .nav-item .dropdown-container {
        flex-direction: column;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    .nav-item .dropdown-menu {
        background: #fafafa;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 4px 0 8px;
        min-width: 0;
        border-right: none;
        width: 100%;
    }
    .nav-item .dropdown-item {
        padding: 12px 20px 12px 36px;
        font-size: 14px;
        border-bottom: none;
    }
    .nav-item .dropdown-item:hover { background: #f0f0f0; }
    .nav-item .dropdown-preview {
        display: none; /* 移动端隐藏图片预览 */
    }

    /* 移动端右侧图标：与汉堡一致，图标间距更近 */
    .header-icons { gap: 0; }
    .icon-btn {
        width: 22px;
        height: 22px;
        min-width: 40px;
        min-height: 40px;
        padding: 9px;
        box-sizing: border-box;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
    }
    .icon-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    .icon-btn-with-text {
        width: 40px;
        height: 40px;
        gap: 0;
    }
    .icon-text {
        display: none !important;
    }

    /* 未登录时右上角 Login 文本按钮在移动端可见 */
    #loginTextLink {
        width: auto;
        min-width: 0;
        padding: 0 8px;
    }
    #loginTextLink .icon-text {
        display: inline-block !important;
        font-size: 14px;
    }
    
    /* 移动端搜索框 */
    .search-container {
        position: relative;
    }
    
    .search-box {
        position: fixed;
        top: var(--mobile-nav-top, 56px);
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        transform: translateY(-100%);
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: 1px solid #e5e5e5;
        padding: 12px 16px;
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        z-index: 10000;
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
        margin: 0;
    }
    
    .search-box.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        width: 100vw !important;
    }
    
    .search-input {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 8px 12px;
        width: 100%;
        flex: 1;
        min-width: 0;
        box-sizing: border-box;
    }
    
    .search-box {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .search-btn,
    .search-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        padding: 0;
    }
    
    .search-btn svg,
    .search-close svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .top-bar { font-size: 10px; padding: 6px 8px; }

    .header {
        min-height: 56px;
    }
    .header-inner { 
        padding: 10px 12px; 
        gap: 8px;
        min-height: 56px;
        height: 56px;
    }
    .logo { 
        font-size: 17px;
        line-height: 1;
    }
    .nav-toggle { min-width: 40px; min-height: 40px; width: 40px; height: 40px; }
    .nav-toggle-bar { width: 18px; }

    .nav-link { padding: 12px 16px; font-size: 14px; min-height: 44px; }
    .nav-item .dropdown-item { padding: 10px 16px 10px 32px; font-size: 13px; }

    .header-icons { gap: 0; }
    .icon-btn { width: 20px; height: 20px; min-width: 36px; min-height: 36px; padding: 8px; }
    .icon-btn svg { width: 18px; height: 18px; }
    .icon-btn-with-text {
        width: 36px;
        height: 36px;
        gap: 0;
    }
    .icon-text {
        display: none !important;
    }
    
    /* 小屏移动端搜索框 */
    .search-box {
        padding: 10px 12px;
        width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
    }
    
    .search-box.active {
        width: 100vw !important;
    }
    
    .search-input {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 6px 10px;
        width: 100%;
        flex: 1;
        min-width: 0;
        box-sizing: border-box;
    }
}

/* ===== 联系我们弹窗样式 ===== */
.contact-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.contact-modal-overlay.active {
    opacity: 1;
}

.contact-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.contact-modal-overlay.active .contact-modal {
    transform: scale(1);
}

.contact-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #e5e5e5;
}

.contact-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #111;
    margin: 0;
}

.contact-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    padding: 0;
}

.contact-modal-close:hover {
    background: #f5f5f5;
    color: #000;
}

.contact-modal-close svg {
    width: 20px;
    height: 20px;
}

.contact-modal-body {
    padding: 24px;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.contact-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    border-radius: 8px;
    color: #333;
    flex-shrink: 0;
}

.contact-icon svg {
    width: 24px;
    height: 24px;
}

.contact-content {
    flex: 1;
}

.contact-label {
    font-size: 14px;
    color: #666;
    margin: 0 0 8px 0;
}

.contact-value {
    font-size: 18px;
    color: #111;
    margin: 0;
    font-weight: 500;
}

.contact-email {
    color: #000;
    text-decoration: none;
    transition: color 0.2s;
}

.contact-email:hover {
    color: #333;
    text-decoration: underline;
}

/* 响应式 */
@media (max-width: 768px) {
    .contact-modal {
        width: 95%;
        max-width: none;
        margin: 20px;
    }

    .contact-modal-header {
        padding: 20px;
    }

    .contact-modal-title {
        font-size: 20px;
    }

    .contact-modal-body {
        padding: 20px;
    }

    .contact-item {
        gap: 12px;
    }

    .contact-icon {
        width: 40px;
        height: 40px;
    }

    .contact-icon svg {
        width: 20px;
        height: 20px;
    }

    .contact-value {
        font-size: 16px;
    }
}
