/* 全局样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* 导航栏 */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.navbar-logo {
    width: 32px;
    height: 32px;
    transition: transform 0.3s ease;
}

.navbar-brand:hover .navbar-logo {
    transform: rotate(360deg) scale(1.1);
}

/* 文章卡片 */
.post-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.post-card h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.post-card h2 a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

.post-card h2 a:hover {
    color: #0d6efd;
}

.post-meta {
    font-size: 0.9rem;
    color: #6c757d;
}

.post-summary {
    color: #555;
    line-height: 1.6;
}

/* 文章详情页 */
.post-container {
    display: flex;
    gap: 2rem;
    position: relative;
}

.post-detail {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 0;
    transition: max-width 0.3s ease;
}

/* 当目录隐藏时，文章内容占据全部宽度 */
.post-container:has(.toc-sidebar.toc-hidden) .post-detail {
    max-width: 100%;
}

.post-title {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #333;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #333;
    margin-top: 2rem;
}

.post-content h1 {
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #0d6efd;
    scroll-margin-top: 80px;
}

.post-content h2 {
    font-size: 1.75rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    scroll-margin-top: 80px;
}

.post-content h3 {
    font-size: 1.5rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    scroll-margin-top: 80px;
}

.post-content h4,
.post-content h5,
.post-content h6 {
    scroll-margin-top: 80px;
}

.post-content p {
    margin-bottom: 1rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1rem 0;
}

.post-content code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.post-content pre {
    background-color: #f4f4f4;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

.post-content blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #666;
    font-style: italic;
}

.post-tags {
    margin-bottom: 1rem;
}

.post-tags .badge {
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

/* 目录样式 */
.toc-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toc-sidebar.toc-hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

.toc-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-toggle-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.toc-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.toc-nav {
    padding: 1rem 0.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

.toc-nav::-webkit-scrollbar {
    width: 6px;
}

.toc-nav::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.toc-nav::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.toc-nav::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.toc-placeholder {
    padding: 1rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

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

.toc-list .toc-list {
    padding-left: 1rem;
    margin-top: 0.25rem;
}

.toc-item {
    margin: 0.25rem 0;
}

.toc-link {
    display: block;
    padding: 0.4rem 0.75rem;
    color: #555;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    background-color: #f0f0f0;
    color: #0d6efd;
    padding-left: 1rem;
}

.toc-link.active {
    background-color: #e7f1ff;
    color: #0d6efd;
    border-left-color: #0d6efd;
    font-weight: 600;
}

/* 不同层级的目录项样式 */
.toc-level-1 .toc-link {
    font-weight: 600;
    font-size: 0.95rem;
}

.toc-level-2 .toc-link {
    font-size: 0.9rem;
}

.toc-level-3 .toc-link {
    font-size: 0.85rem;
    color: #666;
}

.toc-level-4 .toc-link,
.toc-level-5 .toc-link,
.toc-level-6 .toc-link {
    font-size: 0.8rem;
    color: #777;
}

/* 目录展开按钮（当目录隐藏时显示） */
.toc-show-btn {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toc-show-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.toc-show-btn i {
    font-size: 1.5rem;
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    right: 2rem;
    bottom: 6rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.3s ease;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.back-to-top i {
    font-size: 1.5rem;
}

/* 目录遮罩层 */
.toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1040;
}

.toc-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 评论区域 */
.comments-section {
    margin-top: 3rem;
}

.comment-form {
    background: white;
}

.comment-item {
    background: #f8f9fa;
}

.comment-header {
    font-size: 0.95rem;
}

.comment-content {
    color: #555;
    line-height: 1.6;
}

/* 侧边栏 */
.sidebar .card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar ul li {
    padding: 0.25rem 0;
}

.sidebar ul li a {
    text-decoration: none;
    color: #333;
    transition: color 0.2s;
}

.sidebar ul li a:hover {
    color: #0d6efd;
}

/* 分页 */
.pagination {
    justify-content: center;
}

/* 后台管理 */
.admin-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-section h1 {
    color: #333;
    margin-bottom: 1.5rem;
}

/* 登录页面 */
.card-header {
    font-weight: bold;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .toc-sidebar {
        width: 240px;
    }
}

@media (max-width: 992px) {
    .post-container {
        flex-direction: column;
    }
    
    .post-detail {
        width: 100%;
        max-width: 100%;
    }
    
    .toc-sidebar {
        position: fixed;
        right: 0;
        top: 0;
        width: 320px;
        max-width: 80%;
        height: 100vh;
        max-height: 100vh;
        z-index: 1050;
        box-shadow: -4px 0 12px rgba(0,0,0,0.2);
    }
    
    .toc-sidebar.toc-hidden {
        transform: translateX(100%);
    }
    
    .toc-nav {
        max-height: calc(100vh - 80px);
    }
    
    .toc-show-btn {
        right: 1rem;
        bottom: 1rem;
    }
    
    .back-to-top {
        right: 1rem;
        bottom: 5rem;
    }
}

@media (max-width: 768px) {
    .post-title {
        font-size: 2rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .post-content h1 {
        font-size: 1.75rem;
    }
    
    .post-content h2 {
        font-size: 1.5rem;
    }
    
    .post-content h3 {
        font-size: 1.25rem;
    }
    
    .post-card {
        padding: 1.5rem;
    }
    
    .admin-section {
        padding: 1rem;
    }
    
    .logo-main {
        max-width: 200px;
    }
    
    .logo-banner {
        padding: 2rem 1rem !important;
    }
    
    .logo-banner .lead {
        font-size: 0.9rem;
    }
    
    .navbar-logo {
        width: 28px;
        height: 28px;
    }
    
    .post-detail {
        padding: 1.5rem;
    }
    
    .toc-sidebar {
        width: 280px;
        max-width: 85%;
    }
    
    .toc-show-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .toc-show-btn i {
        font-size: 1.3rem;
    }
    
    .back-to-top {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        bottom: 4.5rem;
    }
    
    .back-to-top i {
        font-size: 1.3rem;
    }
}

/* 页脚 */
footer {
    margin-top: auto;
}

/* 按钮美化 */
.btn {
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
}

/* 表格美化 */
.table-responsive {
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 4px;
}

/* 搜索框样式 */
.navbar form input[type="text"] {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.navbar form input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.navbar form input[type="text"]:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.1);
}

.search-highlight {
    background-color: #fff3cd;
    padding: 2px 4px;
    border-radius: 2px;
}

/* 响应式搜索框 */
@media (max-width: 991px) {
    .navbar form {
        width: 100% !important;
        margin: 1rem 0;
    }
}

/* Logo 展示区 */
.logo-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.logo-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-10%, -10%) scale(1.1);
    }
}

.logo-main {
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    animation: float 3s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.logo-banner .lead {
    position: relative;
    z-index: 1;
    font-size: 1.1rem;
    color: #4b5563;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

/* Bootstrap Icons support - 已改用本地文件，在 base.html 中引入，此处注释掉 */
/* @import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css"); */

