/**
 * TECNO3D STYLES — Visualizador 3D Universal de Engenharia
 * Paleta: Deep Slate (#090d16), Cards (#0f172a), Acentos Cyan Tech (#06b6d4) & Teal (#14b8a6)
 */

:root {
  --t3d-bg: #090d16;
  --t3d-surface: #0f172a;
  --t3d-surface-glass: rgba(15, 23, 42, 0.88);
  --t3d-border: rgba(148, 163, 184, 0.15);
  --t3d-border-bright: rgba(6, 182, 212, 0.4);
  --t3d-cyan: #06b6d4;
  --t3d-cyan-hover: #22d3ee;
  --t3d-cyan-glow: rgba(6, 182, 212, 0.25);
  --t3d-teal: #14b8a6;
  --t3d-blue: #3b82f6;
  --t3d-amber: #f59e0b;
  --t3d-emerald: #10b981;
  --t3d-text: #f8fafc;
  --t3d-text-muted: #94a3b8;
  --t3d-text-dim: #64748b;
  --t3d-radius: 10px;
  --t3d-radius-sm: 6px;
}

/* ==========================================================================
   Hero Canônico Tecno3D
   ========================================================================== */
.t3d-hero {
  background: radial-gradient(circle at 50% -20%, rgba(6, 182, 212, 0.18), transparent 70%),
              linear-gradient(180deg, #090d16 0%, #0c1220 100%);
  border-bottom: 1px solid var(--t3d-border);
  padding: 40px 20px 30px;
  margin-top: 140px; /* Alinhamento estrito com header fixo do Martin Tools */
  text-align: center;
  position: relative;
  overflow: hidden;
}

.t3d-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid var(--t3d-border-bright);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--t3d-cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.t3d-hero-title {
  font-family: 'Oswald', 'Inter', sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--t3d-text);
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.t3d-hero-title span {
  background: linear-gradient(135deg, var(--t3d-cyan), #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.t3d-hero-desc {
  font-size: 1.05rem;
  color: var(--t3d-text-muted);
  max-width: 820px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.t3d-formats-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.t3d-format-pill {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--t3d-border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  font-family: 'JetBrains Mono', monospace;
}

.t3d-format-pill.highlight {
  border-color: var(--t3d-cyan);
  color: var(--t3d-cyan);
  background: rgba(6, 182, 212, 0.1);
}

/* ==========================================================================
   Layout Principal da Estacao 3D
   ========================================================================== */
.t3d-app-layout {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Dropzone Card */
.t3d-dropzone-card {
  background: var(--t3d-surface-glass);
  backdrop-filter: blur(12px);
  border: 2px dashed var(--t3d-border);
  border-radius: var(--t3d-radius);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.t3d-dropzone-card:hover, .t3d-dropzone-card.dragover {
  border-color: var(--t3d-cyan);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: 0 0 25px var(--t3d-cyan-glow);
}

.t3d-dropzone-card.has-file {
  padding: 14px 20px;
  border-style: solid;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.t3d-dropzone-card.has-file .t3d-drop-initial {
  display: none !important;
}

.t3d-dropzone-card.has-file #t3d-file-banner {
  display: flex !important;
}

.t3d-drop-icon {
  font-size: 2.2rem;
  color: var(--t3d-cyan);
  margin-bottom: 8px;
}

.t3d-drop-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--t3d-text);
  margin-bottom: 4px;
}

.t3d-drop-subtext {
  font-size: 0.8rem;
  color: var(--t3d-text-dim);
  margin-bottom: 14px;
}

.t3d-samples-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.t3d-btn-sample {
  background: #1e293b;
  border: 1px solid var(--t3d-border);
  color: var(--t3d-text);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.t3d-btn-sample:hover {
  border-color: var(--t3d-cyan);
  color: var(--t3d-cyan);
  background: rgba(6, 182, 212, 0.1);
}

/* File Banner */
#t3d-file-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.t3d-file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.t3d-file-icon {
  font-size: 1.8rem;
  color: var(--t3d-emerald);
}

.t3d-file-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--t3d-text);
}

.t3d-file-meta {
  font-size: 0.75rem;
  color: var(--t3d-text-muted);
}

/* ==========================================================================
   Ribbon 3D & Barra de Ferramentas
   ========================================================================== */
.t3d-ribbon {
  background: var(--t3d-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--t3d-border);
  border-radius: var(--t3d-radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.t3d-ribbon-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.t3d-ribbon-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--t3d-border);
  padding: 4px 8px;
  border-radius: var(--t3d-radius-sm);
}

.t3d-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--t3d-text-dim);
  text-transform: uppercase;
  margin-right: 4px;
}

.t3d-btn-tool {
  background: transparent;
  border: 1px solid transparent;
  color: var(--t3d-text-muted);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.t3d-btn-tool:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--t3d-text);
}

.t3d-btn-tool.active {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--t3d-cyan);
  color: var(--t3d-cyan);
}

.t3d-btn-primary {
  background: linear-gradient(135deg, var(--t3d-cyan), #0284c7);
  border: none;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px var(--t3d-cyan-glow);
  transition: all 0.2s;
}

.t3d-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   Viewport 3D WebGL & HUD Lateral
   ========================================================================== */
.t3d-main-stage {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  min-height: 640px;
}

@media (max-width: 1024px) {
  .t3d-main-stage {
    grid-template-columns: 1fr;
  }
}

.t3d-viewport-container {
  background: #090d16;
  border: 1px solid var(--t3d-border);
  border-radius: var(--t3d-radius);
  position: relative;
  overflow: hidden;
  min-height: 600px;
}

#t3d-viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* Painel Lateral HUD */
.t3d-hud-sidebar {
  background: var(--t3d-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--t3d-border);
  border-radius: var(--t3d-radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: 640px;
}

.t3d-hud-block {
  border-bottom: 1px solid var(--t3d-border);
  padding-bottom: 14px;
}

.t3d-hud-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.t3d-hud-title {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--t3d-text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.t3d-hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.t3d-hud-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--t3d-border);
  border-radius: 6px;
  padding: 8px 10px;
}

.t3d-hud-card-label {
  font-size: 0.7rem;
  color: var(--t3d-text-dim);
  text-transform: uppercase;
  font-weight: 700;
}

.t3d-hud-card-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--t3d-cyan);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* Lista de Medicoes */
.t3d-measure-item {
  background: rgba(30, 41, 59, 0.7);
  border-left: 3px solid var(--t3d-cyan);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.t3d-measure-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.t3d-measure-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--t3d-text);
}

.t3d-measure-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--t3d-cyan);
  font-family: 'JetBrains Mono', monospace;
}

.t3d-measure-details {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--t3d-text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.t3d-empty-msg {
  font-size: 0.8rem;
  color: var(--t3d-text-dim);
  text-align: center;
  padding: 16px 0;
}

/* ==========================================================================
   Painel Flutuante de Planos de Corte (Clipping Panel)
   ========================================================================== */
.t3d-clip-panel {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--t3d-border-bright);
  border-radius: var(--t3d-radius);
  padding: 14px 18px;
  width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 20;
}

.t3d-clip-panel.active {
  display: block;
}

.t3d-clip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.t3d-clip-row:last-child {
  margin-bottom: 0;
}

.t3d-clip-axis {
  font-weight: 700;
  font-size: 0.8rem;
  width: 50px;
  color: var(--t3d-cyan);
}

.t3d-clip-slider {
  flex: 1;
  accent-color: var(--t3d-cyan);
  cursor: pointer;
}

.t3d-clip-val {
  font-size: 0.75rem;
  width: 40px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  color: var(--t3d-text-muted);
}

/* Loading Overlay */
.t3d-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.t3d-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--t3d-cyan);
  border-radius: 50%;
  animation: t3d-spin 0.8s linear infinite;
  margin-bottom: 12px;
}

.t3d-progress-container {
  width: 220px;
  height: 6px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.t3d-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--t3d-cyan), #38bdf8);
  transition: width 0.2s ease;
}

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

/* ==========================================================================
   Arvore de Componentes & Montagem CAD
   ========================================================================== */
.t3d-tree-section {
  background: var(--t3d-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--t3d-border);
  border-radius: var(--t3d-radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.t3d-tree-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--t3d-border);
  padding-bottom: 12px;
}

.t3d-tree-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--t3d-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.t3d-tree-count-badge {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid var(--t3d-border-bright);
  color: var(--t3d-cyan);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

.t3d-tree-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.t3d-btn-tree-tool {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--t3d-border);
  color: var(--t3d-text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.t3d-btn-tree-tool:hover {
  border-color: var(--t3d-cyan);
  color: var(--t3d-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.t3d-tree-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.t3d-tree-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--t3d-text-dim);
  font-size: 0.85rem;
  padding: 24px;
  font-style: italic;
}

.t3d-tree-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--t3d-border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s;
}

.t3d-tree-card:hover {
  border-color: var(--t3d-border-bright);
  background: rgba(15, 23, 42, 0.95);
  transform: translateY(-1px);
}

.t3d-tree-card.is-hidden {
  opacity: 0.45;
  border-style: dashed;
}

.t3d-tree-card.is-selected {
  border-color: var(--t3d-cyan);
  box-shadow: 0 0 10px var(--t3d-cyan-glow);
}

.t3d-tree-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.t3d-tree-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
}

.t3d-tree-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.t3d-tree-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--t3d-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t3d-tree-meta {
  font-size: 0.72rem;
  color: var(--t3d-text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.t3d-tree-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.t3d-tree-action-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--t3d-border);
  color: var(--t3d-text-muted);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.t3d-tree-action-btn:hover {
  color: var(--t3d-cyan);
  border-color: var(--t3d-cyan);
}

.t3d-tree-action-btn.active {
  color: #090d16;
  background: var(--t3d-cyan);
  border-color: var(--t3d-cyan);
}

/* Item de Medicao no HUD */
.t3d-measure-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--t3d-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  position: relative;
}

.t3d-measure-item:hover {
  border-color: var(--t3d-border-bright);
}

.t3d-measure-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.t3d-measure-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--t3d-cyan);
}

.t3d-measure-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: #38bdf8;
}

.t3d-measure-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--t3d-text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.t3d-measure-del-btn {
  background: transparent;
  border: none;
  color: var(--t3d-text-dim);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.75rem;
  transition: color 0.15s;
}

.t3d-measure-del-btn:hover {
  color: #ef4444;
}
