/* =========================================================
   ORGANIGRAMA — Estilos globales (editor + vista pública)
   ========================================================= */

/* --- CONTENEDOR PÚBLICO --- */
#org-chart-publico {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 1rem;
  padding: 1.5rem;
  margin: 2rem auto;
  width: 95%;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .12);
}

/* --- ZOOM / PAN WRAPPER --- */
#org-zoom-wrapper {
  overflow: hidden;
  cursor: grab;
  user-select: none;
  min-height: 65vh;
  position: relative;
  background: rgba(255, 255, 255, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.4);
  border-radius: .75rem;
}

#org-zoom-wrapper:active {
  cursor: grabbing;
}

#org-zoom-inner {
  transform-origin: 0 0;
  transition: transform 0.1s ease-out;
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  min-width: max-content;
  min-height: max-content;
  padding: 3rem;
}

/* --- CONTROLES DE ZOOM --- */
.zoom-controls {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
  margin-bottom: .5rem;
}

.zoom-controls button {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #ccc;
  border-radius: .4rem;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}

.zoom-controls button:hover {
  background: #fff;
}

/* --- ÁRBOL --- */
#org-tree-root {
  display: flex;
  justify-content: center;
}

.org-tree {
  display: flex;
  justify-content: center;
}

.org-tree ul {
  padding-top: 24px;
  padding-left: 0;
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
}

.org-tree li {
  list-style-type: none;
  text-align: center;
  position: relative;
  padding: 24px 12px 0 12px;
}

/* --- LÍNEAS CONECTOR --- */
.org-tree li::before,
.org-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid rgba(0, 0, 0, .25);
  width: 50%;
  height: 24px;
}

.org-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid rgba(0, 0, 0, .25);
}

.org-tree li:only-child::after,
.org-tree li:only-child::before {
  display: none;
}

.org-tree li:only-child {
  padding-top: 0;
}

.org-tree li:first-child::before,
.org-tree li:last-child::after {
  border: 0 none;
}

.org-tree li:last-child::before {
  border-right: 2px solid rgba(0, 0, 0, .25);
  border-radius: 0 6px 0 0;
}

.org-tree li:first-child::after {
  border-radius: 6px 0 0 0;
}

/* --- NODO --- */
.org-node {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border: 3px solid #222;
  border-radius: .75rem;
  width: 148px;
  min-height: 110px;
  margin: 0 auto;
  padding: .5rem .5rem .6rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .10);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.org-node:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

/* IMG DEL NODO */
.org-node img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: #e8e8e8;
  border: 2px solid rgba(0, 0, 0, .08);
}

.node-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

/* TEXTOS */
.org-name {
  font-size: .72rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
  word-break: break-word;
  max-width: 130px;
}

.org-role {
  font-size: .62rem;
  color: #444;
  line-height: 1.2;
  word-break: break-word;
  max-width: 130px;
}

/* CINTILLO PROYECTO */
.org-project {
  background: #1a1a1a;
  color: #fff;
  font-size: .55rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: .5rem .5rem 0 0;
  position: absolute;
  top: -1.25rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  letter-spacing: .03em;
}

/* --- COLORES POR TIPO (borde + fondo tenue) --- */
.node-jefe {
  border-color: #e53935;
  background: rgba(229, 57, 53, .08);
}

.node-coord {
  border-color: #fb8c00;
  background: rgba(251, 140, 0, .08);
}

.node-resp {
  border-color: #8e24aa;
  background: rgba(142, 36, 170, .08);
}

.node-jefe-eq {
  border-color: #3949ab;
  background: rgba(57, 73, 171, .08);
}

.node-prog {
  border-color: #1e88e5;
  background: rgba(30, 136, 229, .08);
}

.node-colab {
  border-color: #00897b;
  background: rgba(0, 137, 123, .08);
}

/* --- LEYENDA --- */
.org-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding: .6rem 1rem;
  background: rgba(255, 255, 255, .5);
  border-radius: .6rem;
  margin-top: 1rem;
  font-size: .72rem;
}

.org-legend-item {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.org-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
}

/* --- TOAST NOTIFICATIONS --- */
#org-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.org-toast-msg {
  background: #1a1a1a;
  color: #fff;
  padding: .6rem 1.1rem;
  border-radius: .6rem;
  font-size: .85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
  animation: toastIn .25s ease, toastOut .3s ease 2.5s forwards;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.org-toast-msg.success {
  border-left: 4px solid #43a047;
}

.org-toast-msg.error {
  border-left: 4px solid #e53935;
}

.org-toast-msg.info {
  border-left: 4px solid #1e88e5;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* --- BADGE DE HIJOS AL ELIMINAR --- */
.children-count-badge {
  background: #e53935;
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  padding: .1rem .4rem;
  margin-left: .3rem;
}

/* --- RESPONSIVE --- */
@media (max-width: 960px) {
  .org-page {
    grid-template-columns: 1fr;
  }

  .org-node {
    width: 120px;
  }

  .org-name {
    font-size: .65rem;
  }
}