/* 代码高亮组件CSS样式 */

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.nav {
    margin-top: 10px;
}

.nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
}

.nav a {
    text-decoration: none;
    color: #666;
    font-size: 16px;
    transition: color 0.3s;
}

.nav a:hover {
    color: #007bff;
}

/* 主内容区域样式 */
.main-content {
    padding: 40px 0;
}

/* 组件部分样式 */
.component-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section-header {
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 10px;
}

.section-description {
    font-size: 16px;
    color: #666;
}

/* 组件概览样式 */
.component-overview,
.component-features,
.usage-guide,
.responsive-design,
.accessibility {
    margin-bottom: 40px;
}

.component-overview h3,
.component-features h3,
.usage-guide h3,
.responsive-design h3,
.accessibility h3 {
    font-size: 22px;
    color: #333;
    margin-bottom: 15px;
}

.component-overview p,
.usage-guide p,
.responsive-design p,
.accessibility p {
    font-size: 16px;
    color: #666;
    margin-bottom: 15px;
}

.component-features ul,
.responsive-design ul,
.accessibility ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.component-features li,
.responsive-design li,
.accessibility li {
    font-size: 16px;
    color: #666;
    margin-bottom: 8px;
}

/* 代码示例样式 */
.code-example {
    margin-bottom: 40px;
}

.example-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.example-header h3 {
    font-size: 20px;
    color: #333;
}

.example-actions {
    display: flex;
    gap: 10px;
}

/* 代码容器样式 */
.code-container {
    position: relative;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* pre和code元素样式 */
pre {
    margin: 0;
    background-color: #f8f8f8;
    padding: 20px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 8px;
    position: relative;
}

code {
    background: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
}

/* 复制按钮样式 */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, background-color 0.3s;
    z-index: 10;
}

.copy-btn:hover {
    background-color: #45a049;
}

.code-container:hover .copy-btn {
    opacity: 1;
}

/* 主题切换按钮和行号按钮样式 */
.theme-btn,
.line-numbers-btn {
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.theme-btn:hover,
.line-numbers-btn:hover {
    background-color: #0056b3;
}

.line-numbers-btn {
    background-color: #6c757d;
}

.line-numbers-btn:hover {
    background-color: #5a6268;
}

/* 行号样式 */
.code-container.with-line-numbers {
    padding-left: 40px;
}

.line-numbers {
    position: absolute;
    left: 0;
    top: 14.4px;
    height: 100%;
    width: 40px;
    background-color: #f1f1f1;
    border-right: 1px solid #ddd;
    text-align: right;
    padding: 20px 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #999;
    user-select: none;
    overflow: hidden;
    border-radius: 8px 0 0 8px;
}

.line-numbers span {
    display: block;
}

/* 带有行号的pre元素样式 */
pre.with-line-numbers {
    padding-left: 60px;
    position: relative;
}

/* 使用指南样式 */
.usage-guide h4 {
    font-size: 18px;
    color: #333;
    margin: 25px 0 15px 0;
}

.usage-guide pre {
    margin: 15px 0;
}

.usage-guide code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

/* 页脚样式 */
.footer {
    background-color: #333;
    color: white;
    padding: 30px 0;
    margin-top: 50px;
}

.footer p {
    margin: 0;
    text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 头部响应式 */
    .header .container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    /* 组件部分响应式 */
    .component-section {
        padding: 20px;
    }
    
    .section-header h2 {
        font-size: 24px;
    }
    
    /* 示例头部响应式 */
    .example-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .example-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .example-actions button {
        flex: 1;
        min-width: 120px;
    }
    
    /* 代码块响应式 */
    pre {
        padding: 15px;
        font-size: 13px;
    }
    
    /* 行号响应式 */
    .line-numbers {
        width: 35px;
        padding: 15px 6px;
        font-size: 13px;
    }
    
    .code-container.with-line-numbers {
        padding-left: 35px;
    }
    
    pre.with-line-numbers {
        padding-left: 50px;
    }
}

@media (max-width: 480px) {
    /* 主内容响应式 */
    .main-content {
        padding: 20px 0;
    }
    
    /* 组件部分响应式 */
    .component-section {
        padding: 15px;
    }
    
    .section-header h2 {
        font-size: 22px;
    }
    
    /* 按钮响应式 */
    .example-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .example-actions button {
        width: 100%;
        min-width: auto;
    }
    
    /* 代码块响应式 */
    pre {
        padding: 12px;
        font-size: 12px;
    }
    
    /* 复制按钮响应式 */
    .copy-btn {
        opacity: 1;
        font-size: 11px;
        padding: 6px 12px;
    }
}

/* 动画效果 */
.code-example,
.component-overview,
.component-features,
.usage-guide,
.responsive-design,
.accessibility {
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 代码块滚动条样式 */
pre::-webkit-scrollbar {
    height: 8px;
}

pre::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .code-container {
        box-shadow: 0 0 0 2px #000;
    }
    
    .copy-btn,
    .theme-btn,
    .line-numbers-btn {
        border: 2px solid currentColor;
    }
    
    .line-numbers {
        border-right: 2px solid #000;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #e0e0e0;
    }
    
    .header {
        background-color: #1e1e1e;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    .logo {
        color: #e0e0e0;
    }
    
    .nav a {
        color: #b0b0b0;
    }
    
    .nav a:hover {
        color: #64b5f6;
    }
    
    .component-section {
        background-color: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .section-header h2,
    .component-overview h3,
    .component-features h3,
    .usage-guide h3,
    .responsive-design h3,
    .accessibility h3,
    .example-header h3,
    .usage-guide h4 {
        color: #e0e0e0;
    }
    
    .section-description,
    .component-overview p,
    .component-features li,
    .usage-guide p,
    .responsive-design p,
    .responsive-design li,
    .accessibility p,
    .accessibility li {
        color: #b0b0b0;
    }
    
    .code-container {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    pre {
        background-color: #2d2d2d;
    }
    
    .line-numbers {
        background-color: #252526;
        border-right: 1px solid #464647;
        color: #858585;
    }
    
    .usage-guide code {
        background-color: #2d2d2d;
        color: #d4d4d4;
    }
    
    .footer {
        background-color: #1e1e1e;
    }
    
    /* 滚动条暗色模式 */
    pre::-webkit-scrollbar-track {
        background: #2d2d2d;
    }
    
    pre::-webkit-scrollbar-thumb {
        background: #555;
    }
    
    pre::-webkit-scrollbar-thumb:hover {
        background: #777;
    }
}

/* 无障碍支持增强 */
button {
    outline: none;
}

button:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.copy-btn,
.theme-btn,
.line-numbers-btn {
    transition: all 0.2s ease;
}

.copy-btn:active,
.theme-btn:active,
.line-numbers-btn:active {
    transform: scale(0.95);
}

/* 打印样式 */
@media print {
    .header,
    .footer,
    .copy-btn,
    .theme-btn,
    .line-numbers-btn {
        display: none;
    }
    
    .main-content {
        padding: 0;
    }
    
    .component-section {
        box-shadow: none;
        padding: 0;
    }
    
    pre {
        background-color: white !important;
        border: 1px solid #ddd;
        white-space: pre-wrap;
        word-wrap: break-word;
    }
}