/* wiki.css */
.wiki-page-content {
    line-height: 1.6;
}

.wiki-page-content h1,
.wiki-page-content h2,
.wiki-page-content h3,
.wiki-page-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.wiki-page-content p {
    margin-bottom: 1rem;
}

.wiki-page-content code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.wiki-page-content pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
}

.wiki-page-content blockquote {
    border-left: 4px solid #007bff;
    padding-left: 1rem;
    margin-left: 0;
    color: #666;
    font-style: italic;
}

.wiki-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

.wiki-page-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.wiki-page-content table th,
.wiki-page-content table td {
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    text-align: left;
}

.wiki-page-content table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

/* Tree view styles */
.wiki-tree-item {
    transition: background-color 0.2s;
}

.wiki-tree-item:hover {
    background-color: #f8f9fa;
}

.wiki-tree-item.active {
    background-color: #e7f1ff;
    border-left: 3px solid #007bff;
}

/* Editor styles */
.toastui-editor-defaultUI {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.toastui-editor-defaultUI-toolbar {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ced4da;
}

/* Statistics cards */
.stat-card {
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    opacity: 0.8;
}

.stat-number {
    font-weight: bold;
    color: #333;
}

.stat-label {
    font-size: 0.9em;
}

/* Adicione ao seu CSS existente */
.badge.bg-success .fas.fa-star {
    font-size: 0.8em;
}

.wiki-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 10px 0;
}

.wiki-page-content pre {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
}

.wiki-page-content code {
    background-color: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Estilo para a badge de página inicial */
.badge.bg-success {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(25, 135, 84, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0);
    }
}

.toastui-editor-defaultUI {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.toastui-editor-defaultUI-toolbar {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ced4da;
    border-radius: 0.375rem 0.375rem 0 0;
}

.toastui-editor-contents {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
}

.toastui-editor-contents h1,
.toastui-editor-contents h2,
.toastui-editor-contents h3,
.toastui-editor-contents h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.toastui-editor-contents ul,
.toastui-editor-contents ol {
    padding-left: 2rem;
    margin-bottom: 1rem;
}

.toastui-editor-contents code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.toastui-editor-contents pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
}

.toastui-editor-contents blockquote {
    border-left: 4px solid #007bff;
    padding-left: 1rem;
    margin-left: 0;
    color: #6c757d;
    font-style: italic;
}

.toastui-editor-contents img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

/* No seu arquivo CSS principal */
.wiki-page-content {
    line-height: 1.6;
    font-size: 1rem;
}

.wiki-page-content h1,
.wiki-page-content h2,
.wiki-page-content h3,
.wiki-page-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #333;
}

.wiki-page-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.5rem;
}

.wiki-page-content h2 {
    font-size: 1.75rem;
}

.wiki-page-content h3 {
    font-size: 1.5rem;
}

.wiki-page-content p {
    margin-bottom: 1rem;
}

.wiki-page-content ul,
.wiki-page-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.wiki-page-content li {
    margin-bottom: 0.5rem;
}

.wiki-page-content li > ul,
.wiki-page-content li > ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.wiki-page-content code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

.wiki-page-content pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1rem 0;
}

.wiki-page-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.9em;
}

.wiki-page-content blockquote {
    border-left: 4px solid #007bff;
    padding-left: 1rem;
    margin-left: 0;
    color: #666;
    font-style: italic;
    background-color: #f8f9fa;
    padding: 0.5rem 1rem;
    border-radius: 0 5px 5px 0;
}

.wiki-page-content a {
    color: #007bff;
    text-decoration: none;
}

.wiki-page-content a:hover {
    text-decoration: underline;
}

.wiki-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 1rem 0;
}

.wiki-page-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.wiki-page-content table th,
.wiki-page-content table td {
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    text-align: left;
}

.wiki-page-content table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.wiki-page-content hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 2rem 0;
}

.wiki-page-content strong {
    font-weight: 600;
    color: #333;
}

.wiki-page-content em {
    font-style: italic;
    color: #555;
}

/* Adicionar ao seu CSS */
/* Transição suave para mostrar/esconder árvore */
.col-md-3 {
    transition: all 0.3s ease;
}

.col-md-9, .col-md-12 {
    transition: all 0.3s ease;
}

/* Ajustes para o Toast UI Editor em tela cheia */
.col-md-12 .toastui-editor-defaultUI {
    border-radius: 0.375rem;
}

/* Melhorar a visualização do editor em modo expandido */
@media (min-width: 768px) {
    .col-md-12 #wiki-toast-editor {
        min-height: 500px;
    }

    .col-md-12 .toastui-editor-defaultUI {
        height: 500px;
    }
}

/* Ajustes para o formulário em modo expandido */
.col-md-12 .card-body {
    padding: 1.5rem;
}

.col-md-12 .form-control,
.col-md-12 .form-select {
    font-size: 1rem;
}

/* Container principal do editor */
#wiki-toast-editor {
    position: relative;
    overflow: hidden;
    border-radius: 0.375rem;
}

/* Estilos específicos para o modo edição */
.col-md-12 #wiki-toast-editor {
    height: 500px !important; /* Altura fixa no modo expandido */
}

.col-md-12 .toastui-editor-defaultUI {
    height: 500px !important;
    display: flex;
    flex-direction: column;
}

/* Container do editor Toast UI */
.toastui-editor-defaultUI {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    overflow: hidden;
    display: flex !important;
    flex-direction: column !important;
    height: 100%;
}

/* Barra de ferramentas */
.toastui-editor-defaultUI-toolbar {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ced4da;
    border-radius: 0.375rem 0.375rem 0 0;
    flex-shrink: 0;
    z-index: 10;
}

/* Área de edição */
.toastui-editor-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.toastui-editor-main-container {
    height: 100% !important;
}

.toastui-editor-md-container,
.toastui-editor-ww-container {
    height: calc(100% - 40px) !important; /* Ajuste para toolbar */
    overflow-y: auto !important;
}

/* Ajustes para o modo de edição markdown */
.toastui-editor-md-container .toastui-editor {
    min-height: 300px !important;
    height: 100% !important;
}

/* Área de preview */
.toastui-editor-md-preview {
    overflow-y: auto !important;
    max-height: 100% !important;
}

/* Para garantir que o editor não ultrapasse em qualquer situação */
.toastui-editor {
    max-height: 100% !important;
    overflow: hidden !important;
}

/* Quando em layout expandido (modo edição) */
.col-md-12 .toastui-editor-defaultUI {
    max-height: 600px;
    min-height: 400px;
}

/* Ajustes responsivos */
@media (max-width: 768px) {
    .toastui-editor-defaultUI {
        height: 400px !important;
    }

    .col-md-12 .toastui-editor-defaultUI {
        height: 450px !important;
    }
}

/* Correção para o textarea fallback */
#wiki-fallback-editor {
    min-height: 300px;
    max-height: 500px;
    resize: vertical;
}

/* Garantir que o form não cause overflow */
#wiki-editor-form {
    overflow: visible;
}

/* Ajuste específico para o container do editor no card */
.card-body .toastui-editor-defaultUI {
    border: 1px solid #ced4da;
}

/* Melhorar a visualização do conteúdo Wiki */
.wiki-content-preview {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
}

/* Ajustes para modais */
.modal-body .wiki-content-preview {
    max-height: 50vh;
}

/* Garantir que o editor não cause scroll horizontal */
#wiki-toast-editor,
.toastui-editor-defaultUI,
.toastui-editor-main-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Correção para o modo de edição em telas pequenas */
@media (max-width: 768px) {
    .col-md-12 #wiki-toast-editor {
        height: 400px !important;
    }

    .col-md-12 .toastui-editor-defaultUI {
        height: 400px !important;
    }

    /* Ajustar formulário em mobile */
    .col-md-12 .card-body {
        padding: 1rem;
    }
}

/* Melhorar espaçamento nos formulários */
#wiki-editor-form .row {
    margin-bottom: 1.5rem;
}

#wiki-editor-form label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Ajuste para dropdowns */
.dropdown-menu {
    z-index: 1060; /* Garantir que fique acima do editor */
}

/* SYNTAX HIGHLIGHTING - ESTILOS PERSONALIZADADOS */

/* Container para blocos de código */
.wiki-page-content pre {
    position: relative;
    background-color: #f6f8fa !important;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.875em;
    line-height: 1.45;
}

/* Cabeçalho do bloco de código (mostra linguagem) */
.wiki-page-content pre::before {
    content: attr(data-language);
    position: absolute;
    top: 0;
    right: 0;
    background-color: #e1e4e8;
    color: #24292e;
    font-size: 0.75em;
    padding: 0.25em 0.75em;
    border-bottom-left-radius: 6px;
    border-top-right-radius: 5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Remove o cabeçalho se não tiver linguagem definida */
.wiki-page-content pre:not([data-language])::before {
    display: none;
}

/* Código dentro do pre */
.wiki-page-content pre code {
    background-color: transparent !important;
    padding: 0;
    border: none;
    border-radius: 0;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    display: block;
    overflow-x: auto;
}

/* Scrollbar personalizada para blocos de código */
.wiki-page-content pre::-webkit-scrollbar {
    height: 8px;
}

.wiki-page-content pre::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.wiki-page-content pre::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.wiki-page-content pre::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Cores específicas para highlight.js (tema customizado) */
.hljs {
    color: #24292e;
    background: transparent !important;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
    color: #d73a49;
    font-weight: bold;
}

.hljs-string,
.hljs-doctag {
    color: #032f62;
}

.hljs-comment,
.hljs-quote {
    color: #6a737d;
    font-style: italic;
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
    color: #005cc5;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
    color: #6f42c1;
    font-weight: bold;
}

.hljs-function,
.hljs-title.class_ {
    color: #6f42c1;
}

.hljs-type,
.hljs-class .hljs-title {
    color: #e36209;
}

.hljs-tag,
.hljs-name,
.hljs-attribute {
    color: #22863a;
}

.hljs-regexp,
.hljs-link {
    color: #032f62;
}

.hljs-symbol,
.hljs-bullet {
    color: #e36209;
}

.hljs-built_in,
.hljs-builtin-name {
    color: #005cc5;
}

.hljs-meta {
    color: #6a737d;
}

.hljs-deletion {
    background-color: #ffeef0;
    color: #b31d28;
}

.hljs-addition {
    background-color: #f0fff4;
    color: #22863a;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: bold;
}

/* Para código inline */
.wiki-page-content code:not(pre code) {
    background-color: rgba(27, 31, 35, 0.05);
    color: #e36209;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Ajustes para Toast UI Editor (modo preview) */
.toastui-editor-contents pre {
    background-color: #f6f8fa !important;
    border: 1px solid #e1e4e8 !important;
}

.toastui-editor-contents .hljs {
    background: transparent !important;
}

/* Dark mode opcional */
@media (prefers-color-scheme: dark) {
    .wiki-page-content pre {
        background-color: #161b22 !important;
        border-color: #30363d;
    }

    .wiki-page-content pre::before {
        background-color: #30363d;
        color: #c9d1d9;
    }

    .hljs {
        color: #c9d1d9;
    }

    .hljs-keyword,
    .hljs-selector-tag {
        color: #ff7b72;
    }

    .hljs-string {
        color: #a5d6ff;
    }

    .hljs-comment {
        color: #8b949e;
    }

    .wiki-page-content code:not(pre code) {
        background-color: rgba(110, 118, 129, 0.4);
        color: #ffa657;
    }
}

/* Botão de copiar código */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

pre:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: #f0f0f0;
}

/* ESTILOS PARA ÍNDICE DE CONTEÚDO */

/* Índice completo (Opção 1) */
#wiki-index-container {
    scroll-behavior: smooth;
}

.index-item {
    transition: all 0.2s ease;
}

.index-item-link {
    color: #212529;
    background-color: transparent;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.index-item-link:hover {
    background-color: rgba(13, 110, 253, 0.05);
    border-color: rgba(13, 110, 253, 0.2);
    text-decoration: none;
}

.index-item-link:active {
    background-color: rgba(13, 110, 253, 0.1);
}

.index-title {
    font-size: 1rem;
    line-height: 1.4;
}

.index-preview {
    font-size: 0.875rem;
    line-height: 1.3;
    color: #6c757d;
}

.index-slug {
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

.index-expand-btn {
    color: #6c757d;
    transition: transform 0.2s ease;
}

.index-expand-btn:hover {
    color: #0d6efd;
}

.index-expand-btn.expanded {
    transform: rotate(90deg);
}

.index-children {
    border-left: 2px dashed #dee2e6;
    padding-left: 1rem;
    margin-left: 0.5rem;
}

/* Índice compacto (Opção 2) */
.compact-index-item {
    font-size: 0.875rem;
    transition: background-color 0.15s ease;
}

.compact-index-item:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.compact-index-title {
    font-weight: 500;
}

.compact-expand-btn {
    color: #adb5bd;
    min-width: 16px;
}

.compact-expand-btn:hover {
    color: #495057;
}

.compact-expand-btn.expanded {
    transform: rotate(90deg);
}

.compact-children {
    border-left: 1px dashed #e9ecef;
}

/* Filtro de busca no índice */
.index-item.hidden {
    display: none !important;
}

.index-item.highlighted .index-item-link {
    background-color: #fff3cd;
    border-color: #ffc107;
}

/* Animações */
@keyframes fadeInIndex {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.index-item {
    animation: fadeInIndex 0.3s ease-out;
}

/* Scrollbar personalizada para container do índice */
#wiki-index-container::-webkit-scrollbar {
    width: 8px;
}

#wiki-index-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#wiki-index-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#wiki-index-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Estilo para o item de exportação PDF no dropdown */
.dropdown-item .fa-file-pdf.text-danger {
    color: #dc3545 !important;
}

.dropdown-item:hover .fa-file-pdf {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Feedback durante geração do PDF */
.pdf-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pdf-loading-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.pdf-loading-spinner {
    width: 3rem;
    height: 3rem;
    border-width: 0.25em;
}