/* ============================================================
   粤车南下服务门户 - 公共样式
   移动优先 + PC 适配，4 个断点
   政务蓝主调，避免 AI 模板化堆叠
   ============================================================ */

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

:root {
    color-scheme: light;

    /* 主色调 */
    --c-primary: #1890ff;
    --c-primary-dark: #096dd9;
    --c-primary-light: #e6f7ff;

    /* 功能色 */
    --c-success: #52c41a;
    --c-warn: #faad14;
    --c-danger: #ff4d4f;
    --c-info: #909399;

    /* 中性色 */
    --c-text: #303133;
    --c-text-2: #606266;
    --c-text-3: #909399;
    --c-border: #dcdfe6;
    --c-bg: #f8fafc;        /* 页面底色：浅灰白（对齐参考站 --bg #F8FAFC） */
    --c-bg-2: #fafafa;
    --c-surface: #fff;      /* 卡片/输入框等表面色 */
    --c-white: #fff;        /* 纯白文字用，暗色下不变 */

    /* 尺寸 */
    --radius: 6px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.1);

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* 字体 */
    --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "SF Mono", Menlo, Consolas, monospace;
}

html, body {
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* PC 端底色（参考站 home 实现：>=1024px 页面底色略深一档，白色内容更聚焦；暗色仍走 --c-bg） */
@media (min-width: 1024px) {
    html:not([data-theme="dark"]) body { background-color: #f1f5f9; }
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); }

img { max-width: 100%; height: auto; display: block; }

ul, ol { list-style: none; }

input, button, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button { cursor: pointer; border: none; background: none; }

/* ---------- 布局容器 ---------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* PC 站点最大宽度限制 */
@media (min-width: 1200px) {
    .container { padding: 0 var(--space-lg); }
}

/* ---------- 应用主容器（白色内容列，参考 home 的 .app-container 实现） ----------
   移动端全宽白底；≥1024px 限宽 1200 居中，两侧露出 body 灰色底色 */
.app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
}
@media (min-width: 1024px) {
    .app-container {
        max-width: 1200px;
        margin: 0 auto;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
    }
}
/* 所有直接子元素填满容器宽度（避免 margin:auto 的 flex item 退化为内容自适应；
   各页面 max-width 内容区仍可在容器内居中） */
.app-container > * { width: 100%; }

/* ---------- 顶部导航 ---------- */
/* sticky 必须放在外层 #navbar-container 上：sticky 元素只能在父元素范围内吸附，
   导航的父容器高度与导航同高，若把 sticky 放在 .navbar 上，滚过容器后导航会被带走 */
#navbar-container {
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow);
}

/* 导航现为 .app-container 子元素，宽度自动随容器（桌面限宽 1200），不再单独限宽 */

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: 16px;
    color: var(--c-text);
}

/* 站名 + 站点地址 上下两行（地址与站名左对齐） */
.navbar-brand .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.navbar-brand .brand-url {
    font-size: 11px;
    font-weight: 400;
    color: var(--c-text-3);
    white-space: nowrap;
}

.navbar-brand .logo {
    display: inline-flex;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #1890ff, #36cfc9);
    border-radius: 6px;
    color: #fff;
    font-size: 16px;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.navbar-nav {
    display: none;
    gap: var(--space-lg);
}

.navbar-nav a {
    color: var(--c-text-2);
    padding: var(--space-sm) 0;
    position: relative;
}

.navbar-nav a.active {
    color: var(--c-primary);
    font-weight: 500;
}

.navbar-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--c-primary);
    border-radius: 1px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ---------- 移动端导航「车牌预览」入口（位于暗色模式按钮之前） ---------- */
.navbar-plate-mobile {
    display: none;
}

/* ---------- 移动端导航「海关查询」入口（位于车牌预览之前，浅红色名称） ---------- */
.navbar-customs-mobile {
    display: none;
}

@media (max-width: 767px) {
    .navbar-customs-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 30px;
        padding: 0 10px;
        border-radius: 999px;
        background: rgba(255, 120, 117, 0.14);
        color: #ff8a87;
        font-size: 12px;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
    }
    .navbar-customs-mobile:hover {
        color: #ff7875;
    }
}

@media (max-width: 767px) {
    .navbar-plate-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 30px;
        padding: 0 10px;
        border-radius: 999px;
        background: var(--c-primary-light);
        color: var(--c-primary);
        font-size: 12px;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
    }
    .navbar-plate-mobile:hover {
        color: var(--c-primary-dark);
    }
}

/* ---------- 导航栏用户头像（移动端仅显示圆形头像，桌面端保持昵称按钮） ---------- */
.nav-avatar {
    display: none;
}

@media (max-width: 767px) {
    /* 「我的」按钮收缩为圆形头像，点击进入个人中心 */
    #navUser {
        width: 34px;
        height: 34px;
        padding: 0;
        border-radius: 50%;
        overflow: hidden;
    }
    #navUser .nav-user-name {
        display: none;
    }
    #navUser .nav-avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.22);
        color: #fff;
        font-size: 15px;
        font-weight: 600;
        line-height: 1;
    }
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
    user-select: none;
}

.btn-primary {
    background: var(--c-primary);
    color: var(--c-white);
}
.btn-primary:hover { background: var(--c-primary-dark); }

/* 会员红色名称特权：等级勾选「红色名称」后导航昵称按钮红名样式 */
.btn-primary.vip-red-name {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.btn-primary.vip-red-name:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-outline {
    background: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text-2);
}
.btn-outline:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.btn-danger { background: var(--c-danger); color: var(--c-white); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- 表单 ---------- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--c-text-2);
    font-size: 13px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
}

.form-input::placeholder { color: var(--c-text-3); }

/* 输入框组（带按钮） */
.input-group {
    display: flex;
    gap: var(--space-sm);
}
.input-group .form-input { flex: 1; }

/* 验证码图片按钮 */
.captcha-img {
    height: 40px;
    width: 120px;
    cursor: pointer;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-bg);
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ---------- 文字辅助 ---------- */
.text-sm { font-size: 12px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; font-weight: 600; }
.text-3xl { font-size: 30px; font-weight: 700; }

.text-primary { color: var(--c-primary); }
.text-success { color: var(--c-success); }
.text-warn { color: var(--c-warn); }
.text-danger { color: var(--c-danger); }
.text-muted { color: var(--c-text-3); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ---------- 响应式断点切换 ---------- */
@media (min-width: 768px) {
    .navbar-nav { display: flex; }
    .navbar-toggle { display: none; }
}

/* 移动端菜单按钮 */
.navbar-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--c-text);
}

/* ---------- 底部 ---------- */
.footer {
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    padding: 12px 0;
    text-align: center;
    color: var(--c-text);
    font-size: 13px;
    margin-top: 8px;
}

/* 页脚现为 .app-container 子元素，宽度自动随容器，不再单独限宽 */

.footer p { margin: var(--space-xs) 0; }
.footer a { color: var(--c-primary); margin: 0 var(--space-xs); }

/* 移动端：底部 fixed Tab 占位由 footer padding-bottom 承担
   - .mobile-tabbar 高 56px + env(safe-area-inset-bottom)
   - .mobile-tabbar-spacer 高度设为 0，避免按钮与页脚之间出现大块空白
   - footer padding-bottom 预留 56px + safe-area，确保页脚内容不被 tabbar 遮挡 */
@media (max-width: 768px) {
    .footer {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}

/* ---------- Toast 提示 ---------- */
.toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--c-text);
    color: var(--c-white);
    padding: 10px 20px;
    border-radius: var(--radius);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   通用确认弹窗（App.confirm）
   替代原生 confirm，移动端 / PC 端自适应，自动适配暗色主题
   ============================================================ */
.app-confirm-mask {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.2s ease;
}
.app-confirm {
    width: 100%;
    max-width: 340px;
    background: var(--c-surface);
    border-radius: 18px;
    padding: 28px 24px 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: transform 0.2s ease, opacity 0.2s ease;
    animation: app-confirm-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes app-confirm-in {
    from { opacity: 0; transform: translateY(18px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.app-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.app-confirm-icon svg { width: 28px; height: 28px; }
.app-confirm-icon.info   { background: linear-gradient(135deg, #409eff, #36cfc9); }
.app-confirm-icon.warn   { background: linear-gradient(135deg, #faad14, #f59e0b); }
.app-confirm-icon.danger { background: linear-gradient(135deg, #ff7875, #ff4d4f); }

.app-confirm-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--c-text);
    margin-bottom: 8px;
}
.app-confirm-content {
    font-size: 14px;
    color: var(--c-text-2);
    line-height: 1.6;
    margin-bottom: 20px;
    word-break: break-word;
}
.app-confirm-actions {
    display: flex;
    gap: 12px;
}
.app-confirm-btn {
    flex: 1;
    padding: 11px 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.app-confirm-btn:active { transform: scale(0.97); }
.app-confirm-btn.cancel {
    background: var(--c-bg-2);
    color: var(--c-text-2);
}
.app-confirm-btn.confirm {
    background: linear-gradient(135deg, var(--c-primary), #36cfc9);
    color: #fff;
}
.app-confirm-btn.confirm.danger {
    background: linear-gradient(135deg, #ff7875, #ff4d4f);
}
.app-confirm-btn:hover { opacity: 0.9; }
.app-confirm-btn:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}
/* 移动端小屏适配 */
@media (max-width: 360px) {
    .app-confirm { padding: 24px 18px 18px; }
    .app-confirm-icon { width: 52px; height: 52px; }
    .app-confirm-icon svg { width: 26px; height: 26px; }
}

/* ---------- 加载中 ---------- */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- 移动端底部 Tab ---------- */
.mobile-tabbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-tabbar-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
}

.mobile-tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--c-text-3);
    font-size: 11px;
    text-decoration: none;
    padding: 4px;
    flex: 1;
}

.mobile-tabbar-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
}

.mobile-tabbar-item.active {
    color: var(--c-primary);
}

.mobile-tabbar-spacer {
    display: none;
    height: 0;
}

/* 移动端显示底部 Tab */
@media (max-width: 768px) {
    .mobile-tabbar { display: block; }
    .mobile-tabbar-spacer { display: block; }
}

/* ============================================================
   电脑端内容宽度（容器化后）
   - 骨架元素（navbar/footer/section/banner/countdown）自动填满 .app-container
   - 各页面内容区使用 max-width 在白色容器内居中，窄屏可自适应收缩
   ============================================================ */
@media (min-width: 768px) {
    .news-page,
    .act-wrap        { max-width: 1000px; margin-left: auto; margin-right: auto; }
    .ins-wrap,
    .ld-detail-wrap  { max-width: 1024px; margin-left: auto; margin-right: auto; }
    .ab-wrap         { max-width: 896px;  margin-left: auto; margin-right: auto; }
    .legal-wrap,
    .fq-wrap         { max-width: 860px;  margin-left: auto; margin-right: auto; }
    .news-detail-page,
    .msg-wrap        { max-width: 800px;  margin-left: auto; margin-right: auto; }
    .user-center     { max-width: 720px;  margin-left: auto; margin-right: auto; }
}

/* ============================================================
   主题切换按钮
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--c-text-2);
    transition: color 0.2s, background 0.2s;
}
.theme-toggle:hover {
    color: var(--c-primary);
    background: var(--c-primary-light);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 无导航页面（登录/404）右上角浮动切换按钮 */
.theme-toggle-float {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999;
    width: 40px;
    height: 40px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow);
}

/* ============================================================
   暗黑模式
   ============================================================ */
html[data-theme="dark"] {
    color-scheme: dark;

    /* 主色调（暗色下 hover 提亮） */
    --c-primary: #1668dc;
    --c-primary-dark: #47a3f3;
    --c-primary-light: rgba(22, 104, 220, 0.22);

    /* 功能色 */
    --c-success: #6abe39;
    --c-warn: #e8b339;
    --c-danger: #e05d5f;
    --c-info: #8c8f99;

    /* 中性色 */
    --c-text: rgba(255, 255, 255, 0.88);
    --c-text-2: rgba(255, 255, 255, 0.66);
    --c-text-3: rgba(255, 255, 255, 0.42);
    --c-border: #33383e;
    --c-bg: #0e1116;
    --c-bg-2: #16191e;
    --c-surface: #1a1f26;

    /* 阴影加深 */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.55);
}

/* 暗色下的组件微调 */
html[data-theme="dark"] .toast {
    background: rgba(255, 255, 255, 0.92);
    color: #16191e;
}
html[data-theme="dark"] .navbar,
html[data-theme="dark"] .footer {
    border-color: var(--c-border);
}
/* 输入框自动填充保持暗色 */
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--c-text);
    -webkit-box-shadow: 0 0 0 1000px var(--c-surface) inset;
    transition: background-color 9999s ease-in-out 0s;
}
/* 切换动画（尊重减少动效偏好） */
@media (prefers-reduced-motion: no-preference) {
    body, .navbar, .footer, .card, .mobile-tabbar, .form-input, .form-select, .form-textarea {
        transition: background-color 0.25s ease, border-color 0.25s ease;
    }
}
