/* ASAS-AI — BIM viewer. Colours follow the user's chat theme (asas-themes.css). */
#asas-bim {
  --ab-bg: #0d1424;
  /* Full-screen modal above the WordPress admin bar (z-index 99999), like the exam screen. */
  position: fixed; inset: 0; z-index: 100060; display: flex; flex-direction: column;
  background: var(--bg, #0a0f1e); color: var(--tx, #e8eaf2);
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
#asas-app[data-theme^="light-"] #asas-bim { --ab-bg: #e9edf4; }
html.asas-bim-open, html.asas-bim-open body { overflow: hidden !important; }
#asas-bim *, #asas-bim *::before, #asas-bim *::after { box-sizing: border-box; }
#asas-bim :focus-visible { outline: 2px solid var(--ac, #D4A847); outline-offset: 2px; border-radius: 6px; }

/* Bar */
#asas-bim .ab-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-shrink: 0;
  background: var(--sb, #111827); border-bottom: 1px solid var(--bd, rgba(255,255,255,.1)); }
#asas-bim .ab-close { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--bd, rgba(255,255,255,.12)); background: var(--sf, #131c2e); color: var(--tx, #e8eaf2); }
#asas-bim .ab-title { flex: 1; min-width: 0; margin: 0; padding: 0; border: 0; background: none; color: var(--tx, #e8eaf2);
  font-family: 'Lora', Georgia, serif; font-weight: 600; font-size: 18px; line-height: 1.3; letter-spacing: 0; text-transform: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#asas-bim .ab-title:focus, #asas-bim .ab-title:focus-visible { outline: none; }
#asas-bim .ab-tools { display: flex; gap: 6px; flex-shrink: 0; }
#asas-bim .ab-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--bd, rgba(255,255,255,.12)); background: var(--s2, #1a2540); color: var(--tx, #e8eaf2); font: inherit; font-size: 13.5px; font-weight: 600; }
#asas-bim .ab-btn:hover { border-color: var(--ac, #D4A847); }
#asas-bim .ab-btn[aria-expanded="true"] { border-color: var(--ac, #D4A847); background: var(--ad, rgba(212,168,71,.12)); }
#asas-bim .ab-only-narrow { display: none; }

/* Layout */
#asas-bim .ab-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; }
#asas-bim .ab-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px; background: var(--sf, #131c2e); }
#asas-bim .ab-left { border-right: 1px solid var(--bd, rgba(255,255,255,.1)); }
#asas-bim .ab-right { border-left: 1px solid var(--bd, rgba(255,255,255,.1)); }
#asas-bim h3 { margin: 4px 0 10px; padding: 0; border: 0; background: none; font-family: 'Lora', Georgia, serif; font-weight: 600; font-size: 16px;
  color: var(--tx, #e8eaf2); letter-spacing: 0; text-transform: none; line-height: 1.3; }
#asas-bim .ab-stage { position: relative; min-width: 0; min-height: 0; background: var(--ab-bg); }
#asas-bim .ab-canvas { position: absolute; inset: 0; }
#asas-bim .ab-canvas canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
#asas-bim .ab-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: min(460px, 90%); margin: 0;
  padding: 14px 18px; border-radius: 12px; text-align: center; background: var(--sf, #131c2e); border: 1px solid var(--bd, rgba(255,255,255,.12));
  color: var(--tx, #e8eaf2); font-size: 14.5px; box-shadow: 0 12px 30px -12px rgba(0,0,0,.6); }
#asas-bim .ab-status[hidden] { display: none; }
#asas-bim .ab-status.ab-error { border-color: var(--ab-bad, #f87171); }
#asas-app[data-theme^="light-"] #asas-bim .ab-status.ab-error { --ab-bad: #b91c1c; }

/* Types panel */
#asas-bim .ab-row { display: flex; gap: 14px; margin-bottom: 8px; }
#asas-bim .ab-link { background: none; border: 0; padding: 2px 0; cursor: pointer; color: var(--ac, #D4A847); font: inherit; font-size: 13.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; }
#asas-bim .ab-classes { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 2px; }
#asas-bim .ab-classes li { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 8px; }
#asas-bim .ab-classes li:hover { background: var(--s2, #1a2540); }
#asas-bim .ab-classes input { width: 16px; height: 16px; accent-color: var(--ac, #D4A847); flex-shrink: 0; margin: 0; }
#asas-bim .ab-classes label { flex: 1; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-size: 14px; color: var(--tx, #e8eaf2); }
#asas-bim .ab-count { color: var(--t2, #a3afc6); font-variant-numeric: tabular-nums; font-size: 13px; }
#asas-bim .ab-section { display: flex; align-items: center; gap: 10px; }
#asas-bim .ab-range { flex: 1; accent-color: var(--ac, #D4A847); }
#asas-bim .ab-range-val { min-width: 62px; text-align: right; font-size: 13px; color: var(--t2, #a3afc6); font-variant-numeric: tabular-nums; }

/* Properties panel */
#asas-bim .ab-hint { margin: 0; font-size: 14px; color: var(--t2, #a3afc6); }
#asas-bim .ab-dl { display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: 6px 10px; margin: 0 0 12px; font-size: 13.5px; }
#asas-bim .ab-dl dt { color: var(--t2, #a3afc6); margin: 0; overflow-wrap: anywhere; }
#asas-bim .ab-dl dd { margin: 0; color: var(--tx, #e8eaf2); overflow-wrap: anywhere; }
#asas-bim .ab-pset { border-top: 1px solid var(--bd, rgba(255,255,255,.1)); padding-top: 8px; margin-top: 4px; }
#asas-bim .ab-pset summary { cursor: pointer; font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--tx, #e8eaf2); }

/* Loader toast (shown while the engine downloads) */
#asas-app .asas-bim-toast, body > .asas-bim-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 100070; padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: min(460px, 92vw); text-align: center;
  background: var(--sf, #131c2e); color: var(--tx, #e8eaf2); border: 1px solid var(--ac, #D4A847); box-shadow: 0 12px 30px -12px rgba(0,0,0,.6); }
.asas-bim-toast[hidden] { display: none; }
.asas-bim-toast.asas-bim-toast-error { border-color: #f87171; }

/* "View in 3D" buttons in the chat */
#asas-app .asas-bim-view { display: inline-flex; align-items: center; gap: 6px; }
#asas-app .asas-att-view { flex-shrink: 0; padding: 3px 8px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 700;
  border: 1px solid var(--ac, #D4A847); background: transparent; color: var(--ac, #D4A847); }
#asas-app .asas-file-view { flex-shrink: 0; margin-left: 4px; padding: 2px 7px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 11px; font-weight: 700;
  border: 1px solid var(--ac, #D4A847); background: transparent; color: var(--ac, #D4A847); }

/* Tablets and phones: panels become drawers over the 3D view */
@media (max-width: 860px) {
  #asas-bim .ab-main { grid-template-columns: minmax(0, 1fr); position: relative; }
  #asas-bim .ab-only-narrow { display: inline-flex; }
  #asas-bim .ab-panel { position: absolute; top: 0; bottom: 0; z-index: 2; width: min(330px, 88vw); display: none; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  #asas-bim .ab-left { left: 0; } #asas-bim .ab-right { right: 0; }
  #asas-bim .ab-panel.ab-open { display: block; }
}
@media (max-width: 560px) {
  #asas-bim .ab-bar { padding: 8px 10px; gap: 6px; }
  #asas-bim .ab-btn { padding: 8px; }
  #asas-bim .ab-btn-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #asas-bim .ab-title { font-size: 16px; }
}
