:root {
    --bg-color: #F9FAFB;
    --sidebar-bg: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --accent-purple: #8B5CF6;
    --accent-purple-light: #F5F3FF;
    --accent-pink: #EC4899;
    --note-bg: #EEF2FF;
    --note-border: #818CF8;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

body.sidebar-open {
    overflow: hidden;
}

.grecaptcha-badge {
    visibility: hidden;
}

.docs-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "header header" "sidebar main";
    min-height: 100vh;
}

.docs-header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 32px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.menu-toggle svg {
    width: 28px;
    height: 28px;
    color: var(--text-primary);
}

.search-wrapper {
    position: relative;
    width: 400px;
}

.search-wrapper svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 16px;
    font-family: var(--font-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.login-button {
    padding: 10px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background-image: linear-gradient(to right, #A855F7, #D946EF, #EC4899);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.2);
    white-space: nowrap;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.3);
}

.docs-sidebar {
    grid-area: sidebar;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    position: sticky;
    top: 73px;
    height: calc(100vh - 73px);
}

.docs-sidebar nav ul {
    list-style: none;
}

.docs-sidebar nav ul li {
    margin-bottom: 4px;
}

.docs-sidebar nav > ul > li {
    margin-bottom: 16px;
}

.docs-sidebar .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    display: block;
}

.docs-sidebar .nav-link {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.docs-sidebar .subsection {
    padding-left: 20px;
}

.docs-sidebar .nav-link:hover {
    background-color: var(--bg-color);
}

.docs-sidebar .nav-link.active {
    background-color: var(--accent-purple-light);
    color: var(--accent-purple);
    font-weight: 600;
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}

body.sidebar-open .menu-overlay {
    display: block;
}

.docs-main-content {
    grid-area: main;
    padding: 32px 48px;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 73px);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    list-style: none;
    margin-bottom: 24px;
    font-size: 14px;
}

.breadcrumbs li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs li a:hover {
    color: var(--accent-purple);
}

.breadcrumbs li::after {
    content: '/';
    color: var(--border-color);
    margin: 0 10px;
}

.breadcrumbs li:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumbs li:last-child::after {
    content: '';
}

.docs-main-content h1 {
    font-size: 36px;
    margin-bottom: 12px;
    border: none;
    padding: 0;
}

.docs-main-content h2 {
    font-size: 28px;
    margin-top: 48px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.docs-main-content h3 {
    font-size: 22px;
    margin-top: 32px;
}

.docs-main-content h1, .docs-main-content h2, .docs-main-content h3 {
    margin-bottom: 16px;
    font-weight: 700;
}

.docs-main-content p {
    margin-bottom: 20px;
    font-size: 16px;
}

.docs-main-content a {
    color: var(--accent-purple);
    text-decoration: none;
    font-weight: 500;
}

.docs-main-content ul {
    margin-bottom: 20px;
    padding-left: 20px;
}

.docs-main-content .note {
    background-color: var(--note-bg);
    border-left: 4px solid var(--note-border);
    padding: 16px 20px;
    margin: 24px 0;
    border-radius: 0 8px 8px 0;
}

.docs-main-content .note p {
    margin: 0;
    font-size: 15px;
    color: #374151;
}

.docs-main-content figure {
    margin: 32px 0;
}

.docs-main-content img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: box-shadow 0.2s;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.docs-main-content img:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.docs-main-content figcaption {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(23, 26, 31, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.image-modal-overlay.visible {
    display: flex;
}

.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    border-radius: 8px;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 40px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
}

/* === СТИЛИ ДЛЯ РЕЗУЛЬТАТОВ ПОИСКА === */
.search-results-container {
    display: none;
}

.search-result-item {
    display: block;
    background-color: #fff;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 16px;
    text-decoration: none;
    transition: box-shadow 0.2s, transform 0.2s;
}

.search-result-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.result-breadcrumbs {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.result-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.result-snippet {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Стиль для подсвеченного текста */
.search-result-item mark {
    background-color: var(--accent-purple-light);
    color: var(--accent-purple);
    font-weight: 600;
    padding: 1px 0;
    border-radius: 3px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* --- Стили для кнопок навигации --- */

.wiki-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 48px;
}

.nav-button {
    display: flex;
    align-items: center;
    padding: 16px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nav-button:hover {
    background-color: var(--accent-purple-light);
    border-color: var(--accent-purple);
}

.nav-button .arrow {
    font-size: 24px;
    line-height: 1;
    color: var(--text-secondary);
}

.nav-button .nav-text {
    display: flex;
    flex-direction: column;
}

/* Стили для левой кнопки (Назад) */
.nav-button.prev {
    grid-column: 1 / 2; /* Явно указываем, что это первая колонка */
}

.nav-button.prev .arrow {
    margin-right: 14px;
}

.nav-button.prev .nav-text {
    text-align: left;
}

/* Стили для правой кнопки (Вперед) */
.nav-button.next {
    grid-column: 2 / 3; /* Явно указываем, что это вторая колонка */
    text-align: right;
    justify-content: flex-end;
}

.nav-button.next .arrow {
    margin-left: 14px;
    order: 2; /* Меняем стрелку и текст местами */
}

.nav-button.next .nav-text {
    order: 1;
    text-align: right; /* Выравниваем текст по правому краю */
}


.nav-label {
    font-size: 13px;
    color: #6c757d; /* Второстепенный текст */
    margin-bottom: 4px;
}

.nav-title {
    font-size: 14px;
    font-weight: 500;
}

.docs-article {
    flex-grow: 1;
}

.docs-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    margin-top: 48px;
    width: 100%;
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-col {
    display: flex;
    flex-direction: column;
}

.footer-center {
    align-items: center;
}

span {
    color: var(--accent-purple);
}

@media (max-width: 1024px) {
    .docs-container {
        grid-template-columns: 1fr;
        grid-template-areas: "header" "main";
    }

    .docs-header {
        padding: 12px 16px;
    }

    .menu-toggle {
        display: block;
    }

    .search-wrapper {
        width: auto;
        flex-grow: 1;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-right: 1px solid var(--border-color);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }

    body.sidebar-open .docs-sidebar {
        transform: translateX(0);
    }

    .docs-main-content {
        padding: 24px 16px;
        min-height: calc(100vh - 65px);
    }

    .docs-main-content h1 {
        font-size: 30px;
    }

    .docs-main-content h2 {
        font-size: 24px;
    }

    .docs-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 24px;
        padding: 24px 0 0 0; /* Убираем боковые отступы, т.к. они есть у родителя */
        margin-top: 32px;
    }
}

@media (max-width: 640px) {
    .wiki-navigation {
        grid-template-columns: 1fr; /* На мобилках одна колонка */
    }

    .breadcrumbs {
        font-size: 12px;
    }
}