/* =====================================================
   Mashreq HQ Digital Twin — Main Stylesheet
   ===================================================== */

/* ---- Fonts ---- */
@font-face {
  font-family: "F29LT Bukra";
  src: url("../fonts/bukra.woff2") format("woff2"), url("../fonts/bukra.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "F29LT Bukra Md";
  src: url("../fonts/bukra-md.woff2") format("woff2"), url("../fonts/bukra-md.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "F29LT Bukra Rg";
  src: url("../fonts/bukra-rg.woff2") format("woff2"), url("../fonts/bukra-rg.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "F29LT Bukra Lt";
  src: url("../fonts/bukra-lt.woff2") format("woff2"), url("../fonts/bukra-lt.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "F29LT Bukra SmBd";
  src: url("../fonts/bukra-smbd.woff2") format("woff2"), url("../fonts/bukra-smbd.woff") format("woff");
  font-weight: normal; font-style: normal; font-display: swap;
}

/* ---- Reset ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: url("../img/bg-sky.png") center top / 100% 100% no-repeat;
  font-family: "F29LT Bukra Rg", "F29LT Bukra", sans-serif;
  color: #1a2030;
}
#app { position: absolute; inset: 0; }
canvas { display: block; }

/* ---- Glass Panel ---- */
.panel {
  position: absolute; backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
}

/* ---- Info Panel ---- */
#info { position: relative; top: auto; left: auto; min-width: unset; padding: 14px 16px; }
#info .info-top { display: flex; align-items: center; gap: 12px; }
#info .floor-badge {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, #f28c00, #f28c00);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#info .floor-num {
  font-size: 24px; font-weight: 600; line-height: 1.2em;
  color: #fff; letter-spacing: -0.5px; padding-top: 7px;
}
#info .info-text { flex: 1; min-width: 0; }
#info h1 { font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #7a8fa8; margin-bottom: 3px; }
#info .floor-label { font-size: 12px; font-weight: 500; color: #1a2030; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#info .meta {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 0; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
#info .meta-item { text-align: center; padding: 0 4px; }
#info .meta-item:not(:last-child) { border-right: 1px solid rgba(0,0,0,0.07); }
#info .meta-val { font-size: 13px; font-weight: 500; color: #1a2030; line-height: 1; }
#info .meta-lbl { font-size: 9px; color: #8a9ab0; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Floor Directory ---- */
#floors {
  position: absolute; top: 80px; right: 18px;
  width: fit-content; min-width: 210px; max-width: 280px;
  max-height: calc(100vh - 98px);
  padding: 14px 12px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.floors-header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; margin-bottom: 10px; }
.floors-header h2 { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: #7a8fa8; margin-bottom: 0; padding: 0 4px; cursor: default; }
#btnToggleFloors {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: none; background: rgba(0,0,0,0.06);
  border-radius: 6px; cursor: pointer; color: #7a8fa8; flex-shrink: 0;
  transition: background 0.18s, transform 0.28s cubic-bezier(.4,0,.2,1);
}
#btnToggleFloors:hover { background: rgba(0,0,0,0.12); color: #1a2030; }
#btnToggleFloors svg { width: 14px; height: 14px; transition: transform 0.28s cubic-bezier(.4,0,.2,1); }
#floors.collapsed #btnToggleFloors svg { transform: rotate(180deg); }
#floors.collapsed #floorList { display: none; }
#floors.collapsed { max-height: unset; }
#floorList { overflow-y: auto; overflow-x: hidden; flex: 1; padding-right: 6px; }
#floorList::-webkit-scrollbar { width: 3px; }
#floorList::-webkit-scrollbar-track { background: transparent; }
#floorList::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 10px; }
#floorList::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }

/* ---- Floor Group (Leasable 9–23) ---- */
.floor-group { margin-bottom: 2px; }
.floor-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 8px; cursor: pointer;
  background: rgba(177,221,181,0.20);
  transition: background 0.18s;
}
.floor-group-header:hover { background: rgba(177,221,181,0.40); }
.floor-group-header .name { flex: 1; font-size: 11px; font-weight: 600; color: #3a6040; }
.group-chevron { width: 13px; height: 13px; color: #5a8060; flex-shrink: 0; transition: transform 0.26s cubic-bezier(.4,0,.2,1); }
.floor-group.collapsed .group-chevron { transform: rotate(180deg); }
.floor-group-body { overflow: hidden; max-height: 800px; transition: max-height 0.35s cubic-bezier(.4,0,.2,1); }
.floor-group.collapsed .floor-group-body { max-height: 0; }
.floor-group-body .floor-btn { padding-left: 18px; }

/* ---- Tooltips ---- */
.has-tip { position: relative; }
.has-tip::after {
  content: attr(data-tip);
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: rgba(26,32,48,0.9); color: #fff;
  font-size: 10px; font-family: "F29LT Bukra Rg", sans-serif;
  padding: 5px 10px; border-radius: 7px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.22s ease, transform 0.22s ease;
  transform: translateY(-50%) translateX(4px); z-index: 200;
}
.has-tip::before {
  content: ''; position: absolute; right: calc(100% + 4px); top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-left-color: rgba(26,32,48,0.9);
  pointer-events: none; opacity: 0; transition: opacity 0.22s ease; z-index: 200;
}
.has-tip:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
.has-tip:hover::before { opacity: 1; }
.tip-down::after { right: auto; left: 50%; top: calc(100% + 10px); transform: translateX(-50%) translateY(-4px); }
.tip-down::before { right: auto; left: 50%; top: calc(100% + 2px); transform: translateX(-50%); border-left-color: transparent; border-bottom-color: rgba(26,32,48,0.9); }
.tip-down:hover::after { transform: translateX(-50%) translateY(0); }
.tip-down:hover::before { opacity: 1; }

/* ---- Floor Button ---- */
.floor-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  font-size: 12px; color: #3a4a5c; margin-bottom: 2px;
  white-space: nowrap; transition: background .15s, color .15s; user-select: none;
}
.floor-btn:hover { background: rgba(0,0,0,0.05); color: #1a2030; }
.floor-btn.active { background: rgba(82,148,255,0.15); color: #1a5cbf; font-weight: 600; }
.floor-btn { transition: background 0.22s ease, color 0.22s ease, font-weight 0.1s; }
.floor-btn .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.floor-btn .name { flex: 1; margin-left: 10px; }
.floor-btn .num { opacity: .45; font-variant-numeric: tabular-nums; margin-left: 8px; }
.floor-btn { opacity: 0; transform: translateX(8px); }
.floor-btn.gsap-ready { opacity: 1; transform: none; }

/* ---- Controls Bar ---- */
#controls { bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; padding: 10px 12px; }
.btn {
  padding: 8px 14px; border-radius: 8px; background: rgba(255,255,255,0.6);
  border: 1px solid rgba(0,0,0,0.10); color: #3a4a5c;
  font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transform: scale(1); transition: background .15s, color .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: rgba(255,255,255,0.9); color: #1a2030; }
.btn.active { background: rgba(82,148,255,0.18); color: #1a5cbf; border-color: rgba(82,148,255,0.35); box-shadow: 0 0 0 2px rgba(82,148,255,0.35), 0 4px 12px rgba(82,148,255,0.18); }
.btn:active { transform: scale(0.94); }
.btn svg { width: 14px; height: 14px; }

/* ---- Hint ---- */
#hint {
  position: absolute; bottom: 18px; left: 18px; font-size: 11px;
  color: #8a9ab0; padding: 8px 12px; background: rgba(255,255,255,0.6);
  border-radius: 8px; border: 1px solid rgba(0,0,0,0.07);
}

#copyright {
  position: absolute; bottom: 6px; left: 18px; font-size: 9px;
  color: #8a9ab0; letter-spacing: 0.5px;
}

/* ---- Loader ---- */
#loader {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #eeeeee; z-index: 100; transition: opacity .5s;
}
#loader.hide { opacity: 0; pointer-events: none; }
.spinner {
  width: 38px; height: 38px; border: 2px solid rgba(0,0,0,0.1);
  border-top-color: #5294ff; border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Scene Fade / Sky ---- */
#scene-fade {
  position: absolute; inset: 0; z-index: 49; pointer-events: none;
  background: url("../img/bg-sky.png") center top / 100% 100% no-repeat;
  opacity: 1; transition: opacity 0.7s cubic-bezier(0.4,0,0.2,1);
}
#scene-fade.out { opacity: 0; }

/* ---- Left Column ---- */
#left-col {
  position: absolute; top: 80px; left: 18px; bottom: 18px;
  width: 280px; z-index: 10;
}
#left-box {
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  max-height: calc(100vh - 98px); overflow-y: auto; overflow-x: hidden;
  padding: 6px 10px 6px 6px;
}
#left-box::-webkit-scrollbar { width: 3px; }
#left-box::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 10px; margin: 6px 0; }
#left-box::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.20); border-radius: 10px; }
#left-box::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.36); }
#info {
  min-width: unset; top: auto; left: auto; position: relative;
  background: none; border: none; border-radius: 0; box-shadow: none; padding: 14px 16px;
}
.left-divider { height: 1px; background: rgba(0,0,0,0.07); margin: 0 16px; }

/* ---- Floor Plan Panel ---- */
#fp-panel {
  padding: 14px 16px;
  overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height 0.45s ease, opacity 0.35s ease;
}
#fp-panel.visible { max-height: 700px; opacity: 1; pointer-events: auto; }
#fp-header { display: flex; align-items: center; margin-bottom: 6px; }
#fp-title { font-size: 11px; font-weight: 700; color: #3a4a5c; text-transform: uppercase; letter-spacing: 1px; }
#fp-name { font-size: 12px; color: #6b7e96; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fp-canvas { width: 100%; display: block; border-radius: 8px; border: 1px solid rgba(0,0,0,0.07); }
#fp-img { width: 100%; display: none; border-radius: 8px; border: 1px solid rgba(0,0,0,0.07); object-fit: cover; }

/* ---- Image Slider ---- */
#fp-slider { position: relative; display: none; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0,0,0,0.07); }
.fp-slider-track { display: flex; transition: transform 0.40s cubic-bezier(.4,0,.2,1); will-change: transform; }
.fp-slider-track img { width: 100%; flex-shrink: 0; object-fit: cover; border-radius: 0; display: block; }
.fp-slide-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,0.38); border: none; color: #fff;
  font-size: 22px; line-height: 1; width: 30px; height: 42px;
  cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background 0.18s; z-index: 2;
}
.fp-slide-btn:hover { background: rgba(0,0,0,0.62); }
.fp-slide-prev { left: 6px; }
.fp-slide-next { right: 6px; }
.fp-slide-dots { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; z-index: 2; }
.fp-slide-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; transition: background 0.2s, transform 0.2s; }
.fp-slide-dot.active { background: #fff; transform: scale(1.25); }

#fp-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 10px; color: #7a8fa8; }
#fp-legend span { display: flex; align-items: center; gap: 4px; }
.fpdot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

/* ---- Header ---- */
header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 62px;
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  border-bottom: none; box-shadow: none;
}
header .logo { height: 38px; width: auto; }
header .header-tag { font-size: 1.4rem; font-weight: 700; color: #ffffff; letter-spacing: 3px; text-transform: uppercase; }

/* ---- CO2 Panel ---- */
#co2-panel {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px;
  overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height 0.45s ease, opacity 0.35s ease;
}
#co2-panel.visible { max-height: 300px; opacity: 1; pointer-events: auto; }
.co2-box {
  background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.06); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 12px;
}
.co2-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0; background: #efefef;
}
.co2-info .co2-value { font-size: 21px; font-weight: 300; color: #1a2030; line-height: 1; }
.co2-info .co2-unit { font-size: 10px; color: #8a9ab0; }
.co2-info .co2-lbl { font-size: 10px; font-weight: 600; color: #5a6a7c; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }

/* ---- Chart Panel ---- */
#chart-panel {
  padding: 14px 16px;
  overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height 0.45s ease, opacity 0.35s ease;
}
#chart-panel.visible { max-height: 300px; opacity: 1; pointer-events: auto; }
#chart-panel .chart-title { font-size: 10px; font-weight: 700; color: #3a4a5c; text-transform: uppercase; letter-spacing: 1px; }
#chart-panel .chart-sub { font-size: 11px; color: #6b7e96; margin: 3px 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#floor-chart { width: 100%; display: block; border-radius: 6px; }
#chart-stats { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.06); }
.cstat { flex: 1; }
.cstat-val { font-size: 18px; font-weight: 300; color: #1a2030; line-height: 1; }
.cstat-unit { font-size: 10px; color: #8a9ab0; }
.cstat-lbl { font-size: 9px; font-weight: 600; color: #8a9ab0; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }

/* ---- Floor Callout ---- */
#fc-svg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 48; overflow: visible;
  opacity: 0; transition: opacity 0.35s ease;
}
#fc-svg.visible { opacity: 1; }
#fc-dot-wrap {
  position: fixed; pointer-events: none; z-index: 50;
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity 0.35s ease;
}
#fc-dot-wrap.visible { opacity: 1; }
#fc-label-wrap {
  position: fixed; pointer-events: none; z-index: 50;
  opacity: 0; transition: opacity 0.35s ease;
  font-size: 13px; color: #5f6570; font-weight: 400;
  font-family: "F29LT Bukra Rg", "F29LT Bukra", sans-serif;
  white-space: nowrap; letter-spacing: 0.3px;
}
#fc-label-wrap.visible { opacity: 1; }
.fc-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ccc; position: relative;
}
.fc-dot::after {
  content: ''; position: absolute; inset: -3px;
  border-radius: 50%; border: 2px solid #5f6570;
  animation: fc-pulse 1.6s ease-out infinite;
}
@keyframes fc-pulse {
  0%   { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(2.8); opacity: 0; }
}

/* ---- Performance hints ---- */
#left-col, #floors, #controls, #hint { will-change: transform, opacity; }
