/* ===== Reset & Fonts ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f4f6f9;
  color: #333;
  overflow: hidden;
}

/* ===== Header ===== */
header {
  background-color: #2c3e50;
  color: #fff;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

header h2 {
  flex: 1 1 100%;
  font-size: 1.5rem;
  margin-bottom: 10px;
}

header select,
header input,
header button {
  border-radius: 4px;
  border: none;
  outline: none;
}

header select,
header input {
  padding: 6px 10px;
  font-size: 14px;
}

header button {
  padding: 6px 12px;
  background-color: #3498db;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

header button:hover {
  background-color: #2980b9;
}

/* ===== Breadcrumb ===== */
#breadcrumb {
  margin: 5px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

/* ===== Main Container ===== */
.container {
  display: flex;
  height: calc(100vh - 80px);
  overflow: hidden;
}

/* ===== Tree Section ===== */
.left {
  flex: 2;
  background-color: #fff;
  border-right: 1px solid #ccc;
  padding: 10px;
  overflow: auto;
  position: relative;
}

.left svg {
  width: 100%;
  height: 100%;
}

/* Fullscreen tree */
.left.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  background-color: #fff;
  padding: 0;
  overflow: hidden;
}

/* Hide header when fullscreen */
body.fullscreen header {
  display: none;
}

/* ===== Tooltip ===== */
.tooltip {
  position: absolute;
  text-align: left;
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border-radius: 5px;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.2s;
}

/* ===== Panel ===== */
.panel {
  flex: 1;
  background-color: #fdfdfd;
  padding: 15px;
  overflow-y: auto;
  border-left: 1px solid #ccc;
  transition: all 0.3s ease;
}

.panel.hide {
  width: 0;
  padding: 0;
  border-left: none;
  overflow: hidden;
}

.panel h3 {
  margin-bottom: 8px;
  color: #2c3e50;
}

.panel .meta {
  font-size: 13px;
  color: #666;
  margin-bottom: 10px;
}

.panel label {
  font-weight: 600;
  margin-top: 8px;
  display: block;
}

.panel textarea,
.panel input[type="text"],
.panel input[type="number"] {
  width: 100%;
  padding: 6px 10px;
  margin-top: 4px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* ===== Panel Sections ===== */
.panel-section {
  margin-bottom: 15px;
}

.panel-header {
  background-color: #3498db;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 5px;
}

.panel-header:hover {
  background-color: #2980b9;
}

.panel-section.collapsed .panel-content {
  display: none;
}

.panel-content {
  padding: 6px 10px;
  border-left: 3px solid #3498db;
  margin-top: 5px;
}

.panel-content button {
  margin-top: 6px;
  margin-right: 5px;
  background-color: #2ecc71;
  color: #fff;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: 0.2s;
}

.panel-content button:hover {
  background-color: #27ae60;
}

/* ===== Control Buttons ===== */
#expandAllBtn,
#collapseAllBtn,
#toggleLayoutBtn,
#expandLevelBtn,
#collapseLevelBtn {
  background-color: #e67e22;
}

#expandAllBtn:hover,
#collapseAllBtn:hover,
#toggleLayoutBtn:hover,
#expandLevelBtn:hover,
#collapseLevelBtn:hover {
  background-color: #d35400;
}

#exportJsonBtn,
#exportPngBtn {
  background-color: #9b59b6;
}

#exportJsonBtn:hover,
#exportPngBtn:hover {
  background-color: #8e44ad;
}

/* ===== Node Text & Circles ===== */
.node text {
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}

.node circle {
  fill: #4f6ef7;
  stroke: #ffffff;
  stroke-width: 2px;
  r: 6;
  transition: transform 0.15s ease, fill 0.15s ease;
}

/* Highlight nodes */
.node.highlight circle {
  stroke: #ff4d4d;
  stroke-width: 4px;
}

.link.highlight {
  stroke: #ff4d4d;
  stroke-width: 3px;
}

/* Tooltip always visible on hover */
.node:hover text {
  pointer-events: all;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 4px;
  border-radius: 3px;
}

/* Search highlight */
.node.search-highlight circle {
  stroke: #ff5733;
  stroke-width: 4px;
}

.link.search-highlight {
  stroke: #ff5733;
  stroke-width: 3px;
}

/* ===== Profile Popup ===== */
#profilePopup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-height: 80%;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  padding: 20px;
  z-index: 1000;
  border-radius: 8px;
}

#profilePopup button {
  background-color: #e74c3c;
  color: #fff;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
}

#profilePopup button:hover {
  background-color: #c0392b;
}

/* Minimized profile popup */
#profilePopup.minimized {
  width: 200px;
  height: 40px;
  overflow: hidden;
  padding: 5px 10px;
}

#profilePopup.minimized #profileContent,
#profilePopup.minimized #downloadProfileTxt,
#profilePopup.minimized #downloadProfilePdf,
#profilePopup.minimized #profileTitle,
#profilePopup.minimized #profileTaxonomyBadge {
  display: none;
}

/* Responsive Layout */
@media screen and (max-width: 900px) {
  .container {
    flex-direction: column;
  }

  .left,
  .panel {
    flex: unset;
    height: 50vh;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }
}
