html, body {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
}

main.container-fluid {
  flex: 1;
  min-height: 0;
}

.full-height-row {
  height: 100%;
}

.control-column, .visualizer-column, #visualizer-sidebar {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease-in-out;
}

.visualizer-column {
  padding: 1rem;
  align-items: center;
  justify-content: center;
}

#site-graph-container {
  background-color: var(--bs-body-secondary);
  width: 100%;
  height: 100%;
  border-radius: .375rem;
}

#jsonInput {
  font-family: monospace;
  font-size: 0.8rem;
}

#visualizer-page-list-container {
  min-height: 200px;
}

body.fullscreen-mode .control-column, body.fullscreen-mode #visualizer-sidebar, body.fullscreen-mode .navbar {
  display: none !important;
}

body.fullscreen-mode .visualizer-column {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  padding: 0 !important;
  z-index: 1000;
}

@media (max-width: 991.98px) {
  html, body {
    height: auto;
    overflow-y: auto;
  }
}

@media (max-width: 991.98px) {
  .full-height-row {
    height: auto;
    flex-direction: column;
  }
  
  /* Column order: left controls → right sidebar → visualizer (last) */
  .control-column    { order: 1; }
  #visualizer-sidebar { order: 2; }
  .visualizer-column  { order: 3; min-height: 70vh; }
}

@media (max-width: 991.98px) {
  .control-column, .visualizer-column, #visualizer-sidebar {
    height: auto;
    min-height: 50vh;
    overflow-y: visible;
  }
}

@media (max-width: 991.98px) {
  #visualizer-sidebar {
    min-height: 70vh;
  }
}

#view-legend {
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color-translucent);
  font-size: 0.8rem;
  transition: background-color 0.3s ease;
}

#view-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#view-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#view-legend .legend-color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

#node-inspector h3 {
  word-break: break-all;
}

#inspector-details strong {
  color: var(--bs-primary);
}

#visualizer-page-list .list-group-item-action {
  cursor: pointer;
}

/* Updated grid layout for render button */

.d-grid.gap-2 {
  grid-template-columns: 1fr auto;
}

.d-grid.gap-2 > .btn-outline-secondary {
  padding-left: .75rem;
  padding-right: .75rem;
}

/* Styles for Regex Cluster Controls */

#topic-cluster-controls {
  border: 1px solid var(--bs-border-color-translucent);
  padding: 0.75rem;
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-body-bg);
}

.cluster-rule-item .form-control-color {
  max-width: 50px;
}


/* ─────────────────────────────────────────
   STATS DASHBOARD
───────────────────────────────────────── */

.stat-card {
    background: var(--bg-elevated, #0f1a11);
    border: 1px solid var(--border-subtle, rgba(67, 160, 71, 0.15));
    border-radius: var(--radius-sm, 8px);
    padding: 0.6rem 0.75rem;
    text-align: center;
    transition: border-color 0.15s ease;
}

.stat-card:hover {
    border-color: var(--border-glow, rgba(67, 160, 71, 0.3));
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--em-400, #43a047);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted, #98b39b);
    margin-top: 0.15rem;
    letter-spacing: 0.02em;
}

.stat-card--warning .stat-value {
    color: #f0ad4e;
}

.stat-card--warning {
    border-color: rgba(240, 173, 78, 0.2);
}

.stat-card--danger .stat-value {
    color: #d9534f;
}

.stat-card--danger {
    border-color: rgba(217, 83, 79, 0.2);
}

#stats-insights {
    font-size: 0.78rem;
    line-height: 1.5;
}

#stats-insights .insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.35rem 0;
}

#stats-insights .insight-item i {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

/* ── Scrollbar alignment: left column scrollbar on the right (inner edge) ── */
.control-column {
  direction: ltr;          /* scrollbar moves to the right side */
}
.control-column > * {
  direction: rtl;          /* restore RTL for all content inside */
}

/* ── Floating scroll-to-top button ── */
#scrollToTopBtn {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;                /* centered horizontally */
  transform: translateX(-50%);
  z-index: 1090;
  width: 48px;
  height: 48px;
  display: none !important; /* hidden by default, shown via JS */
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#scrollToTopBtn.visible {
  display: flex !important;
  opacity: 1;
  pointer-events: auto;
}

/* Only on mobile */
@media (min-width: 992px) {
  #scrollToTopBtn {
    display: none !important;
  }
}

/* ── Inspector Link Lists ── */

.inspector-link-list {
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.75rem;
}

.inspector-link-list .list-group-item {
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  border-color: var(--bs-border-color-translucent);
}

.inspector-link-list .list-group-item:hover {
  background-color: var(--bs-tertiary-bg);
}

#inspector-links-section .btn-outline-secondary {
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
}

/* ── Stabilization Progress Overlay ── */

.stabilization-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border-radius: .375rem;
  transition: opacity 0.4s ease;
}

.stabilization-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.stabilization-content {
  text-align: center;
  min-width: 220px;
}

.stabilization-icon {
  font-size: 2rem;
  color: var(--em-400, #43a047);
  animation: spin-slow 3s linear infinite;
}

@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.stabilization-text {
  font-size: 0.85rem;
  color: #ccc;
  margin: 0.5rem 0;
  font-weight: 600;
}

.stabilization-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

.stabilization-bar {
  height: 100%;
  width: 0%;
  background: var(--em-400, #43a047);
  border-radius: 3px;
  transition: width 0.15s ease;
}

.stabilization-percent {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}

/* ── Context Menu ── */

.ctx-menu {
  position: fixed;
  z-index: 1200;
  min-width: 200px;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.35rem 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  direction: rtl;
}

.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.85rem;
  border: none;
  background: none;
  color: var(--bs-body-color);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: right;
  transition: background 0.12s ease;
}

.ctx-menu-item:hover,
.ctx-menu-item:focus-visible {
  background: var(--bs-tertiary-bg);
  outline: none;
}

.ctx-menu-item--danger:hover {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}

.ctx-menu-item--restore {
  color: var(--em-400, #43a047);
}

.ctx-menu-item--restore:hover {
  background: rgba(67, 160, 71, 0.12);
}

.ctx-menu-divider {
  height: 1px;
  background: var(--bs-border-color-translucent);
  margin: 0.25rem 0;
}

/* ── Community Detection ── */

.community-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  vertical-align: middle;
}

#view-legend .community-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.4rem;
}

#view-legend .community-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
}

/* ── Zoom Controls Divider ── */

.visualizer-column .vr {
  align-self: stretch;
  min-height: 0;
}

/* ── Processing Progress Overlay ── */

.processing-overlay {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  border-radius: .375rem;
  transition: opacity 0.3s ease;
}

.processing-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* ── Depth Distribution Chart ── */

#depth-chart-container {
  padding: 0.4rem 0;
}

.depth-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 56px;
  padding: 0 2px;
}

.depth-chart-bar {
  flex: 1;
  min-width: 0;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  position: relative;
  transition: opacity 0.15s ease, filter 0.15s ease;
  min-height: 3px;
}

.depth-chart-bar:hover {
  filter: brightness(1.25);
}

.depth-chart-bar.active {
  outline: 2px solid var(--bs-body-color);
  outline-offset: 1px;
}

.depth-chart-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.65rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.depth-chart-bar:hover .depth-chart-tooltip {
  opacity: 1;
}

.depth-chart-labels {
  display: flex;
  gap: 3px;
  padding: 0 2px;
  margin-top: 2px;
}

.depth-chart-label {
  flex: 1;
  text-align: center;
  font-size: 0.55rem;
  color: var(--text-muted, #98b39b);
  font-variant-numeric: tabular-nums;
}
