/* Глобальные переменные и сброс стилей */
:root {
    --bg-color: #f0f2f5;
    --surface-color: #ffffff;
    --text-color: #333;
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --border-color: #e9ecef;
    --brand-font: 'Montserrat', sans-serif;
}
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Заставляет body занимать всю высоту экрана */
}

/* Структура страницы */
.page-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Основной контейнер растягивается, выталкивая футер вниз */
}
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Хедер */
.header {
    background: var(--surface-color);
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.6em;
    font-weight: 700;
    text-decoration: none;
    color: #1a2b40;
    font-family: var(--brand-font);
}
nav.main-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}
nav.main-nav a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
nav.main-nav a.btn { /* Стиль для любой ссылки-кнопки в навигации */
    color: #fff; /* Белый текст */
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}
nav.main-nav a.btn:hover {
    color: #fff; /* Белый текст при наведении */
    background-color: #0056b3; /* Более темный синий при наведении */
}
nav.main-nav a.btn-secondary {
    background-color: transparent;
    color: var(--secondary-color);
}
nav.main-nav a.btn-secondary:hover {
    background-color: var(--secondary-color);
    color: #fff;
}
.btn { 
    padding: 8px 18px; 
    border-radius: 20px; 
    text-decoration: none; 
    border: 1px solid transparent; 
    /* --- ДОБАВЬТЕ ЭТИ 3 СТРОКИ --- */
    display: inline-flex;   /* Включаем flex-режим для выравнивания */
    align-items: center;    /* Вертикально центрируем иконку и текст */
    gap: 8px;               /* Добавляем отступ между иконкой и текстом */
}

/* Основной макет: Сайдбар + Контент */
.main-layout {
    display: grid;
    grid-template-columns: 240px 1fr; /* Сайдбар 240px, остальное - контент */
    gap: 30px;
    padding-top: 30px;
    padding-bottom: 30px;
    flex-grow: 1; /* Эта секция будет расти, чтобы заполнить пространство до футера */
}

/* Сайдбар */
.sidebar .widget {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.sidebar h3 { margin-top: 0; font-size: 1.1em; }
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    text-decoration: none;
    color: #555;
    border-radius: 6px;
    transition: background-color 0.2s;
}
.sidebar-item:hover, .sidebar-item.active {
    background-color: #e9ecef;
    color: #000;
}
.sidebar-item i { width: 20px; text-align: center; color: var(--secondary-color); }
.sidebar-item.active i { color: var(--primary-color); }

/* Сетка постов */
.main-content h1 { margin-top: 0; }
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}
.post-card {
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}
.post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.post-card img { width: 100%; height: 200px; object-fit: cover; }
.post-content { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.post-category { font-size: 0.8em; color: var(--primary-color); font-weight: bold; text-transform: uppercase; }
.post-card h2 { font-size: 1.4em; margin: 10px 0; line-height: 1.3; }
.post-card p { color: #666; font-size: 1em; line-height: 1.6; flex-grow: 1; }
.post-date { font-size: 0.8em; color: #999; margin-top: 15px; display: block; }

/* Футер */
.footer {
    background: #343a40;
    color: #adb5bd;
    padding: 20px 0;
    text-align: center;
    font-size: 0.9em;
}
.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer a { color: #fff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* Адаптивность для мобильных */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr; /* Сайдбар и контент встают друг под другом */
    }
    .header .container { flex-direction: column; gap: 15px; }
    .footer .container { flex-direction: column; gap: 10px; }
}
@media (max-width: 500px) {
    .posts-grid { grid-template-columns: 1fr; } /* Один пост в ряд на самых маленьких экранах */
}

/* =========================================== */
/* === СТИЛИ ДЛЯ ТЕМНОЙ ТЕМЫ И ПЕРЕКЛЮЧАТЕЛЯ === */
/* =========================================== */

/* 1. Определяем переменные для темной темы */
body.dark-theme {
    --bg-color: #1a233a;
    --surface-color: #25314c;
    --text-color: #e0e0e0;
    --border-color: #3a4a6d;
}

/* 2. Стили для кнопки-переключателя */
.theme-switch-btn {
    background: none;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}
.theme-switch-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(15deg);
}

/* 3. Логика показа иконки */
.theme-switch-btn .fa-sun {
    display: none; /* Скрываем солнце по умолчанию */
}
body.dark-theme .theme-switch-btn .fa-sun {
    display: inline-block; /* Показываем солнце в темной теме */
}
body.dark-theme .theme-switch-btn .fa-moon {
    display: none; /* Скрываем луну в темной теме */
}

/* 4. Небольшие правки для темной темы */
body.dark-theme .logo { color: #fff; }
body.dark-theme nav.main-nav a { color: #a0b0d0; }
body.dark-theme nav.main-nav a:hover { color: #fff; }
body.dark-theme .sidebar-item { color: #c0c0c0; }
body.dark-theme .sidebar-item:hover, body.dark-theme .sidebar-item.active {
    background-color: #34495e;
    color: #fff;
}
body.dark-theme .post-card { box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
body.dark-theme .post-card h2 { color: #fff; }
body.dark-theme .post-card p { color: #a0b0d0; }

/* --- Стили для страницы отдельного поста --- */
.breadcrumbs {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 15px;
}
.breadcrumbs a {
    color: var(--primary-color);
    text-decoration: none;
}
.post-full {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 8px;
}
.post-title {
    font-size: 2.2em;
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.2;
}
.post-meta {
    color: #777;
    margin-bottom: 25px;
    font-size: 0.9em;
}
.post-image-full {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 25px;
}
.post-body {
    line-height: 1.7;
    font-size: 1.1em;
}
.post-body h2 {
    font-size: 1.6em;
    margin-top: 40px;
}
.post-body ul {
    padding-left: 20px;
}