/* ==================== МОДАЛЬНОЕ ОКНО ДОКУМЕНТАЦИИ ==================== */

.docs-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10070;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.docs-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.light-theme .docs-modal-overlay {
    background-color: rgba(255, 255, 255, 0.85);
}

body.modal-open-docs {
    overflow: hidden !important;
}

/* ===== Само окно ===== */
.docs-modal {
    width: 100%;
    max-width: 1100px;
    height: 90vh;
    max-height: 900px;
    background-color: #0a0a0a;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    transform: translateY(30px) scale(0.96);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.5s ease,
    border-color 0.5s ease;
}

.docs-modal-overlay.active .docs-modal {
    transform: translateY(0) scale(1);
}

body.light-theme .docs-modal {
    background-color: #ffffff;
    border: 1px solid #ddd;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ===== Заголовок ===== */
.docs-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    transition: border-color 0.5s ease;
}

body.light-theme .docs-modal-header {
    border-bottom: 1px solid #ddd;
}

.docs-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color 0.5s ease;
}

.docs-modal-title svg {
    width: 22px;
    height: 22px;
    color: #B7FF69;
}

body.light-theme .docs-modal-title {
    color: #000000;
}

body.light-theme .docs-modal-title svg {
    color: #480096;
}

.docs-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.docs-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.1);
}

.docs-modal-close svg {
    width: 20px;
    height: 20px;
}

body.light-theme .docs-modal-close {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000;
}

body.light-theme .docs-modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* ===== Тело с прокруткой ===== */
.docs-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 32px 40px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.docs-modal-body::-webkit-scrollbar {
    width: 10px;
}

.docs-modal-body::-webkit-scrollbar-track {
    background: #111;
}

.docs-modal-body::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 5px;
    border: 2px solid #111;
}

body.light-theme .docs-modal-body::-webkit-scrollbar-track {
    background: #f0f0f0;
}

body.light-theme .docs-modal-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border: 2px solid #f0f0f0;
}

/* ===== Типографика документации ===== */
.docs-content {
    max-width: 900px;
    margin: 0 auto;
    color: #D4D4D4;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    transition: color 0.5s ease;
}

body.light-theme .docs-content {
    color: #1a1a1a;
}

/* --- Заголовки --- */
.docs-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #B7FF69;
    margin: 0 0 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid rgba(183, 255, 105, 0.25);
    transition: color 0.5s ease, border-color 0.5s ease;
}

body.light-theme .docs-content h1 {
    color: #480096;
    border-bottom-color: rgba(72, 0, 150, 0.2);
}

.docs-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #7BD7DD;
    margin: 36px 0 16px;
    padding-top: 8px;
    transition: color 0.5s ease;
}

body.light-theme .docs-content h2 {
    color: #2F6F7A;
}

.docs-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #FFD467;
    margin: 24px 0 12px;
    transition: color 0.5s ease;
}

body.light-theme .docs-content h3 {
    color: #B48206;
}

.docs-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #EE67C6;
    margin: 20px 0 10px;
    transition: color 0.5s ease;
}

body.light-theme .docs-content h4 {
    color: #A00060;
}

/* --- Параграфы и списки --- */
.docs-content p {
    margin: 0 0 14px;
}

.docs-content ul,
.docs-content ol {
    margin: 0 0 16px;
    padding-left: 26px;
}

.docs-content li {
    margin-bottom: 6px;
}

.docs-content li > ul,
.docs-content li > ol {
    margin-top: 6px;
    margin-bottom: 6px;
}

/* --- Выделение --- */
.docs-content strong {
    color: #FFFFFF;
    font-weight: 600;
}

body.light-theme .docs-content strong {
    color: #000000;
}

.docs-content em {
    color: #FFD467;
    font-style: italic;
}

body.light-theme .docs-content em {
    color: #B48206;
}

/* --- Инлайн-код --- */
.docs-content code {
    font-family: 'Source Code Pro', 'Consolas', 'Monaco', monospace;
    font-size: 0.88em;
    padding: 2px 6px;
    background-color: rgba(183, 255, 105, 0.1);
    border: 1px solid rgba(183, 255, 105, 0.2);
    border-radius: 4px;
    color: #B7FF69;
    transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

body.light-theme .docs-content code {
    background-color: rgba(72, 0, 150, 0.08);
    border-color: rgba(72, 0, 150, 0.2);
    color: #480096;
}

/* ============================================================
   БЛОКИ КОДА С НУМЕРАЦИЕЙ СТРОК
   ============================================================
   Каждая строка внутри <code> — отдельный <span class="docs-code-line">
   с data-line="N". Номер рисуется псевдоэлементом ::before.

   🎯 Фон прозрачный — только шрифт, отступ и нумерация.
   ============================================================ */

.docs-content pre {
    margin: 14px 0;
    padding: 0;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow-x: auto;
    font-family: 'Source Code Pro', 'Consolas', 'Monaco', monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    color: #D4D4D4;
}

body.light-theme .docs-content pre {
    background: transparent !important;
    color: #1a1a1a;
}

/* Внутренний <code> — блочный контейнер для строк */
.docs-content pre code {
    display: block;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre;
}

/* ============================================================
   ОДНА СТРОКА КОДА С НОМЕРОМ
   ============================================================
   Используем CSS Grid:
     [колонка номеров 2.6em] [gap 14px] [колонка кода 1fr]
   Номер выравнивается по правому краю.
   ============================================================ */

.docs-content pre code.docs-code-with-lines {
    display: grid;
    grid-template-columns: 2.6em 1fr;
    column-gap: 14px;
    align-items: start;
}

.docs-content pre code.docs-code-with-lines .docs-code-line {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    min-height: 1.65em;
    white-space: pre;
}

/* Номер строки */
.docs-content pre code.docs-code-with-lines .docs-code-line::before {
    content: attr(data-line);
    display: block;
    grid-column: 1;
    text-align: right;
    color: rgba(183, 255, 105, 0.35);
    font-variant-numeric: tabular-nums;
    user-select: none;
    pointer-events: none;
    font-size: inherit;         /* 🎯 такой же, как у текста кода */
    line-height: inherit;
    padding-right: 2px;
}

body.light-theme .docs-content pre code.docs-code-with-lines .docs-code-line::before {
    color: rgba(72, 0, 150, 0.35);
}

/* Сам текст строки */
.docs-content pre code.docs-code-with-lines .docs-code-line > span,
.docs-content pre code.docs-code-with-lines .docs-code-line > * {
    grid-column: 2;
}

/* Если строка пустая — оставляем пустое место, чтобы высота сохранилась */
.docs-content pre code.docs-code-with-lines .docs-code-line.is-empty::after {
    content: '';
    grid-column: 2;
}

/* --- Таблицы --- */
.docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
}

.docs-content th {
    text-align: left;
    padding: 10px 14px;
    background-color: rgba(183, 255, 105, 0.1);
    color: #B7FF69;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.docs-content td {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}

.docs-content tr:last-child td {
    border-bottom: none;
}

.docs-content tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

body.light-theme .docs-content table {
    background-color: rgba(0, 0, 0, 0.02);
}

body.light-theme .docs-content th {
    background-color: rgba(72, 0, 150, 0.08);
    color: #480096;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme .docs-content td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.light-theme .docs-content tr:hover td {
    background-color: rgba(0, 0, 0, 0.03);
}

/* --- Разделитель --- */
.docs-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg,
    transparent,
    rgba(183, 255, 105, 0.3) 50%,
    transparent);
    margin: 32px 0;
}

body.light-theme .docs-content hr {
    background: linear-gradient(90deg,
    transparent,
    rgba(72, 0, 150, 0.25) 50%,
    transparent);
}

/* --- Блоки-примечания --- */
.docs-content .docs-note {
    margin: 16px 0;
    padding: 12px 16px;
    background-color: rgba(123, 215, 221, 0.08);
    border-left: 3px solid #7BD7DD;
    border-radius: 6px;
    font-size: 0.92rem;
}

body.light-theme .docs-content .docs-note {
    background-color: rgba(47, 111, 122, 0.06);
    border-left-color: #2F6F7A;
}

.docs-content .docs-warning {
    margin: 16px 0;
    padding: 12px 16px;
    background-color: rgba(255, 165, 0, 0.08);
    border-left: 3px solid #FFA500;
    border-radius: 6px;
    font-size: 0.92rem;
}

body.light-theme .docs-content .docs-warning {
    background-color: rgba(180, 95, 6, 0.06);
    border-left-color: #B45F06;
}

/* ===== Кнопка "Документация" в шапке редактора ===== */
.editor-modal-docs {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    background-color: rgba(123, 215, 221, 0.1);
    color: #7BD7DD;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    margin-right: 8px;
}

.editor-modal-docs:hover {
    background-color: rgba(123, 215, 221, 0.2);
    transform: scale(1.1);
    color: #B7FF69;
}

.editor-modal-docs svg {
    width: 20px;
    height: 20px;
    color: currentColor;
}

body.light-theme .editor-modal-docs {
    background-color: rgba(47, 111, 122, 0.08);
    color: #2F6F7A;
}

body.light-theme .editor-modal-docs:hover {
    background-color: rgba(47, 111, 122, 0.16);
    color: #480096;
}

/* ===== Адаптация для мобильных ===== */
@media (max-width: 768px) {
    .docs-modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .docs-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        transform: translateY(100%);
    }

    .docs-modal-overlay.active .docs-modal {
        transform: translateY(0);
    }

    .docs-modal-header {
        padding: 12px 16px;
    }

    .docs-modal-title {
        font-size: 1.05rem;
    }

    .docs-modal-title svg {
        width: 18px;
        height: 18px;
    }

    .docs-modal-body {
        padding: 16px 18px 32px;
    }

    .docs-content {
        font-size: 14px;
    }

    .docs-content h1 { font-size: 1.5rem; }
    .docs-content h2 { font-size: 1.25rem; margin-top: 26px; }
    .docs-content h3 { font-size: 1.05rem; }
    .docs-content h4 { font-size: 0.95rem; }

    .docs-content pre {
        font-size: 0.78rem;
    }

    .docs-content table {
        font-size: 0.8rem;
    }

    .docs-content th,
    .docs-content td {
        padding: 7px 10px;
    }
}

@media (max-width: 480px) {
    .docs-modal-body {
        padding: 14px 14px 28px;
    }

    .docs-content {
        font-size: 13px;
    }

    .docs-content h1 { font-size: 1.35rem; }
    .docs-content h2 { font-size: 1.15rem; }
}

/* ============================================================
   🆕 ПАНЕЛЬ НАВИГАЦИИ ПО РАЗДЕЛАМ
   ============================================================
   Структура модального окна документации:
     .docs-modal
       ├── .docs-modal-header       — заголовок с кнопками
       └── .docs-modal-main         — flex-контейнер
             ├── .docs-modal-nav    — боковая панель навигации
             └── .docs-modal-body   — тело с прокруткой
   ============================================================ */

/* ===== Основной контейнер ===== */
.docs-modal-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

/* ===== Кнопка-гамбургер в заголовке ===== */
.docs-modal-nav-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.docs-modal-nav-toggle:hover {
    background-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.08);
}

.docs-modal-nav-toggle svg {
    width: 18px;
    height: 18px;
}

body.light-theme .docs-modal-nav-toggle {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000;
}

body.light-theme .docs-modal-nav-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* ===== Боковая панель навигации ===== */
.docs-modal-nav {
    width: 260px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 10px 24px;
    background-color: #080808;
    border-right: 1px solid #222;
    scrollbar-width: thin;
    transition: width 0.25s ease, padding 0.25s ease,
    opacity 0.2s ease, border-color 0.25s ease;
}

.docs-modal-nav::-webkit-scrollbar {
    width: 6px;
}

.docs-modal-nav::-webkit-scrollbar-track {
    background: transparent;
}

.docs-modal-nav::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 3px;
}

body.light-theme .docs-modal-nav {
    background-color: #f8f8f8;
    border-right: 1px solid #e6e6e6;
}

body.light-theme .docs-modal-nav::-webkit-scrollbar-thumb {
    background: #ccc;
}

/* ===== Список пунктов ===== */
.docs-modal-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.docs-modal-nav-item {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: #b8b8b8;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.docs-modal-nav-item:hover {
    background-color: rgba(183, 255, 105, 0.08);
    color: #B7FF69;
}

.docs-modal-nav-item.active {
    background-color: rgba(183, 255, 105, 0.12);
    color: #B7FF69;
    border-left-color: #B7FF69;
    font-weight: 600;
}

body.light-theme .docs-modal-nav-item {
    color: #555;
}

body.light-theme .docs-modal-nav-item:hover {
    background-color: rgba(72, 0, 150, 0.06);
    color: #480096;
}

body.light-theme .docs-modal-nav-item.active {
    background-color: rgba(72, 0, 150, 0.1);
    color: #480096;
    border-left-color: #480096;
}

/* ===== Свёрнутое состояние (десктоп) ===== */
.docs-modal.nav-collapsed .docs-modal-nav {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    border-right-color: transparent;
    pointer-events: none;
}

/* Тело документации занимает всё освободившееся место */
.docs-modal-body {
    flex: 1;
    min-width: 0;
}

/* ===== Мобильные: панель превращается в горизонтальный скролл ===== */
@media (max-width: 768px) {
    .docs-modal-main {
        flex-direction: column;
    }

    .docs-modal-nav {
        width: 100%;
        max-width: 100%;
        flex-shrink: 0;
        padding: 8px 12px;
        border-right: none;
        border-bottom: 1px solid #222;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .docs-modal-nav::-webkit-scrollbar {
        display: none;
    }

    body.light-theme .docs-modal-nav {
        border-right: none;
        border-bottom: 1px solid #e6e6e6;
    }

    .docs-modal-nav-list {
        flex-direction: row;
        gap: 6px;
        min-width: max-content;
    }

    .docs-modal-nav-item {
        flex-shrink: 0;
        padding: 6px 12px;
        border-radius: 16px;
        border-left: none;
        border: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.78rem;
        white-space: nowrap;
        max-width: none;
    }

    .docs-modal-nav-item.active {
        border-left: none;
        border-color: rgba(183, 255, 105, 0.5);
        background-color: rgba(183, 255, 105, 0.15);
    }

    body.light-theme .docs-modal-nav-item {
        border: 1px solid rgba(0, 0, 0, 0.1);
    }

    body.light-theme .docs-modal-nav-item.active {
        border-color: rgba(72, 0, 150, 0.4);
    }

    /* На мобильных гамбургер не нужен — навигация и так в виде полосы */
    .docs-modal-nav-toggle {
        display: none;
    }

    /* Свёрнутое состояние на мобильных отключаем */
    .docs-modal.nav-collapsed .docs-modal-nav {
        width: 100%;
        padding: 8px 12px;
        opacity: 1;
        border-bottom-color: #222;
        pointer-events: auto;
    }
}

@media (max-width: 480px) {
    .docs-modal-nav {
        padding: 6px 10px;
    }

    .docs-modal-nav-item {
        padding: 5px 10px;
        font-size: 0.72rem;
    }
}

