/**
 * 博客系统 - 默认主题
 * 简约蓝紫色调
 */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #06b6d4;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #f9fafb;
    --bg-white: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

a { color: var(--primary-color); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }

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

.main-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    padding: 30px 0;
}

@media (max-width: 968px) { .main-wrapper { grid-template-columns: 1fr; } }

.header {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); }
.logo:hover { color: var(--primary-dark); }

.nav-menu { display: flex; list-style: none; gap: 30px; }

.nav-menu a {
    color: var(--text-color);
    font-weight: 500;
    padding: 5px 0;
    position: relative;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-menu a:hover::after, .nav-menu a.active::after { width: 100%; }

.mobile-menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-color); }

@media (max-width: 768px) {
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-white);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow);
        gap: 15px;
    }
    .nav-menu.active { display: flex; }
    .mobile-menu-toggle { display: block; }
}

.search-box { position: relative; margin-left: 20px; }

.search-box input {
    padding: 8px 35px 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 200px;
    transition: var(--transition);
}

.search-box input:focus { outline: none; border-color: var(--primary-color); width: 250px; }

.search-box button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
}

@media (max-width: 768px) {
    .search-box { margin: 15px 0 0 0; width: 100%; }
    .search-box input { width: 100%; }
    .search-box input:focus { width: 100%; }
}

.content-area { min-height: 500px; }

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
}

.post-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    transition: var(--transition);
}

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

.post-image { width: 100%; height: 250px; object-fit: cover; }

.post-content { padding: 25px; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.875rem;
    color: var(--text-light);
    flex-wrap: wrap;
}

.post-meta span { display: flex; align-items: center; gap: 5px; }

.post-category {
    background: var(--primary-color);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
}

.post-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 15px; line-height: 1.3; }

.post-title a { color: var(--text-color); }
.post-title a:hover { color: var(--primary-color); }

.post-excerpt { color: var(--text-light); margin-bottom: 20px; line-height: 1.8; }

.post-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.post-tag {
    background: var(--bg-color);
    color: var(--text-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
}

.post-tag:hover { background: var(--primary-color); color: white; }

.read-more { display: inline-flex; align-items: center; gap: 5px; margin-top: 15px; font-weight: 500; }

.post-detail {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}

.post-detail .post-image { border-radius: var(--radius); margin-bottom: 30px; }
.post-detail .post-title { font-size: 2rem; margin-bottom: 20px; }
.post-detail .post-meta { padding-bottom: 20px; border-bottom: 1px solid var(--border-color); margin-bottom: 30px; }

.post-body { font-size: 1.1rem; line-height: 1.9; }

.post-body h2, .post-body h3, .post-body h4 { margin: 30px 0 15px; color: var(--text-color); }
.post-body p { margin-bottom: 20px; }
.post-body img { border-radius: var(--radius); margin: 20px 0; }

.post-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-light);
    font-style: italic;
}

.post-body code { background: var(--bg-color); padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', monospace; }

.post-body pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 20px 0;
}

.post-body pre code { background: none; padding: 0; }

.sidebar { position: sticky; top: 100px; height: fit-content; }

.widget {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.widget-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid var(--border-color); }

.widget-list { list-style: none; }

.widget-list li { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.widget-list li:last-child { border-bottom: none; }

.widget-list a { color: var(--text-color); display: flex; justify-content: space-between; align-items: center; }
.widget-list a:hover { color: var(--primary-color); }

.widget-list .count { background: var(--bg-color); color: var(--text-light); padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

.tag-cloud a {
    background: var(--bg-color);
    color: var(--text-light);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.875rem;
}

.tag-cloud a:hover { background: var(--primary-color); color: white; }

.author-box {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-top: 40px;
    margin-bottom: 40px;
    width: 100%;
    box-sizing: border-box;
}

.author-avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.author-info { flex: 1; min-width: 0; }
.author-info h4, .author-info p { color: var(--text-color); font-size: 0.95rem; margin: 5px 0; }
.author-label { color: var(--text-light); font-weight: normal; }
.author-info h4 { margin-bottom: 10px; }

@media (max-width: 576px) { .author-avatar { width: 50px; height: 50px; } }

.comments-section { margin-top: 40px; padding-top: 40px; border-top: 1px solid var(--border-color); }
.comments-title { font-size: 1.5rem; margin-bottom: 30px; }

.comment-form { background: var(--bg-color); padding: 25px; border-radius: var(--radius); margin-bottom: 30px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; }

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary-color); }
.form-group textarea { resize: vertical; min-height: 120px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 576px) { .form-row { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--bg-color); color: var(--text-color); }
.btn-secondary:hover { background: var(--border-color); }

.comment-list { list-style: none; }

.comment-item { display: flex; gap: 15px; padding: 25px 0; border-bottom: 1px solid var(--border-color); }

.comment-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.comment-content { flex: 1; }

.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.comment-author { font-weight: 600; }
.comment-date { font-size: 0.875rem; color: var(--text-light); }
.comment-text { color: var(--text-light); line-height: 1.7; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }

.page-link {
    padding: 10px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    transition: var(--transition);
}

.page-link:hover, .page-link.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.page-dots { color: var(--text-light); }

.friend-links-section {
    background: var(--bg-color);
    padding: 20px 0;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
}

.friend-links-section h4 { font-size: 16px; color: var(--text-color); margin-bottom: 15px; font-weight: 600; }

.friend-links { display: flex; flex-wrap: wrap; gap: 15px; align-items: center; }

.friend-links a {
    color: var(--text-light);
    text-decoration: none;
    padding: 5px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.friend-links a:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.no-links { color: var(--text-light); font-size: 14px; }

.footer { background: var(--text-color); color: white; padding: 50px 0 20px; margin-top: 0; }

.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 40px; margin-bottom: 40px; }

.footer-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 10px; }
.footer-links a { color: #9ca3af; }
.footer-links a:hover { color: white; }

.footer-bottom { text-align: center; padding-top: 20px; border-top: 1px solid #374151; color: #9ca3af; }

.alert { padding: 15px 20px; border-radius: var(--radius); margin-bottom: 20px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.breadcrumb { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 0.875rem; color: var(--text-light); }
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary-color); }

.error-page { text-align: center; padding: 80px 20px; }
.error-code { font-size: 8rem; font-weight: 700; color: var(--primary-color); line-height: 1; }
.error-message { font-size: 1.5rem; color: var(--text-light); margin: 20px 0 30px; }

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    z-index: 999;
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--primary-dark); transform: translateY(-3px); }

.loading { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: white; animation: spin 1s ease-in-out infinite; }

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media print {
    .header, .sidebar, .footer, .comments-section, .back-to-top { display: none; }
    .main-wrapper { display: block; }
    .post-detail { box-shadow: none; padding: 0; }
}

.main-container { display: flex; gap: 30px; max-width: 1200px; margin: 0 auto; padding: 20px; }
.main-content { flex: 1; min-width: 0; }
.sidebar { width: 280px; flex-shrink: 0; }

.sidebar-widget { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.widget-title { font-size: 18px; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #1890ff; color: #333; }
.widget-title i { color: #ff4d4f; margin-right: 8px; }

.popular-posts { list-style: none; padding: 0; margin: 0; }
.popular-post-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.popular-post-item:last-child { border-bottom: none; }

.rank { width: 24px; height: 24px; border-radius: 50%; background: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; margin-right: 12px; flex-shrink: 0; }
.rank-1 { background: #ff4d4f; color: #fff; }
.rank-2 { background: #faad14; color: #fff; }
.rank-3 { background: #1890ff; color: #fff; }

.popular-post-link {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.popular-post-link:hover { color: #1890ff; }
.popular-post-views { font-size: 12px; color: #999; margin-left: 10px; flex-shrink: 0; }

@media (max-width: 768px) {
    .main-container { flex-direction: column; }
    .sidebar { width: 100%; }
}



/* ===== 暗夜模式样式 ===== */
[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --secondary-color: #22d3ee;
    --text-color: #e5e7eb;
    --text-light: #9ca3af;
    --bg-color: #111827;
    --bg-white: #1f2937;
    --border-color: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .header {
    background: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .logo {
    color: #818cf8;
}

[data-theme="dark"] .nav-menu a {
    color: #e5e7eb;
}

[data-theme="dark"] .mobile-menu-toggle {
    color: #e5e7eb;
}

[data-theme="dark"] .search-box input {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .search-box input::placeholder {
    color: #9ca3af;
}

[data-theme="dark"] .post-card,
[data-theme="dark"] .widget,
[data-theme="dark"] .post-detail {
    background: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .post-title a {
    color: #e5e7eb;
}

[data-theme="dark"] .post-tag,
[data-theme="dark"] .tag-cloud a {
    background: #374151;
    color: #9ca3af;
}

[data-theme="dark"] .tag-cloud a:hover,
[data-theme="dark"] .post-tag:hover {
    background: #6366f1;
    color: white;
}

[data-theme="dark"] .widget-list li {
    border-bottom-color: #374151;
}

[data-theme="dark"] .comment-item {
    border-bottom-color: #374151;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .form-group textarea::placeholder {
    color: #9ca3af;
}

[data-theme="dark"] .comment-form {
    background: #374151;
}

[data-theme="dark"] .page-link {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .friend-links-section {
    background: #1f2937;
    border-top-color: #374151;
}

[data-theme="dark"] .friend-links a {
    background: #374151;
    border-color: #4b5563;
    color: #9ca3af;
}

[data-theme="dark"] .footer {
    background: #0f172a;
}

[data-theme="dark"] .footer-grid {
    border-bottom-color: #1e293b;
}

[data-theme="dark"] .footer-bottom {
    border-top-color: #1e293b;
}

[data-theme="dark"] .alert-success {
    background: #064e3b;
    color: #a7f3d0;
    border-color: #065f46;
}

[data-theme="dark"] .alert-error {
    background: #7f1d1d;
    color: #fecaca;
    border-color: #991b1b;
}

[data-theme="dark"] .author-box {
    background: #374151;
}

[data-theme="dark"] .author-info h4,
[data-theme="dark"] .author-info p {
    color: #e5e7eb;
}

[data-theme="dark"] .popular-post-link {
    color: #e5e7eb;
}

[data-theme="dark"] .popular-post-item {
    border-bottom-color: #374151;
}

[data-theme="dark"] .rank {
    background: #374151;
    color: #9ca3af;
}

[data-theme="dark"] .rank-1,
[data-theme="dark"] .rank-2,
[data-theme="dark"] .rank-3 {
    background: #4f46e5;
    color: white;
}

[data-theme="dark"] .popular-post-views {
    color: #9ca3af;
}

[data-theme="dark"] .widget-title {
    color: #e5e7eb;
    border-bottom-color: #374151;
}

[data-theme="dark"] .sidebar-widget {
    background: #1f2937;
}

[data-theme="dark"] .popular-post-link:hover {
    color: #818cf8;
}

/* 主题切换按钮样式 */
.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-color);
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

[data-theme="dark"] .theme-toggle {
    color: #e5e7eb;
}

[data-theme="dark"] .theme-toggle:hover {
    background: #374151;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .theme-toggle {
        position: absolute;
        right: 60px;
        top: 50%;
        transform: translateY(-50%);
    }
}
