/**
 * NATURADMIN - Hoja de Estilos Moderna
 * Diseño limpio estilo SaaS (Notion / Google Drive) con soporte de modo claro y oscuro
 */

:root {
    --font-sans: 'Atkinson Hyperlegible', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

    /* Tamaño base accesible (WCAG 16px) */
    font-size: 16px;

    /* Tema Claro */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-surface-active: #e2e8f0;
    --bg-sidebar: #ffffff;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    --text-main: #0f172a;
    --text-muted: #475569; /* Contraste mejorado > 4.5:1 */
    --text-light: #64748b;

    --primary: #1d4ed8; /* Contraste mejorado > 4.5:1 sobre blanco */
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --primary-text: #1e40af;

    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #06b6d4;
    --info-light: #ecfeff;

    /* Colores por extensión */
    --color-pdf: #ef4444;
    --color-pdf-bg: #fee2e2;
    --color-md: #3b82f6;
    --color-md-bg: #dbeafe;
    --color-csv: #10b981;
    --color-csv-bg: #d1fae5;
    --color-html: #f97316;
    --color-html-bg: #ffedd5;
    --color-xml: #f59e0b;
    --color-xml-bg: #fef3c7;
    --color-img: #8b5cf6;
    --color-img-bg: #ede9fe;
    --color-code: #64748b;
    --color-code-bg: #f1f5f9;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --header-height: 64px;
    --sidebar-width: 300px;
}

[data-theme="dark"] {
    --bg-main: #090d16;
    --bg-surface: #111827;
    --bg-surface-hover: #1f2937;
    --bg-surface-active: #374151;
    --bg-sidebar: #0d1321;
    --border-color: #1f2937;
    --border-subtle: #172033;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #64748b;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e293b;
    --primary-text: #93c5fd;

    --color-pdf-bg: #450a0a;
    --color-md-bg: #172554;
    --color-csv-bg: #064e3b;
    --color-html-bg: #431407;
    --color-xml-bg: #451a03;
    --color-img-bg: #2e1065;
    --color-code-bg: #1e293b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

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

/* Accesibilidad WCAG: Indicador de Foco Visible de Alto Contraste */
:focus-visible {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px !important;
}

/* Ocultación semántica para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    line-height: 1.6;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Header / Barra Superior
   ========================================================================== */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 30;
    gap: 16px;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-main);
    text-decoration: none;
    user-select: none;
}

.brand-badge {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    padding: 6px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.brand-text span {
    color: var(--primary);
}

.search-box {
    flex: 1;
    max-width: 450px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

.search-input {
    width: 100%;
    padding: 9px 12px 9px 38px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background-color: var(--bg-surface);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Botones Generales
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--text-light);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

/* ==========================================================================
   Layout Principal (Sidebar + Contenido)
   ========================================================================== */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 16px 14px;
}

.sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 6px;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Árbol de Carpetas */
.tree-node {
    margin-bottom: 2px;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-main);
    transition: background-color 0.15s;
    user-select: none;
    position: relative;
}

.tree-node-content:hover {
    background-color: var(--bg-surface-hover);
}

.tree-node-content.active {
    background-color: var(--primary-light);
    color: var(--primary-text);
    font-weight: 600;
}

.tree-node-content.drag-over {
    background-color: rgba(37, 99, 235, 0.2) !important;
    outline: 2px dashed var(--primary);
}

.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-badge {
    background-color: var(--bg-surface-active);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    margin-left: 6px;
}

.tree-actions {
    display: none;
    margin-left: 6px;
}

.tree-node-content:hover .tree-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tree-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
}

.tree-action-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-active);
}

.tree-children {
    padding-left: 18px;
}

/* ==========================================================================
   Área Principal del Explorador
   ========================================================================== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-main);
}

/* Barra de Herramientas Superior */
.toolbar {
    padding: 16px 24px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-muted);
    flex: 1;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-item:hover {
    color: var(--primary);
}

.breadcrumb-item.active {
    color: var(--text-main);
    font-weight: 600;
    cursor: default;
}

.toolbar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Filtros por Formato */
.format-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.filter-pill {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-muted);
    transition: all 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-pill:hover {
    border-color: var(--text-light);
    color: var(--text-main);
}

.filter-pill.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ==========================================================================
   Vistas de Archivos (Cuadrícula y Lista)
   ========================================================================== */
.files-container {
    padding: 24px;
    flex: 1;
}

/* Cuadrícula */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.file-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative;
    user-select: none;
}

.file-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.file-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.file-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.file-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.file-card-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-word;
    margin-bottom: 8px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

.file-relations-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: var(--primary-light);
    color: var(--primary-text);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.72rem;
}

/* Vista en Lista / Tabla */
.files-table-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.files-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.files-table th {
    background-color: var(--bg-main);
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}

.files-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.files-table tr:hover td {
    background-color: var(--bg-surface-hover);
}

/* Estado Vacío */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    width: 64px;
    height: 64px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 400px;
    margin-bottom: 20px;
}

/* ==========================================================================
   Modales (Visor, Relaciones, Mapa de Grafo, Nueva Carpeta)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    width: 100%;
    max-width: 600px;
    overflow: hidden;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-container.modal-lg {
    max-width: 900px;
}

.modal-container.modal-fullscreen {
    max-width: 96vw;
    height: 92vh;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-surface);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background-color: var(--bg-surface);
}

/* ==========================================================================
   Pestañas del Visor (Visor / Relaciones / Metadatos)
   ========================================================================== */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    padding: 0 24px;
    gap: 20px;
}

.tab-btn {
    padding: 12px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-pane {
    display: none;
    height: 100%;
}

.tab-pane.active {
    display: block;
}

/* Estilos de los Visores Específicos */
.viewer-content-box {
    width: 100%;
    height: 100%;
    min-height: 550px;
    display: flex;
    flex-direction: column;
}

/* Visor PDF */
.pdf-frame {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: none;
    border-radius: var(--radius-md);
    background-color: #525659;
}

/* Visor Markdown */
.markdown-preview {
    padding: 24px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    line-height: 1.7;
    overflow-y: auto;
    max-height: 650px;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-main);
}

.markdown-preview pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 14px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 14px 0;
}

.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.markdown-preview th, .markdown-preview td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
}

/* Visor CSV */
.csv-table-wrapper {
    max-height: 550px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.csv-table th {
    position: sticky;
    top: 0;
    background-color: var(--bg-surface-active);
    color: var(--text-main);
    padding: 10px 14px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.csv-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

/* Visor de Código / XML / HTML */
.code-viewer-container {
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: #1e293b;
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    position: relative;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

.code-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: #0f172a;
    border-bottom: 1px solid #334155;
    font-size: 0.8rem;
    color: #94a3b8;
}

.code-viewer-pre {
    margin: 0;
    padding: 16px;
    overflow: auto;
    flex: 1;
}

/* Visor de Imágenes */
.image-viewer-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-main);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 500px;
}

.image-viewer-box img {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    object-fit: contain;
}

/* ==========================================================================
   Mapa de Relaciones (vis-network)
   ========================================================================== */
#graph-canvas {
    width: 100%;
    height: 620px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--bg-main);
}

.graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.graph-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ==========================================================================
   Formularios
   ========================================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Notificaciones Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    max-width: 360px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Paginación y Barra de Controles CSV
   ========================================================================== */
.csv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    background-color: var(--bg-surface-hover);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.csv-pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.csv-page-btn {
    min-width: 34px;
    height: 34px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 500;
}

.csv-page-btn:hover:not(:disabled) {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.csv-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================================================
   Editor en Línea de Documentos (Markdown, XML, HTML, TXT)
   ========================================================================== */
.inline-editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 520px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.inline-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background-color: var(--bg-surface-hover);
    border-bottom: 1px solid var(--border-color);
}

.inline-editor-textarea {
    flex: 1;
    width: 100%;
    min-height: 480px;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: none;
    outline: none;
    resize: none;
}

/* ==========================================================================
   Inspector Flotante del Mapa de Relaciones (vis-network)
   ========================================================================== */
.graph-body-layout {
    display: flex;
    gap: 16px;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.graph-canvas-wrapper {
    flex: 1;
    height: 100%;
    position: relative;
}

.graph-inspector-panel {
    width: 320px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    padding: 18px;
    overflow-y: auto;
    z-index: 10;
    transition: all 0.2s ease;
}

.graph-inspector-panel.active {
    display: flex;
}

.graph-inspector-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.graph-inspector-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    display: inline-block;
}

.graph-inspector-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-word;
}

