/* ================= TREE LAYOUT ================= */

.tree-container {
  background: white;
  padding: 40px 20px;
  border-radius: 14px;
  box-shadow: 0 4px 15px rgba(30, 58, 138, 0.05);
  width: 100%;
  min-height: 300px;
  overflow: hidden;
  position: relative;
  text-align: center;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
}

.tree-container:active {
  cursor: grabbing;
}

#treeZoomLayer {
  display: inline-block;
  min-width: 100%;
  min-height: 100%;
  text-align: left; /* reset text align inside the zoom layer so nodes behave correctly */
}

/* Each node + its children grouped together */
.tree-family {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 10px;
  vertical-align: top;
  white-space: normal;
}

/* Row of sibling families */
.tree-children {
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin-top: 40px;
  position: relative;
  flex-shrink: 0;
}

/* The node box */
.tree-node {
  background: #f8f9fa;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 10px 18px;
  min-width: 110px;
  text-align: center;
  font-weight: 500;
  position: relative;
  z-index: 1;
  cursor: pointer;
  white-space: nowrap;
}

.tree-node:hover {
  background: #e8f4fd;
  border-color: #3498db;
}

/* Edit mode action links */
.tree-node-actions {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.tree-node-actions a {
  font-size: 11px;
  color: #3498db;
  text-decoration: none;
  background: #eaf4fb;
  padding: 2px 6px;
  border-radius: 3px;
}

.tree-node-actions a:hover {
  background: #3498db;
  color: white;
}

/* ================= TREE TOOLBAR ================= */
.tree-toolbar {
  margin: 15px 0 20px 0;
}

.tree-toolbar .btn {
  display: inline-block;
  padding: 8px 14px;
  background: #2c3e50;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  margin-right: 10px;
  font-weight: 500;
}

.tree-toolbar .btn:hover {
  background: #1f2d3a;
}

.tree-toolbar .btn-edit {
  background: #27ae60;
}

.tree-toolbar .btn-edit:hover {
  background: #1e8449;
}

/* ================= TREE PAGE HEADER ================= */
.tree-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.tree-page-title h1 {
  margin-bottom: 8px;
}

/* ================= TREE CONTROLS (DEPTH DROPDOWN) ================= */
.tree-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-controls label {
  font-weight: 500;
  font-size: 14px;
  color: #333;
}

.tree-controls select {
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.tree-controls select:focus {
  outline: none;
  border-color: #3498db;
}

/* ================= BACK BUTTON ================= */
.btn-back {
  background: #7f8c8d;
}

.btn-back:hover {
  background: #636e72;
}

/* ================= NODE INFO BUTTON ================= */
.tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tree-node-name {
  font-weight: 500;
}

.tree-node-link {
  color: #2c3e50;
  text-decoration: none;
  font-weight: 500;
}

.tree-node-link:hover {
  color: #3498db;
}

.tree-node-info {
  font-size: 13px;
  color: #3498db;
  text-decoration: none;
  cursor: pointer;
}

.tree-node-info:hover {
  color: #1a6fa8;
}

/* ================= ROOT NODE HIGHLIGHT ================= */
.tree-node-root {
  background: #eaf4fb;
  border-color: #3498db;
}

/* ================= TREE CONTAINER HEADER ================= */
.tree-container-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  width: 100%;
}

@media (max-width: 768px) {
  .tree-container {
    padding: 15px 10px;
    text-align: left; /* Solves the center-clipping bug definitively on mobile */
  }
  
  .tree-node {
    padding: 8px 12px;
    min-width: 80px;
    font-size: 13px;
  }
  
  .tree-node-name {
    font-size: 13px;
  }
  
  .tree-node-info {
    font-size: 12px;
  }
  
  .tree-node-actions a {
    font-size: 10px;
    padding: 2px 4px;
  }
  
  .tree-children {
    margin-top: 30px;
  }
  
  .tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 15px 0;
  }
  
  .tree-toolbar .btn {
    margin-right: 0;
    flex: 1 1 auto;
    text-align: center;
    font-size: 13px;
    padding: 6px 10px;
  }
  
  .tree-controls select {
    width: 100%;
    font-size: 13px;
    padding: 5px 10px;
  }
}

/* ================= TREE NODE BORDERS ================= */
.tree-node-male {
  border: 2px solid #3498db !important;
}

.tree-node-female {
  border: 2px solid #e74c3c !important;
}

.tree-node-deen {
  border: 2px solid #2ecc71 !important;
}

/* ================= RELATIONSHIP BORDERS ================= */
.rel-child {
  outline: 3px solid #1abc9c !important; /* Turquoise */
  outline-offset: 3px;
}

.rel-spouse {
  outline: 3px solid #9b59b6 !important; /* Purple */
  outline-offset: 3px;
}

.rel-father {
  outline: 3px solid #34495e !important; /* Navy */
  outline-offset: 3px;
}

.rel-mother {
  outline: 3px solid #e67e22 !important; /* Orange */
  outline-offset: 3px;
}
