/* ================================================================
   panels.css  --  Metadata panel (lightbox) & Brain template / atlas panel
   ================================================================ */

/* ---------- Metadata panel ---------- */

.metadata-panel {
  position: fixed;
  top: 120px;
  right: 20px;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: blur(var(--chrome-blur));
  backdrop-filter: blur(var(--chrome-blur));
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 12px;
  font-size: 11px;
  color: #e8e8e8;
  z-index: 9993;
  min-width: 180px;
  max-width: 300px;
  max-height: calc(100vh - 140px);
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.3s ease;
  pointer-events: none;
  overflow-y: auto;
}

.metadata-panel.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.metadata-panel h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: #4dabf7;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

/* Lightbox metadata panel row overrides */
.metadata-panel .metadata-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  align-items: flex-start;
}

.metadata-panel .metadata-label {
  min-width: 90px;
  flex-shrink: 0;
  font-weight: 500;
}

.metadata-panel .metadata-value {
  flex: 1;
  word-wrap: break-word;
}

.metadata-panel .metadata-value.virus-name {
  white-space: normal;
  line-height: 1.3;
}

/* ---------- Panel header (shared) ---------- */

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-header h4 {
  margin: 0;
  flex: 1;
}

/* ---------- Panel close / back buttons ---------- */

.panel-close-btn {
  border: none;
  background: transparent;
  color: #e8e8e8;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  transition: var(--btn-transition);
  flex-shrink: 0;
}

.panel-close-btn:hover {
  color: #ff6b6b;
  transform: scale(1.1);
}

.panel-back-btn {
  border: none;
  background: transparent;
  color: #e8e8e8;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  transition: var(--btn-transition);
  flex-shrink: 0;
}

.panel-back-btn:hover {
  color: #4dabf7;
  transform: scale(1.1);
}

/* ---------- Generic metadata row (outside panel context) ---------- */

.metadata-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  line-height: 1.3;
}

.metadata-label {
  color: #a0a0a0;
  font-weight: 500;
}

.metadata-value {
  color: #e8e8e8;
  font-family: monospace;
  font-weight: 400;
}

#biologicalMetadata {
  display: none;
}

/* ---------- Brain template panel ---------- */

.brain-template-panel {
  position: fixed;
  left: 0;
  top: 140px;
  transform: scale(0.95);
  width: 250px;
  height: auto;
  max-height: calc(100vh - 160px);
  background: var(--chrome-bg);
  -webkit-backdrop-filter: blur(var(--chrome-blur));
  backdrop-filter: blur(var(--chrome-blur));
  border: 1px solid #2a2f3a;
  border-left: none;
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
  z-index: 9991;
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 16px;
}

.brain-template-panel.visible {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.brain-template-toggle {
  flex-shrink: 0;
}

.brain-template-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.brain-template-info {
  flex-shrink: 0;
}

.brain-template-info h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: #4dabf7;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.brain-position-display {
  font-size: 10px;
  color: #a0a0a0;
  line-height: 1.4;
}

/* ---------- Brain template image area ---------- */

.brain-template-image {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 150px;
}

.brain-placeholder {
  display: none;
}

.ccf-slice-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 300px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  object-fit: contain;
  display: none;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.ccf-slice-image:hover {
  transform: scale(1.02);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)) brightness(1.1);
}

#atlasCanvas {
  max-width: 100%;
  max-height: 300px;
  width: auto;
  height: auto;
  display: none;
}

/* ---------- Atlas region info ---------- */

.atlas-region-info {
  margin-top: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  font-size: 11px;
  min-height: 80px;
  flex-shrink: 0;
}

.atlas-region-info .placeholder-text {
  color: #888;
}
