/* ===========================================================
   ORGANIGRAMA ITA PROFESSIONAL
   style.css - CORREGIDO
=========================================================== */

:root {
    --tec-azul:#003B70;
    --tec-azul2:#005A9C;
    --tec-gris:#F2F4F7;
    --tec-borde:#D9DDE3;
    --tec-texto:#2C3E50;

    --card-width:270px;
    /* 1. Incrementamos la altura total de la tarjeta para absorber el nuevo tamaño del avatar */
    --card-height:360px; 

    --shadow:0 8px 20px rgba(0,0,0,.15);
}

/*===========================================================*/

*{
    margin:0;
    padding:0;
    box-sizing:border-box; /* Excelente que ya lo tuvieras */
}

html,body{
    width:100%;
    height:100%;
    overflow:hidden;
    font-family: "Segoe UI", Arial, sans-serif;
    background:var(--tec-gris);
}

/*===========================================================*/
/* BARRA SUPERIOR                                            */
/*===========================================================*/

#toolbar{
    height:70px;
    background:var(--tec-azul);
    color:white;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 20px;
    box-shadow:0 2px 10px rgba(0,0,0,.25);
    z-index:999;
    position:relative;
}

.logo{
    font-size:22px;
    font-weight:bold;
}

.acciones{
    display:flex;
    gap:10px;
    align-items:center;
}

#buscar{
    width:300px;
    padding:10px;
    border:none;
    border-radius:6px;
    outline:none;
    font-size:15px;
}

button{
    padding:10px 15px;
    border:none;
    border-radius:6px;
    background:white;
    cursor:pointer;
    font-weight:bold;
    transition:.25s;
}

button:hover{
    background:#E3EAF3;
}

/*===========================================================*/
/* ÁREA DEL ORGANIGRAMA - ADAPTADA PARA MÓVILES               */
/*===========================================================*/

#workspace {
    width: 100%;
    height: calc(100vh - 70px);
    
    /* CAMBIO CLAVE: Cambiamos 'hidden' por 'auto' para permitir deslices con el dedo */
    overflow: auto; 
    
    position: relative;
    background: #ECEFF3;
    
    /* Mejora la fluidez del scroll táctil en iPhones y Android */
    -webkit-overflow-scrolling: touch; 
}

#viewport{
    position:absolute;
    top:0;
    left:0;
    transform-origin:0 0;
    will-change:transform;
    touch-action:none;
}

#connections{
    position:absolute;
    top:0;
    left:0;
    width:8000px; /* Aumentado ligeramente por si el árbol se extiende */
    height:8000px;
    overflow:visible;
    pointer-events:none;
    z-index:1; /* Asegura que se dibuje correctamente detrás/entre nodos */
}

#tree{
    position:absolute;
    top:0;
    left:0;
    z-index:2;
}

/*===========================================================*/
/* TARJETAS MODIFICADAS                                      */
/*===========================================================*/

.node {
    position:absolute;
    width:var(--card-width);
    height:var(--card-height); /* Mantiene la consistencia matemática para las líneas SVG */
    background:white;
    border-radius:14px;
    box-shadow:var(--shadow);
    border-top:6px solid var(--tec-azul);
    transition: box-shadow .25s ease, border-color .25s ease;
    padding:14px; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation:aparecer .35s ease;
}

/* Rediseño del Hover: Quitamos el "scale" y el "translateY" que rompían las líneas matemáticas */
.node:hover{
    box-shadow: 0 12px 30px rgba(0,0,0,.25);
    border-top-color: var(--tec-azul2);
}

.node h3{
    font-size:16px;
    color:var(--tec-azul);
    margin-bottom:6px;
    line-height: 1.2;
}

.node h4{
    font-size:14px;
    color:#555;
    font-weight:600;
    margin-bottom:6px;
}

.node p{
    font-size:13px;
    color:#666;
    line-height:1.3;
}

.fade{
    opacity:.18;
    filter:grayscale(100%);
}

/*===========================================================*/
/* FOTOS Y CONTENIDO INTERNO                                 */
/*===========================================================*/

.avatar {
    width: 100%;
    /* 2. Hacemos el contenedor del avatar más largo verticalmente */
    height: 165px; 
    background:#EAF2FB;
    display:flex;
    justify-content:center;
    align-items:center;
    overflow:hidden;
    border-radius: 8px;
    margin-bottom: 10px;
}

.avatar img {
    width:100%;
    height:100%;
    /* 3. "cover" evita la desproporción y "top" asegura que no se recorte la cabeza */
    object-fit: cover; 
    object-position: top center; 
    background:white;
}

.contenido {
    padding:4px 0 0 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
/*===========================================================*/
/* LÍNEAS SVG Y BUSCADOR                                     */
/*===========================================================*/

.search, .highlight{
    border:4px solid #FF9800 !important;
    box-shadow:0 0 20px rgba(255,152,0,.6) !important;
    z-index:999 !important;
}

line{
    stroke:#003B70;
    stroke-width:3;
    stroke-linecap:round;
    animation:draw .6s ease;
}

@keyframes draw{
    from{ opacity:0; }
    to{ opacity:1; }
}

/*===========================================================*/
/* RESPONSIVE & ANIMACIONES                                  */
/*===========================================================*/

@media(max-width:900px){
    #buscar{ width:180px; }
    .logo{ font-size:18px; }
}

@keyframes aparecer{
    from{
        opacity:0;
        transform:translateY(20px);
    }
    to{
        opacity:1;
        transform:none;
    }
}


/*===========================================================*/
/* OPTIMIZACIÓN EXCLUSIVA PARA PANTALLAS DE CELULARES        */
/*===========================================================*/

@media (max-width: 600px) {
    #toolbar {
        height: auto;
        padding: 15px 10px;
        flex-direction: column; /* Apila el título y los botones para que quepan */
        gap: 12px;
    }

    .logo {
        font-size: 16px;
        text-align: center;
        line-height: 1.3;
    }

    .acciones {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap; /* Si los botones no caben, bajan ordenadamente */
    }

    #buscar {
        width: 100%; /* El buscador ocupa todo el ancho disponible en el cel */
        max-width: 280px;
        font-size: 14px;
        padding: 8px;
    }

    button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* Da un margen extra al espacio de trabajo para que el usuario pueda 
       deslizar el dedo cómodamente desde las orillas */
    #viewport {
        padding: 20px;
    }
}