/* ==========================================================================
   ATENAVAULT - ESTILOS DA INTERFACE WEB
   ========================================================================== */

/* 1. RESET GLOBAL E LAYOUT PRINCIPAL */
html, body {
    margin: 0;
    padding: 0;
    height: 100%; 
    width: 100%;
    overflow: hidden; 
    background-color: #f8f9fa; 
    box-sizing: border-box;
}

.vault-app-container {
    display: flex;
    height: 100%; 
    width: 100%;
    overflow: hidden;
    border-bottom: 1px solid #ced4da; 
    box-sizing: border-box;
    flex-direction: row-reverse; /* Inverte: sidebar agora fica na direita */
}

/* ==========================================================================
   2. BARRA LATERAL E NAVEGAÇÃO
   ========================================================================== */
.vault-sidebar { 
    width: 240px; 
    min-width: 240px;
    max-width: 280px;
    height: 100%; 
    display: flex;
    flex-direction: column;
    overflow: hidden !important; 
    border-left: 1px solid #dee2e6; 
    background-color: #f8f9fa; 
    padding: 12px; 
    transition: width 0.3s ease, padding 0.3s ease; 
    position: relative;
    order: 3; /* Fica na direita agora */
    flex-shrink: 0;
}

.vault-sidebar.collapsed {
    margin-left: -280px;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-right: none;
}

.sidebar-header { flex-shrink: 0; }
.sidebar-body { flex-grow: 1; overflow-y: auto; padding-right: 5px; margin-top: 5px; }
.sidebar-body::-webkit-scrollbar { width: 5px; }
.sidebar-body::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 4px; }

/* Resizer da sidebar (à direita agora) */
#sidebar-resizer {
    position: absolute;
    top: 0;
    left: 0; /* Agora está à esquerda da sidebar direita */
    width: 5px;
    height: 100%;
    cursor: col-resize;
    background-color: transparent;
    z-index: 100;
    transition: background-color 0.2s ease;
}
#sidebar-resizer:hover, #sidebar-resizer.resizing { background-color: #0d6efd; }

.tree-toolbar { 
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    background-color: #ffffff;
}

.btn-tree-tool { 
    background: transparent !important; 
    border: 1px solid #e9ecef !important;
    color: #6c757d !important;
    padding: 4px 6px !important;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-tree-tool:hover { 
    background-color: #f0f2f5 !important; 
    border-color: #ced4da !important;
    color: #495057 !important;
}

.btn-tree-tool.active { 
    background-color: #0d6efd !important; 
    border-color: #0d6efd !important;
    color: #ffffff !important;
}

.tree-tool-sep {
    width: 1px;
    height: 18px;
    background-color: #dee2e6;
    margin: 0 2px;
}

.tree-node { 
    width: 100%;
    display: flex;
    flex-direction: column;
}

.file-item { 
    cursor: pointer; 
    padding: 6px 8px; 
    border-radius: 3px; 
    transition: all 0.1s ease; 
    border: 1px solid transparent; 
    margin-bottom: 2px;
    font-size: 0.85rem;
    color: #495057;
}

.file-item:hover { 
    background-color: #f0f2f5; 
    border-color: #e9ecef;
    color: #212529;
}

.file-item.selected { 
    background-color: #e7f1ff; 
    color: #0d6efd; 
    font-weight: 600;
    border-color: #0d6efd;
}


/* ==========================================================================
   PAINEL DE METADADOS ATENAHUB (sidebar direita)
   ========================================================================== */
/* ==========================================================================
   PAINEL DE METADADOS (DIREITA)
   ========================================================================== */

.vault-metadata-panel {
    width: 260px;
    min-width: 240px;
    max-width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #dee2e6;
    background-color: #f8f9fa;
    overflow: hidden;
    flex-shrink: 0;
    order: 3;
}

.meta-header {
    background-color: #ffffff;
    flex-shrink: 0;
}

.meta-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.meta-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
}

.meta-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.meta-input {
    width: 100%;
    font-size: 0.8rem;
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #ffffff;
    color: #212529;
}

.meta-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.meta-input[readonly] {
    background-color: #f8f9fa;
    color: #495057;
}

.meta-value {
    padding: 6px 8px;
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    color: #495057;
}

.meta-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: #0d6efd;
    color: #ffffff;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.meta-tag-close {
    cursor: pointer;
    opacity: 0.7;
}

.meta-tag-close:hover {
    opacity: 1;
}

/* ==========================================================================
   3. ÁREA PRINCIPAL E PAINÉIS DE EDIÇÃO
   ========================================================================== */
.vault-main-area {
    flex: 1; 
    display: flex;
    flex-direction: row;
    height: 100%;
    min-width: 0;
    order: 1; /* Fica na esquerda/centro */
}

#editors-container {
    display: flex;
    flex: 1;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    width: 100%;
}

/* Container da navegação de arquivos (novo painel esquerdo) */
.vault-navigator {
    width: 340px;
    min-width: 280px;
    max-width: 450px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dee2e6;
    background-color: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
    order: 1;
}

.vault-navigator .sidebar-header {
    flex-shrink: 0;
    border-bottom: 1px solid #e9ecef;
}

.vault-navigator .tree-toolbar {
    flex-shrink: 0;
    border-bottom: 1px solid #e9ecef;
    overflow-x: auto;
}

.vault-navigator #tree-local {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Container dos editores (novo painel central) */
.vault-editor-area {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    order: 2;
}

/* Dashboard quando nenhum arquivo está aberto */
#library-dashboard {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: #f9fafb;
    overflow-y: auto;
}

/* Melhor espaçamento do search input no navigator */
.vault-navigator .view-mode-bar {
    flex-shrink: 0;
}

.vault-navigator .input-group-sm .form-control-sm {
    font-size: 0.75rem !important;
    height: 24px !important;
}

/* Melhor estilo do badge de modo */
.vault-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: #f0f2f5;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.vault-mode-badge:hover {
    background-color: #e9ecef;
}

/* Container elástico do painel - divide a tela sozinho ou lado a lado */
.editor-pane { 
    display: flex;
    flex-direction: column;
    flex: 1; 
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

/* Estilização da barra consolidada do editor */
.editor-pane > .d-flex {
    padding: 6px 12px !important; /* Mais compacta para ganhar espaço */
    background-color: #ffffff;
    min-height: 45px;
    z-index: 100;
}

/* Garante que o input do nome do arquivo não tenha bordas e pareça um título */
.editor-pane input.form-control-sm {
    box-shadow: none !important;
    outline: none !important;
}

/* Remove o espaçamento entre a toolbar e o cabeçalho */
.editor-toolbar {
    border-top: none !important;
}
/* ==========================================================================
   4. O EDITOR DE TEXTO (EASYMDE E CODEMIRROR)
   ========================================================================== */
/* O container principal do editor agora não rola */
.EasyMDEContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; 
    overflow: hidden; /* Fundamental para travar a barra no topo */
}

/* A barra de ferramentas fica estática no topo do container */
.editor-toolbar { 
    border: none !important; 
    border-bottom: 1px solid #f0f0f0 !important;
    background-color: #ffffff; 
    padding: 5px 15px; 
    border-radius: 0 !important; 
    opacity: 0.8; 
    transition: opacity 0.2s;
    /* Remover o position: sticky e z-index problemáticos */
    flex-shrink: 0; /* Impede a barra de encolher */
}
.editor-toolbar:hover { opacity: 1; }
.editor-toolbar button { width: 28px !important; height: 28px !important; margin: 2px !important; border-radius: 4px; }
.editor-toolbar button.active, .editor-toolbar button:hover { background: #f0f0f0 !important; border-color: transparent !important; }

/* O CodeMirror ocupa o resto do espaço disponível */
.CodeMirror { 
    flex: 1 !important; 
    height: auto !important; /* Importante: mudar de 100% para auto */
    min-height: 0 !important;
    border: none !important; 
    border-radius: 0 !important; 
    font-size: 15px !important; 
    line-height: 1.6;
    padding: 0; /* Padding movido para a área de rolagem */
    background-color: #ffffff !important;
    font-family: 'Consolas', 'Courier New', monospace !important;
    overflow: hidden !important; /* Esconde a rolagem do wrapper externo */
}

.CodeMirror .cm-header { font-family: 'Consolas', 'Courier New', monospace !important; }

/* A área de texto em si, onde a rolagem DE FATO acontece */
.CodeMirror-scroll {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100% !important; /* Preenche o CodeMirror */
    padding: 0 20px 40px 20px !important; /* Padding lateral movido para cá */
    box-sizing: border-box;
}

/* Garante o espaço físico largo para a barra de rolagem */
.CodeMirror-vscrollbar {
    width: 16px !important; 
    display: block !important; 
    overflow-y: scroll !important;
    right: 0 !important; /* Posiciona a barra corretamente */
}

/* ==========================================================================
   5. MODO DE LEITURA E PREVIEW LADO A LADO DO EASYMDE
   ========================================================================== */

/* Preview em tela inteira */
.editor-preview-active { 
    background-color: #ffffff !important; 
    padding: 20px 40px !important; 
    overflow-y: auto !important; 
    height: 100% !important; 
}
.editor-preview-active::before { 
    content: 'LEITURA'; 
    position: absolute; top: 15px; right: 20px; 
    background-color: #f8f9fa; color: #adb5bd; 
    padding: 2px 10px; border-radius: 4px; 
    font-size: 0.8rem; font-weight: bold; border: 1px solid #e9ecef;
    z-index: 100; pointer-events: none; 
}

/* Modo Lado a Lado (Código na esquerda, Visualização na direita) */
.CodeMirror.CodeMirror-sided {
    flex: 1 1 50% !important; /* Ajuste para Flexbox */
    width: 50% !important;
    height: 100% !important; /* Preenche a altura */
    box-sizing: border-box;
}

.editor-preview-side { 
    flex: 1 1 50% !important; /* Ajuste para Flexbox */
    width: 50% !important;
    height: 100% !important; /* Preenche a altura */
    box-sizing: border-box;
    border-radius: 0 !important; 
    border: none !important; 
    border-left: 1px solid #dee2e6 !important; 
    background-color: #ffffff !important; 
    padding: 20px 30px !important;
    overflow-y: auto !important; /* Adiciona rolagem independente ao preview */
}

/* ==========================================================================
   6. ROLAGEM GLOBAL E SCROLLBAR DO WINDOWS
   ========================================================================== */

/* Garante o espaço físico largo para a barra do editor */
.CodeMirror-vscrollbar {
    width: 16px !important; 
    display: block !important; 
    overflow-y: scroll !important;
}

/* Personalização global da barra do navegador */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: #f8f9fa; border-left: 1px solid #e9ecef; }
::-webkit-scrollbar-thumb { background-color: #adb5bd; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background-color: #6c757d; }


/* ==========================================================================
   7. EXTRAS E RESPONSIVIDADE
   ========================================================================== */
.cloud-header { 
    background: transparent; padding: 5px 0; font-weight: bold; 
    font-size: 0.75rem; text-transform: uppercase; color: #6c757d; letter-spacing: 0.5px;
    margin-bottom: 5px; margin-top: 10px; border-bottom: 1px solid #e9ecef;
}
.dropdown-toggle-no-caret::after { display: none !important; }
/* Oculta botões de nuvem opt-in. Precisa de !important para vencer o .d-flex
   do Bootstrap (que também é !important); vault.css carrega depois do bootstrap. */
.cloud-hidden { display: none !important; }
.CodeMirror-dialog { 
    background: #f8f9fa !important; 
    color: #212529 !important; 
    border-bottom: 2px solid #0d6efd !important; 
    padding: 10px 15px !important; 
    font-size: 0.9rem !important; 
    /* Novas regras para alinhar a caixa e o contador lado a lado: */
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap;
}

.CodeMirror-dialog input { 
    border: 1px solid #ced4da !important; 
    border-radius: 4px !important; 
    padding: 4px 8px !important; 
    outline: none !important; 
}

/* Estilo da etiqueta do contador de busca */
#cm-search-count {
    font-size: 0.8rem;
    padding: 5px 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    white-space: nowrap; /* Evita que o texto "encontrado(s)" quebre no meio */
}

@media (max-width: 1200px) {
    .vault-navigator {
        max-width: 380px;
    }
    .vault-sidebar {
        max-width: 220px;
    }
}

@media (max-width: 992px) {
    .vault-navigator {
        width: 260px;
        min-width: 200px;
    }
    .vault-metadata-panel {
        width: 220px;
        min-width: 180px;
    }
    .vault-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .vault-navigator {
        width: 220px;
        min-width: 160px;
    }
    .vault-metadata-panel {
        width: 180px;
        min-width: 36px;
    }
    .vault-sidebar { display: none; }
    #navigator-resize-handle { display: none !important; }
}

/* Caracteres invisíveis */
.cm-invisibles-space { position: relative; display: inline-block; }
.cm-invisibles-space::after { content: "·"; position: absolute; left: 50%; transform: translateX(-50%); color: #adb5bd; pointer-events: none; }
.cm-invisibles-tab { position: relative; display: inline-block; }
.cm-invisibles-tab::after { content: "→"; position: absolute; left: 0; color: #adb5bd; pointer-events: none; }
.cm-show-invisibles .CodeMirror-line::after { content: "↵"; color: #adb5bd; opacity: 0.6; pointer-events: none; margin-left: 4px; }

/* Linhas modificadas/salvas no editor (gutter simples) */
.CodeMirror-gutters .cm-dirty-gutter {
    width: 12px;
    border-right: none;
}

.cm-dirty-line-marker {
    display: block;
    width: 4px;
    height: 100%;
    min-height: 1.5em;
    margin-left: 4px;
    border-radius: 2px;
    opacity: 0.95;
}

.cm-dirty-line-marker.dirty-modified {
    background-color: #dc3545;
    box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.22);
}

.cm-dirty-line-marker.dirty-saved {
    background-color: #198754;
    box-shadow: 0 0 0 1px rgba(25, 135, 84, 0.22);
}

body[data-theme="dark"] .cm-dirty-line-marker.dirty-modified,
body[data-theme="soft-dark"] .cm-dirty-line-marker.dirty-modified,
body[data-theme="mid-tone"] .cm-dirty-line-marker.dirty-modified {
    background-color: #ff6b7d;
}

body[data-theme="dark"] .cm-dirty-line-marker.dirty-saved,
body[data-theme="soft-dark"] .cm-dirty-line-marker.dirty-saved,
body[data-theme="mid-tone"] .cm-dirty-line-marker.dirty-saved {
    background-color: #40c98b;
}


/* ==========================================================================
   8. VISUALIZAÇÃO DE PROPRIEDADES (YAML FRONTMATTER)
   ========================================================================== */
.atena-properties-container { border: 1px solid #e3e6ea; border-radius: 6px; background-color: #fdfdfd; overflow: hidden; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
.atena-properties-header { padding: 10px 15px; color: #495057; font-size: 0.85rem; cursor: pointer; user-select: none; display: flex; align-items: center; background-color: #f8f9fa; border-bottom: 1px solid transparent; transition: background-color 0.2s ease; }
.atena-properties-header:hover { background-color: #e9ecef; }
.atena-properties-body { display: flex; flex-direction: column; padding: 6px 0; }
.property-row { display: flex; padding: 6px 15px; font-size: 0.85rem; align-items: center; border-bottom: 1px solid transparent; }
.property-row:hover { background-color: #f1f3f5; }
.property-key { width: 35%; color: #6c757d; font-weight: 500; }
.property-value { width: 65%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.property-chip { background-color: #e2e8f0; color: #334155; padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; border: 1px solid #cbd5e1; }
.property-link { color: #0d6efd; text-decoration: none; background-color: #e7f1ff; padding: 2px 8px; border-radius: 4px; word-break: break-all; }
.property-link:hover { text-decoration: underline; background-color: #cfe2ff; }
.property-text { color: #212529; }
.atena-properties-container.collapsed .atena-properties-body { display: none; }
.atena-properties-container.collapsed .atena-properties-header { border-bottom: none; }
.atena-properties-container.collapsed .toggle-icon { transform: rotate(-90deg); }
.toggle-icon { transition: transform 0.2s ease; font-size: 0.75rem; }

/* Editor YAML nativo */
.yaml-editor-bg { background-color: #f6f8fa; border-left: 3px solid #0d6efd; }
.yaml-fold-btn { display: inline-block; margin-left: 15px; font-size: 11px; font-weight: bold; color: #6c757d; cursor: pointer; user-select: none; padding: 2px 8px; border-radius: 4px; background: #e9ecef; transition: all 0.2s; vertical-align: middle; }
.yaml-fold-btn:hover { background: #ced4da; color: #212529; }
.yaml-fold-btn.is-folded { background: #0d6efd; color: #ffffff; box-shadow: 0 2px 5px rgba(13, 110, 253, 0.3); }

/* AtenaView inline fields */
.av-field{ display:inline-flex; align-items:center; gap:6px; padding:2px 8px; margin:2px 6px 2px 0; border:1px solid #dee2e6; border-radius:999px; background:#f8f9fa; font-size:0.78rem; line-height:1.2; white-space:nowrap; }
.av-field .av-k{ font-weight:700; color:#495057; }
.av-field .av-v{ color:#0d6efd; }
.av-field .av-v.neg{ color:#dc3545; }


/* ==========================================================================
   9. NAVEGAÇÃO LATERAL DO TEXTO (Outline/TOC)
   ========================================================================== */
.outline-container { 
    position: absolute; top: 50px; right: 0; bottom: 0; width: 250px; 
    background: rgba(255,255,255,0.95); backdrop-filter: blur(5px);
    border-left: 1px solid #ddd; overflow-y: auto; z-index: 1040; display: none; padding: 15px; 
    box-shadow: -5px 0 15px rgba(0,0,0,0.03); 
}
.outline-container.show-outline { display: block; }
/* O puxador invisível para redimensionar o índice */
.outline-resizer {
    position: absolute;
    top: 0;
    left: -3px; /* Fica na borda esquerda do índice */
    width: 6px;
    height: 100%;
    cursor: ew-resize; /* Cursor de arrastar horizontal */
    background-color: transparent;
    z-index: 1050;
    transition: background-color 0.2s ease;
}

.outline-resizer:hover, .outline-resizer.resizing {
    background-color: #0d6efd;
    opacity: 0.8;
}
.outline-item { position: relative; display: flex; justify-content: space-between; align-items: center; cursor: pointer; color: #495057; padding: 4px 0; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.outline-item:hover { color: #0d6efd; text-decoration: underline; }
.outline-h1 { font-weight: bold; margin-top: 10px; } 
.outline-h2 { margin-left: 15px; } 
.outline-h3 { margin-left: 30px; font-size: 0.85rem; }
.outline-alpha { padding-left: 10px !important; }

.outline-item-actions { opacity: 0; transition: opacity 0.2s ease; display: flex; gap: 2px; }
.outline-item:hover .outline-item-actions { opacity: 1; }
.outline-action-btn { background: transparent; border: none; color: #6c757d; cursor: pointer; padding: 0 4px; font-size: 0.9em; border-radius: 3px; }
.outline-action-btn:hover { background: #e9ecef; color: #0d6efd; }

/* ==========================================================================
   PALETA DE COMANDOS (VS CODE STYLE)
   ========================================================================== */
#modalCommandPalette .modal-content {
    background-color: #f8f9fa;
    border: 1px solid #ced4da !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
}

#cmd-list {
    padding: 6px;
    overflow-x: hidden; /* Mata a rolagem horizontal feia */
}

/* Redefine a barra de rolagem EXCLUSIVAMENTE para a Paleta (Fininha e sutil) */
#cmd-list::-webkit-scrollbar { width: 6px; height: 6px; }
#cmd-list::-webkit-scrollbar-track { background: transparent; border: none; }
#cmd-list::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 8px; border: none; }
#cmd-list::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; }

/* Itens da lista com bordas arredondadas e sem transbordar */
#modalCommandPalette .list-group-item {
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    background-color: transparent;
    border-radius: 6px;
    margin-bottom: 2px; /* Apenas margem para baixo, sem empurrar as laterais */
}

#modalCommandPalette .list-group-item.active {
    background-color: #0d6efd;
    color: white;
}

#modalCommandPalette .list-group-item:hover:not(.active) {
    background-color: #e9ecef;
}

/* ==========================================================================
   MODO BIBLIOTECA
   ========================================================================== */

#biblioteca-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    flex-direction: column;
    overflow: hidden;
    background: var(--bs-body-bg, #fff);
}

.bib-topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-body-bg, #fff);
    flex-shrink: 0;
}

.bib-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bs-secondary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    flex: 1;
}

.bib-search-input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    font-size: 0.875rem;
    color: var(--bs-body-color, #212529);
    min-width: 0;
}

.bib-sort-select {
    border: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-body-bg, #fff);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    color: var(--bs-body-color, #212529);
    cursor: pointer;
}

.bib-progress-row {
    display: flex;
    align-items: center;
    padding: 0.35rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    flex-shrink: 0;
    background: var(--bs-body-bg, #fff);
}

.biblioteca-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.bib-card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    border-radius: 8px;
    overflow: visible;
    transition: transform 0.15s ease;
    user-select: none;
}

.bib-card:hover { transform: translateY(-4px); }
.bib-card:hover .bib-cover { box-shadow: 0 8px 24px rgba(0,0,0,0.22); }

.bib-cover {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-size: cover;
    background-position: center top;
    position: relative;
    box-shadow: 2px 3px 10px rgba(0,0,0,0.15);
    transition: box-shadow 0.15s ease;
}

.bib-cover-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: rgba(255,255,255,0.92);
    padding: 0.5rem;
    text-align: center;
    pointer-events: none;
}

.bib-cover-inner i { font-size: 2rem; }

.bib-ext {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: rgba(0,0,0,0.25);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.bib-cover-spinner {
    position: absolute;
    bottom: 0.4rem;
    right: 0.4rem;
    pointer-events: none;
}

.bib-info { padding: 0.4rem 0.1rem 0.3rem; }

.bib-title {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--bs-body-color, #212529);
}

.bib-pasta {
    font-size: 0.65rem;
    color: var(--bs-secondary-color, #6c757d);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.1rem;
}

@media (max-width: 768px) {
    .biblioteca-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .biblioteca-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }
    .bib-topbar { padding: 0.5rem 0.6rem; }
}

/* ==========================================================================
   ZEN MODE (FOCO DE ESCRITA)
   ========================================================================== */
body.zen-mode .vault-sidebar,
body.zen-mode .vault-navigator,
body.zen-mode .vault-metadata-panel,
body.zen-mode #navigator-resize-handle,
body.zen-mode #sidebar-backdrop,
body.zen-mode #pane-resizer,
body.zen-mode .outline-container {
    display: none !important;
}

body.zen-mode .vault-main-area {
    width: 100% !important;
}

body.zen-mode .EasyMDEContainer .editor-toolbar {
    display: none !important;
}

/* Mantém apenas o badge de status (e o botão de Zen) visíveis no topo */
body.zen-mode .editor-pane > .d-flex {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    min-height: 0 !important;
    padding: 6px 10px !important;
    background: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

body.zen-mode .editor-pane > .d-flex > :not(#status-1):not(#status-2):not(.d-flex) {
    display: none !important;
}

body.zen-mode .editor-pane > .d-flex > .d-flex > *:not(.btn-zen-mode) {
    display: none !important;
}

body.zen-mode #status-1,
body.zen-mode #status-2 {
    display: inline-block !important;
}

body.zen-mode .editor-pane {
    border-right: none !important;
}

body.zen-mode .CodeMirror-scroll {
    padding-top: 20px !important;
    padding-bottom: 60px !important;
    padding-left: clamp(20px, 12vw, 220px) !important;
    padding-right: clamp(20px, 12vw, 220px) !important;
}

body.zen-mode .editor-preview-active,
body.zen-mode .editor-preview-side {
    padding-left: clamp(20px, 12vw, 220px) !important;
    padding-right: clamp(20px, 12vw, 220px) !important;
}

.btn-zen-mode.active {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}


/* ==========================================================================
   FIX: MANTER TOOLBAR DO EDITOR FIXA NO TOPO (MODO NORMAL E LADO A LADO)
   ========================================================================== */
.EasyMDEContainer .editor-toolbar {
   /* ... */
}

/* Opcional: Se você usa o Dark Mode no EasyMDE, adicione isto também */
body[data-theme="dark"] .EasyMDEContainer .editor-toolbar {
   /* ... */
}

/* ==========================================================================
   MODO ESCURO (DARK MODE) GLOBAL E DEFINITIVO
   ========================================================================== */
/* Fundos e Textos Principais */
body[data-theme="dark"],
body[data-theme="dark"] .vault-app-container,
body[data-theme="dark"] .vault-main-area,
body[data-theme="dark"] #editors-container,
body[data-theme="dark"] .bg-white,
body[data-theme="dark"] .bg-light,
body[data-theme="dark"] .bg-transparent {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}

/* Menu Lateral e Árvore de Arquivos */
body[data-theme="dark"] .vault-sidebar {
    background-color: #1a1a1a !important;
    border-right: 1px solid #333 !important;
}

body[data-theme="dark"] .vault-navigator {
    background-color: #1a1a1a !important;
    border-right: 1px solid #333 !important;
}

body[data-theme="dark"] .vault-metadata-panel {
    background-color: #1a1a1a !important;
    border-left: 1px solid #333 !important;
}

body[data-theme="dark"] .meta-header {
    background-color: #1e1e1e !important;
    border-bottom: 1px solid #333 !important;
}

body[data-theme="dark"] .meta-input,
body[data-theme="dark"] .meta-value {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

body[data-theme="dark"] .meta-input[readonly] {
    background-color: #252525 !important;
}

body[data-theme="dark"] .file-item { color: #e0e0e0 !important; }
body[data-theme="dark"] .file-item:hover { background-color: #2d2d2d !important; color: #fff !important; }
body[data-theme="dark"] .file-item.selected { background-color: #0d6efd !important; color: #fff !important; }
body[data-theme="dark"] .text-muted, 
body[data-theme="dark"] .text-dark { color: #a0a0a0 !important; }

/* Paineis do Editor e Toolbar */
body[data-theme="dark"] .editor-pane > .d-flex {
    background-color: #1e1e1e !important;
    border-bottom: 1px solid #333 !important;
}
body[data-theme="dark"] .EasyMDEContainer .editor-toolbar,
body[data-theme="dark"] .editor-toolbar.fullscreen {
    background-color: #1e1e1e !important;
    border-bottom: 1px solid #333 !important;
}

/* Colorir o texto/ícone do próprio <button> do EasyMDE */
body[data-theme="dark"] .editor-toolbar button,
body[data-theme="dark"] .editor-toolbar i { 
    color: #e0e0e0 !important; 
}

/* Efeito de hover e botão ativo */
body[data-theme="dark"] .editor-toolbar button.active, 
body[data-theme="dark"] .editor-toolbar button:hover { 
    background-color: #333 !important; 
    border-color: transparent !important;
    color: #ffffff !important;
}

/* Separadores verticais da barra de ferramentas (aquelas linhazinhas finas) */
body[data-theme="dark"] .editor-toolbar i.separator {
    border-left: 1px solid #333 !important;
    border-right: 1px solid #111 !important;
}

/* Área de Texto (CodeMirror) */
body[data-theme="dark"] .CodeMirror {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body[data-theme="dark"] .CodeMirror-cursor { border-left: 1px solid #fff !important; }

/* Modo de Leitura (Markdown Preview) */
body[data-theme="dark"] .editor-preview-active,
body[data-theme="dark"] .editor-preview-side,
body[data-theme="dark"] .markdown-body {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}
body[data-theme="dark"] .markdown-body table tr,
body[data-theme="dark"] .markdown-body table th,
body[data-theme="dark"] .markdown-body table td {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
    color: #e0e0e0 !important;
}
body[data-theme="dark"] .markdown-body pre, 
body[data-theme="dark"] .markdown-body code {
    background-color: #2d2d2d !important;
    color: #f8f8f2 !important;
}

/* Inputs, Modais e Botões */
body[data-theme="dark"] input.form-control,
body[data-theme="dark"] select.form-select {
    background-color: #2d2d2d !important;
    color: #fff !important;
    border-color: #444 !important;
}
body[data-theme="dark"] input.form-control::placeholder { color: #888 !important; }
body[data-theme="dark"] .modal-content {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}
body[data-theme="dark"] .modal-header,
body[data-theme="dark"] .modal-footer { border-color: #333 !important; }
body[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ==========================================================================
   MODO COMPARAÇÃO (DIFF MATCH PATCH)
   ========================================================================== */
.text-diff-removido {
    background-color: rgba(220, 53, 69, 0.25) !important;
    text-decoration: line-through; /* Risca o que foi removido no Painel 1 */
}

.text-diff-adicionado {
    background-color: rgba(25, 135, 84, 0.3) !important;
    font-weight: bold; /* Destaca o que foi adicionado no Painel 2 */
}

.timeline-list-panel {
    min-height: 55vh;
    max-height: 60vh;
    background: #ffffff;
}

.timeline-list-items {
    max-height: calc(60vh - 48px);
    overflow-y: auto;
    padding-right: 2px;
}

.timeline-item {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    cursor: pointer;
    background: #f8f9fa;
    transition: all 0.15s ease;
}

.timeline-item:hover {
    border-color: #cfe2ff;
    background: #eef4ff;
}

.timeline-item.active {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.timeline-item-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
}

.timeline-item-meta {
    font-size: 0.75rem;
    color: #6c757d;
}

.timeline-diff-panel {
    min-height: 55vh;
    max-height: 60vh;
    background: #ffffff;
}

.timeline-diff-content {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fcfcfd;
    min-height: calc(60vh - 56px);
    max-height: calc(60vh - 56px);
    overflow: auto;
    padding: 10px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.timeline-diff-add {
    background: rgba(25, 135, 84, 0.22);
}

.timeline-diff-del {
    background: rgba(220, 53, 69, 0.22);
    text-decoration: line-through;
}

.timeline-diff-eq {
    color: #334155;
}

/* Modo Escuro */
body[data-theme="dark"] .text-diff-removido { background-color: rgba(220, 53, 69, 0.45) !important; color: #ffb3b3 !important; }
body[data-theme="dark"] .text-diff-adicionado { background-color: rgba(25, 135, 84, 0.5) !important; color: #a3ffcc !important; }

body[data-theme="dark"] .timeline-list-panel,
body[data-theme="dark"] .timeline-diff-panel,
body[data-theme="dark"] .timeline-diff-content {
    background: #151515 !important;
    border-color: #2e2e2e !important;
}

body[data-theme="dark"] .timeline-item {
    background: #1f1f1f;
    border-color: #333;
}

body[data-theme="dark"] .timeline-item:hover {
    background: #273447;
    border-color: #365072;
}

body[data-theme="dark"] .timeline-item.active {
    background: #213246;
    border-color: #0d6efd;
}

body[data-theme="dark"] .timeline-item-title,
body[data-theme="dark"] .timeline-diff-eq {
    color: #dbe4ef;
}

body[data-theme="dark"] .timeline-item-meta,
body[data-theme="dark"] #timelineResumoDiff,
body[data-theme="dark"] #timelineContador {
    color: #9aa7b8 !important;
}

/* ==========================================================================
   CORREÇÃO DEFINITIVA: MENU EXPORTAR VS PREVIEW LADO A LADO
   ========================================================================== */

/* 1. Força a barra superior (título e botões) a ficar numa camada muito alta */
.editor-pane > .d-flex {
    position: relative !important;
    z-index: 1050 !important;
}

/* 2. Garante que o menu suspenso do Bootstrap acompanha essa elevação */
.dropdown-menu {
    z-index: 1060 !important;
}

/* 3. Rebaixa APENAS o painel branco da direita para não engolir o menu */
.editor-preview-side {
    z-index: 10 !important; /* Suficiente para funcionar, mas perde para o menu (1060) */
}

/* ==========================================================================
   10. MODO TELA CHEIA (FULLSCREEN DE PLUGINS DA PLATAFORMA)
   ========================================================================== */
.atena-presentation-mode-global {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
}

.atena-presentation-mode-global .atena-plugin-scroll-container {
    max-height: calc(100vh - 55px) !important; /* Desconta a barra de título do plugin */
    height: calc(100vh - 55px) !important;
    border: none !important;
}

/* Fundo unificado para garantir que áreas vazias não fiquem transparentes em tela cheia */
.atena-presentation-mode-global .atena-plugin-canvas {
    background: #f8f9fa;
    min-height: 100%;
}
/* FIX: Force transparent background on plugin wrappers when grid is active */
.atena-plugin-canvas.bg-grid-active > div { background-color: transparent !important; background: transparent !important; }

/* ==========================================================================
   NOVOS TEMAS (DIMMED, PAPER, MID-TONE, SOFT-DARK)
   ========================================================================== */

/* 1. DIMMED LIGHT */
body[data-theme='dimmed'], body[data-theme='dimmed'] .vault-app-container, body[data-theme='dimmed'] .vault-main-area, body[data-theme='dimmed'] #editors-container, body[data-theme='dimmed'] .bg-white, body[data-theme='dimmed'] .bg-light { background-color: #f0f2f5 !important; color: #333 !important; }
body[data-theme='dimmed'] .vault-sidebar { background-color: #e9ecef !important; border-right: 1px solid #dee2e6 !important; }
body[data-theme='dimmed'] .editor-pane > .d-flex, body[data-theme='dimmed'] .EasyMDEContainer .editor-toolbar { background-color: #ffffff !important; border-bottom: 1px solid #dee2e6 !important; }
body[data-theme='dimmed'] .CodeMirror, body[data-theme='dimmed'] .editor-preview-active, body[data-theme='dimmed'] .markdown-body { background-color: #ffffff !important; color: #333 !important; border-color: #dee2e6 !important; }

/* 2. WARM PAPER */
body[data-theme='paper'], body[data-theme='paper'] .vault-app-container, body[data-theme='paper'] .vault-main-area, body[data-theme='paper'] #editors-container, body[data-theme='paper'] .bg-white, body[data-theme='paper'] .bg-light { background-color: #fdf6e3 !important; color: #494435 !important; }
body[data-theme='paper'] .vault-sidebar { background-color: #eee8d5 !important; border-right: 1px solid #d1c8b3 !important; }
body[data-theme='paper'] .file-item:hover { background-color: #e6dfcc !important; }
body[data-theme='paper'] .editor-pane > .d-flex, body[data-theme='paper'] .EasyMDEContainer .editor-toolbar { background-color: #fdf6e3 !important; border-bottom: 1px solid #d1c8b3 !important; }
body[data-theme='paper'] .CodeMirror, body[data-theme='paper'] .editor-preview-active, body[data-theme='paper'] .markdown-body { background-color: #fdf6e3 !important; color: #494435 !important; border-color: #d1c8b3 !important; }

/* 3. MID-TONE */
body[data-theme='mid-tone'], body[data-theme='mid-tone'] .vault-app-container, body[data-theme='mid-tone'] .vault-main-area, body[data-theme='mid-tone'] #editors-container, body[data-theme='mid-tone'] .bg-white, body[data-theme='mid-tone'] .bg-light { background-color: #737373 !important; color: #f8f9fa !important; }
body[data-theme='mid-tone'] .vault-sidebar { background-color: #666666 !important; border-right: 1px solid #555 !important; }
body[data-theme='mid-tone'] .file-item:hover { background-color: #555555 !important; }
body[data-theme='mid-tone'] .editor-pane > .d-flex, body[data-theme='mid-tone'] .EasyMDEContainer .editor-toolbar { background-color: #666666 !important; border-bottom: 1px solid #555 !important; }
body[data-theme='mid-tone'] .CodeMirror, body[data-theme='mid-tone'] .editor-preview-active, body[data-theme='mid-tone'] .markdown-body { background-color: #737373 !important; color: #f8f9fa !important; border-color: #555 !important; }
body[data-theme='mid-tone'] .modal-content, body[data-theme='mid-tone'] input.form-control, body[data-theme='mid-tone'] select.form-select, body[data-theme='mid-tone'] .dropdown-menu { background-color: #666666 !important; color: #fff !important; border-color: #555 !important; }
body[data-theme='mid-tone'] .dropdown-item { color: #f8f9fa !important; }
body[data-theme='mid-tone'] .dropdown-item:hover { background-color: #555 !important; color: #fff !important; }

/* 4. SOFT DARK */
body[data-theme='soft-dark'], body[data-theme='soft-dark'] .vault-app-container, body[data-theme='soft-dark'] .vault-main-area, body[data-theme='soft-dark'] #editors-container, body[data-theme='soft-dark'] .bg-white, body[data-theme='soft-dark'] .bg-light { background-color: #2d333b !important; color: #adbac7 !important; }
body[data-theme='soft-dark'] .vault-sidebar { background-color: #22272e !important; border-right: 1px solid #444c56 !important; }
body[data-theme='soft-dark'] .file-item:hover { background-color: #373e47 !important; color: #cdd9e5 !important; }
body[data-theme='soft-dark'] .file-item.selected { background-color: #316dca !important; color: #fff !important; }
body[data-theme='soft-dark'] .editor-pane > .d-flex, body[data-theme='soft-dark'] .EasyMDEContainer .editor-toolbar { background-color: #22272e !important; border-bottom: 1px solid #444c56 !important; }
body[data-theme='soft-dark'] .editor-toolbar button, body[data-theme='soft-dark'] .editor-toolbar i { color: #adbac7 !important; }
body[data-theme='soft-dark'] .CodeMirror, body[data-theme='soft-dark'] .editor-preview-active, body[data-theme='soft-dark'] .markdown-body { background-color: #2d333b !important; color: #adbac7 !important; border-color: #444c56 !important; }
body[data-theme='soft-dark'] .modal-content, body[data-theme='soft-dark'] input.form-control, body[data-theme='soft-dark'] select.form-select, body[data-theme='soft-dark'] .dropdown-menu { background-color: #22272e !important; color: #adbac7 !important; border-color: #444c56 !important; }
body[data-theme='soft-dark'] .dropdown-item { color: #adbac7 !important; }
body[data-theme='soft-dark'] .dropdown-item:hover { background-color: #373e47 !important; color: #cdd9e5 !important; }

/* ==========================================================================
   INBOX / CAPTURAS
   ========================================================================== */
.inbox-list-panel { overflow: hidden; }

.inbox-list-item {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.12s;
}
.inbox-list-item:hover { background: #fffbf0; }
.inbox-item-active { background: #fff3cd !important; border-left: 3px solid #ffc107; }

.inbox-ignore-btn { opacity: 0; transition: opacity 0.15s; }
.inbox-list-item:hover .inbox-ignore-btn { opacity: 1; }

.inbox-tag-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: #e9ecef;
    color: #495057;
    user-select: none;
}
.inbox-tag-chip.selected,
.inbox-tag-chip.promo-tag:hover { background: #ffc107; color: #000; }

.inbox-relacionada-item { transition: background 0.12s; }
.inbox-relacionada-item:hover { background: #f8f9fa; }

/* ── Abas de topo do Explorador (Lista/Grafo/Insights) ── */
.explorer-toptabs { }
.explorer-toptab {
    padding: 5px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #6c757d;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.12s;
}
.explorer-toptab:hover { background: #fffbf0; color: #495057; }
.explorer-toptab.active { background: #ffc107; border-color: #ffc107; color: #000; }

/* ── Insights ── */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.insight-card {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    background: #fff;
    text-align: center;
    transition: all 0.15s;
}
.insight-card:hover { border-color: #ffc107; box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.insight-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.insight-label { font-size: 0.72rem; color: #6c757d; margin-top: 2px; }
.insight-tag {
    display: inline-block;
    background: #e9ecef; color: #495057;
    padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; cursor: pointer;
    transition: background 0.12s;
}
.insight-tag:hover { background: #ffc107; color: #000; }

/* ── Sub-navegação do cockpit de Insights ── */
.insight-subnav { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid #dee2e6; padding-bottom: 8px; }
.insight-subtab {
    padding: 4px 12px; font-size: 0.74rem; font-weight: 500;
    border: 1px solid #dee2e6; background: #fff; color: #6c757d;
    border-radius: 999px; cursor: pointer; transition: all 0.12s;
}
.insight-subtab:hover { background: #fffbf0; color: #495057; }
.insight-subtab.active { background: #ffc107; border-color: #ffc107; color: #000; }

/* Chips de entidade */
.entity-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 8px; font-size: 0.75rem;
    background: #fff; border: 1px solid #e9ecef; cursor: pointer; transition: all 0.12s;
}
.entity-chip:hover { border-color: #ffc107; background: #fffbf0; }

/* Painel flutuante de metadados no visualizador */
.viewer-meta-panel {
    position: absolute; top: 12px; right: 12px; width: 320px; max-height: 80%;
    overflow-y: auto; z-index: 1060;
    background: rgba(33,37,41,0.96); border: 1px solid #495057; border-radius: 10px;
    padding: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.viewer-meta-panel .form-control { background: #2b3035; border-color: #495057; color: #e9ecef; }

/* ── Abas do inbox ── */
.inbox-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    flex-shrink: 0;
}
.inbox-tab-btn {
    flex: 1;
    padding: 9px 4px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #6c757d;
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.inbox-tab-btn:hover { background: #fffbf0; color: #495057; }
.inbox-tab-btn.active { color: #e6a800; border-bottom-color: #ffc107; }

.inbox-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    font-size: 0.58rem;
    font-weight: 600;
    background: #e9ecef;
    color: #495057;
    margin-left: 3px;
    vertical-align: middle;
}
.inbox-tab-btn.active .inbox-tab-badge { background: #ffc107; color: #000; }

/* ── Cockpit ── */
.cockpit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.cockpit-stat-card {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.cockpit-stat-card:hover {
    border-color: #ffc107;
    background: #fffbf0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.07);
}
.cockpit-stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}
.cockpit-stat-card .stat-label {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 5px;
}

/* ── Tags livres no formulário de promoção ── */
.inbox-tag-livre {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: #d1e7dd;
    color: #0a3622;
    border: 1px solid #a3cfbb;
}
.inbox-tag-livre-remove {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1;
    color: #0a3622;
    opacity: 0.6;
    cursor: pointer;
}
.inbox-tag-livre-remove:hover { opacity: 1; }

/* ── Modal de Configurações ── */
.cfg-nav-link {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #495057;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s;
}
.cfg-nav-link:hover { background: #e9ecef; color: #212529; }
.cfg-nav-link.active { background: #fff3cd; color: #664d03; font-weight: 600; }

.cfg-modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.cfg-mode-card {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.cfg-mode-card:hover { border-color: #ffc107; background: #fffbf0; transform: translateY(-1px); }
.cfg-mode-card.cfg-mode-active { border-color: #ffc107; background: #fff3cd; }
.cfg-mode-label { font-size: 0.72rem; font-weight: 600; color: #212529; margin-top: 4px; }
.cfg-mode-desc  { font-size: 0.62rem; color: #6c757d; margin-top: 2px; line-height: 1.3; }

.cfg-lang-card {
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 18px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 120px;
}
.cfg-lang-card:hover { border-color: #ffc107; background: #fffbf0; }
.cfg-lang-card.cfg-lang-active { border-color: #ffc107; background: #fff3cd; }

.cfg-theme-card {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.13s;
    min-width: 80px;
}
.cfg-theme-card:hover { border-color: #adb5bd; background: #f8f9fa; }
.cfg-theme-card.cfg-theme-active { border-color: #ffc107; background: #fff3cd; }

/* ── Abas do painel de detalhe (Análise / Prévia) ── */
.detail-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}
.detail-tab {
    padding: 8px 18px;
    font-size: 0.78rem;
    border: none;
    background: transparent;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.12s;
    font-weight: 500;
}
.detail-tab:hover { background: #fffbf0; color: #495057; }
.detail-tab.active { color: #e6a800; border-bottom-color: #ffc107; }

/* ── Chips de termos clicáveis na promoção ── */
.inbox-term-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    background: #e8f4f8;
    color: #0c525d;
    border: 1px solid #b8dde4;
    cursor: pointer;
    transition: all 0.12s;
    user-select: none;
}
.inbox-term-chip:hover { background: #c7e8f0; border-color: #7ec8d8; }
.inbox-term-chip.added { background: #d1e7dd; color: #0a3622; border-color: #a3cfbb; opacity: 0.65; pointer-events: none; }

/* ── Painel de Prévia ── */
.previa-meta { min-height: 44px; }
.previa-content { font-size: 0.88rem; line-height: 1.65; }
.previa-content pre { background: #f6f8fa; padding: 12px; border-radius: 6px; }
.previa-content h1,.previa-content h2,.previa-content h3 { margin-top: 1.2em; }

/* ── inbox-detail flex quando mostra abas ── */
#inbox-detail { display: flex; flex-direction: column; }

/* ── Viewer de arquivos (PDF, DOCX, XLSX) ── */
.viewer-docx-body {
    max-width: 860px;
    margin: 0 auto;
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #212529;
}
.viewer-docx-body h1, .viewer-docx-body h2, .viewer-docx-body h3 { margin-top: 1.2em; font-weight: 600; }
.viewer-docx-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.viewer-docx-body td, .viewer-docx-body th { border: 1px solid #dee2e6; padding: 6px 10px; }
.viewer-docx-body th { background: #f8f9fa; font-weight: 600; }

/* CBZ — galeria de páginas */
.viewer-cbz-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: #2b2b2b;
    min-height: 100%;
}
.viewer-cbz-page {
    max-width: 900px;
    width: 100%;
    height: auto;
    box-shadow: 0 2px 12px rgba(0,0,0,.4);
}

/* Aba ativa de planilha */
.sheet-tab.active { background: #ffc107; border-color: #ffc107; color: #000; }

.viewer-sheet-wrap { background: #fff; }
.viewer-sheet-table table { border-collapse: collapse; font-size: 0.8rem; }
.viewer-sheet-table td, .viewer-sheet-table th {
    border: 1px solid #dee2e6;
    padding: 3px 8px;
    white-space: nowrap;
    min-width: 60px;
}
.viewer-sheet-table th { background: #f8f9fa; font-weight: 600; text-align: center; }
.viewer-sheet-table tr:hover { background: #fffbf0; }

/* ── Badge do modo do vault (barra lateral) ── */
.vault-mode-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.66rem;
    font-weight: 600;
    color: #495057;
    background: #fff3cd;
    border: 1px solid #ffe69c;
    border-radius: 999px;
    padding: 2px 10px;
    margin-top: 6px;
    max-width: 100%;
    transition: background 0.12s;
}
.vault-mode-badge:hover { background: #ffe69c; }
.vault-mode-badge-default {
    color: #6c757d;
    background: #f1f3f5;
    border: 1px dashed #ced4da;
}
.vault-mode-badge-default:hover { background: #e9ecef; }

/* ── Toolbar da árvore de arquivos ── */
.tree-toolbar { background: #f8f9fa; min-height: 30px; }

.btn-tree-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 5px;
    font-size: 0.73rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1;
}
.btn-tree-tool:hover { background: #e9ecef; color: #495057; border-color: #adb5bd; }
.btn-tree-tool.active { background: #fff3cd; border-color: #ffc107; color: #664d03; }
.btn-tree-tool:focus { outline: none; box-shadow: 0 0 0 2px rgba(255,193,7,.3); }

.tree-tool-sep {
    display: inline-block;
    width: 1px;
    height: 16px;
    background: #dee2e6;
    margin: 0 1px;
    flex-shrink: 0;
}

/* ── Metadados na linha do arquivo ── */
.tree-meta {
    font-size: 0.62rem;
    color: #6c757d;
    padding: 1px 0 3px;
    line-height: 1.4;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.tree-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.tree-meta-item i { font-size: 0.6rem; }
.tree-tag-chip {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.6rem;
}

/* ── Snapshots / Histórico de Versões ── */
.snap-item {
    padding: 10px 14px;
    border-bottom: 1px solid #e9ecef;
    transition: background 0.12s;
}
.snap-item:hover { background: #fffbf0; }
.snap-item-active { background: #fff3cd !important; border-left: 3px solid #ffc107; }

.snap-raw {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    background: #f6f8fa;
    padding: 12px;
    border-radius: 6px;
}

/* Flash visual ao criar snapshot na árvore */
.snap-flash {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    animation: snapFade 1.6s ease forwards;
    pointer-events: none;
}
@keyframes snapFade {
    0%   { opacity: 1; transform: translateY(-50%) scale(1.2); }
    100% { opacity: 0; transform: translateY(-80%) scale(0.8); }
}

/* overflow-y helper */
.overflow-y-auto { overflow-y: auto !important; }

/* ── AtenaLibrary View Mode Bar & Reading Notes Panel ── */
.view-mode-bar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}
body[data-theme="dark"] .view-mode-bar {
    background: #1a1a1a !important;
    border-bottom-color: #333 !important;
}

#viewer-notes-panel {
    border-left: 1px solid #dee2e6;
    z-index: 10;
}
body[data-theme="dark"] #viewer-notes-panel {
    background-color: #1a1a1a !important;
    color: #e0e0e0 !important;
    border-left-color: #333 !important;
}
body[data-theme="dark"] #viewer-notes-panel .border-bottom {
    border-bottom-color: #333 !important;
    background-color: #252525 !important;
}
body[data-theme="dark"] #viewer-notes-panel .fw-semibold {
    color: #fff !important;
}
body[data-theme="dark"] #viewer-notes-panel .btn-outline-dark {
    color: #adbac7 !important;
    border-color: #444c56 !important;
}
body[data-theme="dark"] #viewer-notes-panel .editor-toolbar {
    background-color: #252525 !important;
    border-color: #333 !important;
}
body[data-theme="dark"] #viewer-notes-panel .CodeMirror {
    background-color: #1a1a1a !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}

