/* --- ENVOLTORIO PRINCIPAL --- */
#organigrama-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding-bottom: 20px;
    box-sizing: border-box;
    background: linear-gradient(to right, #ffffff 90%, rgba(0, 0, 0, 0.05));
}

/* --- ÁRBOL ORGANIZACIONAL --- */
#organigrama-tree {
    display: inline-flex;
  
    flex-direction: column;
    align-items: center;
    white-space: normal;
   min-width: max-content;

    padding: 20px;
    box-sizing: border-box;
    
}

/* --- ESTILOS DE LA ESTRUCTURA --- */
.tree>ul {
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
}

.tree ul {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

.tree ul ul {
    display: flex;
    justify-content: center;
    padding-top: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

/* --- CONEXIONES --- */
.tree li {
    text-align: center;
    position: relative;
    padding: 20px 5px 0 5px;
}

.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1px solid #ccc;
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid #ccc;
}

.tree li:only-child::before,
.tree li:only-child::after {
    display: none;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: none;
}

.tree li:last-child::before {
    border-right: 1px solid #ccc;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* --- NODOS Y BOTONES --- */
.node-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.node {
    width: 200px;              /* Ajusta a tu gusto: ancho fijo para todos */
    min-height: 150px;         /* Altura mínima uniforme */
    max-height: 200px;         /* Opcional: altura máxima */
    box-sizing: border-box;
    padding: 10px;
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 8px;
    text-align: center;
    overflow: hidden;          /* Esconde texto que se desborde */
    white-space: normal;       /* Permite múltiples líneas */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.node img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 5px;
}
.node div, .node small {
    font-size: clamp(10px, 1.5vw, 14px); /* Ajusta automáticamente según el contenedor/pantalla */
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;  /* Permite múltiples líneas */
    max-height: 3.6em;    /* Máximo de 3 líneas aprox */
}

.toggle-btn {
    background: #007BFF;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- TARJETAS Y NIVELES --- */
.nodo-card {
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 12px;
    width: 180px;
    text-align: center;
    background-color: #fefefe;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.nodo-card img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 8px;
}

.titulo-nivel {
    text-align: center;
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 8px;
}

.nivel-fila {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    #organigrama-tree {
        overflow-x: auto;
        overflow-y: visible;
        max-height: none;
        padding-bottom: 40px;
        min-width: max-content;
    }

    .tree ul ul {
        flex-wrap: nowrap;
    }
}

@media (max-width: 600px) {
    .nodo-card {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .node {
        width: 140px;
        min-height: 120px;
    }
}


.scroll-buttons {
    position: relative;
}

#scroll-left,
#scroll-right {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 24px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.3s ease;
}

#scroll-left:hover,
#scroll-right:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

#scroll-left {
    left: 10px;
}

#scroll-right {
    right: 10px;
}

/* Modal organigrama */
/* ================= ORGANIGRAMA ================= */
#modalorg {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}


#modalorg.show {
    display: flex;
    /* Se muestra centrado cuando se activa */
    align-items: center;
    justify-content: center;
}

*/
.modalorganigrama {
    
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    
    justify-content: center;
    align-items: center;
}

/* Contenido modal con animación */
.modalorganigrama-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    text-align: center;
    animation: fadeZoomIn 0.4s ease;
    position: relative;
}

.modalorganigrama-content h2 {
    margin: 10px 0;
}

.modalorganigrama-content h3 {
    margin: 10px 0;
    color: #666;
}

.modalorganigrama-content p {
    font-size: 14px;
    color: #333;
}


.modalorganigrama .close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    color: #444;
    font-weight: bold;
    cursor: pointer;
    z-index: 1000;
}

.modalorganigrama .close:hover {
    color: red;
}

/* Animación */

@keyframes fadeZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInOrganigrama {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

