/* --- Contenedor General --- */
.org-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1920px;
    margin: 20px auto;
    padding: 20px 10px;
    font-family: var(--font-primary), sans-serif;
    color: #4a6a8a;
    position: relative;
    overflow-x: hidden; /* Previene scroll horizontal accidental */
}

/* --- Niveles y Ramas --- */
.org-level {
    display: flex;
    justify-content: center;
    width: 100%;
    position: relative;
}

.level-1 {
    align-items: flex-start;
    justify-content: center;
    gap: 1rem; /* Espacio reducido entre ramas */
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    position: relative;
}

/* --- LÍNEAS HORIZONTALES --- */
/* Línea que conecta las dos ramas principales */
.level-1::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30%; /* La línea abarca el 80% del contenedor */
    right: 30%;
    height: 4px;
    background-color: #e0e6f1;
}

.level-2 {
    align-items: flex-start;
    justify-content: center;
    gap: 1rem; /* Espacio reducido entre ramas */
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    position: relative;
}

/* --- LÍNEAS HORIZONTALES --- */
/* Línea que conecta las dos ramas principales */
.level-2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%; /* La línea abarca el 80% del contenedor */
    right: 20%;
    height: 4px;
    background-color: #e0e6f1;
}

.org-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1; /* Ambas ramas ocupan el mismo espacio */
    min-width: 0; /* Permite que los elementos flex se encojan */
}

/* --- Filas y Columnas --- */
.org-row {
    display: flex;
    width: 100%;
    margin-top: 15px;
    padding-top: 20px;
    position: relative;
    justify-content: space-around; /* Distribuye las columnas */
    gap: 0.5rem;
}

.level-3 {
    align-items: flex-start;
    justify-content: center;
    /*gap: 1rem; !* Espacio reducido entre ramas *!*/
    width: 100%;
    margin-top: 15px;
    padding-top: 20px;
    position: relative;
}

/* Línea que conecta las columnas de cada rama */
.level-3::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2.5%;
    right: 2.5%;
    height: 4px;
    background-color: #e0e6f1;
}

.org-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    flex: 1; /* Permite que las columnas se ajusten */
    min-width: 0;
}

/* --- Flip Card Container --- */
.flip-card {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* Tamaños específicos para diferentes niveles */
.org-item .flip-card {
    width: 280px; /* Ancho fijo */
    margin: 10px auto;
    min-height: 0; /* Permite que la altura se ajuste al contenido */
    height: auto; /* Altura automática según contenido */
    background: transparent;
    border: none;
}

.org-item-area .flip-card {
    width: 260px; /* Ancho fijo */
    margin: 8px auto;
    min-height: 0; /* Permite que la altura se ajuste al contenido */
    height: auto; /* Altura automática según contenido */
    background: transparent;
    border: none;
}

/* Contenedor interno de la tarjeta */
.flip-card-inner {
    position: relative;
    width: 100%;
    height: auto; /* Altura automática según contenido */
    /*min-height: 120px; !* Altura mínima para tarjetas principales *!*/
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

/* Estilos para el frente y reverso de la tarjeta */
.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 150px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 8px;
    background-color: transparent;
    transition: all 0.3s ease;
    margin-top: auto;
}

/* Solo mostrar el fondo y sombra al hacer hover o cuando está girada */
.flip-card:hover .flip-card-front,
.flip-card.flipped .flip-card-back {
    background-color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Estilos específicos para el reverso */
.flip-card-back {
    transform: rotateY(180deg);
    padding: 12px 15px;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px; /* Altura mínima para el reverso */
    box-sizing: border-box;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    position: relative;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Contenedor de la descripción */
.description-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
    padding: 5px 0;
}

/* Estilo del párrafo de descripción */
.description-container p {
    margin: 0 auto;
    font-size: 11px;
    line-height: 1.4;
    color: #4a4a4a;
    padding: 0 5px;
    width: 100%;
    max-width: 100%;
    display: block;
    word-break: auto-phrase;
    text-align: center;
}

/* Ajustes para el reverso de todas las tarjetas */
.flip-card-back {
    padding: 10px 12px !important;
}

.flip-card-back .description-container p {
    font-size: 11px !important;
    line-height: 1.4 !important;
    display: block;
    font-weight: 400;
    color: #5d6d7e !important; /* Color más claro y consistente */
}

.org-item-area .flip-card-back p {
    font-size: 11px;
    line-height: 1.3;
}

/* --- Items y Áreas --- */
.org-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    min-height: 130px;
    width: 100%;
    padding: 0;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
}

/* Íconos más grandes para secciones principales */
.org-item .org-icon {
    width: 70px !important;
    height: 70px !important;
    margin-bottom: 10px;
}

/* Ajuste para el reverso de las tarjetas principales */
.org-item .flip-card-back .org-icon {
    width: 60px !important;
    height: 60px !important;
}

.org-item > .flip-card {
    width: 100%;
    height: 100%;
}

.org-item .flip-card-back {
    font-size: 12px;
    line-height: 1.3;
    color: #5d6d7e;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.org-item > span {
    margin-top: 8px;
    line-height: 1.2;
    display: block;
}

.org-item-area {
    display: flex;
    align-items: center;
    font-size: 11px;
    padding: 10px 12px;
    width: 95%;
    margin: 0 auto;
    cursor: pointer;
    text-align: left;
    /*border: 1px solid #f0f3f8;*/
    border-radius: 6px;
    position: relative;
    min-height: 60px;
    gap: 12px; /* Espacio entre el ícono y el texto */
}

.org-item-area .flip-card {
    min-height: auto;
    width: 100%;
}

.org-item-area .flip-card-back {
    font-size: 11px;
    line-height: 1.3;
    text-align: left;
    padding: 8px;
    justify-content: center;
    align-items: center;
}

/* --- Íconos --- */
.org-icon {
    width: 38px;
    height: 38px;
    transition: transform 0.3s ease;
}

.org-icon-area {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin: 0;
    object-fit: contain;
}

/* Asegurar que los íconos no se muevan durante el flip */
.flip-card-front .org-icon,
.flip-card-back .org-icon {
    /*margin: 0 auto;*/
}

/* Estilos específicos para el ícono en las áreas */
.org-item-area .flip-card-front {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0;
    gap: 12px;
}

.org-item-area .org-icon-area {
    margin: 0 8px 0 0;
}

/* --- Flechas Conectoras --- */
.connector-arrow {
    width: 16px;
    height: auto;
    margin: 2px 0;
}

/* --- Estilos del Tooltip --- */
.info-card {
    display: none;
}

/* ==================================================================
    COMIENZAN LOS AJUSTES EXCLUSIVOS DE RESPONSIVIDAD
=================================================================== */

/*!* --- VISTA TABLET (entre 769px y 1024px) --- *!*/
/*@media (max-width: 1024px) {*/
/*    .level-1::before, .level-2::before, .level-3::before {*/
/*        display: none;*/
/*    }*/

/*    .level-2 {*/
/*        flex-direction: column;*/
/*        align-items: center;*/
/*        gap: 30px;*/
/*    }*/

/*    .org-branch {*/
/*        width: 100%;*/
/*        max-width: 600px;*/
/*    }*/

/*    .org-row {*/
/*        flex-wrap: wrap;*/
/*        justify-content: center;*/
/*    }*/
/*}*/

/* --- VISTA TABLETS Y CELULARES (hasta 1200px) --- */
@media (max-width: 1200px) {
    .level-2 {
        flex-direction: row;
        align-items: flex-start;
        gap: 15px;
    }

    /* Cada .org-branch se convierte en una columna flexible */
    .org-branch {
        flex: 1; /* Cada rama ocupa el 50% del espacio */
    }

    /* Los hijos (.org-column) dentro de .org-row se apilan verticalmente */
    .org-row {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .org-column {
        width: 100%; /* La columna de coordinación ocupa toddo el ancho de su rama */
    }

    /* 💡las tarjetas (flip-card) flexibles y no de ancho fijo */
    .org-item .flip-card,
    .org-item-area .flip-card {
        width: 100%;
        max-width: none;
        margin-left: 14%;
    }
}

/* --- VISTA MÓVIL (hasta 430px) --- */
@media (max-width: 430px) {
    .org-item .flip-card,
    .org-item-area .flip-card {
        margin-left: 0;
    }
}

