/* GLB Embed Builder (Option A) - TONY MARGHELLA-branded editor, white-label export */

:root{
  --bg: #0b0f17;
  --panel: #121a28;
  --panel-2: #0f1623;
  --text: #e7eefc;
  --muted: #9fb0cc;
  --border: rgba(255,255,255,0.10);
  --accent: #23A9E1;
  --danger: #ff6b6b;
  --shadow: rgba(0,0,0,0.35);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Hotspot sizing (controlled by slider) */
  --hs-size: 18px;
  --hs-icon-size: 14px;
  --hs-dot-size: 10px;
  --hs-bubble-offset: 22px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,15,23,0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-logo{
  height: 22px;
  width: auto;
  display: block;
}
.brand-text{ min-width: 0; }
.brand-title{
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-subtitle{
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layout{
  display: grid;
  grid-template-columns: 390px 1fr;
  height: calc(100vh - 52px);
}

.panel{
  overflow: auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 14px;
}

/* Collapsible sections (details/summary) */
.panel-section{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: rgba(255,255,255,0.03);
  overflow: hidden;
}
.panel-section > summary{
  list-style: none;
  cursor: pointer;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  user-select: none;
}
.panel-section > summary::-webkit-details-marker{ display:none; }

.panel-section[open] > summary{
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.16);
}

.section-left{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-num{
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.22);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}

.section-name{
  font-size: 12px;
  letter-spacing: 0.38px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-chevron{
  width: 9px;
  height: 9px;
  border-right: 2px solid rgba(255,255,255,0.35);
  border-bottom: 2px solid rgba(255,255,255,0.35);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
  flex: 0 0 auto;
}
.panel-section[open] .section-chevron{ transform: rotate(45deg); }

.section-body{ padding: 12px; }

.field{ display: block; margin-bottom: 10px; }

.field-label{
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="file"],
.field select,
.field textarea{
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  outline: none;
}

.field textarea { resize: vertical; }

.field input[type="color"]{
  width: 100%;
  height: 40px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
}

.field input[type="range"]{ width: 100%; }

.field-row{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.field-value{
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.checkbox{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}
.checkbox input{ transform: translateY(-0.5px); }

.hint{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.button-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.btn{
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 10px;
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-weight: 700;
}
.btn:hover{ border-color: rgba(255,255,255,0.22); }
.btn:active{ transform: translateY(1px); }

.btn-secondary{
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-weight: 700;
}

.btn-primary{
  background: linear-gradient(180deg, rgba(35,169,225,0.85), rgba(35,169,225,0.55));
  border-color: rgba(35,169,225,0.7);
}

.status{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.viewer{ position: relative; overflow: hidden; }

.viewer-toolbar{
  position: absolute;
  left: 12px;
  top: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

.viewer-toolbar-right{
  display: inline-flex;
  gap: 8px;
  pointer-events: auto; /* enable clicks for buttons */
}

.viewer-btn{
  pointer-events: auto;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.viewer-btn:hover{ border-color: rgba(255,255,255,0.22); background: rgba(0,0,0,0.48); }
.viewer-btn:active{ transform: translateY(1px); }

.viewer-hint{
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.progress{
  width: 220px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  position: absolute;
  left: 12px;
  bottom: 12px;
}
.progress-bar{
  width: 0%;
  height: 100%;
  background: rgba(35,169,225,0.95);
}

.hotspot-list{
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.hotspot-item{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0,0,0,0.20);
}
.hotspot-item-title{ font-weight: 800; margin-bottom: 6px; }
.hotspot-item-meta{
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.hotspot-item-actions{ display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }

.small-btn{
  cursor: pointer;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
}
.small-btn.danger{
  border-color: rgba(255,107,107,0.35);
  background: rgba(255,107,107,0.08);
}

.hidden{ display: none !important; }

.hotspot-form{
  margin-top: 10px;
  border: 1px solid rgba(35,169,225,0.35);
  border-radius: 12px;
  padding: 10px;
  background: rgba(35,169,225,0.08);
}
.hotspot-form-title{ font-weight: 900; margin-bottom: 10px; }

.info-panel{
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: min(380px, calc(100% - 28px));
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10,14,22,0.90);
  box-shadow: 0 10px 40px var(--shadow);
  z-index: 7;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.info-panel-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.info-title{ font-weight: 900; letter-spacing: 0.2px; }
.info-body{
  padding: 12px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.icon-btn{
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 18px;
  line-height: 0;
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .panel{ height: 52vh; border-right: none; border-bottom: 1px solid var(--border); }
  .viewer{ height: calc(48vh - 52px); }
  .brand-subtitle{ display:none; }
}

/* Hotspots inside <model-viewer> (authoring tool) */
.mv-hotspot{ position: relative; pointer-events: auto; }

button.mv-hotspot-btn{
  width: var(--hs-size);
  height: var(--hs-size);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(35,169,225,0.25);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
button.mv-hotspot-btn:hover{ background: rgba(35,169,225,0.42); }
button.mv-hotspot-btn:focus{
  outline: 2px solid rgba(35,169,225,0.75);
  outline-offset: 2px;
}

.mv-hotspot-icon{
  width: var(--hs-icon-size);
  height: var(--hs-icon-size);
  display: block;
}
.mv-hotspot-icon svg{ width: 100%; height: 100%; display: block; }

.mv-hotspot-dot{
  display: block;
  width: var(--hs-dot-size);
  height: var(--hs-dot-size);
  border-radius: 999px;
  background: rgba(255,255,255,0.85);
}

.mv-hotspot-bubble{
  position: absolute;
  left: var(--hs-bubble-offset);
  top: 50%;
  transform: translateY(-50%);
  width: min(320px, 70vw);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10,14,22,0.92);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  overflow: hidden;
  backdrop-filter: blur(10px);
  display: none;
}
.mv-hotspot-bubble.open{ display: block; }

.mv-hotspot-bubble-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.mv-hotspot-bubble-title{ font-weight: 900; letter-spacing: 0.2px; font-size: 13px; }
.mv-hotspot-bubble-close{
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 18px;
  line-height: 0;
}
.mv-hotspot-bubble-body{
  padding: 10px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.mv-hotspot-bubble-body a{ color: var(--accent); }
.mv-hotspot-bubble-body img{
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  margin-top: 8px;
}
.mv-hotspot-bubble-body iframe{
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  border-radius: 10px;
  margin-top: 8px;
}
