/* ===================== API文档管理系统 前台样式 ===================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: #f5f6fa;
    color: #2c3e50;
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- 顶部导航 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
    height: 60px;
}
.topbar-inner {
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 8px; color: #1e9fff; }
.brand i { color: #1e9fff; }
.brand-name { font-size: 18px; font-weight: 600; color: #2c3e50; }
.brand-ver { font-size: 12px; color: #fff; background: #1e9fff; padding: 1px 8px; border-radius: 10px; }
.topbar-search {
    flex: 1;
    max-width: 460px;
    margin: 0 24px;
    position: relative;
}
.topbar-search i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: #999;
}
.topbar-search input {
    width: 100%;
    height: 38px;
    border: 1px solid #e6e8eb;
    border-radius: 19px;
    padding: 0 14px 0 36px;
    background: #f5f6fa;
    font-size: 13px;
    outline: none;
    transition: all .2s;
}
.topbar-search input:focus {
    border-color: #1e9fff;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(30,159,255,.1);
}
.topbar-actions { margin-left: auto; }
.btn-admin {
    display: inline-flex; align-items: center; gap: 4px;
    color: #2c3e50; text-decoration: none;
    padding: 8px 16px; border-radius: 4px;
    border: 1px solid #e6e8eb; background: #fff;
    font-size: 13px; transition: all .2s;
}
.btn-admin:hover { color: #1e9fff; border-color: #1e9fff; }

/* ---------- 布局 ---------- */
.layout { display: flex; max-width: 1600px; margin: 0 auto; align-items: flex-start; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    border-right: 1px solid #eef0f2;
    background: #fff;
}
.sidebar-inner { padding: 16px 0; }
.sidebar-title {
    padding: 0 20px 12px;
    font-size: 12px;
    color: #999;
    letter-spacing: 1px;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 8px;
}
.nav { list-style: none; margin: 0; padding: 0; }
.nav li { margin: 0; }
.nav-cat {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    color: #5a6573; text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .2s;
}
.nav-cat i { font-size: 16px; color: #c2c6cc; }
.nav-cat span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
    font-size: 11px; color: #999;
    background: #f0f2f5; border-radius: 8px;
    padding: 0 6px; min-width: 18px; text-align: center;
    font-style: normal;
}
.nav-cat:hover { background: #f7f9fc; color: #1e9fff; }
.nav-cat:hover i { color: #1e9fff; }
.nav-cat.active {
    background: #eaf6ff;
    color: #1e9fff;
    border-left-color: #1e9fff;
    font-weight: 500;
}
.nav-cat.active i { color: #1e9fff; }
.nav-cat.active .nav-count { background: #1e9fff; color: #fff; }
.nav-empty { padding: 20px; color: #ccc; text-align: center; font-size: 13px; }

/* ---------- 主内容 ---------- */
.main-content { flex: 1; min-width: 0; padding: 24px 32px 48px; }

/* 分类区块 */
.api-section { margin-bottom: 36px; scroll-margin-top: 80px; }
.section-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #1e9fff; }
.section-header h2 {
    margin: 0; font-size: 20px; color: #2c3e50;
    display: flex; align-items: center; gap: 8px;
}
.section-header h2 i { color: #1e9fff; }
.section-desc { margin: 6px 0 0; color: #8a949e; font-size: 13px; }

/* 接口卡片 */
.api-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    margin-bottom: 16px;
    padding: 20px 24px;
    border: 1px solid #eef0f2;
    transition: box-shadow .2s;
}
.api-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.api-card.api-empty { color: #aaa; text-align: center; padding: 30px; }

.api-card-head {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.method-badge {
    font-size: 12px; font-weight: 700;
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: .5px;
    min-width: 56px; text-align: center;
}
.m-get    { background: #16b777; }
.m-post   { background: #1e9fff; }
.m-put    { background: #ffb800; }
.m-delete { background: #ff5722; }
.m-patch  { background: #7a69f6; }
.m-head   { background: #8a94a6; }
.m-options{ background: #8a94a6; }
.m-other  { background: #8a94a6; }

.api-url {
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 14px;
    color: #2c3e50;
    background: #f5f6fa;
    padding: 3px 10px;
    border-radius: 4px;
    flex: 0 1 auto;
    word-break: break-all;
}
.api-title {
    font-size: 15px; font-weight: 600; color: #2c3e50;
    margin-left: auto;
}
.api-actions { margin-left: 4px; }
.icon-btn {
    border: none; background: transparent; cursor: pointer;
    color: #999; padding: 4px; border-radius: 4px;
    transition: all .15s;
}
.icon-btn:hover { color: #1e9fff; background: #eaf6ff; }

.api-desc { margin: 12px 0 0; color: #5a6573; line-height: 1.7; }

/* 参数表格 */
.block { margin-top: 16px; }
.block-title {
    font-size: 13px; font-weight: 600; color: #5a6573;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.block-title i { color: #1e9fff; }
.block-title .icon-btn { margin-left: auto; }

.param-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
    border: 1px solid #eef0f2;
    border-radius: 6px;
    overflow: hidden;
}
.param-table th, .param-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f2f5;
}
.param-table th {
    background: #fafbfc;
    color: #8a949e;
    font-weight: 500;
    font-size: 12px;
}
.param-table tr:last-child td { border-bottom: none; }
.param-table tr:hover td { background: #f7f9fc; }
.param-table code {
    background: #eef4ff; color: #1e9fff;
    padding: 1px 6px; border-radius: 3px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
}
.req-yes { color: #ff5722; font-weight: 600; }
.req-no  { color: #16b777; }
.req-maybe { color: #bbb; }

/* JSON 展示 */
.json-view {
    background: #1e2733;
    color: #c8d3e0;
    padding: 16px 18px;
    border-radius: 6px;
    overflow: auto;
    margin: 0;
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #2a3340;
}
.json-view-err { background: #2b1a1a; border-color: #4a2a2a; }
.json-view code { font-family: inherit; background: none; padding: 0; color: inherit; }
.json-key  { color: #7fdbff; }
.json-str  { color: #a5e075; }
.json-num  { color: #f7c64a; }
.json-bool { color: #ff79c6; }
.json-null { color: #ff79c6; }

.api-remark {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 4px;
    color: #946800;
    font-size: 13px;
}
.api-remark i { color: #d4a017; margin-right: 4px; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: #999;
}
.empty-state i { font-size: 64px; color: #d6dae0; }
.empty-state h2 { color: #5a6573; }
.empty-state a { color: #1e9fff; }

/* 页脚 */
.footer-tip {
    text-align: center;
    color: #b0b6bf;
    font-size: 12px;
    padding: 30px 0 10px;
    margin-top: 20px;
}

/* 复制提示 toast */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0,0,0,.78);
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all .25s;
    z-index: 9999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast i { color: #16b777; }

/* 隐藏（搜索过滤用） */
.api-card.hidden, .api-section.hidden, .sub-group.hidden { display: none; }

/* ---------- 侧边栏二级分类 ---------- */
.nav-item { }
.nav-sub {
    list-style: none; margin: 0; padding: 0 0 4px 0;
    display: none;  /* 默认折叠，展开时由 JS 添加 active */
}
.nav-item.expanded > .nav-sub { display: block; }
.nav-sub-cat {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 20px 7px 40px;
    color: #8a949e; text-decoration: none;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-sub-cat span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub-cat:hover { background: #f7f9fc; color: #1e9fff; }
.nav-sub-cat.active {
    color: #1e9fff;
    border-left-color: #1e9fff;
    background: #eaf6ff;
}
.nav-sub-cat.active .nav-count { background: #1e9fff; color: #fff; }

/* ---------- 二级分组（主区域可折叠） ---------- */
.sub-group {
    margin-bottom: 8px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eef0f2;
    overflow: hidden;
}
.sub-group + .sub-group { margin-top: 10px; }
.sub-group-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 18px;
    cursor: pointer;
    user-select: none;
    background: #fafbfc;
    border-bottom: 1px solid #f0f2f5;
    transition: background .15s;
}
.sub-group-head:hover { background: #f2f6ff; }
.sub-toggle {
    font-size: 14px; color: #1e9fff;
    transition: transform .2s;
}
.sub-group.collapsed .sub-toggle { transform: rotate(0deg); }
.sub-group:not(.collapsed) .sub-toggle { transform: rotate(90deg); }
.sub-group-name { font-size: 15px; font-weight: 600; color: #2c3e50; flex: 1; }
.sub-group-count {
    font-size: 12px; color: #8a949e; font-style: normal;
    background: #f0f2f5; border-radius: 10px; padding: 1px 10px;
}
.sub-group-body { padding: 12px 14px; }
.sub-group.collapsed .sub-group-body { display: none; }
.sub-group-body .api-card { box-shadow: none; border-color: #eef0f2; margin-bottom: 10px; }
.sub-group-body .api-card:last-child { margin-bottom: 0; }

/* ---------- 项目概览 ---------- */
.overview-card {
    background: #fff;
    border-radius: 10px;
    padding: 28px 32px;
    margin-bottom: 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    border: 1px solid #eef0f2;
}
.overview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 18px;
}
.overview-title { display: flex; align-items: center; gap: 10px; }
.overview-title i { font-size: 32px; color: #1e9fff; }
.overview-title h1 { margin: 0; font-size: 24px; color: #2c3e50; font-weight: 700; }
.overview-ver {
    font-size: 12px; color: #fff; background: #1e9fff;
    padding: 2px 10px; border-radius: 10px;
}
.overview-baseurl {
    display: flex; align-items: center; gap: 8px;
    background: #f5f6fa;
    border: 1px solid #e6e8eb;
    border-radius: 6px;
    padding: 6px 10px;
}
.baseurl-label {
    font-size: 11px; color: #8a949e;
    background: #fff; border: 1px solid #e6e8eb;
    border-radius: 3px; padding: 1px 6px;
    font-weight: 600; letter-spacing: .5px;
}
.baseurl-value {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 14px; color: #1e9fff; font-weight: 600;
}
.overview-intro {
    color: #5a6573; font-size: 14px; line-height: 1.8;
    margin-bottom: 18px;
}
.overview-meta {
    display: flex; gap: 28px;
    padding: 16px 0;
    border-top: 1px solid #f0f2f5;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.meta-item { display: flex; align-items: center; gap: 6px; color: #8a949e; font-size: 13px; }
.meta-item i { font-size: 18px; color: #1e9fff; }
.meta-num { font-size: 22px; font-weight: 700; color: #2c3e50; }
.meta-label { color: #8a949e; }
.overview-block { margin-top: 20px; }
.overview-block h3 {
    margin: 0 0 10px;
    font-size: 15px; color: #2c3e50;
    display: flex; align-items: center; gap: 6px;
}
.overview-block h3 i { color: #1e9fff; font-size: 17px; }
.overview-block h3 .icon-btn { margin-left: auto; }
.overview-block-body {
    color: #5a6573; font-size: 13px; line-height: 1.9;
    background: #f8f9fb; border: 1px solid #eef0f2;
    border-radius: 6px; padding: 12px 16px;
    white-space: pre-wrap;
}
.code-table code { background: #eef4ff; color: #1e9fff; padding: 1px 6px; border-radius: 3px; font-family: "SF Mono", Monaco, Consolas, monospace; }

/* 响应式：概览 */
@media (max-width: 768px) {
    .overview-card { padding: 18px; }
    .overview-title h1 { font-size: 20px; }
    .overview-baseurl { width: 100%; }
    .baseurl-value { font-size: 12px; word-break: break-all; }
    .overview-meta { gap: 16px; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .sidebar { width: 200px; }
    .main-content { padding: 16px 18px 36px; }
}
@media (max-width: 768px) {
    .topbar-search { display: none; }
    .layout { flex-direction: column; }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        max-height: 240px;
        border-right: none;
        border-bottom: 1px solid #eef0f2;
    }
    .main-content { padding: 14px; }
    .api-card { padding: 14px; }
    .api-title { margin-left: 0; width: 100%; }
    .param-table th, .param-table td { padding: 7px 8px; font-size: 12px; }
}
