/* ==========================================================================
   KONZPAY - Estilos da Rede Hierárquica e Árvore de Usuários/Parceiros
   ========================================================================== */

/* Top bar com métricas da rede */
.hierarchy-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.hierarchy-stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.hierarchy-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hierarchy-stat-icon.icon-blue {
  background: #eff6ff;
  color: var(--primary-blue);
}

.hierarchy-stat-icon.icon-green {
  background: #ecfdf5;
  color: var(--primary-green);
}

.hierarchy-stat-icon.icon-purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.hierarchy-stat-icon.icon-amber {
  background: #fefce8;
  color: #d97706;
}

.hierarchy-stat-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.hierarchy-stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.hierarchy-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-heading);
}

/* Header & View Toggle */
.hierarchy-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.view-mode-toggle {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.btn-toggle-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-toggle-mode:hover:not(.active) {
  color: #0f172a;
  background: #e2e8f0;
}

.btn-toggle-mode.active {
  background: #facc15;
  color: #0f172a;
  font-weight: 700;
  border: 1px solid #eab308;
  box-shadow: 0 2px 5px rgba(234, 179, 8, 0.3);
}

.btn-toggle-mode svg {
  width: 15px;
  height: 15px;
}

.btn-toggle-mode.active svg {
  color: #0f172a;
  stroke: #0f172a;
}

/* ==========================================================================
   ÁRVORE HIERÁRQUICA INTERATIVA (TREE VIEW)
   ========================================================================== */
.tree-container-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 36px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  overflow-x: auto;
  min-height: 480px;
}

.tree-wrapper {
  display: inline-flex;
  justify-content: center;
  min-width: 100%;
  padding: 10px 20px 40px;
}

/* Tree Node Card */
.tree-node {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px 18px;
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  z-index: 2;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.tree-node:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 8px 22px rgba(29, 104, 216, 0.18);
}

.tree-node.is-root {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.1);
}

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-node-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0f172a;
  color: #facc15;
  border: 1px solid #1e293b;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.tree-node.is-root .tree-node-avatar {
  background: #facc15;
  color: #0f172a;
  border: 1px solid #ca8a04;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(202, 138, 4, 0.35);
}

.tree-node-title-group {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tree-node-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-role {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.tree-node-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.badge-level {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #475569;
}

.badge-commission {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #ecfdf5;
  color: #059669;
}

.tree-node-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.tree-downlines-count {
  font-size: 11.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-add-subnode {
  background: none;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-blue);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-add-subnode:hover {
  background: #eff6ff;
  border-color: var(--primary-blue);
}

/* ==========================================================================
   CONECTORES DA ÁRVORE GENEALÓGICA / ORGANOGRAMA (ZOOM & PAN + SVG PRECISION)
   ========================================================================== */
.tree-container-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  min-height: 560px;
  position: relative;
  overflow: hidden;
}

.tree-viewport {
  width: 100%;
  height: 620px;
  min-height: 560px;
  overflow: hidden;
  cursor: grab;
  position: relative;
  background-color: #ffffff;
  background-image: radial-gradient(#e2e8f0 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  user-select: none;
}

.tree-viewport.is-dragging {
  cursor: grabbing;
}

.tree-zoom-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  gap: 2px;
}

.btn-tree-zoom {
  background: transparent;
  border: none;
  color: #475569;
  min-width: 34px;
  height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.btn-tree-zoom:hover {
  background: #f1f5f9;
  color: var(--primary-blue);
}

.btn-tree-zoom svg {
  width: 16px;
  height: 16px;
}

.zoom-toolbar-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
  margin: 0 2px;
}

.tree-canvas-hint {
  position: absolute;
  bottom: 14px;
  left: 18px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(4px);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
  pointer-events: none;
}

.tree-wrapper {
  display: inline-flex;
  justify-content: center;
  min-width: 100%;
  padding: 40px 60px 80px;
  position: relative;
  transform-origin: 50% 20%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  image-rendering: -webkit-optimize-contrast;
  transform-style: flat;
}

/* ==========================================================================
   CONECTORES PRÉ-RENDERIZADOS DA ÁRVORE (100% CSS PURO E INSTANTÂNEO)
   ========================================================================== */
#treeSvgOverlay {
  display: none; /* Substituído por conectores nativos CSS pré-renderizados */
}

.tree-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 16px;
}

/* 1. Linha vertical que desce do fundo do nó pai até o barramento */
.tree-branch.has-children > .tree-node::after {
  content: '';
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px;
  background: #94a3b8;
  z-index: 1;
}

/* 2. Container dos filhos com espaçamento contínuo */
.tree-children {
  display: flex;
  justify-content: center;
  position: relative;
  padding-top: 48px;
  margin: 0;
  gap: 0;
}

/* 3. Linha vertical que sobe de cada filho até a barra horizontal */
.tree-children > .tree-branch::before {
  content: '';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 24px;
  background: #94a3b8;
  z-index: 1;
}

/* 4. Barra horizontal conectando os nós irmãos */
.tree-children > .tree-branch::after {
  content: '';
  position: absolute;
  top: -24px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #94a3b8;
  z-index: 1;
}

/* O primeiro filho só tem a barra para a direita */
.tree-children > .tree-branch:first-child::after {
  left: 50%;
  width: 50%;
  border-top-left-radius: 4px;
}

/* O último filho só tem a barra para a esquerda */
.tree-children > .tree-branch:last-child::after {
  left: 0;
  width: 50%;
  border-top-right-radius: 4px;
}

/* Quando houver apenas 1 filho (filho único), a barra horizontal desaparece e a linha vertical conecta direto */
.tree-children > .tree-branch:only-child::after {
  display: none;
}

/* ==========================================================================
   TABELA DA REDE (NETWORK TABLE)
   ========================================================================== */
.table-network-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0f172a;
  color: #facc15;
  border: 1px solid #1e293b;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name-col {
  display: flex;
  flex-direction: column;
}

.user-full-name {
  font-weight: 700;
  color: var(--text-heading);
  font-size: 13.5px;
}

.user-id-sub {
  font-size: 11px;
  color: #94a3b8;
}

.upline-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

/* Badges de Status de Vendedores */
.badge-seller-pending {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.1);
}

.badge-seller-rejected {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Filtros por Pílulas de Status */
.seller-status-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.btn-status-pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-status-pill:hover:not(.active) {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-status-pill.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pill-count {
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

.btn-status-pill.active .pill-count {
  background: #0f172a;
  color: #ffffff;
}

.pill-count.pill-warning {
  background: #f59e0b;
  color: #ffffff;
}

/* ==========================================================================
   KONZPAY - Split de Comissões Multinível na Hierarquia
   ========================================================================== */

.split-member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  gap: 12px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.split-member-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.split-member-card.is-direct {
  border-color: #a7f3d0;
  background: #fcfdfd;
}

.split-member-card.is-admin {
  border-color: #fde68a;
  background: #fffdf5;
}

.split-avatar-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11.5px;
  flex-shrink: 0;
}

.split-avatar-icon.direct {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.split-avatar-icon.upline {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.split-avatar-icon.admin {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.split-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.split-tag.direct {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.split-tag.upline {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #dbeafe;
}

.split-tag.admin {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.split-connector-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1px 0;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  user-select: none;
}

.split-connector-line span {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #f1f5f9;
  padding: 1px 8px;
  border-radius: 4px;
}

.split-rate-input-wrap {
  position: relative;
  width: 110px;
  flex-shrink: 0;
}

.split-rate-input-wrap input {
  padding-right: 28px !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  text-align: right !important;
  height: 36px !important;
  border-radius: 8px !important;
  border: 1px solid #cbd5e1 !important;
  transition: all 0.15s ease !important;
}

.split-rate-input-wrap input:focus {
  border-color: #059669 !important;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12) !important;
}

.split-rate-input-wrap .split-percent-sym {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
  font-size: 12px;
  color: #64748b;
  pointer-events: none;
}

