/* KanColleAuto API 文档页面专用样式（在 tailwind.css / styles.css / prism.css 之后加载） */

/* ---- 页面顶栏与两栏布局 ---- */
.api-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1.25rem;
}

.api-page-stats {
    font-size: 0.875rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

.api-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

@media (min-width: 860px) {
    .api-layout {
        grid-template-columns: 248px minmax(0, 1fr);
        gap: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .api-layout {
        grid-template-columns: 288px minmax(0, 1fr);
        gap: 1.5rem;
    }
}

/* ---- 侧边导航：搜索框 + 分组目录 ---- */
.api-sidebar {
    min-width: 0;
}

@media (min-width: 860px) {
    .api-sidebar-inner {
        position: sticky;
        top: 5rem;
    }
}

.api-search-box {
    position: relative;
    margin-bottom: 0.75rem;
}

.api-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #9ca3af;
    pointer-events: none;
}

.api-search-input {
    display: block;
    width: 100%;
    height: 2.5rem;
    padding: 0 2.25rem 0 2.375rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    background: #ffffff;
    color: #111827;
    font-size: 0.875rem;
    line-height: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.api-search-input::placeholder {
    color: #9ca3af;
}

.api-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.api-search-clear {
    position: absolute;
    right: 0.4375rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    padding: 0;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.api-search-clear svg {
    width: 0.875rem;
    height: 0.875rem;
}

.api-search-clear:hover {
    background: #f3f4f6;
    color: #374151;
}

.api-search-clear.hidden {
    display: none;
}

.api-nav {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.api-nav-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.api-nav-status {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.api-nav-toggle-all {
    padding: 0.125rem 0.4375rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 500;
    color: #2563eb;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.api-nav-toggle-all:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.api-nav-scroll {
    max-height: 19rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

@media (min-width: 860px) {
    .api-nav-scroll {
        max-height: calc(100vh - 12.25rem);
    }
}

.api-nav-scroll::-webkit-scrollbar {
    width: 6px;
}

.api-nav-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.api-nav-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 9999px;
}

.api-nav-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.api-nav-group + .api-nav-group {
    border-top: 1px solid #f3f4f6;
}

.api-nav-group.hidden {
    display: none;
}

/* 隐藏 details 默认三角，固定弹性排版与图标尺寸避免错位 */
.api-nav-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color 0.15s ease;
}

.api-nav-summary::-webkit-details-marker {
    display: none;
}

.api-nav-summary:hover {
    background: #f9fafb;
}

.api-nav-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1 1 auto;
}

.api-caret {
    width: 0.875rem;
    height: 0.875rem;
    flex: 0 0 0.875rem;
    color: #9ca3af;
    transition: transform 0.15s ease, color 0.15s ease;
}

.api-nav-group[open] > .api-nav-summary .api-caret {
    transform: rotate(90deg);
    color: #6b7280;
}

.api-nav-class {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    color: #1f2937;
    white-space: nowrap;
}

.api-nav-desc {
    min-width: 0;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.25rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-nav-count {
    flex-shrink: 0;
    min-width: 1.5rem;
    padding: 0.125rem 0.4375rem;
    border-radius: 9999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.api-nav-list {
    margin: 0;
    padding: 0.125rem 0.5rem 0.5rem;
    list-style: none;
}

.api-nav-item.hidden {
    display: none;
}

.api-nav-link {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    min-width: 0;
    padding: 0.375rem 0.625rem 0.375rem 1.75rem;
    border-radius: 0.5rem;
    color: #4b5563;
    text-decoration: none;
    line-height: 1.35;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.api-nav-link:hover {
    background: #eff6ff;
    color: #2563eb;
}

.api-nav-link.is-active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}

.api-nav-fn {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-nav-cn {
    flex: 0 10 auto;
    min-width: 0;
    font-size: 0.75rem;
    font-weight: 400;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-nav-link:hover .api-nav-cn,
.api-nav-link.is-active .api-nav-cn {
    color: #3b82f6;
}

/* ---- 主体区域 ---- */
.api-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* 文档说明与分类快捷跳转 */
.api-intro {
    padding: 1rem 1.25rem;
    border: 1px solid #dbeafe;
    border-radius: 0.75rem;
    background: #eff6ff;
}

.api-intro-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.375rem 1rem;
    margin-bottom: 0.75rem;
}

.api-intro-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e3a8a;
    line-height: 1.5;
}

.api-intro-feedback {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
}

.api-intro-feedback:hover {
    text-decoration: underline;
}

.api-intro-classes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.api-intro-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    padding: 0.375rem 0.6875rem;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    background: #ffffff;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    color: #374151;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.api-intro-chip:hover {
    border-color: #60a5fa;
    background: #f8fafc;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.api-intro-chip-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    color: #1d4ed8;
}

.api-intro-chip-desc {
    color: #4b5563;
}

.api-intro-chip-count {
    padding: 0.0625rem 0.4375rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.api-error {
    padding: 1rem 1.25rem;
    border: 1px solid #fecaca;
    border-radius: 0.75rem;
    background: #fef2f2;
    font-size: 0.875rem;
    color: #b91c1c;
}

.api-empty {
    padding: 2.5rem 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
    text-align: center;
}

.api-empty.hidden {
    display: none;
}

.api-empty-title {
    margin: 0 0 0.375rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #374151;
}

.api-empty-hint {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    color: #6b7280;
}

.api-empty-btn {
    padding: 0.4375rem 1rem;
    border: 1px solid #dbeafe;
    border-radius: 0.5rem;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.api-empty-btn:hover {
    border-color: #93c5fd;
    background: #dbeafe;
}

/* ---- 分类标题与卡片列表 ---- */
.api-section {
    min-width: 0;
}

.api-section.hidden {
    display: none;
}

.api-section-head {
    scroll-margin-top: 5.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.375rem 0.75rem;
    padding-bottom: 0.625rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.api-section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.api-section-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.75rem;
    color: #111827;
}

.api-section-desc {
    font-size: 0.875rem;
    color: #6b7280;
}

.api-section-count {
    font-size: 0.75rem;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

.api-card-list {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---- 单个函数卡片 ---- */
.api-item {
    min-width: 0;
    scroll-margin-top: 5.5rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.api-item.hidden {
    display: none;
}

/* 通过锚点跳转到某个函数时高亮该卡片 */
.api-item:target {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.api-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.api-item-title-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.625rem;
    min-width: 0;
}

.api-item-title {
    display: inline-flex;
    align-items: baseline;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5rem;
    color: #1d4ed8;
    text-decoration: none;
    word-break: break-word;
}

.api-item-class {
    color: #4b5563;
    font-weight: 500;
}

.api-item-dot {
    color: #9ca3af;
    font-weight: 400;
}

.api-item-func {
    color: #1d4ed8;
    font-weight: 600;
}

.api-item-anchor {
    margin-left: 0.375rem;
    color: #93c5fd;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.api-item-title:hover .api-item-func {
    text-decoration: underline;
}

.api-item-title:hover .api-item-anchor {
    opacity: 1;
}

.api-item-cn {
    font-size: 0.875rem;
    line-height: 1.5rem;
    color: #4b5563;
}

.api-version-badge {
    flex-shrink: 0;
    padding: 0.1875rem 0.5625rem;
    border: 1px solid #bbf7d0;
    border-radius: 9999px;
    background: #f0fdf4;
    color: #15803d;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.125rem;
    white-space: nowrap;
}

.api-item-body {
    min-width: 0;
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.875rem;
    color: #374151;
}

/* ---- 函数签名 ---- */
.api-signature-box {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem 0.5rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
}

.api-signature-code {
    min-width: 0;
    flex: 1 1 auto;
    overflow-x: auto;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5rem;
    color: #1e293b;
    scrollbar-width: thin;
}

.api-sig-ret {
    color: #0f766e;
}

.api-sig-class {
    color: #475569;
}

.api-sig-fn {
    color: #1d4ed8;
    font-weight: 600;
}

.api-sig-param {
    color: #9a3412;
}

.api-sig-op {
    color: #94a3b8;
}

.api-copy-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.5625rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.125rem;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.api-copy-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #1e293b;
}

.api-copy-btn.is-copied {
    border-color: #86efac;
    background: #f0fdf4;
    color: #15803d;
}

/* ---- 函数说明 ---- */
.api-note {
    font-size: 0.875rem;
    line-height: 1.75;
    color: #374151;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.api-note a {
    color: #2563eb;
    font-weight: 500;
    text-decoration: none;
}

.api-note a:hover {
    text-decoration: underline;
}

.api-note code {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: #f1f5f9;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
}

/* ---- 参数与返回值表 ---- */
.api-block {
    min-width: 0;
}

.api-block-title {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.04em;
}

.api-table-wrap {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
}

.api-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.api-table thead th {
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.api-table tbody td {
    padding: 0.625rem 0.75rem;
    vertical-align: top;
    border-top: 1px solid #f3f4f6;
    line-height: 1.65;
}

.api-table tbody tr:first-child td {
    border-top: 0;
}

.api-table tbody tr:hover td {
    background: #f9fafb;
}

.api-col-idx,
.api-cell-idx {
    width: 2.5rem;
    text-align: center;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

.api-col-name,
.api-cell-name {
    width: 11rem;
    min-width: 7.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    word-break: break-word;
}

.api-col-type,
.api-cell-type {
    width: 5.75rem;
    white-space: nowrap;
}

.api-col-desc,
.api-cell-desc {
    min-width: 14rem;
    color: #374151;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.api-type-badge {
    display: inline-block;
    padding: 0.125rem 0.4375rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.125rem;
}

.api-type-number {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.api-type-string {
    background: #fffbeb;
    color: #b45309;
    border-color: #fef3c7;
}

.api-type-bool {
    background: #faf5ff;
    color: #7e22ce;
    border-color: #f3e8ff;
}

.api-type-table {
    background: #ecfdf5;
    color: #047857;
    border-color: #d1fae5;
}

.api-type-default {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}

.api-type-empty {
    color: #d1d5db;
}

.api-field-tag {
    display: inline-block;
    margin-right: 0.375rem;
    padding: 0.0625rem 0.375rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.25rem;
    background: #f9fafb;
    color: #6b7280;
    font-size: 0.75rem;
    line-height: 1.25;
}

/* ---- 无参数 / 无返回值提示条 ---- */
.api-meta-empty {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #f3f4f6;
    border-radius: 0.5rem;
    background: #f9fafb;
    font-size: 0.8125rem;
    color: #6b7280;
}

.api-meta-chip strong {
    font-weight: 600;
    color: #4b5563;
}

/* ---- 示例代码块（覆盖 prism.css 默认外边距与背景色） ---- */
.api-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.api-code-header .api-block-title {
    margin: 0;
}

pre.api-code,
pre.api-code[class*="language-"] {
    margin: 0;
    padding: 0.875rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
    font-size: 0.8125rem;
    line-height: 1.65;
    overflow-x: auto;
    text-shadow: none;
}

pre.api-code code[class*="language-"] {
    font-size: 0.8125rem;
    line-height: 1.65;
    text-shadow: none;
}

/* ---- 返回顶部按钮 ---- */
.api-back-top {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    background: #ffffff;
    color: #4b5563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.api-back-top svg {
    width: 1.125rem;
    height: 1.125rem;
}

.api-back-top:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #2563eb;
    transform: translateY(-2px);
}

.api-back-top.hidden {
    display: none;
}

/* ---- 移动端窄屏适配 ---- */
@media (max-width: 639px) {
    .api-intro {
        padding: 0.875rem 1rem;
    }

    .api-item-header {
        padding: 0.75rem 1rem;
    }

    .api-item-body {
        padding: 0.875rem 1rem 1rem;
    }

    .api-col-name,
    .api-cell-name {
        width: auto;
        min-width: 6rem;
    }

    .api-col-desc,
    .api-cell-desc {
        min-width: 11rem;
    }

    .api-back-top {
        right: 1rem;
        bottom: 1rem;
    }
}
