/* ==========================================
   Layout Components
   普慧康泰 - 布局组件
   ========================================== */

/* 全局 box-sizing 设置 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Container System */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    box-sizing: border-box;
}

.container-fluid {
    width: 100%;
    padding: 0 2rem;
}

/* Grid System - 12 Columns */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -1rem;
}

.col {
    flex: 1;
    padding: 0 1rem;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Offset Columns */
.offset-1 { margin-left: 8.333333%; }
.offset-2 { margin-left: 16.666667%; }
.offset-3 { margin-left: 25%; }
.offset-4 { margin-left: 33.333333%; }
.offset-5 { margin-left: 41.666667%; }
.offset-6 { margin-left: 50%; }

/* Flexbox Utilities */
.flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.align-stretch { align-items: stretch; }

/* Grid Layout */
.grid {
    display: grid;
    gap: 2rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Section Spacing - 华为风格：更多留白 */
.section {
    padding: var(--spacing-24) 0;
}

.section-sm { padding: var(--spacing-16) 0; }
.section-lg { padding: var(--spacing-32) 0; }

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Header Layout - 华为风格：白色背景，简洁设计 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    z-index: var(--z-fixed);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: background 0.3s ease, box-shadow 0.3s ease;
    transform: none;
    will-change: auto;
    min-height: 4.5rem;
    max-height: 5rem;
    box-sizing: border-box;
}

.header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    height: 4.5rem;
    min-height: 4.5rem;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 0 2rem;
}

/* Logo Styling */
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
    margin-left: 0;
}

.logo-img {
    width: 3.125rem;
    height: 3.125rem;
    max-width: 3.125rem;
    max-height: 3.125rem;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-gray-900);
    line-height: 1.2;
    white-space: nowrap;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--color-gray-600);
    line-height: 1.2;
    white-space: nowrap;
}

/* Back Navigation */
.back-nav {
    padding: 1rem 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--color-gray-600);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--color-primary);
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Search Bar */
.header-search {
    position: relative;
    width: 12.5rem;
    max-width: 15rem;
    flex-shrink: 0;
    box-sizing: border-box;
}

.header-search-input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: 20px;
    background: var(--color-gray-50);
    font-size: 0.875rem;
    color: var(--color-gray-900);
    transition: all 0.3s ease;
}

.header-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-white);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.header-search-input::placeholder {
    color: var(--color-gray-500);
}

.header-search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-gray-500);
    pointer-events: none;
}

.header-search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-search-btn:hover {
    color: var(--color-primary);
}

/* Navigation Layout */
.nav {
    display: flex;
    align-items: center;
}

/* Mobile Navigation Toggle Button */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.nav-toggle span {
    width: 100%;
    height: 2px;
    background: var(--color-gray-900);
    border-radius: 2px;
    transition: all var(--transition-base);
    transform-origin: center;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Search Bar */
.header-search {
    position: relative;
    width: 240px;
}

.header-search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-gray-700);
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--border-radius-full);
    transition: all 0.2s ease;
}

.header-search-input::placeholder {
    color: var(--color-gray-400);
}

.header-search-input:focus {
    outline: none;
    background: var(--color-white);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.header-search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-gray-400);
    pointer-events: none;
}

.nav-list {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Navigation Menu */
.nav-menu {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    overflow: visible;
    box-sizing: border-box;
}

.nav-list {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0;
    color: var(--color-gray-700);
    text-decoration: none;
    font-size: 1.125rem;
    font-weight: 500;
    transition: color 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-primary);
}

/* Dropdown Menu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.nav-dropdown-icon {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .nav-dropdown-icon {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    min-width: 37.5rem;
    max-width: 56.25rem;
    width: max-content;
    padding: 1.5rem 2rem;
    background: var(--color-white);
    border-radius: var(--border-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    list-style: none;
    margin: 0;
    z-index: 10000;
    box-sizing: border-box;
    /* 华为风格横向布局 */
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    column-gap: 2.5rem;
    row-gap: 0;
}

/* 2列布局（用于个人及家庭产品） */
.nav-dropdown-menu.grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem;
    column-gap: 2.5rem;
    row-gap: 0;
}

/* 添加伪元素填充间隙，确保hover状态连续 */
.nav-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown.active .nav-dropdown-icon {
    transform: rotate(180deg);
}

.nav-dropdown-section {
    padding: 0;
}

.nav-dropdown-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-gray-900);
    margin-bottom: 0;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
    display: block;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-gray-200);
    margin-bottom: 0.75rem;
}

.nav-dropdown-section-item {
    display: block;
    padding: 0.5rem 0;
    color: var(--color-gray-700);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.5;
    transition: all 0.2s ease;
}

.nav-dropdown-section-item:hover {
    background: transparent;
    color: var(--color-primary);
    transform: translateX(2px);
}

.nav-dropdown-divider {
    display: none;
}

/* Main Content */
.main {
    padding-top: var(--header-height);
}

/* Footer Layout */
.footer {
    background: var(--color-gray-50);
    color: var(--color-gray-700);
    padding: var(--spacing-16) 0 var(--spacing-8);
}

.footer-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-8);
}

/* Single column dropdown adjustment */
.nav-dropdown-menu:has(:only-child) {
    min-width: 240px;
    max-width: 320px;
    grid-template-columns: 1fr;
}

/* Two column dropdown adjustment */
.nav-dropdown-menu:has(.nav-dropdown-section:nth-child(2):last-child) {
    grid-template-columns: repeat(2, 1fr);
}

/* ==========================================
   Mobile Navigation Dropdown Content
   ========================================== */

/* 移动端下拉内容容器（默认隐藏） */
.nav-dropdown-content {
    display: none;
}

/* 移动端分区标题 */
.nav-mobile-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem 0.5rem;
    margin: 0;
}

/* 移动端下拉链接 */
.nav-mobile-item {
    display: block;
    padding: 0.875rem 1rem;
    color: var(--color-gray-700);
    text-decoration: none;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--color-gray-100);
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-mobile-item:last-child {
    border-bottom: none;
}

.nav-mobile-item:active,
.nav-mobile-item:hover {
    background: var(--color-gray-100);
    color: var(--color-primary);
}

/* ==========================================
   CRITICAL FIX: Ensure Header is Fixed at Top
   ========================================== */

/* 确保 body 和 html 没有 transform，这会影响 fixed 定位 */
html, body {
    transform: none !important;
    perspective: none !important;
    filter: none !important;
}

/* Ensure header-height variable is correct */
:root {
    --header-height: 72px;
}

/* Force header to be fixed at viewport top */
body > .header,
header.header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: 100vw !important;
    z-index: 99999 !important;
    transform: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    will-change: auto !important;
    box-sizing: border-box !important;
    /* 移除所有可能影响 fixed 定位的属性 */
    transition: background 0.3s ease, box-shadow 0.3s ease !important;
}

/* 确保轮播图在正确位置 */
.hero-carousel {
    position: relative !important;
    top: auto !important;
}

/* Ensure main content has correct padding - will be overridden by JS */
.main {
    padding-top: calc(var(--header-height) + 5px);
}
