/* Override theme wrapper width to accommodate sidebar */
.wrapper {
    max-width: 1200px !important;
    width: 95%; /* Ensure it doesn't touch edges on smaller screens */
}

/* Layout Container */
.main-content-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    justify-content: center;
}

/* Main Content Area */
.main-content-wrapper .page-content {
    flex: 1;
    min-width: 0; /* Fix flex child overflow issues */
    max-width: 800px; /* Prevent it from getting too wide */
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    margin-top: 20px;
}

/* Sidebar Widgets */
.sidebar-widget {
    margin-bottom: 2rem;
    padding: 1.5rem;
    /* 使用主题定义的全局变量 */
    background: var(--bg-content-color); 
    color: var(--text-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    /* 让阴影也随模式变化：白天有阴影，黑夜无阴影 */
    box-shadow: var(--widget-shadow); 
}

html.dark .sidebar-widget {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: none;
}

.widget-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color, #007bff);
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* Recent Posts */
.recent-posts {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recent-posts li {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color, #eee);
}

.recent-posts li:last-child {
    border-bottom: none;
}

.recent-posts a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
    font-size: 0.95rem;
    line-height: 1.4;
    display: block;
}

.recent-posts a:hover {
    color: var(--primary-color, #007bff);
}

/* Categories List */
.categories-list {
    list-style: none;
    padding: 0;
}

.categories-list li {
    margin-bottom: 0.5rem;
}

.categories-list a {
    text-decoration: none;
    color: inherit;
}

.categories-list a:hover {
    text-decoration: underline;
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-link {
    background: var(--bg-secondary-color, #f4f4f4);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.85rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

html.dark .tag-link {
    background: #333;
}

.tag-link:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
}

/* Search Link */
.search-link {
    display: block;
    padding: 0.5rem;
    background: var(--bg-secondary-color, #f4f4f4);
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

html.dark .search-link {
    background: #333;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .main-content-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        margin-top: 40px;
    }

    .main-content-wrapper .page-content {
        max-width: 100%;
    }
}
