/* Shared styles for graph visualization panels - shadcn/ui inspired */

/* Description panel list styling */
#description-panel-content ul {
  list-style: disc;
  list-style-position: outside;
  padding-left: 1rem;
  margin-left: 0;
}

#description-panel-content ul li {
  margin-bottom: 0.5rem;
  padding-left: 0;
  line-height: 1.1rem;
}

/* Panel header and collapse functionality */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.panel-header:hover {
  opacity: 0.8;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(222.2 84% 4.9%);
  letter-spacing: -0.025em;
}

.collapse-icon {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.2s ease;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.collapse-icon svg {
  width: 100%;
  height: 100%;
  stroke: #6b7280;
}

.collapse-icon.collapsed {
  transform: rotate(180deg);
}

.panel-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.panel-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Cluster buttons */
.cluster-buttons {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.cluster-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: hsl(0 0% 100%);
  border: 1px solid hsl(214.3 31.8% 91.4%);
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(222.2 47.4% 11.2%);
  transition: all 0.15s ease;
}

.cluster-btn:hover {
  background: hsl(210 40% 96.1%);
  color: hsl(222.2 47.4% 11.2%);
}

/* Caption rows for categories/clusters */
.caption-row {
  margin: 0.375rem 0;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

/* Active coloring state for link types */
.caption-row.active-coloring {
  background-color: hsl(210 40% 96.1%);
  padding: 0.25rem 0.5rem;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
  border-left: 3px solid var(--active-color, hsl(222.2 47.4% 11.2%));
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Hide checkboxes for category and cluster panels (they use visual circles) */
.caption-row input[type="checkbox"] {
  display: none;
}

/* Show real checkboxes for link types panel (left side) */
#link-types-panel .caption-row input[type="checkbox"] {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  margin-top: 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: hsl(215.4 16.3% 46.9%);
}

/* Link toggle icon for cluster panel (right side) */
#cluster-panel .link-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.5rem;
  margin-top: 0.125rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.1s ease;
  opacity: 0.7;
}

#cluster-panel .link-toggle-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

#cluster-panel .link-toggle-icon svg {
  width: 100%;
  height: 100%;
  stroke: hsl(215.4 16.3% 46.9%);
  fill: none;
}

#link-types-panel .caption-row,
#cluster-panel .caption-row {
  display: flex;
  align-items: flex-start;
}

#link-types-panel .caption-row label,
#cluster-panel .caption-row label {
  flex: 1;
  min-width: 0;
}

/* For non-link-types, non-cluster panels: dim unchecked items */
#type-panel .caption-row input[type="checkbox"]:not(:checked) + label,
#category-panel .caption-row input[type="checkbox"]:not(:checked) + label {
  color: hsl(215.4 16.3% 46.9%);
  opacity: 0.7;
}

/* Circles are unfilled by default for link-types panel, filled only when active coloring is on */
#link-types-panel .caption-row label .circle {
  background-color: white !important;
}

/* Fill the circle when link type is actively being colored */
#link-types-panel .caption-row.active-coloring label .circle {
  background-color: var(--active-color, hsl(222.2 47.4% 11.2%)) !important;
}

/* For other panels (type-panel, category-panel): fill circles based on checked state */
#type-panel .caption-row input[type="checkbox"]:checked + label .circle,
#category-panel .caption-row input[type="checkbox"]:checked + label .circle {
  /* Background color is already set inline from JS, just ensure it's visible */
}

#type-panel .caption-row input[type="checkbox"]:not(:checked) + label .circle,
#category-panel .caption-row input[type="checkbox"]:not(:checked) + label .circle {
  background-color: white !important;
}

/* For cluster panel: fill circles based on cluster visibility (not checkbox state) */
#cluster-panel .caption-row.cluster-visible label .circle {
  /* Background color is already set inline from JS, just ensure it's visible */
}

#cluster-panel .caption-row:not(.cluster-visible) label .circle {
  background-color: white !important;
}

/* For cluster panel: dim hidden clusters */
#cluster-panel .caption-row:not(.cluster-visible) {
  color: hsl(215.4 16.3% 46.9%);
  opacity: 0.7;
}

.caption-row label {
  display: flex;
  flex-direction: row;
  cursor: pointer;
  align-items: flex-start;
  transition: opacity 0.2s ease;
}

.caption-row label:hover {
  opacity: 0.7;
}

.caption-row label .circle {
  flex-shrink: 0;
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 1.25rem;
  box-sizing: border-box;
  margin-right: 0.5rem;
  margin-top: 0.125rem;
  transition: all ease-out 300ms;
  border: 3px solid #6b7280;
}

.caption-row label .icon-container {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.5rem;
  margin-top: 0;
  background-color: hsl(215 16% 47%);
  border-radius: 50%;
  padding: 0.25rem;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.caption-row label .icon-container svg {
  width: 100%;
  height: 100%;
  stroke: hsl(210 40% 98%);
}

.caption-row input[type="checkbox"]:not(:checked) + label .icon-container {
  background-color: hsl(210 40% 96.1%);
}

.caption-row input[type="checkbox"]:not(:checked) + label .icon-container svg {
  stroke: hsl(215.4 16.3% 46.9%);
}

.caption-row label .node-label {
  flex-grow: 1;
  min-width: 0;
}

.caption-row label .node-label > span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(222.2 84% 4.9%);
}

.caption-row label .bar {
  position: relative;
  background: hsl(210 40% 96.1%);
  height: 2px;
  width: 100%;
  border-radius: 2px;
  overflow: hidden;
}

.caption-row label .bar .inside-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: hsl(222.2 47.4% 11.2%);
  transition: all ease-out 300ms;
}
