/* 区块链稳定币教程 - 共享样式 */

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 主题变量 */
:root {
    --primary-color: #6366f1;
    --secondary-color: #f97316;
    --dark-bg: #1e293b;
    --light-bg: #f8fafc;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
}

/* 基础排版 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-bg);
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏 */
.navbar {
    background-color: var(--dark-bg);
    color: white;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-link {
    color: #cbd5e1;
    text-decoration: none;
    transition: color 0.3s;
}

.nav-link:hover,
.nav-link.active {
    color: white;
}

/* 章节下拉菜单 */
.nav-item {
    position: relative;
}

.nav-item.dropdown > .nav-link::after {
    content: ' ▼';
    font-size: 0.75em;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 8px;
    min-width: 200px;
    display: none;
    z-index: 1000;
}

.nav-item.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: background-color 0.3s;
}

.dropdown-item:hover {
    background-color: var(--light-bg);
}

/* 移动端导航 */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* 头部 */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* 章节 */
.chapter {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chapter h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.chapter h3 {
    color: var(--text-dark);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.chapter h4 {
    color: var(--text-dark);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

/* 信息框 */
.info-box, .tip-box, .warning-box, .concept, .intro-box {
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.info-box {
    background-color: #e0f2fe;
    border-left: 4px solid #0284c7;
}

.tip-box {
    background-color: #dcfce7;
    border-left: 4px solid var(--success-color);
}

.warning-box {
    background-color: #fef3c7;
    border-left: 4px solid var(--warning-color);
}

.concept {
    background-color: #f3e8ff;
    border-left: 4px solid #9333ea;
}

.intro-box {
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
}

.intro-box ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.intro-box li {
    margin: 0.25rem 0;
}

/* General list styling for content */
.chapter ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.chapter li {
    margin: 0.25rem 0;
}

/* Nested list styling */
.chapter ul ul {
    margin-left: 1.5rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Timeline and box nested lists */
.timeline ul,
.info-box ul ul,
.warning-box ul ul,
.theory-box ul ul,
.tip-box ul ul,
.example-box ul ul,
.code-example ul ul {
    margin-left: 1.5rem;
}

/* 示例框 */
.example-box {
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

/* 代码块 */
.code-block {
    background-color: #1e293b;
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
}

.code-header {
    background-color: #334155;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-header:hover {
    background-color: #475569;
}

.toggle-icon {
    transition: transform 0.3s;
}

.code-header.expanded .toggle-icon {
    transform: rotate(180deg);
}

.code-content {
    max-height: 500px;
    overflow-y: auto;
}

.code-content pre {
    margin: 0;
    padding: 1rem;
}

.code-content code {
    color: #e2e8f0;
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 练习题 */
.exercise {
    background-color: #fefce8;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.exercise h4 {
    color: var(--warning-color);
    margin-bottom: 1rem;
}

.exercise button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1rem;
}

.exercise button:hover {
    background-color: #4f46e5;
}

.answer {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background-color: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* 答案内容默认隐藏 */
.answer-content {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background-color: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* 答案切换按钮 */
.answer-toggle {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1rem;
}

.answer-toggle:hover {
    background-color: #4f46e5;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th, td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

th {
    background-color: var(--light-bg);
    font-weight: 600;
}

/* 章节导航 */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin: 2rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.chapter-nav a {
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapter-nav a:hover {
    text-decoration: underline;
}

/* 目录 */
.toc {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.toc h3 {
    margin-bottom: 1rem;
}

.toc ul {
    list-style: none;
    padding-left: 0;
}

.toc li {
    margin: 0.5rem 0;
}

.toc a {
    color: var(--text-dark);
    text-decoration: none;
}

.toc a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--dark-bg);
        flex-direction: column;
        padding: 1rem;
    }
    
    .navbar-nav.active {
        display: flex;
    }
    
    .navbar-toggle {
        display: block;
    }
    
    .dropdown-menu {
        position: static;
        box-shadow: none;
        background-color: rgba(255,255,255,0.1);
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .chapter {
        padding: 1rem;
    }
    
    .code-content {
        max-height: 300px;
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .chapter-nav,
    .exercise button {
        display: none;
    }
    
    .answer {
        display: block !important;
    }
    
    .code-content {
        display: block !important;
        max-height: none !important;
    }
}

/* 语法高亮 - Prism.js 覆盖 */
pre[class*="language-"] {
    background: transparent;
    margin: 0;
}

code[class*="language-"] {
    background: transparent;
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter {
    animation: fadeIn 0.5s ease-out;
}

/* 进度条 */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background-color: var(--primary-color);
    transition: width 0.3s;
    z-index: 1001;
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: white;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.back-to-top.visible {
    opacity: 1;
}

.back-to-top:hover {
    background-color: #4f46e5;
}