/* ==========================================================================
   AegisAuth 开发文档页样式 - 技术网格企业风 × 亚麻商务风
   --------------------------------------------------------------------------
   设计语言：
     技术网格企业风 —— 蓝图白底画布、点阵底纹、单一橙色 CTA、轻阴影分层
     亚麻商务风    —— 亚麻磨砂质感底纹、清新商务配色
   布局：左侧 sticky 分类导航 + 右侧文档内容（桌面双栏，移动单栏）
   无障碍：WCAG 2.1 AA 对比度、focus-visible 轮廓、prefers-reduced-motion
   ========================================================================== */

/* ============ 0. CSS 变量（文档页局部补充） ============ */
.docs-body,
.docs-hero {
    --docs-color-canvas: #FAFAF7;
    --docs-color-linen: #F5F2EC;
    --docs-color-brand: #2B6C6F;
    --docs-color-accent: #FF6B35;
    --docs-color-text: #1A1A2E;
    --docs-color-text-muted: #6B7280;
    --docs-color-border: #E5E7EB;
    --docs-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --docs-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --docs-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --docs-code-bg: #1A1A2E;
}

/* ============ 1. 页头 Hero ============ */
.docs-hero {
    position: relative;
    /* padding-top 需 ≥ 100px 以避开 fixed site-header（约 60-72px），
       与全局 HEADER_OFFSET=100 / scroll-padding-top:100px 保持一致 */
    padding: 120px 0 48px;
    background-color: var(--docs-color-canvas, #FAFAF7);
    background-image: radial-gradient(circle, rgba(43, 108, 111, 0.06) 1px, transparent 1px);
    background-size: 20px 20px;
    border-bottom: 1px solid var(--docs-color-border, #E5E7EB);
    overflow: hidden;
}

.docs-hero-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.docs-hero-text {
    flex: 1;
    min-width: 280px;
}

.docs-hero-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--docs-color-text, #1A1A2E);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.docs-hero-subtitle {
    font-size: 1rem;
    color: var(--docs-color-text-muted, #6B7280);
    margin: 0;
    line-height: 1.6;
}

.docs-hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 搜索框 */
.docs-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.docs-search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--docs-color-text-muted, #6B7280);
    pointer-events: none;
}

.docs-search-input {
    width: 240px;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--docs-color-text, #1A1A2E);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.docs-search-input:focus {
    outline: none;
    border-color: var(--docs-color-brand, #2B6C6F);
    box-shadow: 0 0 0 3px rgba(43, 108, 111, 0.12);
}

.docs-search-input::placeholder {
    color: var(--docs-color-text-muted, #6B7280);
}

/* SDK 按钮 */
.docs-sdk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.docs-sdk-btn svg {
    width: 16px;
    height: 16px;
}

/* SDK 按钮占位状态：尚未发布，使用虚线边框 + 半透明提示用户 */
.docs-sdk-btn.is-placeholder {
    border-style: dashed;
    opacity: 0.85;
    cursor: help;
}
.docs-sdk-btn.is-placeholder:hover {
    opacity: 1;
}

/* SDK 即将开源提示卡片 */
.docs-sdk-notice {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1100;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 16px;
    padding-right: 36px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #D4A017;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}
.docs-sdk-notice.is-visible {
    opacity: 1;
    transform: translateX(0);
}
.docs-sdk-notice-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}
.docs-sdk-notice-desc {
    font-size: 13px;
    line-height: 1.5;
    color: #4b5563;
}
.docs-sdk-notice-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.docs-sdk-notice-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}
@media (max-width: 768px) {
    .docs-sdk-notice {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
        transform: translateY(120%);
    }
    .docs-sdk-notice.is-visible {
        transform: translateY(0);
    }
}

/* ============ 2. 主体布局 ============ */
.docs-body {
    padding: 40px 0 80px;
    background-color: var(--docs-color-canvas, #FAFAF7);
    background-image: radial-gradient(circle, rgba(43, 108, 111, 0.06) 1px, transparent 1px);
    background-size: 20px 20px;
}

.docs-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
    align-items: start;
}

/* 移动端导航切换按钮（默认隐藏） */
.docs-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #FFFFFF;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    cursor: pointer;
    color: var(--docs-color-text, #1A1A2E);
}

.docs-nav-toggle svg {
    width: 22px;
    height: 22px;
}

/* ============ 3. 左侧分类导航 ============ */
.docs-sidebar {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.docs-sidebar-inner {
    background: var(--docs-color-linen, #F5F2EC);
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    padding: 16px 12px;
    box-shadow: var(--docs-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}

.docs-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.docs-nav-link {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--docs-color-text-muted, #6B7280);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.docs-nav-link:hover {
    background: rgba(43, 108, 111, 0.06);
    color: var(--docs-color-text, #1A1A2E);
}

.docs-nav-link:focus-visible {
    outline: 2px solid var(--docs-color-brand, #2B6C6F);
    outline-offset: 2px;
}

.docs-nav-link.active {
    background: var(--docs-color-brand, #2B6C6F);
    color: #FFFFFF;
    font-weight: 600;
}

/* ============ 4. 右侧文档内容 ============ */
.docs-content {
    min-width: 0;
}

.docs-no-results {
    padding: 48px 24px;
    text-align: center;
    background: #FFFFFF;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    margin-bottom: 20px;
}

.docs-no-results.is-hidden {
    display: none;
}

.docs-no-results p {
    margin: 0;
    color: var(--docs-color-text-muted, #6B7280);
    font-size: 0.9375rem;
}

/* 章节容器 */
.docs-section {
    scroll-margin-top: 100px;
    margin-bottom: 32px;
}

.docs-section-head {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--docs-color-brand, #2B6C6F);
}

.docs-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--docs-color-text, #1A1A2E);
    margin: 0;
    line-height: 1.4;
}

.docs-section-intro {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--docs-color-text-muted, #6B7280);
    margin: 0 0 20px;
}

/* ============ 5. 信息卡片（API 概览） ============ */
.docs-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.docs-info-card {
    background: #FFFFFF;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--docs-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.docs-info-card:hover {
    box-shadow: var(--docs-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.06));
    transform: translateY(-2px);
}

.docs-info-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--docs-color-text-muted, #6B7280);
    margin-bottom: 8px;
}

.docs-info-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--docs-color-brand, #2B6C6F);
    word-break: break-all;
    margin-bottom: 6px;
}

.docs-info-desc {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--docs-color-text-muted, #6B7280);
}

/* ============ 6. 端点卡片 ============ */
.docs-endpoint {
    background: #FFFFFF;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--docs-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
    transition: box-shadow 0.2s ease;
}

.docs-endpoint:hover {
    box-shadow: var(--docs-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.06));
}

.docs-endpoint-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

/* 方法徽章 */
.docs-method-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #FFFFFF;
    text-transform: uppercase;
}

.docs-method-get {
    background: var(--docs-color-brand, #2B6C6F);
}

.docs-method-post {
    background: var(--docs-color-accent, #FF6B35);
}

.docs-method-put {
    background: #8B5CF6;
}

.docs-method-delete {
    background: #EF4444;
}

.docs-method-patch {
    background: #F59E0B;
}

/* 端点路径 */
.docs-endpoint-path {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--docs-color-text, #1A1A2E);
    word-break: break-all;
    background: transparent;
    padding: 0;
}

.docs-endpoint-desc {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--docs-color-text-muted, #6B7280);
    margin: 0 0 16px;
}

/* ============ 7. 参数表格 ============ */
.docs-params-wrap {
    margin-bottom: 16px;
}

.docs-subheading {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--docs-color-text-muted, #6B7280);
    margin: 0 0 8px;
}

.docs-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--docs-color-border, #E5E7EB);
    border-radius: 8px;
}

.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 480px;
}

.docs-table thead {
    background: var(--docs-color-linen, #F5F2EC);
}

.docs-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--docs-color-text, #1A1A2E);
    border-bottom: 1px solid var(--docs-color-border, #E5E7EB);
    white-space: nowrap;
}

.docs-table td {
    padding: 10px 14px;
    color: var(--docs-color-text, #1A1A2E);
    border-bottom: 1px solid var(--docs-color-border, #E5E7EB);
    vertical-align: top;
}

.docs-table tbody tr:last-child td {
    border-bottom: none;
}

.docs-table tbody tr:hover {
    background: rgba(43, 108, 111, 0.02);
}

.docs-param-name {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-weight: 600;
    color: var(--docs-color-brand, #2B6C6F);
}

.docs-param-type {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--docs-color-text-muted, #6B7280);
}

.docs-param-desc {
    line-height: 1.5;
}

/* 必填/选填标签 */
.docs-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.docs-tag-required {
    background: rgba(255, 107, 53, 0.12);
    color: var(--docs-color-accent, #FF6B35);
}

.docs-tag-optional {
    background: rgba(107, 114, 128, 0.12);
    color: var(--docs-color-text-muted, #6B7280);
}

/* 错误码表格 */
.docs-table-errors .docs-err-code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-weight: 700;
    color: var(--docs-color-brand, #2B6C6F);
}

.docs-table-errors .docs-err-message {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--docs-color-text-muted, #6B7280);
}

.docs-table-errors .docs-err-desc {
    line-height: 1.5;
}

/* ============ 8. 代码块 ============ */
.docs-code-wrap {
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2D2D44;
}

.docs-code-wrap:last-child {
    margin-bottom: 0;
}

.docs-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #16162A;
    border-bottom: 1px solid #2D2D44;
}

.docs-code-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9CA3AF;
}

/* 复制按钮 */
.docs-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #D1D5DB;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.docs-code-wrap:hover .docs-copy-btn {
    opacity: 1;
}

.docs-copy-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
}

.docs-copy-btn:focus-visible {
    outline: 2px solid var(--docs-color-brand, #2B6C6F);
    outline-offset: 2px;
    opacity: 1;
}

.docs-copy-btn svg {
    width: 14px;
    height: 14px;
}

.docs-copy-btn.is-copied {
    background: rgba(43, 108, 111, 0.3);
    color: #6EE7B7;
    border-color: rgba(43, 108, 111, 0.5);
    opacity: 1;
}

.docs-code-block {
    margin: 0;
    padding: 16px;
    background: var(--docs-code-bg, #1A1A2E);
    overflow-x: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #E2E8F0;
}

.docs-code-block code {
    font-family: inherit;
    background: none;
    padding: 0;
    color: inherit;
    white-space: pre;
}

/* 响应示例用不同色调微弱区分 */
.docs-code-response {
    border-top: 1px solid #2D2D44;
}

/* ============ 9. 返回顶部按钮 ============ */
.docs-back-top {
    position: fixed;
    right: 32px;
    bottom: 32px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--docs-color-brand, #2B6C6F);
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(43, 108, 111, 0.3);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 100;
    text-decoration: none;
}

.docs-back-top svg {
    width: 20px;
    height: 20px;
}

.docs-back-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.docs-back-top:hover {
    background: #1F5052;
    box-shadow: 0 6px 16px rgba(43, 108, 111, 0.4);
}

.docs-back-top:focus-visible {
    outline: 2px solid var(--docs-color-accent, #FF6B35);
    outline-offset: 3px;
}

/* ============ 10. 滚动条美化 ============ */
.docs-sidebar::-webkit-scrollbar {
    width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--docs-color-border, #E5E7EB);
    border-radius: 2px;
}

.docs-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--docs-color-text-muted, #6B7280);
}

.docs-code-block::-webkit-scrollbar {
    height: 6px;
}

.docs-code-block::-webkit-scrollbar-track {
    background: #16162A;
}

.docs-code-block::-webkit-scrollbar-thumb {
    background: #3D3D5C;
    border-radius: 3px;
}

.docs-code-block::-webkit-scrollbar-thumb:hover {
    background: #4D4D6C;
}

/* ============ 11. 搜索高亮 ============ */
.docs-search-highlight {
    background: rgba(255, 107, 53, 0.2);
    border-radius: 2px;
    padding: 0 2px;
}

.docs-searchable.is-hidden {
    display: none;
}

/* ============ 12. 响应式适配 ============ */

/* 平板：缩小侧栏宽度 */
@media (max-width: 1023px) {
    .docs-layout {
        grid-template-columns: 200px 1fr;
        gap: 24px;
    }

    .docs-hero-title {
        font-size: 1.75rem;
    }

    .docs-search-input {
        width: 200px;
    }

    .docs-endpoint {
        padding: 20px;
    }
}

/* 手机：侧栏变为水平滚动标签栏 */
@media (max-width: 768px) {
    .docs-hero {
        padding: 100px 0 32px;
    }

    .docs-hero-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }

    .docs-hero-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .docs-search-box {
        width: 100%;
    }

    .docs-search-input {
        width: 100%;
    }

    .docs-sdk-btn {
        width: 100%;
        justify-content: center;
    }

    .docs-hero-title {
        font-size: 1.5rem;
    }

    .docs-hero-subtitle {
        font-size: 0.9375rem;
    }

    .docs-body {
        padding: 24px 0 60px;
    }

    /* 显示移动端导航切换按钮 */
    .docs-nav-toggle {
        display: flex;
    }

    .docs-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* 侧栏变为可折叠的水平滚动标签栏 */
    .docs-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 0;
    }

    .docs-sidebar.is-collapsed .docs-sidebar-inner {
        display: none;
    }

    .docs-sidebar-inner {
        padding: 10px;
    }

    .docs-nav-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .docs-nav-item {
        flex-shrink: 0;
    }

    .docs-nav-link {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.8125rem;
    }

    .docs-endpoint {
        padding: 16px;
    }

    .docs-section-title {
        font-size: 1.1rem;
    }

    .docs-info-grid {
        grid-template-columns: 1fr;
    }

    .docs-info-card {
        padding: 16px;
    }

    .docs-method-badge {
        min-width: 48px;
        font-size: 0.6875rem;
        padding: 3px 8px;
    }

    .docs-endpoint-path {
        font-size: 0.875rem;
    }

    .docs-code-block {
        font-size: 0.75rem;
        padding: 12px;
    }

    /* 始终显示复制按钮（移动端无 hover） */
    .docs-copy-btn {
        opacity: 1;
    }

    .docs-back-top {
        right: 16px;
        bottom: 16px;
        width: 40px;
        height: 40px;
    }

    .docs-back-top svg {
        width: 18px;
        height: 18px;
    }
}

/* 超小屏 */
@media (max-width: 420px) {
    .docs-endpoint-head {
        gap: 8px;
    }

    .docs-table {
        min-width: 360px;
    }

    .docs-table th,
    .docs-table td {
        padding: 8px 10px;
        font-size: 0.8125rem;
    }
}

/* ============ 13. 无障碍：减弱动画 ============ */
@media (prefers-reduced-motion: reduce) {
    .docs-nav-link,
    .docs-info-card,
    .docs-endpoint,
    .docs-copy-btn,
    .docs-back-top {
        transition: none;
    }

    .docs-info-card:hover,
    .docs-endpoint:hover {
        transform: none;
    }

    .docs-back-top {
        transform: none;
    }
}
