/* API文档页面专用样式 */
:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    --accent-color: #e94560;
    --text-color: #f8f9fa;
    --code-bg: #2d3748;
    --border-color: #4a5568;
}

body {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-color);
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
}

.navbar {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.container {
    max-width: 1200px;
    margin-top: 100px;
}

.api-header {
    text-align: center;
    margin-bottom: 50px;
}

.api-header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--accent-color), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
}

.section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    contain: layout style paint;
    will-change: transform;
}

.section h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-block {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    overflow-x: auto;
    position: relative;
    contain: layout style;
}

.code-block.lazy-load {
    min-height: 100px;
    background: var(--code-bg) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect width="40" height="40" fill="%23333"/><circle cx="20" cy="20" r="8" fill="none" stroke="%23666" stroke-width="2"><animate attributeName="r" values="8;12;8" dur="1s" repeatCount="indefinite"/></circle></svg>') center center no-repeat;
}

.code-block.lazy-load pre {
    display: none;
}

.code-block.lazy-load::after {
    content: "正在加载代码示例...";
    color: #666;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.code-block .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.code-block .copy-btn:hover {
    opacity: 1;
}

.endpoint {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

.method {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    margin-right: 10px;
}

.method.get { background: #28a745; }
.method.post { background: #007bff; }
.method.put { background: #ffc107; color: #000; }
.method.delete { background: #dc3545; }

.param-table {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    margin: 15px 0;
}

.param-table table {
    width: 100%;
    margin: 0;
}

.param-table th {
    background: var(--accent-color);
    color: white;
    padding: 12px;
    font-weight: 600;
}

.param-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.status-code {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 11px;
}

.status-200 { background: #28a745; color: white; }
.status-400 { background: #ffc107; color: #000; }
.status-401 { background: #dc3545; color: white; }
.status-500 { background: #6c757d; color: white; }

.toc {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.toc ul {
    list-style: none;
    padding-left: 0;
}

.toc li {
    margin: 8px 0;
}

.toc a {
    color: var(--text-color);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s;
}

.toc a:hover {
    background: var(--accent-color);
    color: white;
}

/* 广告位样式 */
.api-ad-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    text-align: center;
    min-height: 100px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    min-width: 300px !important;
    width: 100% !important;
    display: block !important;
}

.api-ad-container .api-ad-content {
    display: block;
    width: 100%;
    min-height: 90px;
}

.api-ad-top {
    margin-bottom: 30px;
    max-width: 728px;
    margin: 20px auto;
    max-height: 90px !important;
    overflow: hidden !important;
}

.api-ad-top .api-ad-content {
    max-height: 90px !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.api-ad-top .adsbygoogle {
    max-height: 90px !important;
    overflow: hidden !important;
}

.api-ad-sidebar {
    position: sticky;
    top: 120px;
    margin-left: 20px;
    width: 180px !important;
    max-width: 180px !important;
    min-height: 600px;
}

.api-ad-sidebar .api-ad-container {
    width: 100%;
    min-height: 600px;
    padding: 10px;
    min-width: 160px !important;
    width: 100% !important;
}

.api-ad-bottom {
    margin-top: 40px;
    margin-bottom: 20px;
    max-width: 728px;
    margin: 30px auto;
}

/* 确保AdSense广告正确显示 */
.api-ad-container .adsbygoogle {
    display: block !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    width: auto !important;
}

/* 性能优化 */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 主要布局结构 */
.main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.content-main {
    flex: 1;
    min-width: 0; /* 防止flex子项溢出 */
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .api-ad-sidebar {
        width: 140px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .api-ad-sidebar {
        position: static;
        width: 100%;
        height: auto;
        margin: 20px 0;
        order: 2;
    }
    
    .content-main {
        order: 1;
    }
}

@media (max-width: 768px) {
    .container {
        margin-top: 80px;
        padding: 0 15px;
    }
    
    .api-header h1 {
        font-size: 2rem;
    }
    
    .section {
        padding: 20px;
    }
    
    .code-block {
        font-size: 12px;
        padding: 15px;
    }
    
    .param-table th,
    .param-table td {
        padding: 8px;
        font-size: 14px;
    }
    
    .api-ad-container {
        margin: 15px 0;
        padding: 10px;
        min-width: 280px !important;
    }
    
    .method {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .endpoint {
        padding: 12px;
    }
    
    .copy-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .api-ad-responsive {
        min-width: 250px !important;
    }
}

@media (max-width: 480px) {
    .api-header h1 {
        font-size: 1.5rem;
    }
    
    .section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .toc {
        padding: 15px;
    }
    
    .param-table {
        font-size: 12px;
    }
    
    .param-table th,
    .param-table td {
        padding: 6px;
    }
    
    .api-ad-container {
        min-width: 250px !important;
    }
    
    .api-ad-responsive {
        min-width: 200px !important;
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .api-ad-container,
    .copy-btn,
    .loading-overlay {
        display: none !important;
    }
    
    .container {
        margin-top: 0;
        max-width: 100%;
    }
    
    .section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .code-block {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #1a1a1a;
        --accent-color: #ffffff;
        --text-color: #ffffff;
        --code-bg: #333333;
        --border-color: #ffffff;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .loading-spinner,
    .section,
    .code-block {
        animation: none;
        transition: none;
    }
    
    .fade-in {
        opacity: 1;
        transform: none;
    }
}

/* 代码高亮（可选） */
.code-block pre {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
}

.code-block .keyword { color: #ff79c6; }
.code-block .string { color: #f1fa8c; }
.code-block .number { color: #bd93f9; }
.code-block .comment { color: #6272a4; }

/* 加载状态 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 预加载提示 */
.preload-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    padding: 20px;
    border-radius: 10px;
    color: var(--text-color);
    z-index: 10000;
    backdrop-filter: blur(10px);
}

/* Logo样式修复 */
.logo-img {
    filter: none !important;
    max-height: 32px;
    width: auto;
    opacity: 1;
}

.navbar-brand {
    display: flex;
    align-items: center;
    color: var(--text-color) !important;
}

.navbar-brand .fw-bold {
    color: var(--text-color) !important;
}

/* 图标字体修复 */
.fas, .far, .fab, .fa {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 6 Brands" !important;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

/* AdSense响应式广告修复 */
.api-ad-responsive {
    display: block !important;
    margin: 0 auto !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 250px !important;
    min-height: 50px !important;
} 