/* =========================================
   WMApps: TreeTableApp Layout
========================================= */

.wmapp-split-layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%; /* Ocupa todo el alto disponible de la ventana App */
    overflow: hidden;
}

.wmapp-sidebar {
    width: 260px;
    min-width: 200px;
    max-width: 400px; /* Opcional: si más adelante le añades un resizer draggeable */
    flex-shrink: 0;
    border-right: 1px solid var(--color-border-dim, #e0e0e0);
   
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    height:100%;
}

/* El main-area ocupa el resto del espacio disponible */
.wmapp-main {
    flex: 1;
    min-width: 0; /* Previene que flexbox desborde si la tabla es muy ancha */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden; /* Asumo que TableCtl ya tiene su propio overflow para los rows */
    height:100%;
}

/* Layout contenedor (usando Flexbox) */
.wmapp-split-layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Columna izquierda. flex-shrink 0 es vital para que respete el width que inyectamos con JS */
.wmapp-sidebar {
    flex: 0 0 auto; 
    width: 50%; /* Tamaño por defecto inicial */
    overflow-y: auto;
    background-color: var(--bg-secondary, #f5f5f5);
}

/* La columna separadora mágica */
.wmapp-resizer {
    flex: 0 0 4px;
    background-color: var(--border-color, #e0e0e0);
    cursor: ew-resize; /* Cursor de doble flecha */
    transition: background-color 0.2s ease;
    z-index: 10;
}

/* Feedback visual al pasar el ratón o mientras se arrastra */
.wmapp-resizer:hover, 
.wmapp-resizing .wmapp-resizer {
    background-color: var(--accent-color, #007bff);
}

/* Columna principal absorbe el resto del espacio */
.wmapp-main {
    flex: 1 1 auto;
    overflow-y: auto;
}

/* TRUCO UX: Mientras hacemos drag, nada se puede seleccionar y el cursor es forzado en TODA la app */
body.wmapp-resizing, 
body.wmapp-resizing * {
    cursor: ew-resize !important;
    user-select: none !important;
}


/***section sencillo**/

.section .section-content{
    display:none;
}
.section.open .section-content{
    display:block;
}

.tab-btn{
    background: var(--bg-surface);
    border:1px solid var(--c-border-light);
    padding:var(--space-md);
    color:var(--bg-secondary);
    border-bottom: 0;
    margin-right:var(--space-md);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tab-btn.active{
    background: var(--c-surface-hover);
}

/* Tree View */
.tree-view { 
    overflow: auto; 
    height: 100%; 
    min-width: max(150px, 25%); 
    font-size: 0.95em; 
}

/* El contenedor de los hijos usa tu lógica de border-left y padding */
.tree-children { 
    display: none; /* Oculto por defecto */
    padding-left: var(--space-md); 
    border-left: 1px solid var(--c-border-light); 
    margin-left: 10px; 
}

/* El JS ahora le pone .open a este contenedor directamente */
.tree-children.open { 
    display: flex; /* Flex porque es un 'col' en la macro */
}

/* La fila interactiva */
.tree-row { 
    padding: var(--space-xs); 
    border-radius: var(--radius-lg); 
    cursor: pointer; 
    user-select: none;
}
.tree-row:hover { 
    background-color: var(--c-surface-hover); 
}
.tree-row.selected { 
    background-color: var(--c-tree-sel-bg); 
    color: var(--c-tree-sel-color); 
    font-weight: bold; 
}

/* El botón de desplegar */
.tree-toggle { 
    width: 20px; 
    text-align: center; 
    font-size: 0.8em; 
    opacity: 0; /* Totalmente transparente si no hay hijos */
    transition: transform 0.15s ease;
}
.tree-toggle.has-kids { 
    opacity: 0.5; 
}
.tree-toggle.has-kids:hover { 
    opacity: 1; 
}
/* Al hacer click, el JS le pone .expanded al toggle */
.tree-toggle.expanded { 
    transform: rotate(90deg); 
    opacity: 1; 
}

/* 
  TRUCO FLEX: Como ahora usamos 'mkit' para renderizar el icon y el label,
  el contenedor debe tener flex: 1 y min-width: 0 para que el text-overflow: ellipsis
  funcione correctamente sin deformar el árbol.
*/
.tree-item-content {
    flex: 1;
    min-width: 0; 
}

/* El estado de carga/error */
.tree-status {
    padding: var(--space-xs) var(--space-md);
    opacity: 0.6;
    font-style: italic;
    font-size: 0.9em;
}
/* Fields & Extras */
.field-header-actions { opacity: 0.8; }
.field-quote { margin-bottom: 4px; font-style: italic; opacity: 0.7; }
.field-stats { font-size: 0.8em; font-family: monospace; background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; }
.btn-expand-editor { font-size: 0.85em; padding: 2px 8px; }

/* Smart Layout */
.col-grow { flex: 1 1 auto; display: flex; flex-direction: column; }
.smart-editor-layout { align-items: stretch; }
.smart-code-panel .CodeMirror { height: 100%; flex: 1; } /* Fuerza a ocupar el espacio */

/* Tree Moderno */
.tree-toggle { width: 24px; text-align: center; cursor: pointer; transition: transform 0.2s; user-select: none; }
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.empty-kid { opacity: 0.3; cursor: default; }
.tree-children { padding-left: 16px; display: none; }
.tree-children.open { display: flex; }
.tree-row { transition: background 0.15s; }
.tree-row:hover { background: var(--bg-hover); }
.tree-row.selected { background: var(--primary-light); border-left: 2px solid var(--primary); }

.tab-app-container {
    width: 100%;
   
    position: relative;
   
}

#app .tab-app-container{
     height: 100%;
      overflow: hidden;
}

/* =========================================
   TABS DISCRETOS EN TOOLBAR (Pseudo-OS)
   ========================================= */

/* Complementamos la clase .win-tool-btn cuando actúa como pestaña */
.win-menu-toolbar .tab-nav-btn {
    color: var(--slate); /* Texto atenuado para las pestañas inactivas */
    border-radius: var(--radius) var(--radius) 0 0; /* Curvos arriba, planos abajo */
    
    /* Preparamos un borde inferior transparente para que el texto no "salte" al activarse */
    border-bottom: 2px solid transparent; 
    padding-right:1.5rem;
    
   
}

/* Hover sutil para pestañas inactivas */
.win-menu-toolbar .tab-nav-btn:hover:not(.active) {
    background-color: var(--paper-dim);
    color: var(--brass);
    border-bottom: 2px solid var(--brass); /* Pista visual de que es una pestaña */
   
}

/* Estado Activo */
.win-menu-toolbar .tab-nav-btn.active {
    background-color: var(--color-paper); /* En OS modernos, la tab activa suele integrarse con el fondo */
    color: var(--brass);
    font-weight: 600; /* 600 suele renderizar más limpio que 'bold' en UIs */
    
    /* Usamos tu variable de acento. 
       - En tu tema Base será oscuro (#333).
       - En tu tema DOM2 Retro será dorado (#BA7517).
       Si prefieres forzar el azul de Windows 10/11 cámbialo por: #0078d7 */
    border-bottom: 2px solid var(--brass); 
}
/* Magia del modo Borderless para la sub-ventana */
.win.embedded-win {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

/* Ocultamos la cabecera (titlebar) y el control de resize de la sub-ventana */
.win.embedded-win > .win-title,
.win.embedded-win > .win-resize {
    display: none !important;
}

/* El menú de la sub-ventana debe seguir visible, pero le quitamos bordes extra si los tiene */
.win.embedded-win > .win-menu {
    border-top: none;
    background: #fdfdfd; /* Para diferenciar ligeramente del menú de los tabs */
}



/* Calendar view Layout Principal */
.calendar-view {
    width: 100%;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
}

.calendar-header {
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: bold;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.calendar-title {
    text-transform: capitalize;
}

/* Rejilla y Días */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-alt, #f8f9fa);
    text-align: center;
    padding: 8px 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    auto-rows: minmax(110px, auto); /* Altura mínima de las celdas */
    gap: 1px;
    background: var(--border-color, #e0e0e0); /* Truco para simular bordes de grid 1px */
}

/* Celdas individuales */
.calendar-cell {
    background: var(--bg-surface, #ffffff);
    padding: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    overflow: hidden;
}

.calendar-cell:hover:not(.empty) {
    background: var(--bg-hover, #f1f3f5);
}

.calendar-cell.empty {
    background: var(--bg-alt, #f8f9fa);
    cursor: default;
}

.calendar-day-num {
    align-self: flex-end;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendar-cell.today .calendar-day-num {
    background: var(--primary, #007bff);
    color: #ffffff;
    font-weight: bold;
}

/* Listado de items generados por mkit */
.calendar-day-items {
    gap: 4px;
    overflow-y: auto;
}

/* Compactación de la macro mkit para uso en Calendario */
.calendar-event {
    background: var(--primary-light, #e7f1ff);
    color: var(--primary-dark, #004085);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    align-items: center;
    cursor: pointer;
}

.calendar-event:hover {
    filter: brightness(0.95);
}

.calendar-event .mkit-icon { 
    font-size: 14px; 
    margin-right: 4px; 
}

.calendar-event .mkit-title { 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Ocultar elementos secundarios del item estándar para ahorrar espacio en la celda */
.calendar-event .mkit-detail,
.calendar-event .mkit-image { 
    display: none; 
}