@use '@/styles/variables.scss' as *;
// API 文档样式
// 参考 Dify API Reference 设计风格

.api-doc-drawer {
    .ant-drawer-body {
        padding: 0;
    }
}

.api-doc-content {
    padding: $spacing-4 $spacing-5;
    max-width: 850px;
    margin: 0 auto;

    // 章节样式
    .api-section {
        margin-bottom: $spacing-6;

        .section-title {
            font-size: $font-2xl;
            font-weight: $font-weight-semibold;
            color: $text-primary;
            margin-bottom: $spacing-3;
            padding-bottom: $spacing-2;
            border-bottom: 1px solid $border-base;
        }

        .section-content {
            color: $text-secondary;
            line-height: $line-height-relaxed;

            p {
                margin-bottom: $spacing-3;
            }
        }
    }

    // 信息卡片
    .info-cards {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: $spacing-3;
        margin-top: $spacing-3;
    }

    .info-card {
        background: $bg-tertiary;
        border-radius: $radius-lg;
        padding: $spacing-3;
        border: 1px solid $border-light;

        .card-label {
            font-size: $font-sm;
            color: $text-hint;
            margin-bottom: $spacing-1;
        }

        .card-value {
            font-size: $font-md;
            color: $text-primary;
            font-family: monospace;

            code {
                background: $bg-secondary;
                padding: 2px 6px;
                border-radius: $radius-sm;
                font-size: $font-sm;
            }
        }
    }

    // API 项目样式
    .api-item {
        padding: $spacing-4 0;
        border-bottom: 1px solid $border-light;

        &:last-child {
            border-bottom: none;
        }

        .api-header {
            display: flex;
            align-items: center;
            gap: $spacing-2;
            margin-bottom: $spacing-3;

            .api-method {
                display: inline-block;
                padding: 4px 12px;
                border-radius: $radius-md;
                font-size: 12px;
                font-weight: $font-weight-semibold;
                text-transform: uppercase;

                &.method-post {
                    background: rgba($success-color, 0.1);
                    color: $success-color;
                }

                &.method-get {
                    background: rgba($info-color, 0.1);
                    color: $info-color;
                }

                &.method-put {
                    background: rgba($warning-color, 0.1);
                    color: $warning-color;
                }

                &.method-delete {
                    background: rgba($error-color, 0.1);
                    color: $error-color;
                }
            }

            .api-path {
                font-size: $font-lg;
                font-family: monospace;
                color: $text-primary;
                font-weight: $font-weight-medium;
            }
        }

        .api-description {
            color: $text-secondary;
            margin-bottom: $spacing-4;
            line-height: $line-height-relaxed;
        }

        h4 {
            font-size: $font-md;
            font-weight: $font-weight-semibold;
            color: $text-primary;
            margin: $spacing-4 0 $spacing-2 0;
        }
    }

    // 参数表格
    .params-table {
        margin: $spacing-3 0;
        overflow-x: auto;

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: $font-sm;

            th, td {
                padding: $spacing-2 $spacing-3;
                text-align: left;
                border-bottom: 1px solid $border-light;
            }

            th {
                background: $bg-tertiary;
                font-weight: $font-weight-semibold;
                color: $text-primary;
                white-space: nowrap;
            }

            td {
                color: $text-secondary;

                &:nth-child(1) {
                    code {
                        background: $bg-tertiary;
                        padding: 2px 6px;
                        border-radius: $radius-sm;
                        font-size: $font-sm;
                        color: $primary-color;
                    }
                }

                &:nth-child(2) {
                    .param-type {
                        color: $text-hint;
                        font-family: monospace;
                        font-size: $font-sm;
                    }
                }
            }
        }
    }

    // 代码块
    .code-block {
        margin: $spacing-3 0;
        border-radius: $radius-lg;
        overflow: hidden;
        border: 1px solid $border-base;

        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: $spacing-2 $spacing-3;
            background: $bg-tertiary;
            border-bottom: 1px solid $border-light;

            .code-language {
                font-size: $font-sm;
                color: $text-hint;
                text-transform: uppercase;
            }

            .ant-btn {
                font-size: $font-sm;
            }
        }

        .code-content {
            margin: 0;
            padding: $spacing-3;
            background: #1a1a2e;
            overflow-x: auto;

            code {
                font-family: 'Monaco', 'Consolas', monospace;
                font-size: $font-sm;
                line-height: 1.6;
                color: #e0e0e0;
            }

            &::-webkit-scrollbar {
                height: 6px;
            }

            &::-webkit-scrollbar-track {
                background: #1a1a2e;
            }

            &::-webkit-scrollbar-thumb {
                background: rgba(255, 255, 255, 0.2);
                border-radius: 3px;
            }
        }
    }

    // 代码 Tab
    .code-tabs {
        margin-top: $spacing-2;

        .ant-tabs-nav {
            margin-bottom: 0;
        }

        .ant-tabs-content-holder {
            padding: 0;
        }
    }

    // 响应示例
    .response-example {
        margin: $spacing-3 0;

        .example-header {
            font-size: $font-md;
            font-weight: $font-weight-semibold;
            color: $text-primary;
            margin-bottom: $spacing-2;
        }

        .example-content {
            margin: 0;
            padding: $spacing-3;
            background: $bg-tertiary;
            border-radius: $radius-lg;
            border: 1px solid $border-light;
            overflow-x: auto;

            code {
                font-family: 'Monaco', 'Consolas', monospace;
                font-size: $font-sm;
                line-height: 1.6;
                color: $text-primary;
            }
        }
    }

    // API Tabs
    .api-tabs {
        margin-top: $spacing-4;
    }
}

// 响应式适配
@media (max-width: $screen-md) {
    .api-doc-content {
        padding: $spacing-3;

        .info-cards {
            grid-template-columns: 1fr;
        }

        .params-table {
            font-size: $font-xs;

            th, td {
                padding: $spacing-1 $spacing-2;
            }
        }
    }
}
