/* ============================================================
   VLCHEM Site - Final Refined Fix (v18)
   Ensuring Correct Logo Scaling & Hero Layout
   ============================================================ */

:root {
    --primary:        #0f5b79;
    --primary-light:  #2a7ea1;
    --text-main:      #17354b;
    --text-muted:     #617786;
    --bg-page:        #f4f8fb;
    --border:         rgba(21, 73, 102, 0.12);
    --shadow-sm:      0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg:      0 20px 40px rgba(16, 84, 116, 0.12);
    --radius:         12px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
    background-color: var(--bg-page);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* === HEADER (Fixed Height & Logo) === */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 72px; /* 严格固定高度 */
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
    text-decoration: none;
}

.logo-icon {
    height: 40px; /* 严格限制 Logo 图标高度 */
    width: auto;
}

.nav { display: flex; align-items: center; height: 100%; margin-left: auto; margin-right: 40px; }
.nav-link {
    padding: 0 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    height: 100%;
    display: flex;
    align-items: center;
    transition: 0.3s;
}
.nav-link:hover, .nav-link.active { color: var(--primary); }

/* === HERO (Correct 2-Column Layout) === */
.hero {
    height: 420px !important; /* 改为固定高度，防止抖动 */
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.hero-inner {
    display: flex; /* 改用 Flex 确保左右分明 */
    align-items: center;
    justify-content: space-between;
    
    padding: 60px 0;
    position: relative;
    z-index: 5;
}

/* 背景图层 */
.hero::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 65%;
    height: 100%;
    background-image: url('../assets/backgrounds/premium_hero_bg.png');
    background-size: cover;
    background-position: center left;
    mask-image: linear-gradient(to right, transparent 0%, black 40%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 40%);
    z-index: 1;
}

.hero-main {
    max-width: 600px;
    position: relative;
    z-index: 10;
}

.hero-title {
    letter-spacing: 4px !important;
    line-height: 1.4 !important;
    letter-spacing: 4px; /* 增加字间距 */
    line-height: 1.4; /* 增加行高 */
    font-size: 38px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.1;
    margin-bottom: 24px;
}

.hero-desc {
    letter-spacing: 1px !important;
    line-height: 1.8 !important;
    margin-top: 24px !important;
    letter-spacing: 1px;
    line-height: 1.8;
    margin-top: 32px;
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 40px;
    max-width: 440px;
}

.hero-btns { display: flex; gap: 16px; }

/* === QUICKNAV (Panel Fix) === */
.hero-quicknav {
    width: 320px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.quicknav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 32px;
    text-decoration: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: 0.3s;
}
.quicknav-item:last-child { border-bottom: none; }
.quicknav-item:hover { background: #fff; transform: translateX(8px); }
.quicknav-icon { width: 24px; height: 24px; color: var(--primary); }
.quicknav-item span { font-size: 16px; font-weight: 700; color: var(--text-main); }

/* === OTHER SECTIONS (Density Fix) === */
.section { padding: 80px 0; }
.section-title { font-size: 28px; font-weight: 800; margin-bottom: 40px; color: var(--primary); }

/* === FOOTER (Fixed) === */
.footer { background: #fff; border-top: 1px solid var(--border); padding: 80px 0 40px; }
.footer-main { display: flex; justify-content: space-between; margin-bottom: 60px; }

.ai-chat-widget {
    --ai-chat-top: clamp(92px, 12vh, 128px);
    position: fixed;
    right: 0;
    top: var(--ai-chat-top);
    width: 52px;
    height: calc(100vh - var(--ai-chat-top) - 24px);
    z-index: 1200;
    font-family: inherit;
    pointer-events: none;
}

.ai-chat-widget.is-open {
    width: min(460px, calc(100vw - 58px));
}

.ai-chat-toggle,
.ai-chat-form button,
.ai-chat-close {
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.ai-chat-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    min-height: 126px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 16px 0 0 16px;
    background: linear-gradient(180deg, #0f6378 0%, #13829b 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 14px 34px rgba(15, 99, 120, 0.35);
    outline: 1px solid rgba(255,255,255,0.24);
    outline-offset: -4px;
    transition: box-shadow 0.2s ease, background 0.2s ease;
    pointer-events: auto;
}

.ai-chat-widget.is-open .ai-chat-toggle {
    left: -52px;
    right: auto;
}

.ai-chat-toggle:hover {
    background: linear-gradient(180deg, #11748a 0%, #19a0bd 100%);
    box-shadow: 0 18px 42px rgba(15, 99, 120, 0.44);
}

.ai-chat-toggle span {
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0;
    opacity: 0.82;
}

.ai-chat-toggle strong {
    width: 1em;
    font-size: 17px;
    line-height: 1.12;
}

.ai-chat-panel {
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid rgba(15, 99, 120, 0.16);
    border-top: 4px solid #0f6378;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    animation: ai-chat-drawer-in 0.22s ease-out;
    pointer-events: auto;
}

.ai-chat-panel[hidden] {
    display: none !important;
}

@keyframes ai-chat-drawer-in {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.ai-chat-topbar {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 48px 0 14px;
    color: #0f6378;
    background: linear-gradient(180deg, #ffffff 0%, #f2f8fa 100%);
    border-bottom: 1px solid rgba(15, 99, 120, 0.12);
    font-size: 14px;
    font-weight: 800;
}

.ai-chat-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #0f6378;
    background: rgba(15, 99, 120, 0.08);
    font-size: 19px;
    line-height: 1;
    z-index: 2;
}

.ai-chat-close:hover {
    background: rgba(15, 99, 120, 0.14);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: linear-gradient(180deg, #f6fafb 0%, #eef5f7 100%);
}

.ai-chat-message {
    max-width: 90%;
    margin-bottom: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    color: var(--text-main);
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07);
    line-height: 1.6;
    font-size: 13px;
}

.ai-chat-message p {
    margin: 0 0 10px;
}

.ai-chat-message p:last-child,
.ai-chat-message ul:last-child,
.ai-chat-message ol:last-child,
.ai-chat-table-wrap:last-child {
    margin-bottom: 0;
}

.ai-chat-message h1,
.ai-chat-message h2,
.ai-chat-message h3,
.ai-chat-message h4 {
    margin: 0 0 8px;
    color: #0f3f4d;
    font-size: 15px;
    line-height: 1.35;
}

.ai-chat-message ul,
.ai-chat-message ol {
    margin: 0 0 10px 18px;
    padding: 0;
}

.ai-chat-message li {
    margin: 3px 0;
}

.ai-chat-message code {
    padding: 1px 4px;
    border-radius: 4px;
    background: #eef3f5;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.92em;
}

.ai-chat-message hr {
    height: 1px;
    margin: 10px 0;
    border: 0;
    background: rgba(15, 99, 120, 0.16);
}

.ai-chat-recommending {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #0f6378;
    background: rgba(15, 99, 120, 0.08);
    font-size: 12px;
    font-weight: 700;
}

.ai-chat-thinking {
    display: inline-flex;
    align-items: center;
    margin: 0;
    color: #0f6378;
    font-weight: 700;
}

.ai-chat-thinking::after {
    content: '';
    width: 1.2em;
    margin-left: 2px;
    overflow: hidden;
    animation: ai-chat-thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes ai-chat-thinking-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75%, 100% { content: '...'; }
}

.ai-chat-message.user {
    margin-left: auto;
    color: #fff;
    background: #0f6378;
    box-shadow: 0 8px 18px rgba(15, 99, 120, 0.18);
}

.ai-chat-table-wrap {
    max-width: 100%;
    margin: 0 0 10px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.ai-chat-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 280px;
    font-size: 13px;
}

.ai-chat-table-wrap th,
.ai-chat-table-wrap td {
    padding: 8px 9px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.ai-chat-table-wrap th {
    background: #eef5f7;
    color: #0f3f4d;
    font-weight: 700;
}

.ai-chat-table-wrap tr:last-child td {
    border-bottom: none;
}

.ai-chat-product-cards {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.ai-chat-product-cards h4 {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.ai-chat-product-card {
    display: grid;
    min-width: 0;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-main);
    text-decoration: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-chat-product-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 99, 120, 0.42);
    box-shadow: 0 10px 22px rgba(15, 99, 120, 0.14);
}

.ai-chat-product-card span,
.ai-chat-product-card em {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    color: var(--text-muted);
    font-style: normal;
}

.ai-chat-product-card-cta {
    margin-top: 2px;
    color: #0f6378;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.ai-chat-product-card:hover .ai-chat-product-card-cta {
    color: #13829b;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ai-chat-form {
    display: grid;
    grid-template-columns: 1fr 58px;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.ai-chat-form textarea {
    width: 100%;
    min-height: 42px;
    max-height: 78px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    line-height: 1.5;
    font-size: 13px;
}

.ai-chat-form button {
    border-radius: 8px;
    background: #0f6378;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.ai-chat-form button:disabled {
    cursor: wait;
    opacity: 0.55;
}

@media (max-width: 640px) {
    .ai-chat-widget {
        --ai-chat-top: clamp(82px, 10vh, 112px);
        right: 0;
        top: var(--ai-chat-top);
        width: 48px;
        height: calc(100vh - var(--ai-chat-top) - 16px);
    }

    .ai-chat-widget.is-open {
        width: calc(100vw - 56px);
    }

    .ai-chat-toggle {
        width: 48px;
        min-height: 112px;
        right: 0;
    }

    .ai-chat-widget.is-open .ai-chat-toggle {
        left: -48px;
        right: auto;
    }

    .ai-chat-panel {
        width: 100%;
        height: 100%;
    }

    .ai-chat-product-cards {
        grid-template-columns: 1fr;
    }
}
