/* ═══════════════════════════════════════════════════════════════
   网页版公用样式层（site.css）
   —— 三个 base 模板统一引用，页面不再各自内联一份移动端媒体查询
   —— 口径：桌面沿用 Bootstrap 断点（≥768px 常规），手机侧重触控命中率、
      安全区、以及"CDN 挂了也不裸奔"的最小可读版式
   ═══════════════════════════════════════════════════════════════ */

:root {
    --kb-brand: #0d6efd;          /* 主站（询价/知识库）蓝 */
    --kb-brand-policies: #1a5fb4; /* 产品官网蓝 */
    --kb-touch: 44px;             /* 最小触控目标 */
    --kb-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── 基础版式与稳定占位（减少 CLS）── */
body { background: #f8f9fa; }
.navbar-brand { font-weight: 600; }
main { min-height: 60vh; padding-bottom: var(--kb-safe-bottom); }
footer { padding-bottom: max(1.5rem, calc(var(--kb-safe-bottom) + 1rem)); }
.nav-link.active,
.navbar-nav .nav-link[aria-current="page"] { font-weight: 600; text-decoration: underline; text-underline-offset: 6px; }

/* ── 手机（<768px）── */
@media (max-width: 767.98px) {
    .form-control, .form-select { font-size: 16px; }   /* <16px 时 iOS 聚焦会放大页面 */
    .btn, .form-control, .form-select, .nav-link,
    .dropdown-item, .page-link { min-height: var(--kb-touch); }
    .btn-sm { min-height: 38px; }
    .navbar-brand { font-size: 1rem; }
    .form-check { padding: .25rem 0 .25rem 1.9rem; margin: 0; }
    .form-check-input { margin-top: .45rem; }
    .display-3, .display-4, .display-5 { font-size: calc(1.4rem + 2vw); }
    .navbar-nav .btn { margin-top: .5rem; }
    table { font-size: .9rem; }
    .kb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .kb-table-wrap > table { min-width: 560px; }
}

/* ── 提交条：手机端吸附到底部，拇指可及且不遮内容 ── */
.kb-sticky-submit {
    position: sticky;
    bottom: 0;
    z-index: 1020;
    background: linear-gradient(to top, #f8f9fa 60%, rgba(248, 249, 250, 0));
    padding: .75rem 0 calc(.75rem + var(--kb-safe-bottom));
    margin-bottom: -.5rem;
}
@media (min-width: 768px) {
    .kb-sticky-submit { position: static; background: none; padding: 0; margin: 0; }
}

/* ── 竞价表单分步（手机端折叠，桌面端保持单页）── */
.kb-steps > summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    padding: .5rem 0;
}
.kb-steps > summary::-webkit-details-marker { display: none; }
.kb-steps > summary::before {
    content: "";
    display: inline-block;
    width: .75rem; height: .75rem;
    margin-right: .5rem;
    border-right: 2px solid var(--kb-brand);
    border-bottom: 2px solid var(--kb-brand);
    transform: rotate(45deg);
    transition: transform .15s ease;
}
.kb-steps[open] > summary::before { transform: rotate(-135deg); }
.kb-steps .kb-step-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; border-radius: 50%;
    background: var(--kb-brand); color: #fff; font-size: .8rem; margin-right: .5rem;
}
.kb-steps.is-done > summary .kb-step-badge { background: #198754; }
@media (min-width: 992px) {
    /* 桌面端把 details 摊平成单页：摘要只当小标题（箭头隐掉、不可点折叠），
       展开状态由 app 脚本统一置 open；下面这条是无 JS 兜底，让内容不至于消失 */
    .kb-steps-flat > summary { display: none; }
    .kb-steps-flat:not([open]) > *:not(summary) { display: block; }
}

/* ── 状态页步进器：手机端不再把 6 个标签并排挤爆 ── */
.kb-stepper { --kb-step-gap: .35rem; }
.kb-stepper .kb-step-labels { display: flex; justify-content: space-between; font-size: .72rem; }
.kb-stepper .kb-step-labels > div { flex: 1; text-align: center; min-width: 0; color: #adb5bd; }
.kb-stepper .kb-step-labels > div.on { color: #198754; }
.kb-stepper .kb-step-labels > div.now { font-weight: 600; }
@media (max-width: 479.98px) {
    /* 只留当前步骤文案 + 圆点序列，完整步骤名进 title */
    .kb-stepper .kb-step-labels { display: none; }
    .kb-stepper .kb-dots { display: flex !important; gap: var(--kb-step-gap); align-items: center; justify-content: center; }
    .kb-stepper .kb-dots i { width: 10px; height: 10px; border-radius: 50%; background: #dee2e6; display: block; }
    .kb-stepper .kb-dots i.on { background: #198754; }
    .kb-stepper .kb-dots i.now { background: #198754; box-shadow: 0 0 0 3px rgba(25, 135, 84, .25); }
    .kb-stepper .kb-step-now { display: block !important; font-weight: 600; text-align: center; margin-bottom: .25rem; }
}
.kb-stepper .kb-dots, .kb-stepper .kb-step-now { display: none; }

/* ── 筛选区：Bootstrap 的 .col-auto 在窄屏会把三四个控件挤成一排 ── */
@media (max-width: 767.98px) {
    .kb-filter > [class*="col-"] { flex: 1 1 100%; max-width: 100%; }
    .kb-filter .btn { width: 100%; }
    .kb-filter input[type="search"], .kb-filter input[name], .kb-filter select { width: 100%; }
}

/* ── 骨架屏 / 空态（替换裸"加载中..."）── */
.kb-skeleton { display: flex; flex-direction: column; gap: .6rem; padding: .25rem 0; }
.kb-skeleton span {
    position: relative; overflow: hidden; display: block;
    height: 56px; border-radius: .5rem; background: #e9ecef;
}
.kb-skeleton span::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
    animation: kb-shimmer 1.2s infinite;
}
@keyframes kb-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.kb-empty { text-align: center; color: #6c757d; padding: 2.5rem 1rem; }
.kb-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* ── Toast（替代 alert()：手机上有 alert 会带上域名且挡住表单）── */
.kb-toast-wrap {
    position: fixed; top: 1rem; right: 1rem; z-index: 1090;
    display: flex; flex-direction: column; gap: .5rem;
    max-width: min(360px, calc(100vw - 2rem));
}
@media (max-width: 767.98px) {
    .kb-toast-wrap { top: auto; bottom: calc(1rem + var(--kb-safe-bottom)); left: 1rem; right: 1rem; max-width: none; }
}
.kb-toast {
    border: 1px solid transparent; border-radius: .5rem; padding: .6rem .8rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .15); background: #fff;
    display: flex; align-items: flex-start; gap: .5rem; font-size: .92rem;
}
.kb-toast .kb-toast-body { flex: 1; word-break: break-word; }
.kb-toast .kb-toast-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.kb-toast-success { background: #d1e7dd; border-color: #a3cfbb; color: #0a3622; }
.kb-toast-error { background: #f8d7da; border-color: #f1aeb5; color: #58151c; }
.kb-toast-warning { background: #fff3cd; border-color: #ffe69c; color: #664d03; }
.kb-toast-info { background: #cfe2ff; border-color: #9ec5fe; color: #031633; }

/* ── 上传项状态行（逐文件反馈用）── */
.kb-upload-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.kb-upload-item {
    display: flex; align-items: center; gap: .5rem;
    border: 1px solid #dee2e6; border-radius: .4rem; padding: .35rem .5rem; font-size: .88rem;
}
.kb-upload-item.ok { border-color: #a3cfbb; background: #f2fbf5; }
.kb-upload-item.fail { border-color: #f1aeb5; background: #fdf2f3; }
.kb-upload-item .kb-upload-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-upload-item img { max-height: 44px; border-radius: .25rem; }
.kb-progress { height: 4px; border-radius: 2px; background: #e9ecef; overflow: hidden; }
.kb-progress > div { height: 100%; width: 0; background: var(--kb-brand); transition: width .2s ease; }

/* ── 触屏与动效偏好 ── */
@media (hover: none) {
    /* 触屏没有 hover，卡片一旦"悬浮起来"就会被当成"已被选中"的错觉且粘住不放 */
    .feature-card, .hover-card, .hall-card { transform: none !important; }
    .feature-card:hover, .hover-card:hover { box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075) !important; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
}

/* ── 管理后台：手机端把侧栏收成抽屉，桌面端保持 inline ── */
.kb-admin-body { display: flex; min-height: calc(100vh - 56px); }
.kb-admin-side { width: 220px; flex: 0 0 220px; background: #f8f9fa; padding: 1rem .5rem; }
.kb-admin-side .nav-link { color: #212529; border-radius: .375rem; }
.kb-admin-side .nav-link.active { background: #e7f1ff; color: #084298; font-weight: 600; text-decoration: none; }
.kb-admin-main { flex: 1 1 auto; min-width: 0; padding: 1rem; }
@media (max-width: 767.98px) {
    .kb-admin-side { display: none; }
    .kb-admin-main { padding: .75rem; }
    /* 操作列收成图标按钮后，给表格留出横向滚动而不是把页面撑宽 */
    .kb-admin-main .table-responsive { -webkit-overflow-scrolling: touch; }
}
@media (min-width: 768px) {
    .kb-admin-offcanvas { display: none !important; }
}
