/* تخطيط: الصورة البانورامية بملء الشاشة، وكل عناصر الواجهة زجاج أبيض عائم فوقها
   (شريط علوي للهوية · مخطط وبطاقة الغرفة أعلى · أدوات يسار · شريط غرف عائم بالأسفل) */
:root {
  --stage: #17171a;                      /* خلفية العارض قبل تحميل الصورة */
  --glass: rgba(250, 249, 246, 0.86);    /* الزجاج الأبيض */
  --glass-strong: rgba(255, 255, 255, 0.95);
  --ink: #1d1e21;                        /* النص الرئيسي والعناصر النشطة */
  --muted: #6f6b64;                      /* نص ثانوي */
  --accent: #9a7846;                     /* برونزي هادئ */
  --accent-soft: rgba(154, 120, 70, 0.16);
  --line: rgba(29, 30, 33, 0.10);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.08);
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", "Tahoma", sans-serif;
  --top: 76px;        /* مسافة العناصر العائمة تحت الشريط العلوي */
  --bottom: 82px;     /* مسافة العناصر العائمة فوق شريط الغرف */
  --side: max(14px, env(safe-area-inset-left, 0px));
  --side-r: max(14px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
html, body { height: 100%; }
body { background: var(--stage); color: var(--ink); font-family: var(--f-body); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { position: relative; height: 100%; overflow: hidden; background: var(--stage); }
.glass { background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: var(--shadow); }

/* ---------- الشريط العلوي ---------- */
.topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 5; min-width: 0;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 12px rgba(0, 0, 0, 0.08); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; overflow: hidden; background: var(--ink); }
.logo span { font-size: 19px; font-weight: 600; color: #e9dcc3; line-height: 1; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { min-width: 0; padding-inline-start: 12px; border-inline-start: 1px solid var(--line); }
.brand h1 { margin: 0; font-weight: 600; font-size: 17px; letter-spacing: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.apt-select { display: flex; align-items: center; gap: 6px; background: rgba(29, 30, 33, 0.05); border: 1px solid var(--line); border-radius: 10px; padding: 3px 10px; }
.apt-select span { font-size: 11px; color: var(--muted); }
.apt-select select { background: transparent; border: 0; font-weight: 600; font-size: 13px; padding: 5px 2px; }
.wa { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: var(--ink); color: #fff;
  font-weight: 500; font-size: 14px; border-radius: 10px; padding: 9px 15px; transition: background .2s; }
.wa:hover { background: #000; }
.wa svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- المسرح ---------- */
.stage { position: absolute; inset: 0; }
#pano { position: absolute; inset: 0; direction: ltr; }
.pnlm-container { background: var(--stage) !important; font-family: var(--f-body) !important; }
.pnlm-load-box, .pnlm-about-msg { display: none !important; }
.pnlm-fade-img { pointer-events: none; }
.pnlm-hotspot-base { left: 0; }

.scene-card { position: absolute; top: var(--top); right: var(--side-r); z-index: 3; border-radius: 14px; padding: 11px 16px 12px; max-width: min(320px, 55vw); pointer-events: none; }
.scene-card .eyebrow { display: block; font-size: 11px; color: var(--muted); }
.scene-card h2 { margin: 2px 0 0; font-weight: 600; font-size: 22px; line-height: 1.25; color: var(--ink); }
.scene-card h2::after { content: ""; display: block; width: 22px; height: 2px; margin-top: 7px; background: var(--accent); border-radius: 2px; }
.demo-tag { display: inline-block; margin-top: 8px; font-size: 11px; line-height: 1.5; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; }

/* نافذة المخطط */
.plan { position: absolute; top: var(--top); left: var(--side); z-index: 3; width: 236px; border-radius: 14px; overflow: hidden; }
.plan-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: none; border: 0; padding: 10px 13px;
  font-size: 12px; font-weight: 600; color: var(--ink); }
.plan-head svg { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 2; transition: transform .25s; }
.plan.closed .plan-head svg { transform: rotate(180deg); }
.plan.closed .plan-body { display: none; }
.plan.closed { width: 128px; }
.plan-body { padding: 0 11px 11px; }
.plan-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.pl-slab { fill: rgba(29, 30, 33, 0.03); }
.pl-room rect { fill: #fff; stroke: rgba(29, 30, 33, 0.28); stroke-width: 0.05; cursor: pointer; transition: fill .2s; }
.pl-room:hover rect { fill: #f3eee5; }
.pl-room.active rect { fill: #efe5d3; }
.pl-room text, .pl-extra text { font-family: var(--f-body); font-size: 0.6px; fill: var(--ink); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.pl-extra rect { fill: rgba(29, 30, 33, 0.04); stroke: rgba(29, 30, 33, 0.18); stroke-width: 0.04; stroke-dasharray: 0.15 0.12; }
.pl-extra text { fill: var(--muted); font-size: 0.48px; }
.pl-walls { fill: none; stroke: var(--ink); stroke-width: 0.14; }
.pl-door { fill: #fff; stroke: var(--accent); stroke-width: 0.06; }
.pl-cone { fill: rgba(154, 120, 70, 0.30); stroke: rgba(154, 120, 70, 0.75); stroke-width: 0.04; pointer-events: none; }
.pl-cam { cursor: pointer; }
.pl-cam circle { fill: #b9b3a8; stroke: #fff; stroke-width: 0.07; }
.pl-cam .halo { fill: transparent; stroke: none; }
.pl-cam.active circle { fill: var(--accent); }
.pl-cam.active .halo { fill: rgba(154, 120, 70, 0.22); stroke: none; }
.pl-north path { fill: var(--muted); }
.pl-north text { fill: var(--muted); font-size: 0.45px; text-anchor: middle; font-family: var(--f-body); }

/* أزرار التحكم */
.controls { position: absolute; left: var(--side); bottom: var(--bottom); z-index: 3; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; }
.ctl { width: 42px; height: 42px; display: grid; place-items: center; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); transition: background .2s, color .2s; }
.ctl:last-child { border-bottom: 0; }
.ctl:hover { background: rgba(29, 30, 33, 0.06); }
.ctl.on { color: #fff; background: var(--ink); }
.ctl svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* نقاط الانتقال */
.hs { width: 52px; height: 52px; cursor: pointer; }
.hs-ring { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass-strong); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28); transition: transform .2s, background .2s; }
.hs-ring::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); animation: pulse 2.4s ease-out infinite; }
.hs-ring svg { width: 24px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hs:hover .hs-ring { transform: scale(1.08); background: #fff; }
.hs-label { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); white-space: nowrap; direction: rtl; font-size: 13px; font-weight: 600;
  background: var(--glass-strong); color: var(--ink); border-radius: 8px; padding: 4px 11px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

/* التلميح والتحميل والتنبيه */
.hint { position: absolute; left: 50%; bottom: var(--bottom); transform: translateX(-50%); z-index: 2; border-radius: 10px; padding: 8px 14px;
  font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 8px; white-space: nowrap; transition: opacity .5s; pointer-events: none; }
.hint svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 2; }
.hint.gone { opacity: 0; }
.loader { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(23, 23, 26, 0.45); opacity: 0; pointer-events: none; transition: opacity .3s; }
.loader.on { opacity: 1; pointer-events: auto; }
.loader-in { display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 14px; color: #fff; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; left: 50%; bottom: calc(var(--bottom) + 56px); transform: translateX(-50%); z-index: 6; width: min(440px, calc(100% - 32px));
  border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.6; text-align: center; color: var(--ink); }
.edit-panel { position: absolute; right: var(--side-r); bottom: var(--bottom); z-index: 3; border-radius: 12px; padding: 10px 12px; font-size: 12px; line-height: 1.7; }
.edit-panel strong { color: var(--accent); }
.edit-panel div { font-family: ui-monospace, Menlo, monospace; }

/* ---------- شريط الغرف العائم ---------- */
.rooms { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 5; display: flex; justify-content: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); pointer-events: none; }
.rooms-in { pointer-events: auto; display: flex; gap: 4px; max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 5px; border-radius: 14px;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.6); box-shadow: var(--shadow); }
.rooms-in::-webkit-scrollbar { display: none; }
.room-btn { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 10px;
  background: transparent; border: 0; font-size: 14px; font-weight: 500; color: var(--ink); transition: background .2s, color .2s; }
.room-btn .dot { width: 6px; height: 6px; border-radius: 50%; background: #c4bdb1; }
.room-btn:hover { background: rgba(29, 30, 33, 0.06); }
.room-btn.active { background: var(--ink); color: #fff; font-weight: 600; }
.room-btn.active .dot { background: var(--accent); }

/* وضع الشاشة الكاملة البديل (للآيفون) */
#app.immersive { --top: 14px; }
#app.immersive .topbar { display: none; }

@media (max-width: 640px) {
  :root { --top: 68px; --bottom: 76px; --side: max(10px, env(safe-area-inset-left, 0px)); --side-r: max(10px, env(safe-area-inset-right, 0px)); }
  .topbar-in { padding-block: 9px; }
  .brand { gap: 10px; }
  .brand-text { padding-inline-start: 10px; }
  .brand h1 { font-size: 15px; }
  .brand p { font-size: 11px; }
  .logo { width: 34px; height: 34px; border-radius: 9px; }
  .logo span { font-size: 16px; }
  .wa span { display: none; }
  .wa { padding: 9px; }
  .apt-select span { display: none; }
  .plan { width: 138px; }
  .plan.closed { width: 118px; }
  .scene-card { padding: 8px 12px 10px; max-width: calc(100% - 172px); }
  .scene-card h2 { font-size: 18px; }
  .demo-tag { font-size: 10px; }
  .ctl { width: 40px; height: 40px; }
  .hint { font-size: 12px; left: auto; right: var(--side-r); transform: none; }
  .hs { width: 48px; height: 48px; }
  .hs-label { top: 56px; font-size: 12px; }
  .room-btn { padding: 8px 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .hs-ring::after, .spinner { animation: none; }
  * { transition: none !important; }
}
