/* ══════════════════════════════════════════
   Organigrama Plugin — Frontend Público
   ══════════════════════════════════════════ */

/* ──────────────────────────────────────────
   Contenedor principal
────────────────────────────────────────── */
.orgchart-public-wrapper {
    position: relative;
    width: 100%;
    border: 1px solid #dde3ea;
    border-radius: 10px;
    overflow: hidden;
    background: transparent;
    min-height: 600px;
}

.orgchart-public-canvas {
    width: 100%;
    min-height: 600px;
    height: 800px;
    background: transparent;
}

/* ──────────────────────────────────────────
   Toolbar pública (zoom)
────────────────────────────────────────── */
.orgchart-public-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.orgchart-pub-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #c5cdd6;
    background: #fff;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #445;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
    transition: background .15s;
}
.orgchart-pub-btn:hover { background: #e8f0fe; border-color: #4a6fa5; }

/* ──────────────────────────────────────────
   Nodo público
────────────────────────────────────────── */
.orgchart-pub-node-container {
    width: 100%;
    height: 100%;
}

.orgchart-pub-node {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 14px rgba(0,0,0,.18);
    width: 160px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    transition: box-shadow .2s, transform .2s;
    border: 2px solid transparent;
}

.orgchart-pub-node:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.28);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,.4);
}

.orgchart-pub-node__img {
    width: 100%;
    height: 88px;
    background: #d8e2ee;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.orgchart-pub-node__photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.orgchart-pub-node__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #8faac0;
    background: #d8e2ee;
}

.orgchart-pub-node__body {
    padding: 10px 12px 12px;
    background: var(--node-color, #4a6fa5);
    flex: 1;
}

.orgchart-pub-node__name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.3;
    letter-spacing: .03em;
    word-break: break-word;
}

.orgchart-pub-node__role {
    font-size: 10px;
    color: rgba(255,255,255,.82);
    margin-top: 4px;
    line-height: 1.35;
    word-break: break-word;
}

/* ──────────────────────────────────────────
   Modal de nodo
────────────────────────────────────────── */
.orgchart-modal-overlay {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: rgba(0,0,0,.55);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.orgchart-modal-overlay.active {
    display: flex !important;
}

.orgchart-modal {
    display: flex;
    align-items: stretch;
    gap: var(--oc-modal-gap, 0px);
    background: var(--oc-modal-bg, #4a6fa5);
    border-radius: var(--oc-modal-radius, 20px);
    box-shadow: 0 22px 60px rgba(0,0,0,.34);
    width: 100%;
    max-width: var(--oc-modal-max-width, 960px);
    position: relative;
    overflow: hidden;
    animation: orgchart-modal-in .22s ease;
}

@keyframes orgchart-modal-in {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.orgchart-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #fff;
    border-radius: 0;
    box-shadow: none;
    text-shadow: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    opacity: .92;
    transition: opacity .15s;
}
.orgchart-modal__close:hover { background: transparent; opacity: 1; }

.orgchart-modal__img-wrap {
    flex: 0 0 var(--oc-modal-image-width, 250px);
    width: var(--oc-modal-image-width, 250px);
    background: var(--oc-modal-bg, #4a6fa5);
    padding: 16px 0 16px 16px;
    box-sizing: border-box;
    overflow: visible;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orgchart-modal__img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 14px !important;
    background: var(--oc-modal-image-bg, #f5f2ee);
    object-fit: cover;
    object-position: top;
    clip-path: inset(0 round 14px);
    overflow: hidden;
}

.orgchart-modal__img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 14px !important;
    background: var(--oc-modal-image-bg, #f5f2ee);
    color: #8faac0;
    clip-path: inset(0 round 14px);
    overflow: hidden;
}
.orgchart-modal__img-placeholder svg { width: 80px; height: 80px; }

.orgchart-modal__body {
    flex: 1;
    padding: var(--oc-modal-padding, 28px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.orgchart-modal__accent {
    width: 74px;
    height: 2px;
    border-radius: 999px;
    background: var(--oc-modal-accent-color, #86d3a5);
    margin: 8px 0 10px;
}

.orgchart-modal__name {
    font-size: var(--oc-modal-title-size, 20px) !important;
    font-weight: 700;
    color: var(--oc-modal-name-color, #ffffff) !important;
    margin: 0;
    line-height: 1.25 !important;
}

.orgchart-modal__cargo {
    font-size: var(--oc-modal-cargo-size, 14px) !important;
    color: var(--oc-modal-cargo-color, #eef5ff);
    font-weight: 600;
    margin: 0;
    letter-spacing: .02em;
}

.orgchart-modal__desc {
    font-size: var(--oc-modal-desc-size, 14px) !important;
    color: var(--oc-modal-desc-color, #ffffff);
    line-height: 1.62;
}
.orgchart-modal__desc p { margin: 0 0 10px; }
.orgchart-modal__desc p:last-child { margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE MODAL  (≤ 768 px)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    .orgchart-modal-overlay {
        padding: 12px;
        align-items: center;
        justify-content: center;
    }

    /* ── CLAVE: height fijo (no solo max-height) ───────────────────────
       Con solo max-height, cuando el contenido es corto el modal se
       encoge y body no recibe altura — flex:1 del body vale 0, la
       descripción no tiene espacio y no scrollea.
       height:92vh establece una altura real; el body puede expandirse
       hasta llenar ese espacio con flex:1.                             */
    .orgchart-modal {
        flex-direction: column;
        width: 100%;
        height: 92vh;
        max-height: 92vh;
        overflow: hidden;
    }

    /* ── IMAGEN: 45 % del modal, máx. valor configurado ───────────────
       flex: 0 0 45% → en un modal de 92vh da una imagen generosa.
       max-height limita en pantallas muy altas (phablets/tablets).    */
    .orgchart-modal__img-wrap {
        position: relative;
        width: 100%;
        flex: 0 0 45%;
        max-height: var(--oc-modal-mobile-image-h, 260px);
        overflow: hidden;
        padding: 0;
    }

    .orgchart-modal__img {
        position: absolute !important;
        top: 0; right: 0; bottom: 0; left: 0;
        width: 100%  !important;
        height: 100% !important;
        border-radius: 0 !important;
        clip-path: none !important;
        object-fit: cover;
        object-position: 50% 25%;
        display: block;
    }

    .orgchart-modal__img-placeholder {
        position: absolute !important;
        top: 0; right: 0; bottom: 0; left: 0;
        width: 100%  !important;
        height: 100% !important;
        border-radius: 0 !important;
        clip-path: none !important;
    }

    /* ── CUERPO: ocupa el resto del modal ─────────────────────────────
       flex: 1 1 0 + min-height:0 → crece para llenar exactamente
       los píxeles restantes después de la imagen.                     */
    .orgchart-modal__body {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0;
        min-height: 0;
        padding: 16px 18px 0;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        gap: 2px;
    }

    /* Nombre y cargo: nunca se encogen, siempre visibles */
    .orgchart-modal__name {
        flex-shrink: 0 !important;
        font-size: clamp(15px, 4vw, 21px) !important;
        line-height: 1.25 !important;
        margin: 0 !important;
    }

    .orgchart-modal__cargo {
        flex-shrink: 0 !important;
        font-size: clamp(12px, 3vw, 15px) !important;
        margin: 3px 0 0 !important;
        line-height: 1.35 !important;
    }

    .orgchart-modal__accent {
        flex-shrink: 0 !important;
        margin: 8px 0 5px !important;
    }

    /* ── DESCRIPCIÓN: ocupa lo que queda y scrollea ────────────────────
       flex: 1 1 0 → crece hasta llenar el espacio restante del body.
       overflow-y:auto → scroll activo cuando el texto es más largo.   */
    .orgchart-modal__desc {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 16px !important;
        font-size: clamp(12px, 3vw, 14px) !important;
        line-height: 1.55 !important;
    }

    .orgchart-modal__close {
        top: 8px   !important;
        right: 8px !important;
        width: 32px  !important;
        height: 32px !important;
        font-size: 22px !important;
        background: rgba(0,0,0,.50) !important;
        border-radius: 50% !important;
        opacity: 1 !important;
    }
}

/* ── Teléfonos compactos ≤ 390 px ─────────────────────────────────────── */
@media (max-width: 390px) {
    .orgchart-modal-overlay { padding: 8px; }
    .orgchart-modal__body   { padding: 12px 14px 0 !important; }
}

/* Mensaje de error del shortcode */
.orgchart-error {
    padding: 12px 16px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    color: #664d03;
    font-size: 14px;
}
