/* Giao diện theo vtourskin của bản gốc (skin_settings trong tour.xml). */
:root {
  --primary: #1f7a57;                   /* màu chủ đạo — đổi trong /admin */
  --accent: #c99a3e;
  --bg: rgba(45, 62, 80, 0.8);         /* design_bgcolor 0x2D3E50, design_bgalpha 0.8 */
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.3); /* design_bgshadow */
  --opt-bg: rgba(7, 65, 76, 0.7);       /* option.xml 0x07414c */
  --opt-active: rgba(174, 170, 6, 0.85);/* 0xAEAA06 */
  --tip-bg: rgba(4, 147, 241, 0.75);    /* showtext Target 0x0493f1 */
  --text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: #000; color: #fff;
  font: 16px/1.3 Arial, Helvetica, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

#pano { position: fixed; inset: 0; }
.pano-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.pano-canvas:active { cursor: grabbing; }

/* ---------- icon từ sprite vtourskin.png (ô 64px, hiển thị scale 0.5) ---------- */
.ico {
  display: block; width: 32px; height: 32px; position: relative;
  background: url(../assets/skin/vtourskin.png) no-repeat; background-size: 64px 384px;
}
.ico-vr { width: 40px; background-position: 0 0; }
.ico-prev { background-position: 0 -32px; }      .ico-next { background-position: -32px -32px; }
.ico-thumbs { background-position: 0 -64px; }
.ico-left { background-position: 0 -96px; }      .ico-right { background-position: -32px -96px; }
.ico-up { background-position: 0 -128px; }       .ico-down { background-position: -32px -128px; }
.ico-in { background-position: 0 -160px; }       .ico-out { background-position: -32px -160px; }
.ico-gyro { background-position: 0 -192px; }
.ico-hide { background-position: 0 -224px; }     .ico-show { background-position: -32px -224px; }
.ico-fs { background-position: 0 -288px; }       .ico-fsexit { background-position: -32px -288px; }
.ico-play { background-position: 0 -320px; }     .ico-pause { background-position: -32px -320px; }
.ico-sound { background-position: -32px -352px; }

/* skin_glow: quầng sáng (ô 64|384) phía sau nút khi rê chuột / đang bật */
.btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; }
.btn::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px;
  background: url(../assets/skin/vtourskin.png) -32px -192px / 64px 384px no-repeat; opacity: 0; transition: opacity 0.2s;
}
.btn:hover::before, .btn[aria-pressed="true"]::before { opacity: 0.6; }
.btn.dim { opacity: 0.5; }
.btn.dim:hover { opacity: 1; }
.btn .ico { z-index: 1; }

/* ---------- tiêu đề cảnh (layer name_image, giữa trên) ---------- */
#scene-title {
  position: fixed; top: 15px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 5px 10px; font-size: 14px; text-align: center; pointer-events: none; text-shadow: var(--text-shadow);
}

/* ---------- option.xml: Ngày / Đêm / Hiện trạng + "Hình ảnh minh họa" ---------- */
#options { position: fixed; right: 15px; bottom: 15px; display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; }
#options .list { width: 100px; text-align: center; }
#options .list { background: var(--opt-bg); }
#options .list button { display: block; width: 100%; padding: 5px 10px; }
#options .list button.active { background: var(--opt-active); }
#options .list button:hover:not(.active) { background: rgba(255, 255, 255, 0.12); }
#options .caption { padding: 5px 0; white-space: nowrap; text-shadow: var(--text-shadow); }
#options .caption:empty { display: none; }
@media (max-width: 600px) { #options { bottom: 85px; } }
@media (max-width: 400px) { #options { bottom: 110px; } }

/* ---------- mũi tên hai bên khi thanh điều khiển ẩn (skin_btn_prev_fs / next_fs) ---------- */
.side {
  position: fixed; top: 0; bottom: 0; width: 40px; display: grid; place-items: center;
  opacity: 0.25; transition: opacity 0.3s, transform 0.5s;
}
.side:hover { opacity: 1; }
#side-prev { left: 0; }
#side-next { right: 0; }
body:not(.skin-closed) #side-prev { transform: translateX(-50px); }
body:not(.skin-closed) #side-next { transform: translateX(50px); }

/* ---------- thanh điều khiển + thumbnail (skin_scroll_window / skin_control_bar) ---------- */
#skin {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 814px; transition: transform 0.5s ease-out;
}
#skin.closed { transform: translate(-50%, calc(100% + 60px)); }
#panel { position: relative; background: var(--bg); border-radius: 1px; box-shadow: var(--shadow); }
#skin-title {
  position: absolute; left: 4px; bottom: 100%; padding-bottom: 2px;
  font-size: 12px; font-style: italic; white-space: nowrap; text-shadow: var(--text-shadow); pointer-events: none;
}
#thumbs {
  display: flex; gap: 10px; padding: 10px; overflow-x: auto; scrollbar-width: none; cursor: grab;
}
#thumbs::-webkit-scrollbar { display: none; }
.thumb { flex: 0 0 auto; width: 120px; height: 80px; position: relative; outline: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb::after { content: ''; position: absolute; inset: -5px; border: 3px solid #fff; opacity: 0; }   /* thumbborder 3px, padding 2 */
.thumb.active::after, .thumb:hover::after, .thumb:focus-visible::after { opacity: 1; }

#bar { position: relative; height: 40px; display: flex; align-items: center; }
#bar .group { display: flex; align-items: center; }
#bar .left { position: absolute; left: 5px; }
#bar .right { position: absolute; right: 5px; flex-direction: row-reverse; }
#bar .center { margin: 0 auto; }
/* show_dirbuttons: chỉ khi khung đủ rộng (> 520px) */
@media (max-width: 560px) { #bar .navi { display: none; } }

#skin-show {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 814px; height: 40px;
  display: grid; place-items: end center; padding-bottom: 2px; opacity: 0.25; transition: opacity 0.3s;
}
#skin-show:hover { opacity: 1; }
body:not(.skin-closed) #skin-show { display: none; }

/* ---------- loading / tooltip / info ---------- */
#loading {
  position: fixed; left: 50%; top: 50%; transform: translate(calc(-50% + 5px), calc(-50% - 5px));
  font-size: 22px; font-style: italic; text-shadow: var(--text-shadow); pointer-events: none;
}

#tip {
  position: fixed; left: 0; top: 0; pointer-events: none; z-index: 5;
  background: var(--tip-bg); border: 1px solid rgba(255, 255, 255, 0.8); padding: 2px; text-align: center;
  transform: translate(-50%, calc(-100% - 10px));
}
#tip img { display: block; width: 220px; height: 120px; object-fit: cover; }
#tip p { margin: 2px 0 0; font-size: 16px; }

#info { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 16px; z-index: 6; }
#info .card { position: relative; width: min(360px, 100%); background: var(--tip-bg); border: 1px solid rgba(255,255,255,0.8); padding: 10px; user-select: text; }
#info img { width: 100%; display: block; margin-bottom: 8px; }
#info h3 { margin: 0 0 6px; font-size: 18px; }
#info p { margin: 0; font-size: 14px; }
#info .close { position: absolute; top: 2px; right: 8px; font-size: 24px; line-height: 1; }

#toast {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%); max-width: calc(100% - 32px); z-index: 7;
  padding: 8px 14px; background: rgba(0, 0, 0, 0.75); font-size: 14px; word-break: break-word;
}

/* ---------- VR ---------- */
body.vr .ui, body.vr #tip { display: none !important; }
#vr-ui { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#vr-exit {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); pointer-events: auto;
  padding: 6px 14px; background: var(--bg); border: 1px solid rgba(255,255,255,0.6); font-size: 14px;
}
#vr-ui::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: rgba(255,255,255,0.35); }
#vr-rotate {
  display: none; position: absolute; inset: 0; place-items: center; text-align: center; padding: 24px;
  background: rgba(0, 0, 0, 0.8); font-size: 18px;
}
@media (orientation: portrait) { body.vr-cardboard #vr-rotate { display: grid; } }

#classic-menu {
  position: fixed; top: 10px; left: 10px; width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--bg); border-radius: 4px; box-shadow: var(--shadow);
}

/* ---------- nhãn + vùng đa giác trên ảnh 360 ---------- */
.tour-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tour-polys { position: absolute; inset: 0; width: 100%; height: 100%; }
.tour-polys g { pointer-events: auto; cursor: pointer; }
.tour-polys polygon { transition: fill-opacity 0.2s; }
.tour-polys g:hover polygon { fill-opacity: 0.6; }
.tour-polys text {
  fill: #fff; font: bold 14px Arial, sans-serif; text-anchor: middle; dominant-baseline: middle;
  paint-order: stroke; stroke: rgba(0, 0, 0, 0.6); stroke-width: 3px; pointer-events: none;
}
.tour-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: bold; color: #fff;
  background: color-mix(in srgb, var(--primary) 88%, transparent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ---------- hộp thoại / lightbox ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 16px; }
.sheet-card {
  width: min(560px, 100%); max-height: min(86vh, 100%); display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: #1d2a24; border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); user-select: text;
}
#sheet.wide .sheet-card { width: min(1000px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid #e8ece9; }
.sheet-title { flex: 1; margin: 0; font-size: 18px; color: var(--primary); }
.sheet-close { font-size: 28px; line-height: 1; color: #667; width: 36px; height: 36px; border-radius: 50%; }
.sheet-close:hover { background: #f0f2f1; }
.sheet-body { padding: 16px 18px; overflow: auto; font-size: 15px; line-height: 1.55; }
.sheet-body p { margin: 0 0 10px; }
.sheet-body h3 { margin: 18px 0 8px; color: var(--primary); }
.muted { color: #7a857f; }
.full { width: 100%; display: block; border-radius: 8px; cursor: zoom-in; }
.strip, .hero { display: flex; gap: 8px; overflow-x: auto; margin: 8px 0; scroll-snap-type: x mandatory; }
.strip img { height: 140px; border-radius: 8px; cursor: zoom-in; scroll-snap-align: start; }
.hero img { height: min(48vh, 360px); border-radius: 10px; cursor: zoom-in; scroll-snap-align: start; }
.video { position: relative; padding-top: 56.25%; margin: 8px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.media-block video { width: 100%; border-radius: 8px; }
.btn-link, .btn-primary {
  display: inline-block; margin-top: 8px; padding: 8px 16px; border-radius: 20px; font-weight: bold; text-decoration: none;
  background: var(--primary); color: #fff;
}
.amenity-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.amenity-head img { width: 44px; height: 44px; }
.chip { padding: 2px 10px; border-radius: 10px; background: #eef4f0; color: var(--primary); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { padding: 10px 12px; border-radius: 10px; background: #f4f7f5; }
.stat b { display: block; font-size: 18px; color: var(--primary); }
.stat span { font-size: 13px; color: #66716b; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0 10px; }
.tabs button { padding: 6px 12px; border-radius: 16px; background: #eef2ef; color: #33413a; white-space: nowrap; }
.tabs button.active { background: var(--primary); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; gap: 6px; text-align: left; color: #22302a; }
.card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; background: #e9eeeb; }
.card-icon { aspect-ratio: 3 / 2; display: grid; place-items: center; background: #f2f5f3; border-radius: 8px; }
.card-icon img { width: 56px; height: 56px; aspect-ratio: auto; background: none; }
.card span { font-weight: bold; font-size: 14px; }
.docs { margin: 0; padding-left: 20px; }
.docs a { color: var(--primary); }
.units .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.units input, .units select { padding: 7px 10px; border: 1px solid #d5ddd8; border-radius: 8px; font: inherit; font-size: 14px; }
.units input { flex: 1 1 180px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; }
.status::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.table-wrap { overflow: auto; max-height: 56vh; border: 1px solid #e3e8e5; border-radius: 8px; }
.units table { width: 100%; border-collapse: collapse; font-size: 14px; }
.units th { position: sticky; top: 0; background: #f4f7f5; text-align: left; }
.units th, .units td { padding: 7px 10px; border-bottom: 1px solid #edf0ee; white-space: nowrap; }
.units tr.link { cursor: pointer; }
.units tr.link:hover td { background: #f6faf7; }

#lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.92); display: grid; place-items: center; }
#lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; }
#lightbox button { position: absolute; color: #fff; font-size: 44px; width: 56px; height: 56px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-close { top: 8px; right: 8px; }
.lb-count { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 14px; }

/* ---------- bố cục hub (giống VHUB) ---------- */
#hub { position: fixed; inset: 0; pointer-events: none; }
#hub > * { pointer-events: auto; }
.ibtn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, 0.94); color: var(--primary); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.ibtn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.ibtn:hover, .ibtn.on { background: var(--accent); color: #fff; }
.ibtn.round { background: var(--accent); color: #fff; }
.ibtn.zalo { color: #0068ff; }
.hub-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.hub-top > * { pointer-events: auto; }
.hub-logo { height: 40px; border-radius: 6px; }
.hub-search { position: relative; flex: 0 1 480px; margin: 0 auto; }
.hub-search input {
  width: 100%; box-sizing: border-box; height: 44px; padding: 0 16px 0 42px; border: 0; border-radius: 22px;
  background: rgba(255, 255, 255, 0.96); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); font: inherit; font-size: 15px; color: #222;
}
.hub-search .sicon { position: absolute; left: 14px; top: 11px; width: 22px; height: 22px; color: #667; }
.hub-search .sicon svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.search-results {
  position: absolute; top: 50px; left: 0; right: 0; max-height: 50vh; overflow: auto;
  background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.search-results button { display: block; width: 100%; text-align: left; padding: 9px 14px; color: #222; border-bottom: 1px solid #eef1ef; }
.search-results button:hover { background: #f4f8f5; }
.search-results small { display: block; font-size: 11px; color: var(--accent); text-transform: uppercase; }
.hub-title { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); font-size: 14px; text-shadow: var(--text-shadow); pointer-events: none; white-space: nowrap; }
.hub-tools { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }
.hub-side { position: absolute; right: 70px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.pill, .compare {
  display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.95); color: #333; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.pill button { padding: 7px 14px; border-radius: 18px; font-size: 14px; color: #444; }
.pill button.active { background: var(--accent); color: #fff; font-weight: bold; }
.compare { padding: 8px 14px; gap: 10px; font-size: 14px; }
.compare input { width: 120px; accent-color: var(--accent); }
.hub-layers {
  position: absolute; left: 12px; top: 72px; width: 170px; max-height: 40vh; overflow: auto; padding: 8px 10px;
  background: rgba(255, 255, 255, 0.95); color: #333; border-radius: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); font-size: 14px;
}
.layers-head, .layer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 10px; background: #ccd3cf; transition: background 0.2s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.minimap {
  position: absolute; left: 12px; bottom: 12px; width: 230px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); background: #fff; transition: width 0.3s;
}
.minimap > img { display: block; width: 100%; }
.minimap.collapsed { width: 44px; height: 44px; }
.minimap.collapsed > img, .minimap.collapsed .mm-dots { display: none; }
.mm-toggle { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,0.45); display: grid; place-items: center; }
.minimap.collapsed .mm-toggle { inset: 6px; right: auto; background: none; color: var(--primary); }
.mm-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }
.mm-dots { position: absolute; inset: 0; }
.mm-dot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #f5b800; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.mm-dot.active { background: #e53935; z-index: 1; }
.mm-radar {
  position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; pointer-events: none;
  background: conic-gradient(from -30deg, rgba(229, 57, 53, 0.45) 0 60deg, transparent 60deg); border-radius: 50%;
}
.hub-dock {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px);
  display: flex; gap: 2px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none;
  background: rgba(255, 255, 255, 0.96); border-radius: 30px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.hub-dock button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; padding: 6px 8px; border-radius: 22px;
  color: #3b4842; font-size: 12px; font-weight: bold; white-space: nowrap;
}
.hub-dock svg, .drawer-sections svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.hub-dock button:hover { color: var(--primary); }
.hub-dock button.active { background: var(--accent); color: #fff; }
.hub-caption { position: absolute; right: 15px; bottom: 84px; font-size: 13px; text-shadow: var(--text-shadow); pointer-events: none; }
.no-dock .hub-caption { bottom: 15px; }
.drawer-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.drawer-sections button { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: #f2f5f3; color: var(--primary); font-weight: bold; font-size: 14px; }
.drawer-body h4 { margin: 12px 0 6px; color: #66716b; font-size: 13px; text-transform: uppercase; }
.drawer-scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.drawer-scenes button { text-align: left; color: #22302a; font-size: 13px; font-weight: bold; }
.drawer-scenes img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; border: 3px solid transparent; box-sizing: border-box; }
.drawer-scenes button.active img { border-color: var(--accent); }
@media (max-width: 640px) {
  .hub-side { right: 12px; top: 96px; transform: none; }
  .hub-title { top: 62px; }
  .hub-layers { top: auto; bottom: 250px; }
  .hub-tools .ibtn { width: 40px; height: 40px; }
  .minimap { width: 150px; bottom: 84px; }
  .hub-layers { width: 140px; }
  .hub-dock button { min-width: 62px; padding: 6px 4px; font-size: 11px; }
  .hub-caption { bottom: 84px; }
}
