/* Estilos generales del árbol */
#arbolReferidos {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  width: 100%;
  height: 100%;
  padding: 1rem;
  background: linear-gradient(to bottom right, #6ee7b7, #3b82f6);
  border-radius: 10px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  scroll-behavior: smooth;
}

.tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  min-width: max-content;
}

.tree ul {
  padding-top: 10px;
  position: relative;
  display: flex;
  justify-content: space-around;
  flex-wrap: nowrap;
  min-width: 100%;
}

.tree li {
  list-style-type: none;
  text-align: center;
  position: relative;
  margin: 0 1rem;
  padding-top: 30px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tree li > ul {
  margin-top: 1rem;
  display: flex;
  justify-content: space-around;
  flex-wrap: nowrap;
  width: 100%;
}

.tree li.collapsed > ul {
  display: none;
}

.tree li::before,
.tree li::after,
.tree li > ul::before {
  display: none !important;
}

/* Nodo */
.node {
  position: relative;
  padding: 6px 10px;
  border-radius: 9999px;
  border: 2.5px solid transparent;
  font-size: 12px;
  font-weight: bold;
  background-color: rgba(31, 41, 55, 0.9);
  color: white;
  display: inline-block;
  min-width: 80px;
  max-width: 120px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.node:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.node:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(55, 65, 81, 0.96);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 20;
}

.node button {
  background-color: #4ade80;
  color: #1f2937;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  margin-top: 4px;
  transition: background 0.3s ease;
  cursor: pointer;
  border: none;
}

.node button:hover {
  background-color: #3cbf5d;
}

.arrow {
  font-size: 10px;
  margin-right: 4px;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.3s ease;
}

.collapsed .arrow {
  transform: rotate(-90deg);
}

.crown {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
}

/* ====== Aureolas y colores de membresía ====== */

/* Standard */
.aureola-standard-completos {
  border-color: limegreen !important;
  box-shadow: 0 0 0 3px #5eea8f99, 0 0 10px 2px #57d26b44;
  background: linear-gradient(120deg, #f0fff4 60%, #5eea8f 100%);
  color: #1f2937;
}
.aureola-standard-pocos {
  border-color: red !important;
  box-shadow: 0 0 0 3px #ff4d4d99, 0 0 10px 2px #ff4d4d44;
  background: linear-gradient(120deg, #fff0f0 60%, #ff7a7a 100%);
  color: #1f2937;
}

/* Premium */
.aureola-premium-completos {
  border-color: #a8a29e !important;
  box-shadow: 0 0 0 3px #b5b5ff99, 0 0 10px 2px #a8a29e44;
  background: linear-gradient(120deg, #f4f4ff 60%, #b5b5ff 100%);
  color: #1f2937;
}
.aureola-premium-pocos {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px #3b82f699, 0 0 10px 2px #3b82f644;
  background: linear-gradient(120deg, #e0f2ff 60%, #3b82f6 100%);
  color: #1f2937;
}

/* Principal */
.aureola-principal {
  border-color: #ffd700 !important;
  box-shadow: 0 0 0 3px #ffe06699, 0 0 12px 2px #ffd70055;
  background: linear-gradient(120deg, #fffbe0 60%, #ffe066 100%);
  color: #222d3a;
}
.aureola-principal-pocos {
  border-color: orange !important;
  box-shadow: 0 0 0 3px #ffa50099, 0 0 12px 2px #ffa50055;
  background: linear-gradient(120deg, #fffbe0 60%, #ffa500 100%);
  color: #222d3a;
}

/* Modo oscuro */
.dark .aureola-principal {
  border-color: #ffe066 !important;
  box-shadow: 0 0 0 3px #ffe06644, 0 0 10px 2px #ffd70033;
  background: linear-gradient(120deg, #4b4a04 60%, #ffe066 100%);
  color: #fffde7;
}
.dark .aureola-principal-pocos {
  border-color: #ffbb33 !important;
  box-shadow: 0 0 0 3px #ffbb3355, 0 0 10px 2px #ffbb3344;
}
.dark .aureola-premium-completos {
  border-color: #b5b5ff !important;
  background: linear-gradient(120deg, #23274b 60%, #b5b5ff 100%);
  color: #e0e7ff;
}
.dark .aureola-premium-pocos {
  border-color: #3b82f6 !important;
  background: linear-gradient(120deg, #23274b 60%, #3b82f6 100%);
  color: #e0e7ff;
}
.dark .aureola-standard-completos {
  border-color: #5eea8f !important;
  background: linear-gradient(120deg, #1e293b 60%, #5eea8f 100%);
  color: #bbf7d0;
}
.dark .aureola-standard-pocos {
  border-color: #ff4d4d !important;
  background: linear-gradient(120deg, #1e293b 60%, #ff4d4d 100%);
  color: #fecaca;
}

/* Conectores SVG */
svg.connectors {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.animated-line {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: drawLine 1s ease forwards;
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

/* Líneas de niveles */
.level-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: #ccc;
  display: flex;
  align-items: center;
  padding-left: 10px;
  pointer-events: none;
  z-index: 1;
}

/* Leyenda visual */
.legend {
  max-width: 700px;
  margin: 40px auto;
  background: #1f2937;
  padding: 1rem;
  border-radius: 1rem;
  color: white;
}
.legend-sample {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 50%;
  border: 2.5px solid transparent;
}
.legend .aureola-principal,
.legend .aureola-principal-pocos,
.legend .aureola-premium-completos,
.legend .aureola-premium-pocos,
.legend .aureola-standard-completos,
.legend .aureola-standard-pocos {
  box-shadow: none;
  background: none;
}

/* Mobile: forzar diseño horizontal como en escritorio */
@media (max-width: 768px) {
  #arbolReferidos {
    overflow-x: auto;
  }
  .tree {
    min-width: 700px;
    width: max-content;
  }
  #arbolReferidos .legend {
    display: none !important;
  }
}

.legend-sample {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
  border: 2.5px solid transparent;
}
.legend .aureola-principal,
.legend .aureola-principal-pocos,
.legend .aureola-premium-completos,
.legend .aureola-premium-pocos,
.legend .aureola-standard-completos,
.legend .aureola-standard-pocos {
  box-shadow: none !important;
  background: none !important;
}
.ml-2 { margin-left: 0.5rem; }
.align-middle { vertical-align: middle; }