/**
 * WPDEX / GlassCAM Studio Pro — Estilos do Visualizador CAD/CAM Baseado em DTO
 * Arquivo: cloudflare_lab/modular/frontend_experimental/css/viewer.css
 * 
 * Design System Concept 02:
 * - HUD Flutuante com botões de controle de visualização
 * - Painel de alertas informativos e WARN_STANDALONE_LINE
 * - Footer de telemetria em tempo real CAD e Máquina
 * - Drag and Drop com micro-animação
 */

/* ================= ÁREA PRINCIPAL DO VISUALIZADOR ================= */
.viewer-workspace {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--header-h, 62px));
  position: relative;
  overflow: hidden;
  background-color: var(--bg-base, #08090B);
}

/* ================= PAINEL LATERAL ESQUERDO (METADADOS E ALERTAS) ================= */
.viewer-sidebar {
  width: 320px;
  min-width: 300px;
  max-width: 340px;
  background: var(--bg-surface, #111317);
  border-right: 1px solid var(--border-subtle, #25282e);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  flex-shrink: 0;
}

.viewer-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle, #25282e);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.viewer-sidebar-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main, #FFFFFF);
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-sidebar-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cartões de Seção */
.viewer-card {
  background: var(--bg-surface-elevated, #17191D);
  border: 1px solid var(--border-subtle, #25282e);
  border-radius: var(--radius-md, 8px);
  padding: 14px;
}

.viewer-card-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #95999F);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.viewer-prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.viewer-prop-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: 4px;
}

.viewer-prop-label {
  font-size: 10px;
  color: var(--text-dim, #70757c);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.viewer-prop-val {
  font-family: 'Rajdhani', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main, #FFFFFF);
}

/* ================= CARTÃO DE ALERTA WARN_STANDALONE_LINE ================= */
.alert-card-warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md, 8px);
  padding: 12px;
  animation: alert-pulse 2s infinite alternate;
}

@keyframes alert-pulse {
  from { border-color: rgba(245, 158, 11, 0.35); }
  to { border-color: rgba(245, 158, 11, 0.7); }
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #f59e0b;
  margin-bottom: 6px;
}

.alert-body {
  font-size: 11px;
  color: var(--text-muted, #d1d5db);
  line-height: 1.5;
}

.alert-line-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 6px;
  font-family: 'Rajdhani', monospace;
  font-size: 11px;
}

.btn-focus-line {
  background: #f59e0b;
  color: #08090B;
  border: none;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.btn-focus-line:hover {
  background: #fbbf24;
}

/* ================= ÁREA CENTRAL DO CANVAS ================= */
.viewer-canvas-area {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 30;
  background-color: #08090B;
  overflow: hidden;
  cursor: grab;
}

.viewer-canvas-area:active {
  cursor: grabbing;
}

#cadCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* HUD Top Right */
.hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
}

.hud-panel {
  background: rgba(17, 19, 23, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle, #25282e);
  border-radius: var(--radius-md, 8px);
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.hud-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted, #95999F);
  padding: 5px 9px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.hud-btn.active {
  background: #25282e;
  color: #FFFFFF;
  border-color: #4a4e54;
}

.hud-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Footer de Telemetria de Coordenadas */
.hud-status-footer {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-family: 'Rajdhani', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #95999F);
  background: rgba(8, 9, 11, 0.92);
  border: 1px solid var(--border-subtle, #25282e);
  padding: 6px 14px;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 11, 0.85);
  backdrop-filter: blur(8px);
  border: 2px dashed #38bdf8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #FFFFFF;
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.drop-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ==============================================================================
   BARRA FLUTUANTE DE SIMULAÇÃO CNC & CONTROLADOR DE USINAGEM
   ============================================================================== */
.hud-simulation-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 16, 20, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid #30333a;
  border-radius: 12px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.sim-slider {
  width: 220px;
  accent-color: #38bdf8;
  cursor: pointer;
}

.sim-speed-select {
  background: #1e2025;
  border: 1px solid #363a42;
  color: #FFFFFF;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.sim-speed-select:focus {
  outline: none;
  border-color: #38bdf8;
}

.sequence-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s ease;
}

.sequence-item:last-child {
  border-bottom: none;
}

.sequence-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.sequence-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Rajdhani', monospace;
}

.sequence-badge.g01 {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.sequence-badge.g81 {
  background: rgba(192, 132, 252, 0.15);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.3);
}

/* ================= ABAS DO PAINEL LATERAL ================= */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle, #25282e);
  background: var(--bg-surface, #111317);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 11px 6px;
  background: transparent;
  border: none;
  color: var(--text-muted, #95999f);
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main, #ffffff);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ================= COMPONENTE CAD: DROPDOWN DE EXEMPLOS & AMOSTRAS ================= */
.samples-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.dropdown-chevron {
  transition: transform 0.2s ease;
}

.samples-dropdown-wrapper.open .dropdown-chevron {
  transform: rotate(180deg);
}

.samples-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 270px;
  background: #131519;
  border: 1px solid #282b32;
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  animation: fadeInDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.samples-dropdown-wrapper.open .samples-dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-group-header {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim, #70757c);
  padding: 6px 10px 4px 10px;
}

.dropdown-divider {
  height: 1px;
  background: #24272e;
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main, #ffffff);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-indicator.safe { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.status-indicator.warn { background: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.status-indicator.crit { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }

.item-icon {
  flex-shrink: 0;
  color: #95999f;
}

.item-text {
  display: flex;
  flex-direction: column;
}

.item-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.item-desc {
  font-size: 10px;
  color: var(--text-dim, #70757c);
}

/* ================= NOVO PAINEL LATERAL DIREITO: VALIDADOR INDUSTRIAL ================= */
.validator-sidebar {
  width: 380px;
  min-width: 380px;
  max-width: 420px;
  background: var(--bg-surface, #111317);
  border-left: 1px solid var(--border-subtle, #25282e);
  display: flex;
  flex-direction: column;
  z-index: 25;
  transition: width 0.24s cubic-bezier(0.16, 1, 0.3, 1), transform 0.24s ease, margin-right 0.24s ease;
  overflow: hidden;
  height: 100%;
}

.validator-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  margin-right: 0 !important;
  border-left: none;
  opacity: 0;
  pointer-events: none;
}

.val-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle, #25282e);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #14161a;
  flex-shrink: 0;
}

.val-sidebar-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-main, #ffffff);
  display: flex;
  align-items: center;
  gap: 8px;
}

.val-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.val-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted, #95999f);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.val-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Resumo Superior: 4 Métricas Reais */
.val-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle, #25282e);
  background: #0d0f12;
  flex-shrink: 0;
}

.val-summary-box {
  padding: 7px 4px;
  border-radius: 5px;
  text-align: center;
  border: 1px solid transparent;
}

.val-summary-box.crit {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #ef4444;
}

.val-summary-box.warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
}

.val-summary-box.safe {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #10b981;
}

.val-summary-box.inconcl {
  background: rgba(148, 163, 184, 0.06);
  border-color: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

.val-summary-val {
  font-family: 'Rajdhani', monospace;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.val-summary-lbl {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 3px;
  opacity: 0.85;
}

/* Filtros por Severidade */
.val-filters-bar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle, #25282e);
  background: #111317;
  flex-shrink: 0;
  scrollbar-width: none;
}
.val-filters-bar::-webkit-scrollbar { display: none; }

.val-filter-btn {
  background: transparent;
  border: 1px solid var(--border-subtle, #25282e);
  border-radius: 99px;
  padding: 3px 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #95999f);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.val-filter-btn:hover {
  color: #ffffff;
  border-color: #3f444e;
}

.val-filter-btn.active {
  background: #25282e;
  color: #ffffff;
  border-color: #38bdf8;
}

.val-filter-btn.crit.active { border-color: #ef4444; color: #ef4444; }
.val-filter-btn.warn.active { border-color: #f59e0b; color: #f59e0b; }
.val-filter-btn.safe.active { border-color: #10b981; color: #10b981; }

/* Lista de Ocorrências */
.val-list-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 120px;
}

.val-section-title {
  padding: 8px 12px 4px 12px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim, #70757c);
  display: flex;
  align-items: center;
  gap: 6px;
}

.val-occurrences-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Card de Ocorrência */
.val-occ-card {
  background: #15181d;
  border: 1px solid #24272e;
  border-radius: 6px;
  padding: 9px 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.val-occ-card:hover {
  background: #1c1f26;
  border-color: #383c46;
}

.val-occ-card.selected {
  background: rgba(56, 189, 248, 0.07);
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.12);
}

.val-occ-card.critical.selected {
  background: rgba(239, 68, 68, 0.09);
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.18);
}

.val-occ-card.warning.selected {
  background: rgba(245, 158, 11, 0.09);
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.18);
}

.val-occ-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.val-occ-id {
  font-family: 'Rajdhani', monospace;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.val-occ-badge {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.val-occ-badge.badge-crit { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); }
.val-occ-badge.badge-warn { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.4); }
.val-occ-badge.badge-safe { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4); }
.val-occ-badge.badge-info { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }

.val-occ-divergence {
  font-size: 11px;
  color: var(--text-muted, #d1d5db);
  line-height: 1.3;
}

.val-occ-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Rajdhani', monospace;
  font-size: 11px;
  color: var(--text-dim, #70757c);
  margin-top: 2px;
}

.val-occ-metrics .measure-val {
  font-weight: 700;
  color: #ffffff;
}
.val-occ-metrics .measure-val.crit { color: #ef4444; }
.val-occ-metrics .measure-val.warn { color: #f59e0b; }

/* SEÇÃO INFERIOR: DETALHES DO RECORTE SELECIONADO */
.val-detail-section {
  border-top: 1px solid var(--border-subtle, #25282e);
  background: #0f1115;
  padding: 10px 12px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.val-detail-grid {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.val-thumb-wrapper {
  width: 110px;
  height: 110px;
  background: #08090b;
  border: 1px solid #24272e;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

#valThumbCanvas {
  display: block;
  width: 110px;
  height: 110px;
}

.val-detail-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.val-meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.val-detail-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.val-detail-badge {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.val-detail-badge.crit { background: #ef4444; color: #000; }
.val-detail-badge.warn { background: #f59e0b; color: #000; }
.val-detail-badge.safe { background: #10b981; color: #000; }

.val-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  gap: 4px;
}

.val-meta-label {
  color: var(--text-dim, #70757c);
  font-size: 10px;
  text-transform: uppercase;
}

.val-meta-value {
  font-family: 'Rajdhani', monospace;
  font-weight: 600;
  color: #d1d5db;
  text-align: right;
  white-space: nowrap;
}

.val-meta-value.highlight {
  font-weight: 700;
  color: #ef4444;
}

.val-detail-msg-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-muted, #95999f);
  line-height: 1.4;
}

.val-detail-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.val-action-btn {
  flex: 1;
  background: #1c1f26;
  border: 1px solid #2f343f;
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.val-action-btn:hover {
  background: #282d38;
  border-color: #4a5160;
}

.val-action-btn.primary {
  background: #2563eb;
  border-color: #3b82f6;
}

.val-action-btn.primary:hover {
  background: #1d4ed8;
}

.val-action-btn.active {
  background: #25282e;
  border-color: #10b981;
  color: #10b981;
}

.val-nav-arrows {
  display: flex;
  gap: 4px;
}

.val-action-btn.icon-only {
  flex: none;
  width: 28px;
  padding: 0;
}

/* Botão flutuante na barra superior do Canvas para abrir/fechar o Validador */
.btn-toggle-val-sidebar {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(17, 19, 23, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle, #25282e);
  color: var(--text-main, #ffffff);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 35;
  transition: all 0.2s ease;
}

.btn-toggle-val-sidebar:hover {
  background: #22262e;
  border-color: #38bdf8;
}

.btn-toggle-val-sidebar.active {
  border-color: #38bdf8;
}

.val-badge-counter {
  font-family: 'Rajdhani', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}
.val-badge-counter.crit { background: #ef4444; color: #000000; }
.val-badge-counter.warn { background: #f59e0b; color: #000000; }
.val-badge-counter.safe { background: #10b981; color: #000000; }

/* ==============================================================================
   FERRAMENTA DE STRETCH PARAMÉTRICO COM ANCORAGEM DIRECIONAL E TRAVAS INDIVIDUAIS
   ============================================================================== */

/* Prevenção estrutural de cortes e overflow horizontal na Sidebar */
#tabStretch {
  overflow-x: hidden !important;
  box-sizing: border-box;
}

#tabStretch * {
  box-sizing: border-box;
}

.stretch-section-card {
  margin-bottom: 12px;
  background: #14171c;
  border: 1px solid #232730;
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.stretch-badge-active {
  background: rgba(0, 240, 255, 0.15);
  color: #00f0ff;
  border: 1px solid rgba(0, 240, 255, 0.4);
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 4px;
  animation: stretchPulseBadge 1.8s infinite ease-in-out;
}

@keyframes stretchPulseBadge {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(0, 240, 255, 0.3); }
  50% { opacity: 0.65; box-shadow: 0 0 1px rgba(0, 240, 255, 0.1); }
}

/* Botão Principal do Seletor de Ferragens no Canvas */
.btn-stretch-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #191d24;
  border: 1.5px solid #2e3542;
  border-radius: 6px;
  color: #f1f5f9;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
}

.btn-stretch-selector:hover {
  background: #222731;
  border-color: #00f0ff;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.btn-stretch-selector.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: #00f0ff;
  color: #00f0ff;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
}

.stretch-selection-status-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
}

.stretch-status-label {
  font-size: 11px;
  color: var(--text-dim, #94a3b8);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
}

.stretch-count-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #00f0ff;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
}

.stretch-summary-text {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.4;
  word-break: break-word;
}

.btn-link-action {
  background: none;
  border: none;
  color: #f87171;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  transition: color 0.15s ease;
}

.btn-link-action:hover {
  color: #ef4444;
}

.stretch-cross-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, #94a3b8);
  margin-bottom: 4px;
}

/* CRUZ DE ANCORAGEM DIRECIONAL (SETAS INDEPENDENTES) */
.stretch-cross-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 8px 0;
  min-width: 0;
}

.stretch-cross-grid {
  display: grid;
  grid-template-columns: 68px 68px 68px;
  grid-template-rows: 68px 68px 68px;
  gap: 10px;
  align-items: center;
  justify-items: center;
}

.cross-cell {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cross-cell.empty {
  visibility: hidden;
}

.cross-cell.center-hub {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cross-hub-indicator {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.35);
}

.stretch-arrow-btn {
  width: 68px;
  height: 68px;
  background: #14171d;
  border: 1.5px solid #282d38;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  padding: 0;
}

.stretch-arrow-btn:hover {
  background: #1a202a;
  border-color: #38bdf8;
  transform: scale(1.04);
}

.stretch-arrow-btn.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: #00f0ff;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35);
}

.stretch-arrow-btn .arrow-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.stretch-arrow-btn .anchor-svg {
  width: 52px;
  height: 52px;
  display: block;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Moldura externa da chapa */
.stretch-arrow-btn .anchor-frame {
  stroke: rgba(226, 238, 247, 0.25);
  transition: all 0.2s ease;
}

/* Barra de Referência Ciano Neon */
.stretch-arrow-btn .anchor-active-bar {
  fill: #18d7ff;
  opacity: 0.45;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cadeado Central Suave */
.stretch-arrow-btn .anchor-lock-shackle,
.stretch-arrow-btn .anchor-lock-body {
  stroke: rgba(226, 238, 247, 0.35);
  transition: all 0.2s ease;
}

.stretch-arrow-btn .anchor-lock-dot {
  fill: rgba(226, 238, 247, 0.35);
  transition: all 0.2s ease;
}

/* Hover: Realce da Moldura e da Barra */
.stretch-arrow-btn:hover .anchor-frame {
  stroke: rgba(56, 189, 248, 0.6);
}

.stretch-arrow-btn:hover .anchor-active-bar {
  opacity: 0.85;
  filter: drop-shadow(0 0 3px rgba(24, 215, 255, 0.7));
}

.stretch-arrow-btn:hover .anchor-lock-shackle,
.stretch-arrow-btn:hover .anchor-lock-body {
  stroke: rgba(255, 255, 255, 0.75);
}

.stretch-arrow-btn:hover .anchor-lock-dot {
  fill: #38bdf8;
}

/* Ativo: Ciano Neon Puro com Iluminação Conforme Referência Original */
.stretch-arrow-btn.active .anchor-frame {
  stroke: rgba(24, 215, 255, 0.75);
}

.stretch-arrow-btn.active .anchor-active-bar {
  opacity: 1;
  fill: #18d7ff;
  filter: drop-shadow(0 0 7px rgba(24, 215, 255, 0.95));
}

.stretch-arrow-btn.active .anchor-lock-shackle,
.stretch-arrow-btn.active .anchor-lock-body {
  stroke: #ffffff;
}

.stretch-arrow-btn.active .anchor-lock-dot {
  fill: #18d7ff;
}

.stretch-helper-text {
  font-size: 11.5px;
  color: var(--text-dim, #94a3b8);
  line-height: 1.4;
  margin: 0 0 6px 0;
}

.stretch-mode-banner {
  background: #0d0f12;
  border-left: 3px solid #38bdf8;
  border-radius: 0 6px 6px 0;
  padding: 8px 10px;
  font-size: 11.5px;
  color: #e2e8f0;
  line-height: 1.4;
  margin-top: 8px;
  min-width: 0;
}

/* LISTA DE TRAVAS CRIADAS */
.stretch-locks-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
}

.stretch-locks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 8px;
  padding-right: 2px;
  min-width: 0;
}

.stretch-empty-locks {
  padding: 14px 10px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim, #64748b);
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.stretch-lock-card {
  background: #101318;
  border: 1px solid #232730;
  border-left: 4px solid #00f0ff;
  border-radius: 6px;
  padding: 8px 10px;
  transition: all 0.15s ease;
  min-width: 0;
}

.stretch-lock-card.editing {
  border-color: #00f0ff;
  background: #141a22;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

.stretch-lock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 5px;
  min-width: 0;
}

.stretch-lock-title-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.stretch-lock-name {
  font-size: 12px;
  font-weight: 700;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stretch-lock-ent-count {
  font-size: 10.5px;
  color: var(--text-dim, #94a3b8);
}

.stretch-lock-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  min-width: 0;
}

.stretch-dir-tag {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.stretch-dir-tag.muted {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.stretch-lock-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  margin-bottom: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 4px;
  word-break: break-word;
}

.stretch-lock-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-lock-act {
  background: #181b22;
  border: 1px solid #282c35;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  color: #cbd5e1;
}

.btn-lock-act.focus:hover {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.btn-lock-act.edit:hover {
  border-color: #00f0ff;
  color: #00f0ff;
  background: rgba(0, 240, 255, 0.1);
}

.btn-lock-act.delete:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.stretch-unlocked-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  color: #fde68a;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* DIMENSÕES DA CHAPA FLUIDAS E SEM CORTES */
.stretch-dim-summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.stretch-dim-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stretch-dim-sublabel {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, #94a3b8);
  font-weight: 700;
}

.stretch-dim-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
}

.stretch-dim-inputs-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.stretch-dim-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stretch-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, #94a3b8);
}

.stretch-input {
  width: 100%;
  background: #0d0f12;
  border: 1px solid #282b32;
  color: #38bdf8;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 4px;
  text-align: left;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
}

.stretch-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.stretch-delta-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.stretch-delta-badge.zero {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
}

.stretch-delta-badge.plus {
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.stretch-delta-badge.minus {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}

.stretch-actions-card {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle, #25282e);
  min-width: 0;
}

/* ==============================================================================
   DETALHES TÉCNICOS CAD/CNC (DESIGN SYSTEM FEDEX CONCEPT 02 / TASK 02.5.2)
   ============================================================================== */
.details-frame {
  display: flex;
  flex-direction: column;
  background: #06080b;
  border: 1px solid #1e2630;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75);
  color: #f1f5f9;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  transition: width 0.2s ease, max-height 0.2s ease;
}

.details-frame.maximized {
  width: 480px !important;
  max-height: 85vh !important;
}

.details-frame .frame-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0d1117;
  border-bottom: 1px solid #1e2630;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #e2e8f0;
}

.details-frame .detail-stack {
  display: flex;
  flex-direction: column;
  background: #06080b;
}

.details-frame .detail-box {
  border-bottom: 1px solid #1e2630;
  padding: 10px 12px 12px;
  background: #06080b;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.details-frame .detail-heading {
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e5edef;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.details-frame .detail-sub {
  font-size: 10px;
  color: #8b9bb4;
  font-family: 'Inter', sans-serif;
}

.details-frame .detail-drawing {
  width: 100%;
  height: 200px;
  background: #06080b;
  border-radius: 4px;
  border: 1px solid #151b23;
  margin-top: 4px;
}

.details-frame.maximized .detail-drawing {
  height: 220px;
}




