/**
 * Tengzhuo Header Styles
 * BEM naming convention, modular structure, optimized specificity
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --pl-white: #ffffff;
    --pl-black: #0a192f;
    --pl-gray: #f8f9fa;
    --pl-text: #4a5568;
    --pl-accent: #f09456;
    --pl-accent-hover: #d98149;
    --pl-primary: #1a56a8;
    --pl-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --pl-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
    --pl-shadow-lg: 0 30px 60px rgba(0, 0, 0, 0.08);
    --pl-transition-fast: 0.2s ease;
    --pl-transition-normal: 0.3s ease;
    --pl-z-header: 1000;
    --pl-z-dropdown: 1010;
    --pl-z-megamenu: 1020;
    --pl-z-mobile: 1030;
    --pl-z-overlay: 1040;
}

/* ========================================
   Base & Reset
   ======================================== */
.pl-header,
.pl-header * {
    box-sizing: border-box;
}

.pl-header {
    --header-height: 95px;
    --header-height-compact: 70px;
    --topbar-height: 50px;

    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--pl-z-header);
    font-family: 'Montserrat', 'Inter', sans-serif;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Defensive reset for legacy homepage critical CSS that targets #pl-pro-header */
body #pl-pro-header.pl-header {
    --pl-accent: #f09456 !important;
    --pl-accent-hover: #d98149 !important;
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    pointer-events: auto !important;
}

body #pl-pro-header.pl-header .pl-header__top-bar,
body #pl-pro-header.pl-header .pl-header__top-nav,
body #pl-pro-header.pl-header .pl-header__top-menu,
body #pl-pro-header.pl-header .pl-header__top-item,
body #pl-pro-header.pl-header .pl-header__top-link,
body #pl-pro-header.pl-header .pl-header__top-dropdown,
body #pl-pro-header.pl-header .pl-header__main,
body #pl-pro-header.pl-header .pl-header__menu,
body #pl-pro-header.pl-header .pl-header__item,
body #pl-pro-header.pl-header .pl-header__link,
body #pl-pro-header.pl-header .pl-header__dropdown,
body #pl-pro-header.pl-header .pl-header__megamenu,
body #pl-pro-header.pl-header .pl-header__mega-link,
body #pl-pro-header.pl-header .pl-header__actions,
body #pl-pro-header.pl-header .pl-header__cta,
body #pl-pro-header.pl-header .pl-header__catalog-btn,
body #pl-pro-header.pl-header .pl-header__toggle {
    pointer-events: auto !important;
}

body #pl-pro-header.pl-header .pl-header__top-bar.is-hidden,
body #pl-pro-header.pl-header .pl-header__top-bar.is-hidden * {
    pointer-events: none !important;
}

/* Admin Bar Compensation */
body.admin-bar .pl-header {
    top: 32px;
}

@media (max-width: 782px) {
    body.admin-bar .pl-header {
        top: 46px;
    }
}

/* Placeholder */
.pl-header__placeholder {
    display: none;
    height: 0;
    width: 100%;
}

@media (max-width: 1024px) {
    .pl-header__placeholder {
        height: 0;
    }
}

/* ========================================
   Container
   ======================================== */
.pl-header__container {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pl-header__main > .pl-header__container {
    height: 100%;
    padding-top: 4px;
    padding-bottom: 4px;
}

@media (max-width: 1366px) {
    .pl-header__container {
        padding: 0 24px;
    }
}

@media (max-width: 1024px) {
    .pl-header__container {
        padding: 0 20px;
    }
}

/* ========================================
   Top Bar
   ======================================== */
.pl-header__top-bar {
    background: var(--pl-gray);
    border-bottom: 1px solid #e2e8f0;
    height: var(--topbar-height);
    overflow: visible;
    transition: height var(--pl-transition-normal),
                opacity var(--pl-transition-normal),
                border-color var(--pl-transition-normal);
}

.pl-header__top-bar.is-hidden {
    height: 0;
    opacity: 0;
    border-bottom-color: transparent;
    pointer-events: none;
}

.pl-header__top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    gap: 16px;
    padding: 4px 0;
}

.pl-header__top-menu {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pl-header__top-item {
    position: relative;
}

.pl-header__top-link {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--pl-text);
    text-decoration: none;
    padding: 12px 0;
    display: block;
    transition: color var(--pl-transition-normal);
}

.pl-header__top-link:hover,
.pl-header__top-link.is-active {
    color: var(--pl-primary);
}

/* Top Bar Dropdown */
.pl-header__top-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--pl-white);
    box-shadow: var(--pl-shadow-md);
    border-radius: 4px;
    min-width: 220px;
    padding: 8px 0;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--pl-transition-normal);
    z-index: var(--pl-z-dropdown);
}

.pl-header__top-item:hover .pl-header__top-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pl-header__top-item.is-open .pl-header__top-dropdown,
.pl-header__top-item:focus-within .pl-header__top-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pl-header__top-dropdown li {
    margin: 0;
}

.pl-header__top-dropdown a {
    display: block;
    padding: 10px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #2d3748;
    text-decoration: none;
    transition: all var(--pl-transition-fast);
}

.pl-header__top-dropdown a:hover {
    background: #f7fafc;
    color: var(--pl-primary);
    padding-left: 24px;
}

/* Catalog Button */
.pl-header__catalog-btn {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--pl-primary);
    background: transparent;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--pl-transition-normal);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.pl-header__catalog-btn:hover {
    background: var(--pl-primary);
    color: var(--pl-white);
}

@media (max-width: 1024px) {
    .pl-header__top-bar {
        display: none;
    }
}

/* ========================================
   Main Navigation
   ======================================== */
.pl-header__main {
    background: var(--pl-white);
    height: var(--header-height);
    margin-top: -1px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: height var(--pl-transition-normal), box-shadow var(--pl-transition-normal);
    position: relative;
    z-index: 1;
}

.pl-header.is-compact .pl-header__main {
    height: var(--header-height-compact);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    border-top-color: transparent;
}

/* ========================================
   Logo
   ======================================== */
.pl-header__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 16px;
}

.pl-header__logo-img {
    height: auto;
    max-height: 50px;
    width: auto;
    object-fit: contain;
    transition: max-height var(--pl-transition-normal);
}

.pl-header.is-compact .pl-header__logo-img {
    max-height: 40px;
}

/* ========================================
   Desktop Menu
   ======================================== */
.pl-header__menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    height: 100%;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
}

.pl-header__item {
    list-style: none;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 14px;
    position: relative;
}

@media (max-width: 1366px) {
    .pl-header__item {
        padding: 0 10px;
    }
}

.pl-header__link {
    text-decoration: none;
    color: var(--pl-black);
    font-size: 15px;
    font-weight: 400;
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transition: color var(--pl-transition-normal), background-color var(--pl-transition-normal);
    position: relative;
}

@media (max-width: 1366px) {
    .pl-header__link {
        font-size: 14px;
        padding: 8px;
    }
}

.pl-header__link:hover,
.pl-header__link.is-active {
    color: var(--pl-accent);
    background: rgba(240, 148, 86, 0.05);
}

/* ========================================
   Mega Menu
   ======================================== */
.pl-header__megamenu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: auto;
    min-width: 260px;
    max-width: 360px;
    background: var(--pl-white);
    border-top: 3px solid var(--pl-accent);
    box-shadow: var(--pl-shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--pl-transition-normal),
                visibility var(--pl-transition-normal),
                transform var(--pl-transition-normal);
    z-index: var(--pl-z-megamenu);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

/* Hover bridge for smooth interaction */
.pl-header__megamenu::before {
    content: "";
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
}

.pl-header__item--mega:hover .pl-header__megamenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.pl-header__mega-inner {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    gap: 8px;
}

.pl-header__mega-link {
    display: block;
    color: var(--pl-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    padding: 8px 12px;
    border-radius: 4px;
    transition: color var(--pl-transition-fast),
                background-color var(--pl-transition-fast),
                transform var(--pl-transition-fast);
}

.pl-header__mega-link:hover,
.pl-header__mega-link.is-active {
    color: var(--pl-accent);
    background: rgba(240, 148, 86, 0.08);
    transform: translateX(5px);
}

/* ========================================
   Simple Dropdown
   ======================================== */
.pl-header__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--pl-white);
    width: 240px;
    box-shadow: var(--pl-shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity var(--pl-transition-normal),
                visibility var(--pl-transition-normal),
                transform var(--pl-transition-normal);
    list-style: none;
    padding: 15px 0;
    border-top: 3px solid var(--pl-accent);
    border-radius: 0 0 8px 8px;
    z-index: var(--pl-z-dropdown);
}

.pl-header__item--dropdown:hover .pl-header__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pl-header__dropdown li {
    margin: 0;
}

.pl-header__dropdown a {
    display: block;
    padding: 12px 25px;
    color: var(--pl-text);
    text-decoration: none;
    font-size: 14.5px;
    transition: color var(--pl-transition-fast),
                background-color var(--pl-transition-fast),
                padding-left var(--pl-transition-fast);
}

.pl-header__dropdown a:hover,
.pl-header__dropdown a.is-active {
    background: rgba(240, 148, 86, 0.08);
    color: var(--pl-accent);
    padding-left: 30px;
}

/* ========================================
   Actions
   ======================================== */
.pl-header__actions {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 15px;
    flex-shrink: 0;
}

.pl-header__cta {
    background: var(--pl-accent);
    color: var(--pl-white);
    padding: 14px 28px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(240, 148, 86, 0.2);
    transition: background-color var(--pl-transition-normal),
                transform var(--pl-transition-normal),
                box-shadow var(--pl-transition-normal);
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

@media (max-width: 1366px) {
    .pl-header__cta {
        padding: 12px 18px;
        font-size: 13px;
    }
}

.pl-header__cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(240, 148, 86, 0.3);
    background: var(--pl-accent-hover);
}

/* ========================================
   Mobile Toggle
   ======================================== */
.pl-header__toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    z-index: calc(var(--pl-z-mobile) + 1);
    margin-left: 15px;
}

.pl-header__toggle span {
    width: 100%;
    height: 2px;
    background: var(--pl-black);
    transition: var(--pl-transition-normal);
    border-radius: 2px;
    transform-origin: center;
}

.pl-header__toggle.is-active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.pl-header__toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.pl-header__toggle.is-active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

@media (max-width: 1024px) {
    .pl-header__menu,
    .pl-header__cta {
        display: none;
    }

    .pl-header__toggle {
        display: flex;
    }
}

/* ========================================
   Mobile Drawer
   ======================================== */
.pl-header__drawer {
    position: fixed;
    top: 0;
    right: -350px;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--pl-white);
    z-index: var(--pl-z-mobile);
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                opacity 0.4s ease,
                visibility 0.4s ease;
    overflow-y: auto;
    padding: 80px 30px 40px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
}

.pl-header__drawer.is-open {
    right: 0;
    opacity: 1;
    visibility: visible;
}

.pl-header__drawer-top {
    display: flex;
    justify-content: flex-end;
    margin: -48px 0 20px;
}

.pl-header__drawer-close {
    position: relative;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(10, 25, 47, 0.12);
    border-radius: 999px;
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color var(--pl-transition-fast),
                border-color var(--pl-transition-fast),
                transform var(--pl-transition-fast);
}

.pl-header__drawer-close:hover {
    background: rgba(26, 86, 168, 0.06);
    border-color: rgba(26, 86, 168, 0.2);
    transform: rotate(90deg);
}

.pl-header__drawer-close span {
    position: absolute;
    width: 14px;
    height: 2px;
    border-radius: 2px;
    background: var(--pl-black);
}

.pl-header__drawer-close span:first-child {
    transform: rotate(45deg);
}

.pl-header__drawer-close span:last-child {
    transform: rotate(-45deg);
}

@media (min-width: 1025px) {
    .pl-header__drawer {
        display: none !important;
    }
}

/* Mobile Menu */
.pl-header__mobile-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pl-header__mobile-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.pl-header__mobile-item--action {
    border: none;
    padding-top: 15px;
}

.pl-header__mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pl-header__mobile-link {
    display: block;
    padding: 16px 0;
    color: var(--pl-black);
    text-decoration: none;
    font-size: 16px;
    font-weight: 400;
    flex: 1;
}

/* Accordion Button */
.pl-header__accordion-btn {
    padding: 16px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
}

.pl-header__accordion-icon {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--pl-black);
    border-bottom: 2px solid var(--pl-black);
    transform: rotate(45deg);
    transition: transform var(--pl-transition-normal);
    display: block;
}

.pl-header__mobile-item.is-open .pl-header__accordion-icon {
    transform: rotate(-135deg);
}

/* Mobile Submenu */
.pl-header__mobile-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.pl-header__mobile-item.is-open .pl-header__mobile-submenu {
    max-height: 800px;
}

.pl-header__mobile-submenu a {
    display: block;
    padding: 12px 15px;
    color: var(--pl-text);
    text-decoration: none;
    font-size: 15px;
    transition: color var(--pl-transition-fast);
}

.pl-header__mobile-submenu a:hover,
.pl-header__mobile-submenu a.is-active {
    color: var(--pl-accent);
}

/* Mobile Action Buttons */
.pl-header__mobile-btn {
    display: flex;
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 14px;
    font-size: 14px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 12px;
    transition: all var(--pl-transition-normal);
}

.pl-header__mobile-btn--primary {
    background: var(--pl-accent);
    color: var(--pl-white);
    box-shadow: 0 8px 15px rgba(240, 148, 86, 0.2);
}

.pl-header__mobile-btn--primary:hover {
    background: var(--pl-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(240, 148, 86, 0.3);
}

.pl-header__mobile-btn--secondary {
    background: var(--pl-primary);
    color: var(--pl-white);
}

.pl-header__mobile-btn--secondary:hover {
    background: #144a8f;
    transform: translateY(-1px);
}

/* ========================================
   Mobile Overlay
   ======================================== */
.pl-header__overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: transparent;
    backdrop-filter: none;
    z-index: var(--pl-z-overlay);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.pl-header__overlay.is-active {
    opacity: 1;
    visibility: hidden;
}

@media (min-width: 1025px) {
    .pl-header__overlay {
        display: none !important;
    }
}

/* ========================================
   Focus States (Accessibility)
   ======================================== */
.pl-header__link:focus-visible,
.pl-header__top-link:focus-visible,
.pl-header__mobile-link:focus-visible,
.pl-header__cta:focus-visible,
.pl-header__catalog-btn:focus-visible,
.pl-header__toggle:focus-visible {
    outline: 2px solid var(--pl-accent);
    outline-offset: 2px;
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .pl-header,
    .pl-header *,
    .pl-header__megamenu,
    .pl-header__dropdown,
    .pl-header__top-dropdown,
    .pl-header__drawer,
    .pl-header__overlay,
    .pl-header__drawer-close {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
