@media (max-width: 1200px) {
  .tree-branches {
    gap: 24px;
  }
  .tree-node-box {
    min-width: 100px;
    padding: 8px 8px;
  }
  .node-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.9em;
  }
}

@media (max-width: 900px) {
  .tree-branches {
    gap: 12px;
  }
  .tree-node-box {
    min-width: 80px;
    padding: 6px 4px;
  }
  .node-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.8em;
  }
}

@media (max-width: 600px) {
  .tree-container {
    padding: 2px;
  }
  .tree-branches {
    gap: 4px;
  }
  .tree-node-box {
    min-width: 60px;
    padding: 2px 2px;
    font-size: 0.8em;
  }
  .node-avatar {
    width: 16px;
    height: 16px;
    font-size: 0.7em;
  }
}
/* Frontend Styles */

.wc-affiliate-pro-dashboard {
  max-width: 1200px;
}

/* Welcome Header */
.affiliate-welcome-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.affiliate-welcome-header h2 {
  margin: 0 0 8px 0;
  color: white;
}

.affiliate-id-display {
  margin: 0;
}

.affiliate-id-display .label {
  opacity: 0.9;
}

.affiliate-id-display .id-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-family: monospace;
  margin-left: 8px;
}

/* Referral Link Section */
.referral-link-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.section-icon {
  font-size: 2.5em;
}

.section-content {
  flex: 1;
}

.section-content h3 {
  margin: 0 0 8px 0;
}

.section-desc {
  color: #666;
  margin: 0 0 16px 0;
}

.link-container {
  display: flex;
  gap: 10px;
}

.referral-link-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: monospace;
  font-size: 14px;
  background: #f8f9fa;
}

.copy-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.stat-icon {
  font-size: 2em;
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 1.5em;
  font-weight: bold;
  color: #333;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

.stat-affiliates {
  border-left: 4px solid #667eea;
}

.stat-today {
  border-left: 4px solid #38ef7d;
}

.stat-orders {
  border-left: 4px solid #f093fb;
}

.stat-balance {
  border-left: 4px solid #ffd700;
}

/* Binary Tree Section */
.binary-tree-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.binary-tree-section h3 {
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-emoji {
  font-size: 1.2em;
}

/* Binary Stats Grid */
.binary-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.binary-stat {
  text-align: center;
  padding: 20px;
  border-radius: 12px;
  background: #f8f9fa;
}

.binary-stat.left-stat {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 2px solid #2196f3;
}

.binary-stat.right-stat {
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
  border: 2px solid #e91e63;
}

.binary-stat.pair-stat {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border: 2px solid #4caf50;
}

.stat-side-label {
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  margin-bottom: 8px;
}

.stat-big-number {
  font-size: 2.5em;
  font-weight: bold;
  color: #333;
  line-height: 1;
}

.stat-big-number.pairs {
  color: #4caf50;
}

.stat-small-label {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

.unpaired-badge {
  display: inline-block;
  background: rgba(0, 0, 0, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75em;
  margin-top: 8px;
}

/* Binary Tree Visual */
.binary-tree-visual {
  text-align: center;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-bottom: 24px;
}

.tree-node {
  display: inline-block;
}

.tree-node.root {
  margin-bottom: 20px;
}

.node-content {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 80px;
}

.node-content.you {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.node-icon {
  font-size: 1.5em;
  margin-bottom: 4px;
}

.node-label,
.node-name {
  font-size: 0.85em;
  font-weight: 600;
}

.tree-branches {
  display: flex;
  justify-content: center;
  gap: 36px;
}

.tree-branch {
  text-align: center;
}

.branch-label {
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 8px;
}

.tree-branch.left .branch-label {
  color: #2196f3;
}

.tree-branch.right .branch-label {
  color: #e91e63;
}

.tree-node.child .node-content {
  border: 2px dashed #ddd;
}

.tree-node.child.filled .node-content {
  border: 2px solid #4caf50;
  background: #e8f5e9;
}

.tree-node.child.empty .node-content {
  background: #f5f5f5;
  color: #999;
}

/* Pending Placements */
.pending-placements {
  background: #fff8e1;
  border: 2px solid #ffc107;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}

.pending-placements h4 {
  margin: 0 0 8px 0;
  color: #f57c00;
}

.placement-intro {
  color: #666;
  margin: 0 0 16px 0;
  font-size: 0.9em;
}

.placements-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.placement-item {
  background: white;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.placement-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.user-name {
  font-weight: 600;
}

.user-id {
  font-size: 0.8em;
  color: #666;
  font-family: monospace;
}

.placement-actions {
  display: flex;
  gap: 8px;
}

.place-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s;
}

.place-btn:hover {
  transform: translateY(-2px);
}

.place-btn.left-btn {
  background: #2196f3;
  color: white;
}

.place-btn.right-btn {
  background: #e91e63;
  color: white;
}

.place-btn .arrow {
  font-size: 1.2em;
}

/* Earnings Section */
.earnings-section,
.paired-bonus-section,
.affiliates-section,
.payout-history-section,
.bank-details-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.earnings-section h3,
.paired-bonus-section h3,
.affiliates-section h3,
.payout-history-section h3,
.bank-details-section h3 {
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.earnings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.earning-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
}

.earning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.earning-icon {
  font-size: 1.5em;
}

.earning-title {
  font-weight: 600;
  color: #333;
}

.earning-value {
  font-size: 1.8em;
  font-weight: bold;
  color: #28a745;
  margin-bottom: 8px;
}

.earning-detail {
  font-size: 0.85em;
  color: #666;
}

/* KYC Form */
.wc-affiliate-pro-kyc-form {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wc-affiliate-pro-kyc-form h2 {
  margin: 0 0 8px 0;
}

.kyc-intro {
  color: #666;
  margin: 0 0 24px 0;
}

.kyc-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #eee;
}

.kyc-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.kyc-section h3 {
  margin: 0 0 16px 0;
  color: #333;
}

/* Activation Progress */
.wc-affiliate-activation-progress {
  background: #f8f9fa;
  padding: 24px;
  border-radius: 12px;
  margin: 20px 0;
}

.wc-affiliate-activation-progress h3 {
  margin: 0 0 20px 0;
  text-align: center;
}

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.step {
  text-align: center;
  min-width: 80px;
}

.step-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  font-weight: bold;
  font-size: 1.1em;
}

.step.completed .step-icon {
  background: #28a745;
  color: white;
}

.step.active .step-icon {
  background: #007bff;
  color: white;
}

.step-label {
  font-size: 0.75em;
  color: #666;
  font-weight: 500;
}

.step-line {
  width: 40px;
  height: 3px;
  background: #ddd;
  border-radius: 2px;
}

.step-line.completed {
  background: #28a745;
}

/* Shop Redirect */
.wc-affiliate-shop-redirect {
  text-align: center;
  margin: 30px 0;
}

.wc-affiliate-shop-redirect .button {
  font-size: 16px;
  padding: 15px 30px;
}

/* Registration Form */
.wc-affiliate-pro-registration {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wc-affiliate-pro-registration h2 {
  margin: 0 0 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .binary-stats-grid {
    grid-template-columns: 1fr;
  }

  .referral-link-section {
    flex-direction: column;
  }

  .link-container {
    flex-direction: column;
  }

  .tree-branches {
    flex-direction: column;
    gap: 20px;
  }

  .placement-item {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .placement-actions {
    width: 100%;
  }

  .place-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .progress-steps {
    flex-direction: column;
  }

  .step-line {
    width: 3px;
    height: 20px;
  }
}

/* Recursive Binary Tree Styles */
.tree-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  overflow-x: auto;
}

/* Tree Header with Controls */
.tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.tree-header h4 {
  margin: 0;
  font-size: 1.1em;
}

.tree-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.team-count {
  background: #e3f2fd;
  color: #1976d2;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
}

.tree-expand-all,
.tree-collapse-all {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tree-expand-all:hover,
.tree-collapse-all:hover {
  background: #e0e0e0;
}

.tree-help-text {
  text-align: center;
  color: #888;
  font-size: 0.85em;
  margin: 0 0 20px 0;
  padding: 8px 12px;
  background: #f9f9f9;
  border-radius: 8px;
}

.tree-node-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Node Toggle Button */
.node-toggle {
  background: #f0f0f0;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  margin-right: 4px;
}

.node-toggle:hover {
  background: #e0e0e0;
}

.root-node .node-toggle {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.root-node .node-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.toggle-icon {
  font-size: 0.7em;
  transition: transform 0.2s;
}

.tree-node-wrapper.expanded > .tree-node-box .toggle-icon {
  transform: rotate(0deg);
}

.tree-node-wrapper.collapsed > .tree-node-box .toggle-icon {
  transform: rotate(0deg);
}

/* Clickable nodes */
.tree-node-box.has-children {
  cursor: pointer;
}

.tree-node-box.has-children:hover {
  border-color: #667eea;
}

.root-node.has-children:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

/* Node Meta (status + descendant count) */
.node-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.node-descendants-badge {
  background: #f0f4ff;
  color: #5c6bc0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 600;
  white-space: nowrap;
}

.root-node .node-descendants-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Child count in label */
.child-count {
  font-weight: normal;
  opacity: 0.8;
}

.tree-node-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 2px solid #e0e0e0;
  min-width: 120px;
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    border-color 0.2s;
}

.tree-node-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tree-node-box.root-node {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
  color: white;
}

.tree-node-box.empty-node {
  background: #f5f5f5;
  border: 2px dashed #ccc;
  opacity: 0.7;
  cursor: default;
}

.tree-node-box.empty-node:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.node-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  flex-shrink: 0;
}

.root-node .node-avatar,
.node-avatar.avatar-you {
  background: rgba(255, 255, 255, 0.2);
  font-size: 1.4em;
}

.node-avatar.empty {
  background: #ddd;
  color: #999;
}

.node-info {
  flex: 1;
  min-width: 0;
}

.node-info .node-name {
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.root-node .node-name {
  color: white;
}

.node-info .node-name.empty {
  color: #999;
  font-weight: normal;
}

.node-info .node-id {
  font-size: 0.75em;
  color: #888;
  font-family: monospace;
}

.root-node .node-id {
  color: rgba(255, 255, 255, 0.8);
}

.node-position {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2px;
}

.node-position.left {
  color: #2196f3;
}

.node-position.right {
  color: #e91e63;
}

.node-status {
  flex-shrink: 0;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.active {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
}

.status-dot.pending {
  background: #ff9800;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.5);
}

.root-node .status-dot.active {
  background: #90ee90;
}

/* Tree Children Layout */
.tree-children {
  display: flex;
  gap: 24px;
  margin-top: 18px;
  position: relative;
}

.tree-children::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  width: 2px;
  height: 15px;
  background: #ccc;
}

.tree-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.tree-child::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  width: 50%;
  height: 2px;
  background: #ccc;
}

.tree-child.left-child::before {
  left: 50%;
  right: 0;
}

.tree-child.right-child::before {
  right: 50%;
  left: 0;
}

.child-label {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 10px;
}

.left-child .child-label {
  background: #e3f2fd;
  color: #2196f3;
}

.right-child .child-label {
  background: #fce4ec;
  color: #e91e63;
}

.child-connector {
  display: none;
}

/* Position indicators for children */
.tree-node-child.position-left > .tree-node-box {
  border-left: 4px solid #2196f3;
}

.tree-node-child.position-right > .tree-node-box {
  border-left: 4px solid #e91e63;
}

/* Collapsed indicator styling */
.tree-node-wrapper.collapsed > .tree-node-box {
  position: relative;
}

.tree-node-wrapper.collapsed > .tree-node-box::after {
  content: "...";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2em;
  color: #999;
  line-height: 1;
}

/* Animation for tree children */
.tree-children {
  transition: opacity 0.2s;
}

/* Responsive Tree */
@media (max-width: 768px) {
  .tree-header {
    flex-direction: column;
    text-align: center;
  }

  .tree-controls {
    justify-content: center;
  }

  .tree-container {
    padding: 10px;
    overflow-x: auto;
  }

  .tree-children {
    flex-direction: column;
    gap: 20px;
  }

  .tree-children::before {
    display: none;
  }

  .tree-child::before {
    display: none;
  }

  .tree-node-box {
    min-width: 130px;
    padding: 10px 12px;
  }

  .node-avatar {
    width: 32px;
    height: 32px;
    font-size: 1em;
  }

  .node-toggle {
    width: 20px;
    height: 20px;
  }

  .node-descendants-badge {
    font-size: 0.65em;
  }
}
