/**
 * Header 样式
 * 从 Shopify header.css 迁移
 *
 * @package Laifen_Russia
 * @since 1.0.0
 */

/* ========== CSS 变量 ========== */
:root {
    --logo-height: 48px;
    --logo-height-mobile: 40px;
    --header-offset: 0px;
    --color-header-bg: var(--laifen-bg-white, #fff);
    --color-header-text: var(--laifen-text-primary, #020202);
    --color-header-links: var(--laifen-text-primary, #020202);
    --color-header-border: var(--laifen-border-light, #e5e5e5);
}

/* ========== Header 容器 ========== */
.header {
    position: sticky;
    top: 0;
    z-index: var(--laifen-z-sticky, 100);
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-header-border);
    transition: var(--laifen-transition-base, all 0.3s ease);
    overflow: hidden;
}

.header.header-sticky--active {
    box-shadow: var(--laifen-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
}

.header.header--shadow-none {
    box-shadow: none;
}

.header.header--shadow-small {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header.header--shadow-medium {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.header.header--shadow-large {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.header.transparent--true {
    background: transparent;
    border-bottom-color: transparent;
}

.header.transparent--true.header-sticky--active {
    background: var(--color-header-bg);
    border-bottom-color: var(--color-header-border);
}

/* ========== Header 布局 ========== */
.header .row.expanded {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 15px;
}

@media only screen and (min-width: 768px) {
    .header .row.expanded {
        padding: 0 30px;
    }
}

@media only screen and (min-width: 1200px) {
    .header .row.expanded {
        padding: 0 50px;
    }
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    gap: 15px;
    position: relative;
}

@media only screen and (min-width: 1024px) {
    .header-row {
        min-height: 70px;
    }
}

/* ========== Logo ========== */
.header-logo {
    flex-shrink: 0;
    z-index: 10;
}

.header-logo--center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.logolink {
    display: inline-block;
    line-height: 0;
}

.logoimg {
    height: var(--logo-height-mobile, 32px) !important;
    width: auto !important;
    max-width: 140px;
    object-fit: contain;
    transition: var(--laifen-transition-base, all 0.3s ease);
}

@media only screen and (min-width: 768px) {
    .logoimg {
        height: var(--logo-height, 40px) !important;
        max-width: 180px;
    }
}

@media only screen and (min-width: 1024px) {
    .logoimg {
        height: var(--logo-height, 48px) !important;
        max-width: 200px;
    }
}

.logoimg--light {
    display: none;
}

.header.transparent--true .logoimg {
    display: none;
}

.header.transparent--true .logoimg--light {
    display: block;
}

.header.transparent--true.header-sticky--active .logoimg {
    display: block;
}

.header.transparent--true.header-sticky--active .logoimg--light {
    display: none;
}

.text-logo {
    font-size: var(--laifen-font-2xl, 1.5rem);
    font-weight: var(--laifen-font-bold, 700);
    color: var(--color-header-text);
    text-decoration: none;
    transition: var(--laifen-transition-base, all 0.3s ease);
}

.text-logo:hover,
.text-logo:active,
.text-logo:focus {
    color: #4a9eff;
    outline: none;
}

/* ========== 主导航 ========== */
.header-navigation {
    flex: 1;
    display: none;
}

@media only screen and (min-width: 1280px) {
    .header-navigation {
        display: flex;
        justify-content: center;
    }
}

.header-navigation--left {
    justify-content: flex-start;
}

.header-navigation--left-half,
.header-navigation--right-half {
    flex: 1;
}

.header-navigation--left-half {
    justify-content: flex-end;
    padding-right: 30px;
}

.header-navigation--right-half {
    justify-content: flex-start;
    padding-left: 30px;
}

/* Full Menu */
.full-menu {
    display: flex;
    align-items: center;
}

.thb-full-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

@media only screen and (min-width: 1200px) {
    .thb-full-menu {
        gap: 30px;
    }
}

.thb-full-menu--left {
    justify-content: flex-end;
}

.thb-full-menu--right {
    justify-content: flex-start;
}

.thb-full-menu > li {
    position: relative;
}

.thb-full-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-header-links);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.thb-full-menu > li > a:hover,
.thb-full-menu > li > a:active,
.thb-full-menu > li > a:focus,
.thb-full-menu > li.current-menu-item > a,
.thb-full-menu > li.active > a {
    color: #4a9eff;
    outline: none;
}

.thb-full-menu > li > a .dropdown-icon {
    transition: transform 0.2s ease;
}

.thb-full-menu > li:hover > a .dropdown-icon {
    transform: rotate(180deg);
}

/* 导航徽章 */
.navigation-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--laifen-primary, #ec0101);
    border-radius: 100px;
    margin-left: 5px;
    vertical-align: middle;
}

/* ========== 下拉菜单 ========== */
.thb-full-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--color-header-bg);
    border: 1px solid var(--color-header-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.thb-full-menu > li:hover > .sub-menu,
.thb-full-menu > li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.thb-full-menu .sub-menu li {
    margin: 0;
}

.thb-full-menu .sub-menu a {
    display: block;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--color-header-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.thb-full-menu .sub-menu a:hover,
.thb-full-menu .sub-menu a:active,
.thb-full-menu .sub-menu a:focus {
    background: transparent;
    color: #4a9eff;
    outline: none;
}

/* 嵌套子菜单 */
.thb-full-menu .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-left: 5px;
}

/* ========== Mega Menu ========== */
.menuitem-mega {
    position: static !important;
}

.mega-menu__item__v2 {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-height: 80vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s ease;
    z-index: 1000;
}

.thb-full-menu li.menuitem-mega:hover .mega-menu__item__v2,
.thb-full-menu li.menuitem-mega:focus-within .mega-menu__item__v2 {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-menu__item__v2-inner__container {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.mega-links-v2 .mega-menu__item__v2-inner__container {
    grid-template-columns: 200px 1fr;
}

.mega-links-v3 .mega-menu__item__v2-inner__container {
    display: flex;
    gap: 40px;
    grid-template-columns: none;
}

/* Mega Menu 标题区 */
.mega-menus__headings {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mega-menus__headings li {
    margin-top: 1rem;
    text-align: left;
}

.mega-main-heading {
    margin-top: 0 !important;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-header-text);
}

.mega-sub-heading {
    font-size: 14px;
}

.mega-sub-heading a {
    color: var(--color-header-links);
    text-decoration: none;
    transition: color 0.2s ease;
}

.mega-sub-heading a:hover,
.mega-sub-heading a:active,
.mega-sub-heading a:focus {
    color: #4a9eff;
    outline: none;
}

/* Mega Menu Tab */
.mega-menu-tab {
    cursor: pointer;
    padding: 8px 0;
    position: relative;
}

.mega-menu-tab:after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--laifen-primary, #2b00ff);
    transition: width 0.2s ease;
}

.mega-menu-tab.active:after,
.mega-menu-tab:hover:after,
.mega-menu-tab:focus:after {
    width: 100%;
}

.mega-menu-tab:hover,
.mega-menu-tab:active,
.mega-menu-tab:focus {
    outline: none;
}

/* Mega Menu 图片区 */
.mega-menu__item__v2-inner-images {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.mega-menu__item__v2-inner-item {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--color-header-text);
    transition: transform 0.2s ease;
}

.mega-menu__item__v2-inner-item:hover {
    transform: none;
    text-decoration: none;
}

.mega-menu__item__v2-inner-item-image {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #f6f6f6;
}

.mega-menu__item__v2-inner-item-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.mega-menu__item__v2-inner-item:hover .mega-menu__item__v2-inner-item-image img {
    transform: none;
}

.mega-menu-caption {
    padding-top: 10px;
}

.image-heading-mega {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.image-subheading-mega {
    margin: 5px 0 0;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.6);
    line-height: 1.3;
}

/* Mega Menu V3 列式布局 */
.mega-menu__item__v2-inner-column {
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: 150px;
}

.mega-menu__item__v2-inner-column .mega-main-heading {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-header-border);
}

.mega-menu__item__v2-inner-column .mega-sub-heading {
    margin: 8px 0;
}

/* ========== 次要区域 ========== */
.thb-secondary-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

@media only screen and (min-width: 768px) {
    .thb-secondary-area {
        gap: 15px;
    }
}

.thb-secondary-area-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--color-header-text);
    cursor: pointer;
    transition: color 0.2s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

button.thb-secondary-area-item {
    -webkit-appearance: none;
    appearance: none;
}

.thb-secondary-area-item:hover,
.thb-secondary-area-item:active,
.thb-secondary-area-item:focus {
    color: #4a9eff;
    background: transparent;
    outline: none;
    box-shadow: none;
}

.thb-secondary-area-item:focus-visible {
    outline: none;
    box-shadow: none;
}

.thb-secondary-area-item svg {
    width: 19px;
    height: 19px;
}

.thb-secondary-area-item svg {
    display: block;
    flex-shrink: 0;
}

.thb-secondary-area-item svg path,
.thb-secondary-area-item svg circle,
.thb-secondary-area-item svg line {
    stroke: currentColor;
    vector-effect: non-scaling-stroke;
}

/* 搜索按钮 */
.thb-quick-search svg circle,
.thb-quick-search svg line {
    stroke: currentColor;
}

.thb-quick-search:hover svg circle,
.thb-quick-search:hover svg line,
.thb-quick-search:active svg circle,
.thb-quick-search:active svg line,
.thb-quick-search:focus svg circle,
.thb-quick-search:focus svg line {
    stroke: currentColor;
}

/* Account icon */
.thb-secondary-myaccount .thb-account-icon {
    fill: none;
    stroke: currentColor;
}

/* Cart */
.thb-secondary-cart {
    position: relative;
}

.thb-secondary-item-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thb-item-count {
    position: absolute;
    top: -5px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    background: #000000;
    border-radius: 100px;
    line-height: 1;
}

.thb-item-count:empty,
.thb-item-count[data-count="0"] {
    display: none;
}

/* ========== 移动端菜单切换 ========== */
.thb-header-mobile-left {
    display: flex;
    align-items: center;
}

@media only screen and (min-width: 1280px) {
    .thb-header-mobile-left {
        display: none;
    }
}

.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:active,
.mobile-menu-toggle:focus {
    background: transparent;
    outline: none;
    box-shadow: none;
}

.mobile-menu-toggle:focus-visible {
    outline: none;
    box-shadow: none;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 22px;
    flex-shrink: 0;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-header-text);
    transition: all 0.3s ease;
    transform-origin: center;
    flex-shrink: 0;
}

/* 汉堡菜单动画 */
.mobile-menu-open .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-open .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-open .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ========== 进度条 ========== */
.header_progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
}

.header_progress .progress-bar {
    height: 100%;
    width: 0;
    background: var(--laifen-primary, #2b00ff);
    transition: width 0.1s ease;
}

/* ========== Header 4 种样式 ========== */

/* Style 1: Logo 左, 菜单居中 */
.header.style1 .header-row {
    justify-content: space-between;
}

.header.style1 .header-logo {
    order: 1;
}

.header.style1 .header-navigation {
    order: 2;
    justify-content: center;
}

.header.style1 .thb-secondary-area {
    order: 3;
}

/* Style 2: Logo 左, 菜单左 */
.header.style2 .header-row {
    justify-content: flex-start;
}

.header.style2 .header-logo {
    order: 1;
    margin-right: 30px;
}

.header.style2 .header-navigation {
    order: 2;
    justify-content: flex-start;
    flex: 1;
}

.header.style2 .thb-secondary-area {
    order: 3;
    margin-left: auto;
}

/* Style 3: Logo 居中, 菜单左 */
.header.style3 .header-row {
    justify-content: space-between;
}

.header.style3 .header-navigation {
    order: 1;
    flex: 1;
    justify-content: flex-start;
}

.header.style3 .header-logo {
    order: 2;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header.style3 .thb-secondary-area {
    order: 3;
}

/* Style 4: Logo 居中, 菜单居中 (分布两侧) */
.header.style4 .header-row {
    justify-content: center;
}

.header.style4 .header-navigation--left-half {
    order: 1;
    flex: 1;
    justify-content: flex-end;
    padding-right: 30px;
}

.header.style4 .header-logo {
    order: 2;
}

.header.style4 .header-navigation--right-half {
    order: 3;
    flex: 1;
    justify-content: flex-start;
    padding-left: 30px;
}

.header.style4 .thb-secondary-area {
    position: absolute;
    right: 15px;
}

@media only screen and (min-width: 768px) {
    .header.style4 .thb-secondary-area {
        right: 30px;
    }
}

@media only screen and (min-width: 1200px) {
    .header.style4 .thb-secondary-area {
        right: 50px;
    }
}

/* ========== 透明 Header 颜色覆盖 ========== */
.header.transparent--true {
    --color-header-text: #ffffff;
    --color-header-links: #ffffff;
}

.header.transparent--true .hamburger-icon span {
    background: #ffffff;
}

.header.transparent--true.header-sticky--active {
    --color-header-text: var(--laifen-text-primary, #020202);
    --color-header-links: var(--laifen-text-primary, #020202);
}

.header.transparent--true.header-sticky--active .hamburger-icon span {
    background: var(--laifen-text-primary, #020202);
}

/* ========== 响应式设计 ========== */
@media (max-width: 1279px) {
    .header-row {
        min-height: 56px;
    }

    /* 移动端统一布局 */
    .header.style1 .header-logo,
    .header.style2 .header-logo,
    .header.style3 .header-logo,
    .header.style4 .header-logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        order: 2;
    }

    .header.style1 .thb-header-mobile-left,
    .header.style2 .thb-header-mobile-left,
    .header.style3 .thb-header-mobile-left,
    .header.style4 .thb-header-mobile-left {
        order: 1;
    }

    .header.style1 .thb-secondary-area,
    .header.style2 .thb-secondary-area,
    .header.style3 .thb-secondary-area,
    .header.style4 .thb-secondary-area {
        order: 3;
        position: static;
        margin-left: auto;
    }
}

@media (max-width: 767px) {
    .header .row.expanded {
        padding: 0 10px;
    }

    .header-row {
        gap: 10px;
    }

    .thb-secondary-area {
        gap: 5px;
    }

    .thb-secondary-area-item {
        width: 32px;
        height: 32px;
    }

    .thb-secondary-area-item svg {
        width: 18px;
        height: 18px;
    }
}
