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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8edf2 100%);
    color: #1a1a1a;
    font-size: 17px;
    line-height: 1.8;
    padding: 20px;
}

.container {
    max-width: 1150px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    padding: 50px 80px;
    animation: fadeIn 0.8s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    border-bottom: 3px solid #3498db;
    padding-bottom: 30px;
    margin-bottom: 40px;
}

h1 {
    font-size: 2.2em;
    color: #1a1a1a;
    margin-bottom: 15px;
    line-height: 1.3;
}

.tag {
    display: inline-block;
    background: #ddf4ff;
    color: #0969da;
    border: 1px solid #54aeff;
    padding: 3.6px 10.8px;
    border-radius: 4px;
    font-size: 0.76em;
    font-weight: 500;
    margin-top: 10px;
    margin-right: 8px;
}

/* Кнопка "К списку" */
.back-btn {
    display: inline-block;
    padding: 6px 34px;
    background: #f3f4f6;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.855em;
    margin: 0 0 8px 0;
    transition: all 0.2s;
}

.back-btn:hover {
    background: #e5e7eb;
    color: #000;
}

.back-btn-bottom {
    margin-top: 30px;
    margin-bottom: 0;
}

h2 {
    font-size: 1.76em;
    color: #1a1a1a;
    margin: 35px 0 20px 0;
    padding-left: 15px;
    border-left: 4px solid #3498db;
}

h3 {
    font-size: 1.43em;
    color: #2a2a2a;
    margin: 25px 0 15px 0;
}

p {
    margin-bottom: 15px;
    color: #2a2a2a;
}

strong {
    color: #1a1a1a;
    font-weight: 600;
}

ul, ol {
    margin: 20px 0 20px 40px;
    color: #2a2a2a;
}

li {
    margin-bottom: 12px;
    padding-left: 5px;
}

/* ===== Инлайн код внутри текста ===== */
code {
    background: #f4f4f4;
    color: blue;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    font-weight: 460;
    border: 1px solid #e1e4e8;
}

/* ===== Контейнер для блоков кода ===== */
.code-container {
    position: relative;
    margin: 20px 0;
    max-width: 100%;
}

/* ===== Кнопка копирования кода ===== */
.copy-button {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px 5px 35px;
    background-color: #007bff;
    color: white;
    font-size: 14px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    margin-bottom: 5px;
    background-image: url('data:image/svg+xml;charset=UTF8,<svg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22><path%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M7%205C7%203.34315%208.34315%202%2010%202H19C20.6569%202%2022%203.34315%2022%205V14C22%2015.6569%2020.6569%2017%2019%2017H17V19C17%2020.6569%2015.6569%2022%2014%2022H5C3.34315%2022%202%2020.6569%202%2019V10C2%208.34315%203.34315%207%205%207H7V5ZM9%207H14C15.6569%207%2017%208.34315%2017%2010V15H19C19.5523%2015%2020%2014.5523%2020%2014V5C20%204.44772%2019.5523%204%2019%204H10C9.44772%204%209%204.44772%209%205V7ZM5%209C4.44772%209%204%209.44772%204%2010V19C4%2019.5523%204.44772%2020%205%2020H14C14.5523%2020%2015%2019.5523%2015%2019V10C15%209.44772%2014.5523%209%2014%209H5Z%22%20fill%3D%22white%22/></svg>');
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 20px 20px;
}

.copy-button.copied {
    background-image: url('data:image/svg+xml;charset=UTF8,<svg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22><path%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M18.0633%205.67387C18.5196%205.98499%2018.6374%206.60712%2018.3262%207.06343L10.8262%2018.0634C10.6585%2018.3095%2010.3898%2018.4679%2010.0934%2018.4957C9.79688%2018.5235%209.50345%2018.4178%209.29289%2018.2072L4.79289%2013.7072C4.40237%2013.3167%204.40237%2012.6835%204.79289%2012.293C5.18342%2011.9025%205.81658%2011.9025%206.20711%2012.293L9.85368%2015.9396L16.6738%205.93676C16.9849%205.48045%2017.607%205.36275%2018.0633%205.67387Z%22%20fill%3D%22white%22/></svg>');
}

.copy-button:hover {
    background-color: #0056b3;
}

/* ===== Блоки кода с раскраской ===== */
pre {
    margin: 0;
    padding: 0;
    line-height: 1.5;
    border: none;
    display: block;
    white-space: pre;
    overflow-x: auto;
    word-wrap: normal;
}

/* ===== Заголовок блока кода для сворачивания ===== */
.code-header {
    padding: 8px;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    border-radius: 3px 3px 0 0;
}

.code-header:hover {
    background: #d0d0d0;
}

/* ===== Кнопка сворачивания/разворачивания ===== */
.collapse-btn {
    font-size: 1.2em;
    font-weight: bold;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    color: #2e6df5;
    margin-right: 8px;
}

.collapse-btn::before {
    content: "-";
}

.collapse-btn.collapsed {
    color: #dc3545;
}

.collapse-btn.collapsed::before {
    content: "+";
}

.code-block {
    margin: 0;
    padding: 15px 20px;
    border: 1px solid #ccc;
    background-color: #f4f4f4;
    border-radius: 8px;
    max-width: 100%;
    overflow-x: auto;
    transition: max-height 0.3s ease-out;
    position: relative;
    white-space: nowrap;
    tab-size: 4;
}

/* Если есть заголовок - убираем верхние скругления */
.code-header + .code-block {
    border-radius: 0 0 8px 8px;
}

/* ===== Свернутое состояние блока кода ===== */
.code-block.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

/* ===== Автосворачивание для больших блоков (>20 строк) ===== */
.code-block.auto-collapsed {
    max-height: 400px;
    overflow: hidden;
    position: relative;
    border-radius: 0 0 8px 8px;
}

/* Для auto-collapsed блоков кнопка expand имеет верхние скругления */
.code-block.auto-collapsed + .expand-button {
    margin-top: 0;
}

.code-block.auto-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, rgba(244,244,244,0) 0%, rgba(244,244,244,0.9) 50%, rgba(244,244,244,1) 100%);
    pointer-events: none;
}

.expand-button {
    display: none;
    width: 100%;
    padding: 10px;
    background-color: #b8c9d9;
    color: #3d4a52;
    border: none;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    margin-top: -1px;
    position: relative;
}

.expand-button.visible {
    display: block;
}

.expand-button::before {
    content: '▼';
    margin-right: 8px;
    font-size: 12px;
}

.expand-button.expanded::before {
    content: '▲';
}

.expand-button:hover {
    background-color: #a0b3c5;
}

.code-block code {
    display: inline-block;
    color: blue;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 15.4px;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    white-space: pre;
}

/* ===== Раскраска синтаксиса 1С ===== */
.red {
    color: red;
}

.green {
    color: green;
}

.black {
    color: black;
}

.brown {
    color: brown;
}

.standart {
    color: blue;
}

.space {
    color: black;
}

.line {
    white-space: pre;
}

.footer {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #ecf0f1;
    text-align: center;
    color: #95a5a6;
    font-size: 0.95em;
}

/* ========== СТИЛИ ГЛАВНОЙ СТРАНИЦЫ (INDEX) ========== */

/* Body для главной страницы */
body.index-page {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8edf2 100%);
    padding: 20px;
    min-height: 100vh;
}

body.index-page .container {
    max-width: 1150px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    padding: 40px 60px;
}

/* Шапка главной страницы */
body.index-page .header {
    text-align: left;
    border-bottom: 3px solid #3498db;
}

.header-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.index-page .header h1 {
    font-size: 1.8em;
    margin: 0;
}

.results-count {
    font-size: 0.9em;
    color: #666;
    margin: 0;
}

/* Фильтры */
.filters {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    font-size: 0.65em;
    color: #888;
    margin-bottom: 3px;
    font-weight: 500;
}

.filter-group select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.75em;
    background: white;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: #3498db;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-self: flex-end;
    padding-bottom: 1px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.75em;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

/* Список статей */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article-item {
    padding: 15px 20px;
    border-left: none;
    transition: all 0.2s;
    position: relative;
}

.article-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 90%;
    width: 3px;
    background: linear-gradient(to bottom,
        #e8e8e8 0%,
        #e8e8e8 40%,
        #3498db 40%,
        #3498db 60%,
        #e8e8e8 60%,
        #e8e8e8 100%);
    transition: all 0.2s;
}

.article-item:hover {
    background: #f8f9fa;
}

.article-item:hover::before {
    background: #3498db;
}

.article-meta {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 3px;
}

.article-title {
    font-size: 1.09em;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-title a {
    color: #1a1a1a;
    text-decoration: none;
}

.article-title a:hover {
    color: #3498db;
}

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

/* Теги на главной странице (серые) */
body.index-page .tag {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 2px 7px;
    font-size: 0.665em;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 15px 0;
}

/* Ссылки в пагинации */
.pagination a {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

/* Троеточия как текст (не кнопка) */
.page-dots {
    color: #999;
    font-size: 0.85em;
    padding: 0 4px;
    user-select: none;
}


.pagination-top {
    margin-bottom: 20px;
    border-bottom: 1px solid #e8e8e8;
}

.pagination-bottom {
    margin-top: 30px;
    border-top: 1px solid #e8e8e8;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

.page-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
    transform: none;
    box-shadow: none;
}

.page-btn.disabled {
    color: #ccc;
    cursor: not-allowed;
}

.page-btn.disabled:hover {
    border-color: #ddd;
    color: #ccc;
}

/* ========== АДАПТИВНОСТЬ ========== */

/* Адаптивность для страницы статьи */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.3em;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.3em;
    }

    h3 {
        font-size: 1.1em;
    }

    .header {
        padding-bottom: 20px;
        margin-bottom: 20px;
    }

    .tag {
        padding: 3px 8px;
        font-size: 0.75em;
    }

    .back-btn {
        padding: 5px 20px;
        font-size: 0.8em;
    }

    .back-btn-bottom {
        margin-top: 20px;
    }

    p, li {
        font-size: 0.95em;
    }

    .code-block {
        padding: 10px;
        font-size: 0.85em;
    }

    .code-block code {
        font-size: 13px;
    }

    .copy-button {
        padding: 4px 8px 4px 28px;
        font-size: 12px;
        background-size: 16px 16px;
    }

    ul, ol {
        margin-left: 20px;
    }

    /* Адаптивность для главной страницы */
    body.index-page .container {
        padding: 15px;
    }

    .header-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    body.index-page .header h1 {
        font-size: 1.3em;
    }

    .filters-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .filter-group {
        min-width: auto;
    }

    .filter-buttons {
        align-self: end;
        justify-content: flex-end;
    }

    .article-tags {
        display: none;
    }

    .article-meta {
        font-size: 0.75em;
    }

    .article-title {
        font-size: 1em;
    }

    .pagination .page-btn {
        padding: 5px 9px;
        font-size: 0.75em;
    }

    /* Уменьшаем стрелки на мобильном */
    .pagination .page-btn.nav-btn {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    /* Скрываем первую страницу и троеточия на мобильном */
    .pagination .page-first,
    .pagination a:has(.page-first),
    .pagination .page-dots {
        display: none;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 10px;
        border-radius: 10px;
    }

    body.index-page .container {
        padding: 10px;
    }

    /* Кнопка сброса рядом с отраслью */
    .filter-buttons {
        justify-content: flex-end;
    }

    /* Уменьшаем пагинацию */
    .pagination {
        gap: 5px;
        padding: 10px 0;
    }

    .pagination .page-btn {
        padding: 4px 8px;
        font-size: 0.7em;
    }

    .pagination .page-btn.nav-btn {
        padding: 5px 9px;
        font-size: 0.75em;
    }
}
