/* ==========================================
   MetroDark Theme - Main Styles
   ========================================== */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --bg-card: #333337;
    --text-primary: #cccccc;
    --text-secondary: #999999;
    --text-muted: #666666;
    --accent: #007acc;
    --accent-hover: #1a8ad4;
    --border: #3e3e42;
    --success: #4ec9b0;
    --warning: #ce9178;
    --danger: #f44747;
    --font-mono: 'Consolas', 'Courier New', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    --radius: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.site-branding { flex: 1; }
.site-title { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.5px; }
.site-title a { color: var(--text-primary); transition: color 0.2s; }
.site-title a:hover { color: var(--accent); }
.site-description { font-size: 0.85rem; color: var(--text-secondary); margin-top: 4px; }

.site-nav ul { display: flex; list-style: none; gap: 4px; flex-wrap: wrap; }
.site-nav a {
    display: block;
    padding: 8px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}
.site-nav a:hover, .site-nav a.active { background: var(--bg-tertiary); color: var(--text-primary); }

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 32px;
    padding-top: 32px;
    padding-bottom: 64px;
}

.site-main { min-width: 0; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 24px; }

.widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.2s;
}
.widget:hover { border-color: rgba(0,122,204,0.3); }

.widget-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.widget ul { list-style: none; }
.widget li { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.widget li:last-child { border-bottom: none; }
.widget a { font-size: 0.9rem; color: var(--text-secondary); }
.widget a:hover { color: var(--accent); }

/* Search */
.search-form { display: flex; gap: 8px; }
.search-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
}
.search-btn:hover { background: var(--accent-hover); }

.search-form-large { display: flex; gap: 12px; margin-bottom: 32px; }
.search-input-large {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}
.search-input-large:focus { outline: none; border-color: var(--accent); }
.search-btn-large {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
}
.search-btn-large:hover { background: var(--accent-hover); }

/* Tag Cloud */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-item {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.tag-item:hover { background: var(--accent); color: white; }

/* Posts */
.page-title { font-size: 1.8rem; margin-bottom: 24px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 1.3rem; color: var(--text-secondary); }

.post-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 24px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.post-item:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0,122,204,0.1);
    transform: translateY(-2px);
}

.post-title { font-size: 1.35rem; margin-bottom: 10px; font-weight: 600; line-height: 1.4; }
.post-title a { color: var(--text-primary); transition: color 0.2s; }
.post-title a:hover { color: var(--accent); }

.post-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.post-meta span { display: inline-flex; align-items: center; gap: 4px; }

.post-category { margin-left: 8px; }
.post-category a {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.post-category a:hover { background: var(--accent); color: white; }

.post-excerpt { color: var(--text-secondary); margin-bottom: 16px; line-height: 1.7; font-size: 0.95rem; }

.read-more {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.read-more:hover { background: var(--accent); color: white; }

/* Post Detail */
.post-detail {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 40px 48px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.post-header { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.post-header .post-title { font-size: 2rem; line-height: 1.3; margin-bottom: 12px; }

.post-categories, .post-tags { margin: 16px 0; font-size: 0.9rem; }
.category-link, .tag-link {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.category-link:hover, .tag-link:hover { background: var(--accent); color: white; }

.post-content {
    font-size: 1.05rem;
    line-height: 1.9;
    word-wrap: break-word;
    color: var(--text-primary);
}
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
    margin: 2em 0 0.8em;
    color: var(--text-primary);
    line-height: 1.3;
}
.post-content h2 { font-size: 1.5rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.post-content h3 { font-size: 1.25rem; }
.post-content p { margin-bottom: 1.2em; }
.post-content pre {
    background: #1a1a1d;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 1.5em 0;
}
.post-content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
}
.post-content pre code { background: none; padding: 0; }
.post-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 12px 20px;
    margin: 1.5em 0;
    background: rgba(0,122,204,0.05);
    border-radius: 0 6px 6px 0;
    color: var(--text-secondary);
    font-style: italic;
}
.post-content img { border-radius: var(--radius); margin: 1em 0; }
.post-content table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.post-content th { background: var(--bg-tertiary); }
.post-content ul, .post-content ol { padding-left: 2em; margin: 1em 0; }

/* Post Navigation */
.post-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.post-navigation a {
    font-size: 0.9rem;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    transition: all 0.2s;
}
.post-navigation a:hover { background: var(--accent); color: white; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}
.page-link {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.page-link:hover { background: var(--accent); color: white; border-color: var(--accent); }
.page-info { color: var(--text-secondary); font-size: 0.9rem; }

/* Archive */
.archive-group { margin-bottom: 24px; }
.archive-year {
    font-size: 1.2rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.archive-list { list-style: none; }
.archive-item {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.archive-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    min-width: 100px;
}
.archive-item a { font-size: 0.95rem; }

/* Error */
.error-page { text-align: center; padding: 64px 0; }
.error-page h1 { font-size: 6rem; color: var(--text-muted); margin-bottom: 16px; }
.error-page p { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 24px; }
.btn {
    display: inline-block;
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}
.btn:hover { background: var(--accent-hover); color: white; }

.no-posts { text-align: center; padding: 48px 0; color: var(--text-muted); }

/* Footer */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.site-footer p { margin-bottom: 8px; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { color: var(--text-secondary); transition: color 0.2s; }
.site-footer a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
    .main-container { grid-template-columns: 1fr; }
    .header-inner { flex-direction: column; text-align: center; }
    .site-nav ul { justify-content: center; }
    .post-detail { padding: 24px 20px; }
    .post-header .post-title { font-size: 1.5rem; }
    .archive-item { flex-direction: column; gap: 4px; }
    .post-navigation { flex-direction: column; }
}
