/* =============================================================================
   ATLAS INTELIGENTE - ESTAÇÃO DE TRABALHO CIENTÍFICA & VTK.js (LABORATÓRIO 3D)
   Design System Médico Avançado (PACS / 3D Slicer Workstation)
   ============================================================================= */

:root {
  --lab-bg: #050811;
  --lab-panel: rgba(9, 15, 29, 0.94);
  --lab-panel-solid: #090f1d;
  --lab-border: rgba(0, 210, 255, 0.2);
  --lab-border-strong: rgba(0, 210, 255, 0.5);
  --lab-cyan: #00d2ff;
  --lab-emerald: #10b981;
  --lab-amber: #f59e0b;
  --lab-red: #ef4444;
  --lab-purple: #a855f7;
  --lab-text: #f1f5f9;
  --lab-text-muted: #94a3b8;
  --lab-font-mono: "Fira Code", "Courier New", monospace;
  --lab-font-display: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body.lab3d-body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--lab-bg);
  color: var(--lab-text);
  font-family: var(--lab-font-display);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Header PACS de Alta Densidade */
.lab-header {
  height: 54px;
  background: rgba(5, 8, 17, 0.98);
  border-bottom: 1px solid var(--lab-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}

.lab-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lab-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--lab-cyan);
  background: rgba(0, 210, 255, 0.08);
  border: 1px solid rgba(0, 210, 255, 0.3);
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.lab-back-btn:hover {
  background: rgba(0, 210, 255, 0.2);
  border-color: var(--lab-cyan);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.lab-brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-vhp {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-vtk {
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Indicador de Status do Sistema em Tempo Real (Ponto Verde Néon Pulsante e Anel Radar Compacto) */
.system-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  background: rgba(0, 245, 160, 0.08);
  border: 1px solid rgba(0, 245, 160, 0.38);
  padding: 1.5px 6.5px;
  border-radius: 9999px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #00f5a0;
  text-transform: uppercase;
  user-select: none;
  box-shadow: 0 0 8px rgba(0, 245, 160, 0.15);
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1.1;
  position: relative;
}

.system-live-badge:hover {
  background: rgba(0, 245, 160, 0.16);
  border-color: #00f5a0;
  box-shadow: 0 0 12px rgba(0, 245, 160, 0.35);
}

.live-pulse-dot {
  width: 6px;
  height: 6px;
  background-color: #00f5a0;
  border-radius: 50%;
  position: relative;
  display: inline-block;
  box-shadow: 0 0 6px #00f5a0, 0 0 10px rgba(0, 245, 160, 0.6);
  animation: live-dot-pulse 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
  flex-shrink: 0;
}

.live-pulse-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 1.2px solid #00f5a0;
  opacity: 0.85;
  animation: live-ring-expand 1.8s infinite cubic-bezier(0.15, 0.8, 0.25, 1);
}

@keyframes live-dot-pulse {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.85;
    box-shadow: 0 0 4px #00f5a0;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 10px #00f5a0, 0 0 14px rgba(0, 245, 160, 0.7);
  }
}

@keyframes live-ring-expand {
  0% {
    transform: scale(0.7);
    opacity: 0.95;
  }
  65% {
    transform: scale(2.4);
    opacity: 0.2;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

.live-status-text {
  font-family: var(--lab-font-mono, monospace);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #00f5a0;
}

/* Barra de Ferramentas Central */
.lab-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lab-select {
  background: #0f172a;
  color: var(--lab-text);
  border: 1px solid var(--lab-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.lab-select:hover, .lab-select:focus {
  border-color: var(--lab-cyan);
}

.lab-btn-group {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--lab-border);
  border-radius: 6px;
  overflow: hidden;
}

.lab-tool-btn {
  background: transparent;
  border: none;
  color: var(--lab-text-muted);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lab-tool-btn:hover {
  background: rgba(0, 210, 255, 0.1);
  color: #ffffff;
}

.lab-tool-btn.active {
  background: rgba(0, 210, 255, 0.25);
  color: var(--lab-cyan);
}

/* Área Principal de Visualização */
.lab-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Grid de Quadrantes MPR (PACS Style) */
.mpr-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  background-color: #020408;
  height: 100%;
  width: 100%;
}

.mpr-grid.layout-axial-single {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.mpr-grid.layout-axial-single .mpr-quadrant:not(#quadrantAxial) {
  display: none;
}

.mpr-grid.layout-3d-single {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.mpr-grid.layout-3d-single .mpr-quadrant:not(#quadrant3D) {
  display: none;
}

/* Quadrante Individual */
.mpr-quadrant {
  position: relative;
  background: #060913;
  overflow: hidden;
  border: 1px solid rgba(0, 210, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.mpr-quadrant.active-quadrant {
  border-color: var(--lab-cyan);
}

.quadrant-header {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.plane-tag {
  background: rgba(5, 8, 17, 0.85);
  border: 1px solid var(--lab-border);
  color: var(--lab-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
}

.plane-tag.tag-axial { color: #38bdf8; border-color: rgba(56, 189, 248, 0.4); }
.plane-tag.tag-sagittal { color: #f43f5e; border-color: rgba(244, 63, 94, 0.4); }
.plane-tag.tag-coronal { color: #10b981; border-color: rgba(16, 185, 129, 0.4); }
.plane-tag.tag-3d { color: #a855f7; border-color: rgba(168, 85, 247, 0.4); }

.plane-coords {
  background: rgba(5, 8, 17, 0.85);
  border: 1px solid var(--lab-border);
  color: var(--lab-text-muted);
  font-size: 0.7rem;
  font-family: var(--lab-font-mono);
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

/* Canvas e Contêiner de Imagem */
.viewport-canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04060b;
}

.mpr-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  image-rendering: auto;
  cursor: crosshair;
}

/* Crosshair Overlay */
.crosshair-line-h, .crosshair-line-v {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}
.crosshair-line-h {
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(244, 63, 94, 0.5);
  box-shadow: 0 0 4px rgba(244, 63, 94, 0.8);
}
.crosshair-line-v {
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.8);
}

/* HUD Overlay de Informação Médica */
.quadrant-hud-bottom {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 10;
  pointer-events: none;
  font-size: 0.72rem;
  font-family: var(--lab-font-mono);
  color: #94a3b8;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* Controlo de Fatia Z (Slider Flutuante) */
.slice-nav-control {
  position: absolute;
  right: 12px;
  top: 50px;
  bottom: 50px;
  width: 28px;
  background: rgba(9, 15, 29, 0.85);
  border: 1px solid var(--lab-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  z-index: 15;
  backdrop-filter: blur(8px);
}

.slice-nav-slider {
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  width: 8px;
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

/* Painel Lateral de Órgãos e Parâmetros (Drawer) */
.lab-sidebar {
  width: 320px;
  background: var(--lab-panel);
  border-left: 1px solid var(--lab-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  backdrop-filter: blur(12px);
  transition: transform 0.3s ease;
}

.lab-sidebar.collapsed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
}

.sidebar-tab-header {
  display: flex;
  border-bottom: 1px solid var(--lab-border);
  background: rgba(5, 8, 17, 0.7);
}

.sidebar-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--lab-text-muted);
  padding: 10px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.sidebar-tab-btn.active {
  color: var(--lab-cyan);
  border-bottom-color: var(--lab-cyan);
  background: rgba(0, 210, 255, 0.05);
}

.sidebar-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

/* Lista de Órgãos Interativa */
.organ-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  margin-bottom: 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(0, 210, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.organ-list-item:hover {
  background: rgba(0, 210, 255, 0.1);
  border-color: rgba(0, 210, 255, 0.4);
  transform: translateX(2px);
}

.organ-list-item.selected {
  background: rgba(0, 210, 255, 0.2);
  border-color: var(--lab-cyan);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.2);
}

.organ-meta-primary {
  display: flex;
  flex-direction: column;
}

.organ-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
}

.organ-item-latin {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--lab-text-muted);
}

.organ-slice-badge {
  font-size: 0.7rem;
  font-family: var(--lab-font-mono);
  background: rgba(2, 132, 199, 0.25);
  color: #38bdf8;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Detalhe Anatómico e Clínico Sincronizado */
.organ-detail-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--lab-border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.organ-detail-card h4 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  color: #ffffff;
}

.organ-prop-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.78rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
}
.organ-prop-label { color: var(--lab-text-muted); }
.organ-prop-value { color: var(--lab-text); font-weight: 500; text-align: right; }

/* Controles de Renderização 3D VTK.js */
.vtk-control-group {
  margin-bottom: 14px;
}
.vtk-control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--lab-text-muted);
  margin-bottom: 6px;
}
.vtk-slider {
  width: 100%;
  accent-color: var(--lab-cyan);
}

/* Indicador de Carregamento Assíncrono */
.lab-loading-indicator {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--lab-cyan);
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--lab-cyan);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lab-loading-indicator.visible {
  opacity: 1;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0, 210, 255, 0.2);
  border-top-color: var(--lab-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modo Responsivo */
@media (max-width: 900px) {
  .lab-sidebar {
    position: absolute;
    right: 0;
    top: 54px;
    bottom: 0;
  }
}

/* =============================================================================
   RODAPÉ INSTITUCIONAL & LEGAL PACS (CYLINDER)
   ============================================================================= */

.lab-legal-footer {
  height: 38px;
  min-height: 38px;
  background: rgba(5, 8, 17, 0.98);
  border-top: 1px solid var(--lab-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  font-size: 0.74rem;
  color: var(--lab-text-muted);
  z-index: 95;
  user-select: text;
}

.lab-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cylinder-badge {
  background: linear-gradient(135deg, #00d2ff, #0284c7);
  color: #050811;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.lab-footer-event {
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.72rem;
}

.lab-footer-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  line-height: 1.35;
  color: #cbd5e1;
}

.lab-disclaimer-icon {
  color: var(--lab-amber);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.lab-disclaimer-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
}

.lab-disclaimer-text strong {
  color: #fbbf24;
}

.lab-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lab-tech-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.66rem;
  font-family: var(--lab-font-mono);
  color: #94a3b8;
}

@media (max-width: 1100px) {
  .lab-disclaimer-text {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }
}

@media (max-width: 768px) {
  .lab-legal-footer {
    height: auto;
    padding: 6px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .lab-footer-right {
    display: none;
  }
}

