/* ═══════════════════════════════════════════════════════
   layout.css — 前台全站共用：导航 + 页脚 + 侧边栏 + 回顶部
   被 includes/header.php 全局加载，所有前台页面共用
   ═══════════════════════════════════════════════════════ */

/* ── 全局基础重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'PingFang SC', -apple-system, 'Microsoft YaHei', sans-serif;
    background: var(--bg, #F7F9FC);
    color: var(--ink, #0F1B2D);
    overflow-x: hidden;
}

/* ══════════════════════════════ NAV ══════════════════════════════ */
.nav {
    position: sticky; top: 0; z-index: 1000;
    width: 100%; height: 80px;
    background: var(--bg, #F7F9FC);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 clamp(60px, 12.5vw, 240px);
    border-bottom: 1px solid var(--line, #E6ECF3);
}
.logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none;
}
.logo-mark {
    width: clamp(40px, 2.917vw, 56px); height: clamp(40px, 2.917vw, 56px);
    border-radius: 8px; flex-shrink: 0;
    display: block; object-fit: contain;
}
.logo-text {
    font-size: clamp(18px, 1.458vw, 28px); font-weight: 600;
    color: var(--ink, #0F1B2D);
}
.nav-menu {
    display: flex; align-items: center;
    gap: clamp(20px, 1.875vw, 36px);
}
.nav-menu a {
    font-size: clamp(15px, 0.938vw, 18px); font-weight: 400;
    color: var(--ink-2, #4A5A72); text-decoration: none;
    font-family: 'PingFang SC', 'Inter', sans-serif;
    transition: color .2s;
}
.nav-menu a.active { color: var(--brand, #1A5490); font-weight: 600; }
.nav-menu a:hover  { color: var(--brand, #1A5490); }
.nav-right { display: flex; align-items: center; gap: 16px; }
.btn-switch {
    background: var(--warn, #FF7A45); color: #fff;
    font-size: clamp(15px, 0.938vw, 18px); font-weight: 600;
    height: 42px; width: clamp(96px, 6.458vw, 124px);
    border-radius: var(--radius-sm, 8px);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-family: 'PingFang SC', 'Inter', sans-serif;
    user-select: none; white-space: nowrap;
    text-decoration: none;
}
.hamburger {
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    gap: 5px; width: 36px; height: 36px;
    background: none; border: none; cursor: pointer; padding: 4px;
}
.hamburger span {
    display: block; width: 22px; height: 2px;
    background: var(--ink, #0F1B2D); border-radius: 2px;
    transition: transform .8s cubic-bezier(.4, 0, .2, 1),
                opacity   .8s cubic-bezier(.4, 0, .2, 1);
}
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── 移动端遮罩 ── */
.mobile-nav-overlay {
    display: none; position: fixed;
    top: 60px; left: 0; right: 0; bottom: 0;
    background: rgba(15, 27, 45, .5); z-index: 1050;
    transition: opacity .25s;
}
.mobile-nav-overlay.show { display: block; }

/* ── 移动端下拉菜单 ── */
.mobile-nav {
    position: fixed; top: 60px; left: 0; right: 0; width: 100%;
    max-height: 0; overflow: hidden;
    background: #F7F9FC; z-index: 1080;
    display: flex; flex-direction: column;
    transition: max-height .8s cubic-bezier(.4, 0, .2, 1), box-shadow .3s;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    border-top: 1px solid transparent;
}
.mobile-nav.open {
    max-height: calc(100vh - 60px);
    box-shadow: 0 6px 32px rgba(0, 0, 0, .12);
    border-top-color: var(--line, #E6ECF3);
}
.mobile-nav-header { display: none; }
.mobile-nav ul {
    list-style: none; padding: 16px 20px;
    display: flex; flex-direction: column; gap: 6px;
}
.mobile-nav ul li a {
    display: flex; align-items: center; justify-content: space-between;
    height: 50px; border-radius: 12px; padding: 0 16px;
    font-size: 17px; font-weight: 600; text-decoration: none;
    transition: opacity .15s;
}
.mobile-nav ul li a:hover { opacity: .85; }
.mobile-nav ul li a::after { content: '›'; font-size: 20px; font-weight: 400; }
.mobile-nav ul li:nth-child(1) a { background: #E8F5EC; color: #1A6B3C; }
.mobile-nav ul li:nth-child(2) a { background: #E6F1FB; color: var(--brand, #1A5490); }
.mobile-nav ul li:nth-child(3) a { background: #EDE9FE; color: #6D4AE8; }
.mobile-nav ul li:nth-child(4) a { background: #E1F5F0; color: #0A8F6F; }
.mobile-nav ul li:nth-child(5) a { background: #FFF0E6; color: #D65C2A; }

/* ══════════════════════════════ FOOTER ══════════════════════════════ */
.footer {
    width: 100%; background: var(--footer-bg, #0B2D5C);
    padding: 42px clamp(60px, 12.5vw, 240px) 28px;
    display: flex; flex-direction: column; gap: 12px;
}
.footer-top  { display: flex; gap: clamp(30px, 3.125vw, 60px); width: 100%; }
.footer-brand { display: flex; flex-direction: column; gap: 8px; min-width: 280px; }
.footer-brand-logo { display: flex; align-items: center; gap: 10px; height: 40px; }
.footer-logo-mark {
    width: 40px; height: 40px;
    background: rgba(42, 100, 168, .5); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; font-weight: 700;
}
.footer-brand-name { font-size: clamp(17px, 1.094vw, 21px); font-weight: 600; color: #fff; }
.footer-brand-desc { font-size: clamp(12px, .729vw, 14px); color: var(--footer-muted, #8A98AE); line-height: 1.5; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col-title { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.footer-col-link  { font-size: 13px; color: var(--footer-muted, #8A98AE); cursor: pointer; text-decoration: none; }
.footer-col-link:hover { color: #fff; }
.footer-wechat-row {
    background: var(--footer-divider, #1A3A6C); border-radius: 8px;
    padding: 10px 14px; display: flex; align-items: center; gap: 8px;
}
.wechat-icon {
    width: 20px; height: 20px; background: #07C160; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: #fff; font-weight: 700; flex-shrink: 0;
}
.footer-follow-text  { display: flex; flex-direction: column; gap: 1px; }
.footer-follow-label { font-size: 13px; color: var(--footer-muted, #8A98AE); }
.footer-follow-sub   { font-size: 11px; color: #5F7390; }
.footer-divider { width: 100%; height: 1px; background: var(--footer-divider, #1A3A6C); }
.footer-bottom {
    display: flex; align-items: center; justify-content: space-between; padding-top: 4px;
}
.footer-legal { font-size: 11px; color: var(--footer-legal, #4A5A72); }
.footer-legal a { color: var(--footer-legal, #4A5A72); text-decoration: none; }
.footer-legal a:hover { color: #fff; }

/* ══════════════════════════════ FIXED SIDEBAR ══════════════════════════════ */
.fixed-sidebar {
    position: fixed; right: 0; top: 50%;
    transform: translateY(-50%); z-index: 500;
}
.sidebar-inner {
    width: 64px; background: var(--surface, #fff);
    border-radius: 12px 0 0 12px;
    box-shadow: -3px 0 20px rgba(0, 0, 0, .13), 0 0 0 1px rgba(0, 0, 0, .06);
    overflow: hidden;
}
.sb-btn {
    width: 64px; height: 68px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 5px;
    cursor: pointer; transition: background .15s; position: relative;
    background: var(--surface, #fff);
}
.sb-btn:first-child { border-radius: 12px 0 0 0; }
.sb-btn:last-child  { border-radius: 0 0 0 12px; }
.sb-btn:hover { background: #EEF4FB; }
.sb-icon-chip {
    width: 34px; height: 34px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1; transition: background .15s;
}
.sb-btn-buy  .sb-icon-chip { background: #FFF0E8; color: #D65C2A; }
.sb-btn-svc  .sb-icon-chip { background: #E6F1FB; color: #1A5490; }
.sb-btn-comm .sb-icon-chip { background: #E6FAF8; color: #007F75; }
.sb-text {
    font-size: 10px; font-weight: 700; line-height: 1.25;
    text-align: center; color: var(--ink-2, #4A5A72); transition: color .15s;
}
.sb-div { width: 100%; height: 1px; background: var(--line, #E6ECF3); }
.sb-btn.sb-active { background: var(--brand, #1A5490) !important; }
.sb-btn.sb-active::before {
    content: ''; position: absolute; left: 0; top: 20%; height: 60%;
    width: 3px; border-radius: 0 2px 2px 0;
    background: rgba(255, 255, 255, .8);
}
.sb-btn.sb-active .sb-icon-chip { background: rgba(255, 255, 255, .18); color: #fff; }
.sb-btn.sb-active .sb-text      { color: #fff; }

.sb-popup {
    position: fixed; right: 68px; top: 50%; transform: translateY(-50%);
    width: 200px; background: #fff; border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .14); padding: 14px;
    display: none; flex-direction: column; gap: 10px; z-index: 501;
    max-height: calc(100vh - 80px); overflow-y: auto;
}
.sb-popup.open { display: flex; }
.sb-popup-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: var(--brand, #1A5490);
    padding-bottom: 6px; border-bottom: 1px solid #EEF2F7; margin-bottom: 2px;
}
.sb-popup-title span:first-child { font-size: 15px; line-height: 1; }
.sb-popup-section { display: flex; flex-direction: column; gap: 8px; }
.sb-popup-row     { display: flex; align-items: center; gap: 8px; }
.sb-popup-icon    { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-popup-label-text { font-size: 13px; font-weight: 600; color: #1A1A2E; }
.sb-popup-qr-wrap {
    width: 100%; aspect-ratio: 1; border-radius: 10px;
    background: #F5F7FA; overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.sb-popup-qr-wrap img { width: 100%; height: 100%; object-fit: contain; display: none; position: absolute; inset: 0; }
.sb-popup-qr-wrap img.loaded { display: block; }
.sb-popup-qr-label { font-size: 11px; color: #9CA3AF; text-align: center; pointer-events: none; }
.sb-popup-qr-wrap img.loaded + .sb-popup-qr-label { display: none; }
.sb-popup-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 32px; border-radius: 8px;
    font-size: 12px; font-weight: 600; color: #fff;
    border: none; cursor: pointer; text-decoration: none; flex-shrink: 0;
}
.sb-popup-divider { height: 1px; background: #E6ECF3; margin: 4px -4px; }
.sb-popup-btn-row { display: flex; gap: 8px; }
.sb-popup-btn-row .sb-popup-btn { flex: 1; }
.sb-popup-copy-btn {
    width: 58px; height: 32px; border-radius: 8px;
    background: #EEF2F7; border: none; cursor: pointer;
    font-size: 11px; font-weight: 600; color: #4A5A72; flex-shrink: 0;
    transition: background .2s, color .2s;
}
.sb-popup-copy-btn span { color: #4A5A72; }
.sb-popup-copy-btn.copied { background: #07C160; color: #fff; }
.sb-popup-copy-btn.copied span { color: #fff; }

/* 公众号弹窗 */
.mp-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: none; align-items: center; justify-content: center;
    z-index: 99999; padding: 20px;
}
.mp-modal-overlay.open { display: flex; }
.mp-modal-card {
    background: #fff; border-radius: 20px; width: min(360px,100%);
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.mp-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 20px 20px 12px;
}
.mp-modal-title  { font-size: 17px; font-weight: 700; color: var(--ink, #0F1B2D); }
.mp-modal-sub    { font-size: 12px; color: var(--ink-3, #8A98AE); margin-top: 2px; }
.mp-modal-close  {
    width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
    background: #F0F2F5; color: #6B7280; font-size: 16px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mp-modal-body   { padding: 0 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mp-modal-qr     { width: 160px; height: 160px; border-radius: 12px; overflow: hidden; background: #F5F7FA; }
.mp-modal-qr img { width: 100%; height: 100%; object-fit: contain; }
.mp-modal-hint   { font-size: 12px; color: #8A98AE; text-align: center; }
.mp-modal-actions { display: flex; flex-direction: column; gap: 10px; padding: 0 20px 20px; }
.mp-modal-btn-dl {
    width: 100%; height: 42px; border-radius: 10px; border: none; cursor: pointer;
    background: #F4F6FA; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mp-modal-btn-dl span { font-size: 13px; font-weight: 600; color: #4A5568; }
.mp-modal-btn-follow {
    width: 100%; height: 42px; border-radius: 10px; border: none; cursor: pointer;
    background: #07C160; display: flex; align-items: center; justify-content: center;
    text-decoration: none; gap: 6px;
}
.mp-modal-btn-follow span { font-size: 13px; font-weight: 700; color: #fff; }
.mp-modal-btn-follow.disabled { background: #A8D5B8; cursor: not-allowed; opacity: .6; }

/* ══════════════════════════════ BACK TO TOP ══════════════════════════════ */
.back-to-top {
    position: fixed; right: 8px; bottom: 80px;
    width: 48px; height: 48px;
    background: var(--brand, #1A5490); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 500;
    font-size: 20px; color: #fff; font-weight: 700;
    opacity: 0; transition: opacity .3s, background .2s;
    user-select: none; border: none;
}
.back-to-top.visible { opacity: 1; }
.back-to-top:hover   { background: var(--brand-light, #2E7BC4); }

/* ══════════════════════════════ 移动端响应式 768px ══════════════════════════════ */
@media (max-width: 768px) {
    /* NAV */
    .nav        { height: 60px; padding: 0 16px; }
    .nav-menu   { display: none; }
    .btn-switch { display: none; }
    .hamburger  { display: flex; }

    /* FOOTER */
    .footer { padding: 28px 20px 20px; gap: 16px; }
    .footer-top {
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-rows: auto auto;
        gap: 16px 12px; align-items: start;
    }
    .footer-brand                           { grid-area: 1 / 1 / 2 / 2; min-width: 0; }
    .footer-top > .footer-col:nth-child(2)  { grid-area: 1 / 2 / 2 / 3; }
    .footer-top > .footer-col:nth-child(3)  { grid-area: 1 / 3 / 2 / 4; }
    .footer-top > .footer-col:nth-child(4)  { grid-area: 2 / 1 / 3 / 2; display: flex; }
    .footer-top > .footer-col:nth-child(5)  { grid-area: 2 / 2 / 3 / 4; display: flex; }
    .footer-brand-logo  { height: 32px; gap: 8px; }
    .footer-logo-mark   { width: 30px; height: 30px; font-size: 14px; border-radius: 6px; }
    .footer-brand-name  { font-size: 14px; }
    .footer-brand-desc  { font-size: 11px; line-height: 1.6; }
    .footer-col-title   { font-size: 12px; }
    .footer-col-link    { font-size: 11px; }
    .footer-wechat-row  { padding: 8px 10px; }
    .footer-follow-label { font-size: 11px; }
    .footer-follow-sub   { font-size: 10px; }
    .footer-bottom { flex-direction: column; gap: 4px; align-items: center; text-align: center; }
    .footer-legal  { font-size: 10px; text-align: center; }

    /* SIDEBAR */
    .fixed-sidebar { display: block; top: 65%; }
    .sidebar-inner { width: 48px; border-radius: 10px 0 0 10px; }
    .sb-btn        { width: 48px; height: 52px; }
    .sb-btn:first-child { border-radius: 10px 0 0 0; }
    .sb-btn:last-child  { border-radius: 0 0 0 10px; }
    .sb-text       { font-size: 8px; }
    .sb-icon-chip  { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; }
    .sb-popup      { width: 180px; right: 48px; }
    .back-to-top   { right: 16px; bottom: 20px; width: 40px; height: 40px; font-size: 16px; }
}
