/* ============================================================
   Óc Eo Heritage - Viewer 3D
   ============================================================ */

html, body { height: 100%; overflow: hidden; }
body { background: #1a120c; }

#cesiumContainer { position: absolute; inset: 0; }
#cesiumContainer .cesium-viewer-bottom { display: none; }
.cesium-widget-credits { display: none !important; }

/* ---------- Thanh trên ---------- */
.v-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(26, 15, 8, .82) 0%, rgba(26, 15, 8, .45) 70%, transparent 100%);
  pointer-events: none;
}
.v-topbar > * { pointer-events: auto; }
.v-back {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(253, 250, 242, .12); backdrop-filter: blur(8px);
  border: 1px solid rgba(253, 250, 242, .18);
  color: var(--cream); font-size: 18px;
  transition: background .15s ease;
}
.v-back:hover { background: rgba(180, 85, 45, .55); }
.v-title { color: var(--cream); min-width: 0; }
.v-title h1 {
  font-family: var(--font-heading); font-size: 19px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.v-title small { font-size: 11.5px; color: var(--gold-soft); letter-spacing: .1em; text-transform: uppercase; }
.v-spacer { flex: 1; }
.v-actions { display: flex; gap: 8px; }
.v-btn {
  height: 40px; min-width: 40px; padding: 0 12px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(253, 250, 242, .12); backdrop-filter: blur(8px);
  border: 1px solid rgba(253, 250, 242, .18);
  color: var(--cream); font-size: 15px;
  transition: background .15s ease;
}
.v-btn:hover, .v-btn.active { background: rgba(180, 85, 45, .55); }
.v-btn select {
  background: transparent; border: none; color: var(--cream);
  font-family: inherit; font-size: 13.5px; outline: none; cursor: pointer;
}
.v-btn select option { color: var(--ink); }

/* ---------- Panel thông tin ---------- */
.v-panel {
  position: absolute; top: 66px; right: 14px; bottom: 14px; z-index: 15;
  width: 340px; max-width: calc(100vw - 28px);
  background: rgba(253, 250, 242, .96); backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateX(calc(100% + 20px));
  transition: transform .28s ease;
}
.v-panel.open { transform: translateX(0); }
.v-panel-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--sand-dark);
  background: linear-gradient(135deg, rgba(180,85,45,.08), rgba(201,151,47,.08));
}
.v-panel-head h2 { font-family: var(--font-heading); font-size: 21px; color: var(--clay-deep); }
.v-panel-head .sub { font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.v-panel-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.v-panel-body::-webkit-scrollbar { width: 8px; }
.v-panel-body::-webkit-scrollbar-thumb { background: var(--sand-dark); border-radius: 4px; }
.v-desc { font-size: 13.8px; color: var(--ink-soft); margin-bottom: 18px; white-space: pre-line; }

.v-group { margin-bottom: 18px; }
.v-group h3 {
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--clay); margin-bottom: 10px; font-family: var(--font-body); font-weight: 700;
}
.v-check {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--white); border: 1px solid var(--sand-dark);
  margin-bottom: 7px; font-size: 13.5px; cursor: pointer;
  transition: border-color .15s ease;
}
.v-check:hover { border-color: var(--clay-light); }
.v-check input { accent-color: var(--clay); width: 16px; height: 16px; }

.v-spot {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--white); border: 1px solid var(--sand-dark);
  margin-bottom: 7px; cursor: pointer; width: 100%; text-align: left;
  transition: transform .12s ease, border-color .15s ease;
}
.v-spot:hover { border-color: var(--clay-light); transform: translateX(3px); }
.v-spot .ic {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.v-spot b { font-size: 13.5px; color: var(--ink); display: block; line-height: 1.3; }
.v-spot small { font-size: 11.5px; color: var(--ink-faint); }

/* ---------- Loading ---------- */
.v-loading {
  position: absolute; inset: 0; z-index: 50;
  background: linear-gradient(160deg, #33200f, #5f2a14);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  color: var(--cream); transition: opacity .5s ease;
}
.v-loading.hide { opacity: 0; pointer-events: none; }
.v-loading .mark {
  width: 74px; height: 74px; border-radius: 20px;
  background: linear-gradient(135deg, var(--clay), var(--gold));
  display: grid; place-items: center;
  font-family: var(--font-heading); font-size: 38px; font-weight: 700;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.v-loading p { font-size: 14px; color: rgba(253,250,242,.8); }
.v-loading .bar { width: 190px; height: 4px; border-radius: 2px; background: rgba(253,250,242,.18); overflow: hidden; }
.v-loading .bar i { display: block; height: 100%; width: 40%; border-radius: 2px; background: var(--gold-soft); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%);} 100% { transform: translateX(350%);} }

/* ---------- Chế độ pick (admin) ---------- */
body.picking #cesiumContainer { cursor: crosshair !important; }
.v-pick-hint {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--clay-deep); color: var(--cream);
  padding: 10px 22px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow-lift); display: none;
}
body.picking .v-pick-hint { display: block; }

/* ---------- Modal media ---------- */
.m-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 12, 6, .88); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.m-overlay.open { display: flex; }
.m-box {
  position: relative;
  width: min(1060px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  background: var(--cream); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  animation: mIn .22s ease;
}
@keyframes mIn { from { transform: translateY(16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.m-box.dark { background: #17100a; }
.m-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sand-dark);
  background: linear-gradient(135deg, rgba(180,85,45,.07), rgba(201,151,47,.07));
}
.m-box.dark .m-head { border-color: rgba(253,250,242,.1); background: rgba(253,250,242,.04); }
.m-head .ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.m-head h3 { font-family: var(--font-heading); font-size: 18px; color: var(--clay-deep); flex: 1; min-width: 0; }
.m-box.dark .m-head h3 { color: var(--gold-soft); }
.m-close {
  width: 36px; height: 36px; border-radius: 10px; border: none;
  background: rgba(59,42,31,.08); color: var(--ink); font-size: 17px;
}
.m-box.dark .m-close { background: rgba(253,250,242,.1); color: var(--cream); }
.m-close:hover { background: var(--clay); color: #fff; }
.m-body { flex: 1; overflow: auto; min-height: 0; }
.m-body.center { display: flex; align-items: center; justify-content: center; }
.m-media-frame { width: 100%; height: min(62vh, 600px); background: #000; }
.m-desc { padding: 14px 18px; font-size: 13.5px; color: var(--ink-soft); border-top: 1px solid var(--sand-dark); white-space: pre-line; }
.m-box.dark .m-desc { color: rgba(253,250,242,.7); border-color: rgba(253,250,242,.1); }

/* Gallery */
.g-main { position: relative; background: #000; height: min(58vh, 560px); display: flex; align-items: center; justify-content: center; }
.g-main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.g-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(253,250,242,.15); color: #fff; font-size: 19px;
  backdrop-filter: blur(4px);
}
.g-nav:hover { background: var(--clay); }
.g-prev { left: 14px; } .g-next { right: 14px; }
.g-count { position: absolute; bottom: 12px; right: 16px; color: rgba(255,255,255,.8); font-size: 12.5px; background: rgba(0,0,0,.45); padding: 4px 12px; border-radius: 999px; }
.g-thumbs { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; background: #17100a; }
.g-thumbs img {
  width: 74px; height: 52px; object-fit: cover; border-radius: 6px;
  opacity: .55; cursor: pointer; border: 2px solid transparent; flex: 0 0 auto;
  transition: opacity .15s ease;
}
.g-thumbs img.on { opacity: 1; border-color: var(--gold); }

/* Audio */
.audio-wrap { padding: 34px 30px; text-align: center; }
.audio-art {
  width: 110px; height: 110px; margin: 0 auto 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--clay), var(--gold));
  display: grid; place-items: center; font-size: 44px; color: var(--cream);
  animation: spinSlow 14s linear infinite;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }
.audio-wrap audio { width: 100%; max-width: 440px; }

/* Panorama & model3d container */
#panoContainer, #threeContainer { width: 100%; height: min(68vh, 640px); background: #000; }

/* Info html */
.info-content { padding: 22px 26px; font-size: 14.5px; color: var(--ink); }
.info-content img { border-radius: var(--radius-sm); margin: 12px 0; }
.info-content h1, .info-content h2, .info-content h3 { font-family: var(--font-heading); color: var(--clay-deep); margin: 14px 0 8px; }

/* ---------- Embed mode ---------- */
body.embed .v-topbar, body.embed .v-panel, body.embed .v-panel-toggle { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .v-topbar { padding: 8px 10px; gap: 8px; }
  .v-title h1 { font-size: 16px; }
  .v-title small { display: none; }
  .v-btn { height: 38px; min-width: 38px; padding: 0 9px; font-size: 14px; }
  .v-back { width: 38px; height: 38px; }

  .v-panel {
    top: auto; right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%;
    max-height: 62vh; border-radius: 18px 18px 0 0;
    transform: translateY(105%);
  }
  .v-panel.open { transform: translateY(0); }
  .v-panel-head { padding-top: 12px; }
  .v-panel-head::before {
    content: ''; display: block; width: 44px; height: 4px; border-radius: 2px;
    background: var(--sand-dark); margin: 0 auto 10px;
  }
  .m-box { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .m-media-frame, .g-main, #panoContainer, #threeContainer { height: 52vh; }
}
