/* Документация - основные стили */

/* Контейнер документации */
.documentation {
    display: flex;
    height: calc(100vh - 3rem);
    height: calc(100dvh - 3rem);
    overflow: hidden;
    gap: 0;
}

/* Левая панель - навигация */
.documentation_nav_container {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.documentation_nav_header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.nav_header_title {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.documentation_nav_body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

/* Дерево документации */
.tree_item {
    position: relative;
}

.tree_item_row {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 8px;
}

.tree_toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 4px;
    transition: background 0.15s;
}

.tree_toggle:hover {
    background: #f3f4f6;
}

.toggle_icon {
    transition: transform 0.2s;
    stroke: #6b7280;
}

.tree_item:not(.collapsed)>.tree_item_row .toggle_icon {
    transform: rotate(90deg);
}

.tree_spacer {
    width: 24px;
    flex-shrink: 0;
}

.tree_link {
    flex: 1;
    padding: 6px 10px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.15s;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree_link:hover {
    background: #f3f4f6;
    color: #111827;
}

.tree_link.active {
    background: #5c31ff;
    color: #fff;
}

.tree_children {
    padding-left: 20px;
    overflow: hidden;
}

.tree_item.collapsed>.tree_children {
    display: none;
}

/* Вложенность дерева - отступы */
.tree_children .tree_children .tree_link {
    font-size: 13px;
}

/* Правая панель - контент */
.documentation_container {
    flex: 1;
    background: #f9fafb;
    overflow: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 3rem);
    height: calc(100dvh - 3rem);
    box-sizing: border-box;
}

.documentation_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.doc_title {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.doc_actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 16px;
}

.doc_action_btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.doc_action_btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

.doc_action_btn.add_btn:hover {
    background: #5c31ff;
    color: #fff;
    border-color: #5c31ff;
}

.doc_action_btn.delete_btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Содержимое документации */
.documentation_txt {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.7;
    color: #374151;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.documentation_txt h1,
.documentation_txt h2,
.documentation_txt h3,
.documentation_txt h4,
.documentation_txt h5,
.documentation_txt h6 {
    color: #111827;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.documentation_txt h1:first-child,
.documentation_txt h2:first-child,
.documentation_txt h3:first-child {
    margin-top: 0;
}

.documentation_txt h1 {
    font-size: 24px;
}

.documentation_txt h2 {
    font-size: 20px;
}

.documentation_txt h3 {
    font-size: 18px;
}

.documentation_txt h4 {
    font-size: 16px;
}

.documentation_txt p {
    margin: 0 0 1em;
}

.documentation_txt ul,
.documentation_txt ol {
    margin: 0 0 1em;
    padding-left: 24px;
}

.documentation_txt li {
    margin-bottom: 0.5em;
}

.documentation_txt a {
    color: #5c31ff;
    text-decoration: none;
}

.documentation_txt a:hover {
    text-decoration: underline;
}

.documentation_txt img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
}

.documentation_txt pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.documentation_txt code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #dc2626;
}

.documentation_txt pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.documentation_txt table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.documentation_txt th,
.documentation_txt td {
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    text-align: left;
}

.documentation_txt th {
    background: #f9fafb;
    font-weight: 600;
}

.documentation_txt blockquote {
    border-left: 4px solid #5c31ff;
    margin: 16px 0;
    padding: 12px 20px;
    background: #f8f7ff;
    color: #4c4c6d;
}

/* Метаданные документа */
.documentation_meta {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.doc_updated {
    font-size: 12px;
    color: #9ca3af;
}

/* Пустое состояние */
.documentation_empty {
    text-align: center;
    padding: 80px 40px;
    background: #fff;
    border-radius: 8px;
}

.empty_icon {
    margin-bottom: 24px;
}

.documentation_empty h2 {
    margin: 0 0 12px;
    font-size: 24px;
    color: #374151;
}

.documentation_empty p {
    margin: 0 0 24px;
    color: #6b7280;
}

.create_doc_btn,
.create_first_doc_btn {
    display: inline-block;
    padding: 12px 24px;
    background: #5c31ff;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.15s;
}

.create_doc_btn:hover,
.create_first_doc_btn:hover {
    background: #4a27cc;
}

/* Пустое дерево */
.empty_tree_message {
    padding: 24px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.empty_tree_message p {
    margin: 0 0 16px;
}

/* Хлебные крошки */
.breadcrumb_link {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumb_link:hover {
    color: #5c31ff;
}

.breadcrumb_separator {
    margin: 0 8px;
    color: #d1d5db;
}

.breadcrumb_current {
    color: #374151;
    font-weight: 500;
}

/* Адаптивность */
@media (max-width: 900px) {
    .documentation {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 3rem);
        min-height: calc(100dvh - 3rem);
    }

    .documentation_nav_container {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        max-height: 300px;
    }

    .documentation_container {
        padding: 16px;
    }

    .documentation_txt {
        padding: 20px;
    }

    .doc_title {
        font-size: 22px;
    }
}

@media (max-width: 600px) {
    .documentation_header {
        flex-direction: column;
        gap: 12px;
    }

    .doc_actions {
        margin-left: 0;
    }

    .form_row {
        flex-direction: column;
        gap: 0;
    }

    .form_row .form_group.small {
        flex: 1;
    }
}

figure.image {
    display: table !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    margin: 12px auto;
}

figure.image img {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    display: block;
}

/* Для изображений с inline атрибутами width/height от TinyMCE */
.documentation_txt figure.image {
    display: table !important;
    width: auto !important;
    min-width: 0 !important;
    margin-left: auto;
    margin-right: auto;
}

.documentation_txt figure.image img,
.documentation_txt img[width][height] {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
}

/* Отключение эффекта grayscale при наведении для изображений в документации */
.documentation_txt img:hover,
.documentation_txt figure.image img:hover,
.documentation_txt .image:hover {
    -webkit-filter: none !important;
    filter: none !important;
}
