/* Premium Nuclide Chart Modal - Dark Theme */

.nuclide-chart-button {
  background: linear-gradient(135deg, #96009b, #96009b);
  color: white !important;
  border: none;
  border-radius: 12px;
  padding: 8px 15px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #610064, 0 6px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  margin: 0 5px;
}

.nuclide-chart-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 0 #610064, 0 8px 20px rgba(0, 0, 0, 0.3);
}

.nuclide-chart-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #610064, 0 3px 10px rgba(0, 0, 0, 0.2);
}

.nuclide-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2200;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease-in-out;
}

body.nuclide-modal-open {
  overflow: hidden;
}

.nuclide-modal.visible {
  display: flex;
  z-index: 2400;
}

.nuclide-modal.closing {
  animation: fadeOut 0.3s ease-in-out;
}

/* Animation wrapper - receives the scale transform */
.nuclide-animation-wrapper {
  animation: popOut 0.4s ease-out;
  /* Use will-change to optimize animation performance */
  will-change: transform, opacity;
}

.nuclide-modal.closing .nuclide-animation-wrapper {
  animation: popIn 0.3s ease-in;
}

.modal-close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #aaaaaa;
  font-size: 28px;
  font-weight: bold;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  z-index: 10;
  line-height: 1;
  padding: 0;
}

.modal-close-button:hover {
  color: #ffffff;
}

.nuclide-chart-surface {
  width: calc(100vw - 40px);
  max-width: 1600px;
  height: calc(100vh - 40px);
  max-height: 900px;
  background: #111111;
  border-radius: 25px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: #e0e0e0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.nuclide-chart-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #1a1a1a;
  background: #111111;
}

.nuclide-chart-header h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.5px;
}

.nuclide-chart-header p {
  margin: 0;
  font-size: 13px;
  color: #666;
}

.nuclide-controls {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: #111111;
  border-bottom: 1px solid #1a1a1a;
  flex-wrap: wrap;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-select,
.control-input {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, color 0.12s ease;
  min-width: 140px;
}

.control-select:hover,
.control-input:hover {
  border-color: #3a3a3a;
  background: #1f1f1f;
}

.control-select:focus,
.control-input:focus {
  border-color: #4a4a4a;
  background: #1f1f1f;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 8px 18px rgba(0, 0, 0, 0.35);
}

.control-input {
  min-width: 200px;
}

.control-input::placeholder {
  color: #555;
}

/* Override global orange focus ring from graph-tool.css */
.nuclide-chart-surface .control-input:focus,
.nuclide-chart-surface .control-input:focus-visible,
.nuclide-chart-surface .control-select:focus,
.nuclide-chart-surface .control-select:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.6) !important;
  outline-offset: 0;
  box-shadow: none !important;
  border-color: #ffffff;
  background: #1a1a1a;
}

.color-map-dropdown {
  position: relative;
}

.color-map-toggle {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #e0e0e0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  min-width: 140px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.color-map-toggle:hover {
  background: #1f1f1f;
  border-color: #3a3a3a;
}

.color-map-toggle:focus {
  outline: none;
  border-color: #4a4a4a;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.color-map-toggle .chevron {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: #888;
  transition: transform 0.18s ease, color 0.18s ease;
}

.color-map-dropdown.open .color-map-toggle .chevron {
  transform: rotate(180deg);
  color: #bbb;
}

.color-map-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: #111111;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 10;
}

.color-map-dropdown.open .color-map-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.color-map-option {
  width: 100%;
  background: transparent;
  border: none;
  color: #e0e0e0;
  text-align: left;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.16s ease, color 0.16s ease;
  margin: 2px 0;
}

.color-map-option:hover {
  background: #1c1c1c;
  color: #ffffff;
}

.color-map-option.active {
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #bbb;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-chip:hover {
  background: #252525;
  border-color: #3a3a3a;
}

.filter-chip.active {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: #fff;
}

.nuclide-chart-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  overflow: visible;
}

.nuclide-chart-main {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
  background: #111111;
}

.nuclide-chart-canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: #111111;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12 2v20M2 12h20' stroke='white' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='2' fill='white'/%3E%3C/svg%3E") 12 12, crosshair;
}

.nuclide-chart-canvas.panning {
  cursor: grabbing !important;
}

.nuclide-legend-container {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  padding: 12px;
  backdrop-filter: blur(10px);
  z-index: 100;
}

.nuclide-legend-title {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 600;
}

.nuclide-legend-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 20px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  font-size: 12px;
  color: #ccc;
}

.nuclide-info-panel {
  background: #111111;
  border-left: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.nuclide-info-panel::-webkit-scrollbar {
  width: 8px;
}

.nuclide-info-panel::-webkit-scrollbar-track {
  background: #0a0a0a;
}

.nuclide-info-panel::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 4px;
}

.nuclide-info-panel::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

.info-section {
  padding: 20px;
  border-bottom: 1px solid #1a1a1a;
}

.info-section:last-child {
  border-bottom: none;
}

.info-section h3 {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.isotope-title {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px 0;
  letter-spacing: -1px;
}

.isotope-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.data-item {
  background: #0c0c0c;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s ease;
}

.data-item:hover {
  background: #0f0f0f;
  border-color: #2a2a2a;
}

.data-label {
  display: block;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: 500;
}

.data-value {
  display: block;
  font-size: 16px;
  color: #fff;
  font-weight: 600;
  line-height: 1.3;
}

.data-full {
  grid-column: 1 / -1;
}

.data-full .data-value {
  font-size: 14px;
  line-height: 1.5;
  color: #ccc;
  font-weight: 400;
}

.no-selection {
  text-align: center;
  padding: 40px 20px;
  color: #555;
}

.no-selection-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.no-selection-text {
  font-size: 14px;
}

/* Decay Tree Overlay Styles */
.decay-overlay-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 3000;
}

.decay-overlay-layer.visible {
  opacity: 1;
  pointer-events: auto;
}

.decay-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: 800px;
  max-width: 92vw;
  height: 600px;
  max-height: 88vh;
  background: #111111;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
  pointer-events: auto;
}

.decay-overlay-layer.visible .decay-overlay {
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.22s ease;
}

.decay-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #1a1a1a;
  background: #111111;
}

.decay-overlay-title {
  color: #eee;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.decay-overlay-close {
  background: none;
  border: none;
  color: #aaaaaa;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.decay-overlay-close:hover {
  color: #ffffff;
}

.decay-legend {
  display: flex;
  gap: 10px;
  padding: 10px 20px 10px 20px;
  flex-wrap: wrap;
}

.decay-legend-empty {
  color: #666;
  font-size: 12px;
  padding: 6px 0;
}

.decay-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #bbb;
  background: #0f0f0f;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  padding: 6px 10px;
}

.decay-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid #111;
}

.decay-overlay *:focus {
  outline: none;
}

.decay-tree-view {
  flex: 1;
  background: #070707;
  position: relative;
  overflow: hidden;
}

.decay-tree-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.decay-tree-svg.panning {
  cursor: grabbing;
}

.decay-tree-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

/* SVG Decay Tree Styles */
.decay-edges {
  pointer-events: visibleStroke;
}

.decay-branch {
  stroke: #303262;
  stroke-width: 10; /* base thickness */
  opacity: 0.8;
  transition: opacity 0.2s ease, stroke 0.1s ease;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.branch-group:hover .decay-branch {
  opacity: 1;
  stroke: #fff !important;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.9)) drop-shadow(0 0 12px rgba(255,255,255,0.7));
}

.decay-branch.mode-alpha-decay {
  stroke: #f17700;
}

.decay-branch.mode-beta-minus-decay {
  stroke: #eb004d;
}

.decay-branch.mode-electron-capture-beta-plus-decay {
  stroke: #d00031;
}

.decay-branch.mode-isomeric-transition {
  stroke: #f770ff;
}

.decay-branch.mode-spontaneous-fission {
  stroke: #38163a;
}

.decay-branch.mode-proton-emission {
  stroke: #ff6c5a;
}

.decay-branch.mode-neutron-emission {
  stroke: #6e0029;
}

.decay-branch-hit {
  stroke: transparent;
  stroke-width: 32px;
  fill: none;
  pointer-events: stroke;
}

.decay-branch-label {
  fill: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
  text-anchor: middle;
  pointer-events: none;
  dominant-baseline: middle;
  opacity: 0;
  transition: opacity 0.15s ease;
  stroke: none;
  filter: none;
  white-space: pre-line;
}

.decay-branch-label-bg {
  opacity: 0;
  fill: #111111;
  stroke: #3f3f3f;
  stroke-width: 1.4;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

.decay-branch-labels,
.branch-label-group {
  pointer-events: none;
}

.decay-branch {
  transition: stroke 0.2s ease, opacity 0.2s ease;
}

.branch-label-group.active .decay-branch-label,
.branch-label-group.active .decay-branch-label-bg {
  opacity: 1;
}

.branch-group {
  cursor: pointer;
}

.decay-node {
  stroke: #2a2a2a;
  stroke-width: 1.5;
  transition: all 0.2s ease;
}

.decay-node.stable {
  stroke: #2a2a2a; /* remove special outline */
  stroke-width: 1.5;
}

.decay-node-group {
  cursor: pointer;
  transition: all 0.2s ease;
}

.decay-node-group:hover .decay-node {
  filter: brightness(1.2);
  stroke-width: 2.5;
}

.decay-node-group:hover .decay-node-title {
  fill: #fff;
}

.decay-node-title {
  fill: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.decay-node-meta {
  fill: #fff;
  font-size: 12px;
  font-family: system-ui, -apple-system, sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

/* Highlight/dim styles shared with other modals */
.nuclide-legend-container .legend-item {
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nuclide-legend-container .legend-item.element-highlighted .legend-color,
.decay-legend-item.element-highlighted .decay-legend-swatch {
  background: #ff8000 !important;
}

.nuclide-legend-container .legend-item.element-dimmed .legend-color,
.decay-legend-item.element-dimmed .decay-legend-swatch {
  background: #222222 !important;
}

.nuclide-legend-container .legend-item.element-dimmed .legend-label,
.decay-legend-item.element-dimmed span {
  color: #777777;
}

.nuclide-legend-container .legend-item .legend-color,
.decay-legend-item .decay-legend-swatch {
  transition: background-color 0.2s ease;
}

.decay-legend-item {
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.decay-node-group.element-highlighted .decay-node {
  fill: #ff8000 !important;
  stroke: #ff8000 !important;
}

.decay-node-group.element-highlighted .decay-node-title,
.decay-node-group.element-highlighted .decay-node-meta {
  fill: #ffffff;
}

.decay-node-group.element-dimmed .decay-node {
  fill: #1a1a1a !important;
  stroke: #0f0f0f !important;
}

.decay-node-group.element-dimmed .decay-node-title,
.decay-node-group.element-dimmed .decay-node-meta {
  fill: #555555;
}

.decay-branch.element-highlighted {
  stroke: #ff8000 !important;
  opacity: 1;
}

.decay-branch.element-dimmed {
  stroke: #1a1a1a !important;
  opacity: 0.25;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .nuclide-chart-body {
    grid-template-columns: 1fr 320px;
  }
  
  .decay-overlay {
    width: 700px;
    height: 520px;
  }
}

@media (max-width: 900px) {
  .nuclide-chart-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  
  .nuclide-info-panel {
    border-left: none;
    border-top: 1px solid #1a1a1a;
    max-height: 40vh;
  }
  
  .nuclide-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-select,
  .control-input {
    width: 100%;
  }
  
  .decay-overlay {
    width: 94vw;
    height: 70vh;
  }
}

@media (max-width: 600px) {
  .nuclide-chart-surface {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .data-grid {
    grid-template-columns: 1fr;
  }
  
  .decay-overlay {
    width: 96vw;
    height: 80vh;
    border-radius: 12px;
  }
}

/* Animation keyframes - same as other modals */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes popOut {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  80% {
    transform: scale(1.02) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes popIn {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}
