/*
 * MENÚ JERÁRQUICO EXPANDIBLE - PORTAL DE TRANSPARENCIA
 * Estilo tipo árbol/diagrama para +260 elementos
 * Compatible con WordPress tema VEDA
 * Basado en estructura de transparencia.algesa.org
 * 
 * Autor: Asistente Claude
 * Fecha: 2025
 */

/* ============================================
   VARIABLES CSS - PERSONALIZA AQUÍ LOS COLORES
   ============================================ */
:root {
    --menu-primary-color: #2c3e50;
    --menu-secondary-color: #3498db;
    --menu-hover-color: #e74c3c;
    --menu-bg-color: #ffffff;
    --menu-border-color: #ecf0f1;
    --menu-text-color: #2c3e50;
    --menu-text-light: #7f8c8d;
    --menu-arrow-color: #95a5a6;
    --menu-level-indent: 20px;
    --menu-transition: 0.3s ease;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.transparencia-menu-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 20px;
    font-family: 'Raleway', 'Open Sans', sans-serif;
    box-sizing: border-box;
}

/* ============================================
   ESTRUCTURA PRINCIPAL DEL MENÚ ÁRBOL
   ============================================ */
.tree-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.tree-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-menu li {
    position: relative;
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* ============================================
   ITEMS DE NIVEL 1 (CATEGORÍAS PRINCIPALES)
   ============================================ */
.tree-menu > li {
    border-bottom: 1px solid var(--menu-border-color);
    margin-bottom: 5px;
}

.tree-menu > li > .menu-item-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--menu-primary-color) 0%, #34495e 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--menu-transition);
    border-radius: 4px;
}

.tree-menu > li > .menu-item-header:hover {
    background: linear-gradient(135deg, var(--menu-secondary-color) 0%, #2980b9 100%);
}

.tree-menu > li.open > .menu-item-header {
    background: linear-gradient(135deg, var(--menu-hover-color) 0%, #c0392b 100%);
    border-radius: 4px 4px 0 0;
}

/* ============================================
   ITEMS DE NIVEL 2 (SUBCATEGORÍAS)
   ============================================ */
.tree-menu > li > ul {
    background: #f8f9fa;
    border: 1px solid var(--menu-border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.tree-menu > li > ul > li > .menu-item-header {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 35px;
    background: transparent;
    color: var(--menu-text-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid var(--menu-border-color);
    transition: all var(--menu-transition);
}

.tree-menu > li > ul > li:last-child > .menu-item-header {
    border-bottom: none;
}

.tree-menu > li > ul > li > .menu-item-header:hover {
    background: #e9ecef;
    color: var(--menu-secondary-color);
}

.tree-menu > li > ul > li.open > .menu-item-header {
    background: #e9ecef;
    color: var(--menu-hover-color);
    border-left: 4px solid var(--menu-hover-color);
    padding-left: 31px;
}

/* ============================================
   ITEMS DE NIVEL 3 (SUB-SUBCATEGORÍAS)
   ============================================ */
.tree-menu > li > ul > li > ul {
    background: #ffffff;
    margin-left: 20px;
    border-left: 2px solid var(--menu-border-color);
}

.tree-menu > li > ul > li > ul > li > .menu-item-header {
    display: flex;
    align-items: center;
    padding: 10px 15px 10px 25px;
    background: transparent;
    color: var(--menu-text-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 1px dotted var(--menu-border-color);
    transition: all var(--menu-transition);
}

.tree-menu > li > ul > li > ul > li:last-child > .menu-item-header {
    border-bottom: none;
}

.tree-menu > li > ul > li > ul > li > .menu-item-header:hover {
    background: #f5f6f7;
    color: var(--menu-secondary-color);
}

.tree-menu > li > ul > li > ul > li.open > .menu-item-header {
    color: var(--menu-hover-color);
    font-weight: 600;
    background: #fff8f8;
}

/* ============================================
   ITEMS DE NIVEL 4 (ELEMENTOS)
   ============================================ */
.tree-menu > li > ul > li > ul > li > ul {
    margin-left: 15px;
    border-left: 2px dotted #ddd;
}

.tree-menu > li > ul > li > ul > li > ul > li > .menu-item-header,
.tree-menu > li > ul > li > ul > li > ul > li > a {
    display: flex;
    align-items: center;
    padding: 8px 15px 8px 20px;
    background: transparent;
    color: var(--menu-text-light);
    font-size: 13px;
    font-weight: 400;
    text-decoration: none;
    border-bottom: 1px dotted #e9ecef;
    transition: all var(--menu-transition);
}

.tree-menu > li > ul > li > ul > li > ul > li:last-child > .menu-item-header,
.tree-menu > li > ul > li > ul > li > ul > li:last-child > a {
    border-bottom: none;
}

.tree-menu > li > ul > li > ul > li > ul > li > .menu-item-header:hover,
.tree-menu > li > ul > li > ul > li > ul > li > a:hover {
    background: #f8f9fa;
    color: var(--menu-secondary-color);
    padding-left: 25px;
}

/* ============================================
   ITEMS DE NIVEL 5+ (NIVELES PROFUNDOS)
   ============================================ */
.tree-menu > li > ul > li > ul > li > ul > li > ul {
    margin-left: 15px;
    border-left: 1px dotted #eee;
}

.tree-menu > li > ul > li > ul > li > ul > li > ul > li > a {
    padding: 6px 15px 6px 20px;
    font-size: 12px;
    color: #888;
}

/* ============================================
   FLECHAS/INDICADORES DE EXPANSIÓN
   ============================================ */
.menu-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    font-size: 12px;
    color: inherit;
    transition: transform var(--menu-transition);
    flex-shrink: 0;
}

.menu-arrow::before {
    content: '►';
    font-size: 10px;
}

.open > .menu-item-header .menu-arrow::before {
    content: '▼';
}

/* Con FontAwesome */
.menu-arrow.fa::before {
    content: '\f105';
    font-family: 'FontAwesome';
    font-size: 14px;
}

.open > .menu-item-header .menu-arrow.fa::before {
    content: '\f107';
}

/* ============================================
   ICONOS PARA CATEGORÍAS PRINCIPALES
   ============================================ */
.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-right: 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================
   SUBMENÚS COLAPSADOS/EXPANDIDOS
   ============================================ */
.tree-menu ul {
    display: none;
    overflow: hidden;
}

.tree-menu li.open > ul {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

/* ============================================
   ENLACES
   ============================================ */
.tree-menu a {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: all var(--menu-transition);
}

.tree-menu a:hover {
    text-decoration: none;
}

/* Indicador de documento PDF */
.tree-menu a[href$=".pdf"]::after {
    content: ' [PDF]';
    font-size: 10px;
    color: #e74c3c;
    font-weight: 600;
}

/* ============================================
   CONTROLES: EXPANDIR/COLAPSAR TODO
   ============================================ */
.tree-menu-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tree-menu-controls button {
    padding: 10px 20px;
    background: var(--menu-bg-color);
    border: 2px solid var(--menu-border-color);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--menu-transition);
}

.tree-menu-controls button:hover {
    background: var(--menu-secondary-color);
    color: white;
    border-color: var(--menu-secondary-color);
}

.tree-menu-controls button.active {
    background: var(--menu-primary-color);
    color: white;
    border-color: var(--menu-primary-color);
}

/* ============================================
   BUSCADOR EN EL MENÚ
   ============================================ */
.tree-menu-search {
    position: relative;
    margin-bottom: 20px;
}

.tree-menu-search input {
    width: 100%;
    padding: 12px 50px 12px 15px;
    border: 2px solid var(--menu-border-color);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color var(--menu-transition);
}

.tree-menu-search input:focus {
    outline: none;
    border-color: var(--menu-secondary-color);
}

.tree-menu-search button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--menu-secondary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

/* Resaltado de búsqueda */
.tree-menu .search-highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 2px;
}

.tree-menu li.search-match {
    display: block !important;
}

.tree-menu li.search-match > .menu-item-header,
.tree-menu li.search-match > a {
    background: #fff3cd !important;
}

/* ============================================
   CONTADOR DE ELEMENTOS
   ============================================ */
.item-count {
    margin-left: auto;
    padding: 2px 8px;
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.tree-menu > li > .menu-item-header .item-count {
    background: rgba(255,255,255,0.25);
}

/* ============================================
   ETIQUETAS DE ESTADO
   ============================================ */
.menu-badge {
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 3px;
    text-transform: uppercase;
}

.menu-badge.new {
    background: #28a745;
    color: white;
}

.menu-badge.updated {
    background: #17a2b8;
    color: white;
}

.menu-badge.important {
    background: #dc3545;
    color: white;
}

/* ============================================
   RESPONSIVE - MÓVIL
   ============================================ */
@media screen and (max-width: 768px) {
    .transparencia-menu-container {
        padding: 10px;
    }
    
    .tree-menu > li > .menu-item-header {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .tree-menu > li > ul > li > .menu-item-header {
        padding: 10px 15px 10px 25px;
        font-size: 13px;
    }
    
    .tree-menu > li > ul > li > ul > li > .menu-item-header {
        padding: 8px 10px 8px 20px;
        font-size: 12px;
    }
    
    .tree-menu > li > ul > li > ul > li > ul > li > a {
        padding: 6px 10px 6px 15px;
        font-size: 12px;
    }
    
    .menu-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .tree-menu-controls {
        flex-direction: column;
    }
    
    .tree-menu-controls button {
        width: 100%;
    }
    
    .item-count {
        display: none;
    }
}

/* ============================================
   IMPRESIÓN
   ============================================ */
@media print {
    .tree-menu ul {
        display: block !important;
    }
    
    .menu-arrow {
        display: none;
    }
    
    .tree-menu-search,
    .tree-menu-controls {
        display: none;
    }
    
    .tree-menu > li > .menu-item-header {
        background: #f0f0f0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .tree-menu > li > ul {
        border: 1px solid #ccc;
    }
}
