/**
 * InstanceHierarchyView – hierarchy levels and hover tooltip (glassmorph/glow)
 */

.hierarchyLoading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(242, 88, 67, 0.3);
  border-top-color: var(--primary-color, #f25843);
  border-radius: 50%;
  animation: hierarchySpin 0.8s linear infinite;
}

@keyframes hierarchySpin {
  to {
    transform: rotate(360deg);
  }
}

.hierarchyRoot {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.levelMandateWrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mandateRow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.mandateRow:hover {
  background: rgba(242, 88, 67, 0.12);
  border-color: rgba(242, 88, 67, 0.35);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 0 24px rgba(242, 88, 67, 0.22);
  transform: translateY(-2px);
}

.mandateRow .mandateLabel {
  flex: 1;
  font-weight: 600;
  color: var(--primary-color, #f25843);
}

.mandateRow .mandateMeta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.levelMandate {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  background: rgba(242, 88, 67, 0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(242, 88, 67, 0.25);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.levelMandate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 0 24px rgba(242, 88, 67, 0.22);
  border-color: rgba(242, 88, 67, 0.4);
}

.mandateIcon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color, #f25843);
  box-shadow: 0 0 10px rgba(242, 88, 67, 0.6);
  flex-shrink: 0;
}

.mandateContent {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mandateLabel {
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--primary-color, #f25843);
}

.mandateMeta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.levelFeature {
  margin-left: 1rem;
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.featureHeader {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  border: 1px solid transparent;
}

.featureHeader:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 14px rgba(242, 88, 67, 0.12);
  border-color: rgba(255, 255, 255, 0.08);
}

.featureLabel {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.featureCount {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.levelInstance {
  margin-bottom: 0.25rem;
}

.instanceRowContainer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

.instanceRow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.manageUsersBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  background: rgba(242, 88, 67, 0.12);
  color: var(--primary-color, #f25843);
  border: 1px solid rgba(242, 88, 67, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.manageUsersBtn:hover {
  background: rgba(242, 88, 67, 0.22);
  box-shadow: 0 0 12px rgba(242, 88, 67, 0.25);
}

.instanceRow:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(242, 88, 67, 0.25);
  box-shadow: 0 0 14px rgba(242, 88, 67, 0.15);
  transform: translateY(-1px);
}

.instanceChevron {
  display: flex;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.instanceLabel {
  flex: 1;
  font-weight: 500;
}

.instanceUserCount {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.levelUsers {
  margin-left: 1.5rem;
  margin-top: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.noUsers {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
}

.linkButton {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--primary-color, #f25843);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 0.25rem;
}

.linkButton:hover {
  text-decoration: none;
}

.userRowWrapper {
  position: relative;
  padding: 0.4rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.userRowWrapper:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 12px rgba(242, 88, 67, 0.1);
  transform: translateY(-1px);
}

.userRowWrapper:hover .tooltipBubble {
  opacity: 1;
  visibility: visible;
}

.userRow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
}

.userName {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 120px;
}

.userRoles {
  flex: 1;
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userStatusActive {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(56, 142, 60, 0.2);
  color: #388e3c;
  border: 1px solid rgba(56, 142, 60, 0.35);
}

.userStatusInactive {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(158, 158, 158, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(158, 158, 158, 0.25);
}

.tooltipBubble {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translate(8px, -50%);
  min-width: 200px;
  max-width: 320px;
  padding: 0.75rem 1rem;
  background: rgba(20, 20, 24, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 16px rgba(242, 88, 67, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
  pointer-events: none;
}

.tooltipTitle {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-color, #f25843);
  margin-bottom: 0.35rem;
}

.tooltipEmail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.tooltipRoles {
  font-size: 0.8125rem;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  margin-bottom: 0.25rem;
}

.tooltipStatus {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

:global(.dark-theme) .mandateRow,
:global(.dark-theme) .levelMandate,
:global(.dark-theme) .instanceRow,
:global(.dark-theme) .userRowWrapper {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.08);
}

:global(.dark-theme) .mandateRow:hover {
  background: rgba(242, 88, 67, 0.18);
  border-color: rgba(242, 88, 67, 0.4);
}

:global(.dark-theme) .tooltipBubble {
  background: rgba(10, 10, 14, 0.97);
  border-color: rgba(255, 255, 255, 0.12);
}
