/* ============================================================
   BILDEK — CONVERSOR / VISUALIZADOR IFC
   Mesmo sistema visual da home (site.css): TUDO QUADRADO,
   botoes tateis, degrade laranja, Space Grotesk + IBM Plex +
   JetBrains Mono. Aqui ficam so os estilos do app-shell:
   dropzone, sidebar, arvore, propriedades, corte, marca,
   toolbar 3D e overlays. Tokens vem de site.css.
   ============================================================ */

:root { --sidebar-w: 320px; }

/* ---- app-shell: header fixo no topo + main preenchendo ---- */
body.app-shell {
  height: 100vh; height: 100dvh;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.app-main {
  flex: 1; min-height: 0; position: relative; z-index: 1;
  animation: pageIn .55s var(--ease) both;
}
/* entrada suave ao chegar da home (fallback p/ navegadores sem View Transitions) */
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.stage { width: 100%; height: 100%; }

/* ============================================================
   STAGE 1 — DROPZONE
   ============================================================ */
.stage-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(2rem, 5vw, 4rem) 1.5rem; text-align: center;
  position: relative; overflow: hidden;
}
/* degrade de assinatura, igual ao heroi da home */
.stage-drop::before {
  content: ""; position: absolute; inset: -12% -12% auto -12%; height: 130%; z-index: 0; pointer-events: none;
  background:
    conic-gradient(from 210deg at 50% 16%,
      rgba(253,186,116,0) 0deg, rgba(249,115,22,0.22) 64deg, rgba(194,65,12,0.16) 150deg,
      rgba(249,115,22,0.05) 232deg, rgba(253,186,116,0) 360deg),
    radial-gradient(640px 400px at 50% 2%, rgba(253,186,116,0.14), transparent 66%);
  filter: blur(54px); opacity: 0.85;
  animation: drift 22s ease-in-out infinite;
}
@keyframes drift { 0%,100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(6deg) scale(1.05); } }
.stage-drop > * { position: relative; z-index: 1; }

.stage-drop h1 { font-size: var(--step-3); margin-bottom: var(--sp-2); }
.stage-drop h1 .accent {
  background: linear-gradient(110deg, var(--orange-lit) 0%, var(--orange) 46%, var(--orange-deep) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.stage-drop .lead { color: var(--ink-dim); margin-bottom: var(--sp-4); max-width: 560px; }

.dropzone {
  width: 100%; max-width: 560px; border: 1px dashed var(--line);
  background: var(--surface); padding: clamp(2rem, 4vw, 3rem) 2rem; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--orange); background: var(--orange-lo); }
.dz-icon { font-size: 42px; margin-bottom: 14px; }
.dz-title { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 600; font-size: var(--step-1); letter-spacing: -0.015em; margin-bottom: 6px; }
.dz-hint { color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; letter-spacing: 0.03em; margin-bottom: 22px; }

#status { display: none; margin-top: 22px; max-width: 560px; padding: 12px 16px; font-size: var(--step--1); background: var(--surface); border: 1px solid var(--line); color: var(--ink-dim); }
#status.status-error { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); color: #fca5a5; }

/* ============================================================
   STAGE 2 — LOADING
   ============================================================ */
/* position:absolute pra poder ficar sobreposto ao stage-viewer durante o
   estágio "rendering" (ver showStage em app.js): o viewer precisa estar
   com display real pro canvas se dimensionar, mas o indicador de
   carregamento continua cobrindo tudo até initViewer terminar. */
/* z-index acima de tudo que existe em .stage-viewer (overlay-card 10,
   brand-overlay 11, viewer-tools/actions 12, tooltip 20) pra cobrir de
   verdade o toolbar/painel de info enquanto o viewer ainda está montando. */
.stage-loading { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: absolute; inset: 0; z-index: 30; background: var(--surface, #fff); }
#loading-label { color: var(--ink-dim); font-size: var(--step-0); margin-bottom: 16px; }
.loading-hint { color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; margin-top: 10px; }

/* ---- Barra de progresso (leitura do arquivo + processamento) ---- */
.progress-wrap { width: 100%; max-width: 320px; }
.progress-track {
  width: 100%; height: 8px; border-radius: 8px;
  background: var(--line); overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 8px;
  background: linear-gradient(90deg, var(--orange-lit), var(--orange), var(--orange-deep));
  transition: width .18s var(--ease);
}
/* modo indeterminado: total desconhecido (ex.: streaming de geometria do web-ifc) */
.progress-track.indeterminate .progress-fill {
  width: 35%; transition: none;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(120%); }
  100% { transform: translateX(320%); }
}
.progress-text { color: var(--ink-faint); font-size: 13px; margin-top: 6px; min-height: 1em; }

/* ============================================================
   STAGE 3 — VIEWER (split sidebar + 3D)
   ============================================================ */
.stage-viewer { display: none; flex-direction: row; }

/* ---- Sidebar ---- */
.sidebar { width: var(--sidebar-w); flex: 0 0 auto; min-width: 220px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.panel-tab { flex: 1; background: transparent; border: none; color: var(--ink-dim); font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; letter-spacing: 0.04em; font-weight: 500; padding: 13px 8px; cursor: pointer; border-bottom: 2px solid transparent; transition: color .12s var(--ease), background .12s var(--ease); }
.panel-tab:hover { color: var(--ink); }
.panel-tab.active { color: var(--orange); border-bottom-color: var(--orange); background: var(--orange-lo); }
.panel-pane { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.panel-pane.active { display: flex; }

.sidebar-section { padding: 14px; }
.sidebar-title { font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-faint); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-tree-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0; }
.sidebar-props-wrap { flex: 0 0 auto; max-height: 45%; overflow: auto; border-top: 1px solid var(--line); }

/* ---- Arvore ---- */
.tree { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.tnode { font-size: 0.82rem; }
.thead { display: flex; align-items: center; gap: 5px; padding: 5px 6px; cursor: pointer; user-select: none; transition: background .1s var(--ease); }
.thead:hover { background: var(--elevated); }
.thead.active { background: var(--orange-lo); }
.thead.active .tlabel { color: var(--orange); }
.caret { width: 14px; height: 14px; flex: 0 0 14px; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); transition: transform .12s var(--ease); }
.caret.open { transform: rotate(90deg); }
.caret-spacer { width: 14px; flex: 0 0 14px; }
.tchk { width: 13px; height: 13px; flex: 0 0 13px; accent-color: var(--orange); cursor: pointer; }
.tlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.tstorey > .thead > .tlabel { font-weight: 600; }
.ttype > .thead > .tlabel { color: var(--ink-dim); }
.telabel { color: var(--ink-dim); font-size: 0.78rem; }
.tcount { font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; color: var(--ink-faint); background: var(--tile); padding: 1px 7px; flex: 0 0 auto; }
.tkids { margin-left: 14px; border-left: 1px solid var(--line-soft); padding-left: 2px; }

/* ---- Propriedades ---- */
.props { font-size: 0.78rem; }
.props-empty { color: var(--ink-faint); font-size: 0.78rem; padding: 8px 2px; }
.props .props-head, .props .props-base, .props .props-psets { display: none; }
.props.show .props-empty { display: none; }
.props.show .props-head, .props.show .props-base, .props.show .props-psets { display: block; }
.props-head { margin-bottom: 8px; }
.props-type { display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 0.64rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--orange); background: var(--orange-lo); border: 1px solid rgba(249,115,22,0.35); padding: 4px 10px; }
.props-base { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.props-base td { padding: 5px 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.props-base tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.pk { color: var(--ink-faint); width: 45%; }
.pv { color: var(--ink); font-weight: 500; text-align: right; }
.pset-sec { margin-top: 12px; }
.pset-title { font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--orange); margin-bottom: 5px; }
.pset-table { width: 100%; border-collapse: collapse; }
.pset-table td { padding: 4px; border-bottom: 1px solid var(--line-soft); vertical-align: top; font-size: 0.72rem; }
.pset-table tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.pp-empty { color: var(--ink-faint); font-size: 0.78rem; padding: 6px 2px; }
.cls-inline { cursor: pointer; color: var(--ink-faint); font-size: 16px; line-height: 1; }
.cls-inline:hover { color: var(--orange); }

/* ---- Corte (section box) ---- */
.clip-toggle { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--ink); margin-bottom: 16px; cursor: pointer; }
.clip-toggle input { width: 15px; height: 15px; accent-color: var(--orange); cursor: pointer; }
.clip-axis { margin-bottom: 16px; }
.clip-axis-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.axis-tag { font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; font-weight: 600; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.axis-x { background: #ef4444; }
.axis-y { background: #10b981; }
.axis-z { background: #3b82f6; }
.clip-vals { font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; color: var(--ink-faint); }
.clip-slider { width: 100%; margin: 3px 0; accent-color: var(--orange); }

/* ---- Marca (logo + empresa) ---- */
.brand-help { font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 14px; line-height: 1.5; }
.field-label { display: block; font-family: 'JetBrains Mono', monospace; font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); margin: 12px 0 6px; }
.field-file { width: 100%; font-size: 0.74rem; color: var(--ink-dim); }
.field-file::file-selector-button { background: var(--tile); color: var(--ink); border: 0; padding: 7px 13px; margin-right: 10px; cursor: pointer; font-family: 'Inter', sans-serif; font-size: 0.74rem; box-shadow: 3px 3px 10px rgba(0,0,0,0.5); transition: transform .12s var(--ease), box-shadow .12s var(--ease); }
.field-file::file-selector-button:active { transform: translate(2px,2px); box-shadow: 1px 1px 5px rgba(0,0,0,0.45); }
.field-text { width: 100%; background: var(--base); border: 1px solid var(--line); padding: 10px 12px; color: var(--ink); font-family: 'Inter', sans-serif; font-size: 0.82rem; }
.field-text:focus { outline: none; border-color: var(--orange); }

/* ---- Divisor arrastavel ---- */
.divider { width: 5px; flex: 0 0 5px; cursor: col-resize; background: var(--line); transition: background .12s var(--ease); }
.divider:hover { background: var(--orange); }

/* ---- Viewer 3D ---- */
.viewer-pane { flex: 1; min-width: 0; position: relative; background: var(--base); }
.viewer-pane #c { width: 100%; height: 100%; display: block; }

/* ---- Overlay cards ---- */
.overlay-card { position: absolute; background: rgba(17,17,20,0.92); border: 1px solid var(--line); box-shadow: 6px 6px 24px rgba(0,0,0,0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 10; }
.overlay-info { top: 14px; left: 14px; padding: 14px 18px; color: var(--ink); font-size: 0.74rem; max-width: 290px; }
.overlay-info h2 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.95rem; margin-bottom: 10px; color: var(--ink); font-weight: 600; }
.overlay-info p { margin: 4px 0; color: var(--ink-dim); font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; letter-spacing: 0.02em; }
.overlay-info .v { color: var(--ink); font-weight: 500; }
.overlay-controls { bottom: 14px; left: 14px; padding: 9px 12px; color: var(--ink-faint); font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; letter-spacing: 0.04em; }
.overlay-controls span { background: var(--orange-lo); padding: 2px 7px; color: var(--orange); margin-right: 4px; font-weight: 500; }

/* ---- Toolbar de ferramentas (icones) ---- */
.viewer-tools { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: rgba(17,17,20,0.92); border: 1px solid var(--line); padding: 6px 8px; box-shadow: 6px 6px 24px rgba(0,0,0,0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 12; }
.tools-group { display: flex; gap: 2px; }
.tools-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tool-btn { position: relative; width: 32px; height: 32px; border: none; background: transparent; color: var(--ink-dim); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .12s var(--ease), color .12s var(--ease), transform .1s var(--ease); }
.tool-btn:hover { background: var(--elevated); color: var(--orange); }
.tool-btn:active { background: var(--orange-lo); transform: translate(1px,1px); }
.tool-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--elevated); color: var(--ink); font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; letter-spacing: 0.02em; white-space: nowrap; padding: 6px 9px; border: 1px solid var(--line); box-shadow: 4px 4px 14px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .12s var(--ease); z-index: 20; }
.tool-btn:hover::after { opacity: 1; }
.toolbar-hint { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); background: var(--orange); color: #fff; font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 500; padding: 7px 13px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s var(--ease); box-shadow: 4px 4px 14px rgba(0,0,0,0.5); }
.toolbar-hint.show { opacity: 1; }

/* ---- Overlay de marca (logo + empresa) ---- */
.brand-overlay { position: absolute; bottom: 14px; right: 14px; display: flex; align-items: center; gap: 8px; background: rgba(17,17,20,0.85); padding: 8px 12px; border: 1px solid var(--line); z-index: 11; }
.brand-overlay img { max-height: 36px; max-width: 120px; display: block; }
.brand-overlay span { color: var(--ink); font-size: 0.78rem; font-weight: 600; }

/* ---- Acoes do viewer ---- */
.viewer-actions { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 12; }
.viewer-actions .btn { box-shadow: 4px 4px 16px rgba(0,0,0,0.6); }
.viewer-actions .btn-primary { box-shadow: 4px 4px 16px rgba(0,0,0,0.55), 6px 6px 26px -6px rgba(249,115,22,0.5); }

/* ============================================================
   BOTOES auxiliares nao cobertos pelo site.css
   (.btn / .btn-primary / .btn-surface ja vem de site.css)
   ============================================================ */
.btn-secondary {
  background: var(--tile); color: var(--ink);
  box-shadow: 5px 5px 18px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: transform .13s var(--ease), box-shadow .13s var(--ease), background .2s var(--ease);
}
.btn-secondary:hover { background: #202026; transform: translate(-2px,-2px); box-shadow: 7px 7px 24px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06); }
.btn-secondary:active { transform: translate(4px,4px); box-shadow: 1px 1px 6px rgba(0,0,0,0.5); }
.btn-sm { padding: 0.6rem 1.05rem; font-size: var(--step--1); }
.btn-block { width: 100%; margin-top: 12px; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 720px) {
  .sidebar { width: 240px; }
  .viewer-tools { gap: 3px; padding: 5px; }
  .tool-btn { width: 28px; height: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .app-main, .stage-drop::before { animation: none !important; }
}
