/* ==========================================
   前台样式 - 文章分享网站
   ========================================== */

:root {
    --sidebar-width: 300px;
    --header-height: 52px;
    --primary-color: #007bff;
    --sidebar-bg: #f8f9fa;
    --cat-active-color: #28a745;
    --article-icon-color: #4a90d9;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    background: #f5f6f8;
    margin: 0;
    font-size: 14px;
}

/* ===== Header ===== */
.site-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0 16px;
}

.site-logo {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-logo:hover { color: var(--primary-color); }
.site-logo i { font-size: 22px; color: var(--primary-color); }

.search-form .form-control { width: 220px; }

/* ===== Wrapper ===== */
.site-wrapper {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height) - 50px);
}

/* ===== Sidebar ===== */
.site-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 16px 0;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-title {
    padding: 0 16px 12px;
    font-size: 13px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 8px;
}

.cat-item { margin: 0; }

.cat-link {
    display: flex;
    align-items: center;
    padding: 7px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
    gap: 8px;
    position: relative;
}
.cat-link:hover {
    background: #f0fdf4;
    color: var(--cat-active-color);
}
.cat-link.active {
    background: #f0fdf4;
    color: var(--cat-active-color);
    font-weight: 600;
    border-right: 3px solid var(--cat-active-color);
}
.cat-link i:first-child { font-size: 15px; width: 18px; text-align: center; }
.cat-link span { flex: 1; }
.cat-arrow { font-size: 11px; color: #9ca3af; transition: transform 0.2s; }

.cat-children { padding-left: 12px; }
.depth-1 .cat-link { padding-left: 28px; font-size: 12.5px; }
.depth-2 .cat-link { padding-left: 44px; font-size: 12px; }

/* ===== Main Content ===== */
.site-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px 24px;
    max-width: 100%;
    min-width: 0;
}

/* ===== Article Group (首页) ===== */
.article-group {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.group-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.group-title a { color: inherit; text-decoration: none; }
.group-title a:hover { color: var(--primary-color); }

.group-more {
    font-size: 13px;
    color: #6b7280;
    text-decoration: none;
}
.group-more:hover { color: var(--primary-color); }

/* ===== Article Card ===== */
.article-card {
    border-bottom: 1px solid #f5f5f5;
}
.article-card:last-child { border-bottom: none; }

.article-card-link {
    display: flex;
    align-items: flex-start;
    padding: 12px 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    gap: 14px;
    border-radius: 6px;
}
.article-card-link:hover {
    background: #f8fafc;
}

.article-icon {
    width: 40px;
    height: 40px;
    background: #eff6ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.article-icon i {
    font-size: 20px;
    color: var(--article-icon-color);
}

.article-info { flex: 1; min-width: 0; }

.article-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px;
    line-height: 1.4;
}
.article-card-link:hover .article-title { color: var(--primary-color); }

.article-summary {
    font-size: 12.5px;
    color: #6b7280;
    margin: 0 0 6px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #9ca3af;
}
.article-meta i { margin-right: 3px; }

/* ===== Article Detail ===== */
.article-detail {
    background: #fff;
    border-radius: 8px;
    padding: 36px 42px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.article-detail-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 16px;
    line-height: 1.5;
    letter-spacing: -0.3px;
}

.article-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 13px;
    color: #8b95a5;
    padding-bottom: 20px;
    border-bottom: 1px solid #eef0f3;
}
.article-detail-meta a { color: var(--primary-color); text-decoration: none; }
.article-detail-meta i { margin-right: 4px; }

.article-tags { margin-top: 12px; margin-bottom: 8px; }
.article-tags .badge {
    font-weight: 400; font-size: 12px;
    padding: 4px 10px; border-radius: 12px;
}

/* ====== Article Content - Typography ====== */
.article-content {
    padding: 28px 0 20px;
    line-height: 2;
    color: #2c3e50;
    font-size: 15.5px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Paragraphs */
.article-content p {
    margin: 0 0 22px;
    text-align: justify;
}
.article-content p:last-child {
    margin-bottom: 0;
}
/* br tags should produce visible spacing */
.article-content br {
    display: block;
    content: "";
    margin-top: 10px;
}

/* Headings */
.article-content h1 {
    font-size: 24px; font-weight: 700; margin: 40px 0 16px;
    color: #1a1a1a; line-height: 1.4;
    padding-bottom: 10px; border-bottom: 2px solid var(--primary-color);
}
.article-content h2 {
    font-size: 21px; font-weight: 700; margin: 36px 0 14px;
    color: #1a1a1a; line-height: 1.4;
    padding-bottom: 8px; border-bottom: 1px solid #eef0f3;
    padding-left: 12px;
    border-left: 4px solid var(--primary-color);
}
.article-content h3 {
    font-size: 18px; font-weight: 600; margin: 30px 0 12px;
    color: #2c3e50; line-height: 1.4;
    padding-left: 10px;
    border-left: 3px solid #91d5ff;
}
.article-content h4 {
    font-size: 16px; font-weight: 600; margin: 24px 0 10px;
    color: #374151;
}
.article-content h5, .article-content h6 {
    font-size: 15px; font-weight: 600; margin: 20px 0 8px;
    color: #4b5563;
}
.article-content > h1:first-child,
.article-content > h2:first-child,
.article-content > h3:first-child {
    margin-top: 0;
}

/* Code */
.article-content pre {
    background: #f6f8fa; border: 1px solid #e8ecf0; border-radius: 8px;
    padding: 18px 20px; overflow-x: auto; font-size: 13px; line-height: 1.7;
    margin: 20px 0;
}
.article-content code {
    font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
}
.article-content p code, .article-content li code, .article-content td code {
    background: #f0f4f8; padding: 2px 7px; border-radius: 4px;
    font-size: 0.88em; color: #c7254e;
    border: 1px solid #e8ecf0;
}

/* Images */
.article-content img {
    max-width: 100%; height: auto;
    border-radius: 8px; margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Video / Audio */
.article-content video {
    max-width: 100%; border-radius: 8px; margin: 20px 0;
    background: #000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.article-content audio {
    width: 100%; margin: 16px 0;
}

/* Lists */
.article-content ul, .article-content ol {
    padding-left: 28px; margin: 14px 0 20px;
}
.article-content li {
    margin-bottom: 8px; line-height: 1.9;
}
.article-content li > ul, .article-content li > ol {
    margin: 6px 0 4px;
}

/* Blockquote */
.article-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 16px 20px;
    background: #f7f9fc;
    margin: 24px 0;
    color: #4b5563;
    border-radius: 0 8px 8px 0;
    line-height: 1.9;
}
.article-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Table */
.article-content table {
    width: 100%; border-collapse: collapse; margin: 20px 0;
    font-size: 14px;
}
.article-content th, .article-content td {
    border: 1px solid #e5e7eb; padding: 10px 14px; text-align: left;
}
.article-content th {
    background: #f8fafc; font-weight: 600; color: #374151;
}
.article-content tr:hover td {
    background: #fafbfc;
}

/* Horizontal Rule */
.article-content hr {
    border: none; border-top: 1px solid #eef0f3;
    margin: 32px 0;
}

/* Links */
.article-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.article-content a:hover {
    border-bottom-color: var(--primary-color);
}

/* Text emphasis */
.article-content strong {
    font-weight: 600;
    color: #1a1a1a;
}
.article-content mark {
    background: #fff8c5;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Attachments */
.article-attachments {
    border-top: 2px solid #eef0f3;
    padding-top: 24px;
    margin-top: 12px;
}
.article-attachments h5 {
    font-size: 16px; font-weight: 600; margin-bottom: 14px; color: #374151;
}
.article-attachments .list-group-item {
    font-size: 14px; transition: background 0.15s;
    border-radius: 6px;
}
.article-attachments .list-group-item:hover {
    background: #f0f7ff;
}

/* Article Nav (prev/next) */
.article-nav {
    padding: 24px 0;
    border-top: 2px solid #eef0f3;
    margin-top: 28px;
}
.article-nav a {
    color: #374151; text-decoration: none; display: block;
}
.article-nav a:hover { color: var(--primary-color); }
.article-nav a span { font-size: 14px; font-weight: 500; }

/* Related Articles */
.related-articles {
    padding-top: 24px;
    border-top: 2px solid #eef0f3;
    margin-top: 8px;
}
.related-articles h5 { font-size: 16px; margin-bottom: 14px; font-weight: 600; color: #374151; }
.related-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-radius: 6px; text-decoration: none; color: #374151;
    background: #f9fafb; margin-bottom: 6px; transition: all 0.15s;
}
.related-item:hover { background: #eff6ff; color: var(--primary-color); }
.related-title { font-size: 14px; }

/* Comments */
.comments-section {
    padding-top: 24px;
    border-top: 2px solid #eef0f3;
    margin-top: 24px;
}
.comments-section h5 { font-size: 16px; margin-bottom: 18px; font-weight: 600; color: #374151; }

.comment-item {
    display: flex; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid #f5f5f5;
}
.comment-avatar { font-size: 28px; color: #d1d5db; }
.comment-body { flex: 1; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment-header strong { font-size: 13px; }
.comment-content { font-size: 13px; color: #4b5563; line-height: 1.6; }

/* Category Header */
.category-header h4 {
    font-size: 20px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}

/* ===== Footer ===== */
.site-footer {
    padding: 16px 0;
    margin-left: var(--sidebar-width);
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .site-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1050;
    }
    .site-sidebar.show { transform: translateX(0); }
    .site-main { margin-left: 0; }
    .site-footer { margin-left: 0; }
}

@media (max-width: 767.98px) {
    .article-detail { padding: 20px 18px; }
    .article-detail-title { font-size: 22px; }
    .article-detail-meta { gap: 10px; font-size: 12px; }
    .article-content { font-size: 14.5px; line-height: 1.9; }
    .article-content h2 { font-size: 18px; margin: 28px 0 12px; }
    .article-content h3 { font-size: 16px; margin: 24px 0 10px; }
    .article-group { padding: 14px; }
}

/* ===== Breadcrumb ===== */
.breadcrumb { background: transparent; padding: 0; margin-bottom: 16px; }
.breadcrumb a { color: var(--primary-color); text-decoration: none; }
