/* 博客应用交互样式 */

/* 主题切换 */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-accent: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --accent-color: #007bff;
    --accent-hover: #0056b3;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-accent: #404040;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --border-color: #495057;
    --accent-color: #4dabf7;
    --accent-hover: #339af0;
    --success-color: #51cf66;
    --warning-color: #ffd43b;
    --error-color: #ff6b6b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.theme-toggle:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* 阅读进度条 */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--success-color));
    z-index: 1001;
    transition: width 0.1s ease;
}

/* 返回顶部按钮 */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.scroll-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-5px);
}

/* 图片懒加载 */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.loaded {
    opacity: 1;
}

/* 代码复制按钮 */
.copy-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

pre:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: var(--accent-hover);
}

/* 评论表单增强 */
.char-count {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* 消息提示 */
.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1002;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(10px);
}

.message-info {
    background: var(--accent-color);
}

.message-success {
    background: var(--success-color);
}

.message-warning {
    background: var(--warning-color);
}

.message-error {
    background: var(--error-color);
}

/* 分类筛选 */
.category-filter {
    margin-bottom: 30px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.category-filter a {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.category-filter a:hover,
.category-filter a.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* 文章卡片动画 */
.post-card {
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.post-card.highlighted {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.tag-cloud a {
    padding: 5px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    position: relative;
}

.tag-cloud a:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
    z-index: 10;
}

/* 搜索高亮 */
mark {
    background: yellow;
    color: black;
    padding: 2px 4px;
    border-radius: 3px;
}

[data-theme="dark"] mark {
    background: #ffd60a;
    color: #000;
}

/* 图片画廊 */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1003;
    cursor: pointer;
}

.image-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.image-container img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.close-button {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-button:hover {
    color: #ccc;
}

/* 目录 */
.table-of-contents {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.table-of-contents h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.table-of-contents li {
    margin-bottom: 8px;
}

.table-of-contents a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.table-of-contents a:hover {
    color: var(--accent-color);
}

.toc-h3 {
    padding-left: 0;
}

.toc-h4 {
    padding-left: 20px;
}

.toc-h5 {
    padding-left: 40px;
}

/* 响应式菜单 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

.nav-menu {
    display: flex;
    gap: 20px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        background: var(--bg-primary);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: left 0.3s ease;
        z-index: 998;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .menu-toggle.active {
        position: fixed;
        top: 20px;
        right: 80px;
        z-index: 999;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 选择文本样式 */
::selection {
    background: var(--accent-color);
    color: white;
}

::-moz-selection {
    background: var(--accent-color);
    color: white;
}

/* 焦点样式 */
:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* 按钮悬停效果 */
.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 表单增强 */
.form-group {
    margin-bottom: 20px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

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

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn 0.4s ease-out;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .theme-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .category-filter {
        justify-content: center;
    }
    
    .tag-cloud {
        justify-content: center;
    }
    
    .table-of-contents {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .message {
        width: 90%;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .image-container {
        max-width: 95%;
    }
    
    .copy-button {
        font-size: 10px;
        padding: 3px 6px;
    }
}