/* =====================================================================
 * style.css – Giao diện web VR360 Point One Phú Diễn
 * Bố cục: thanh xanh trên cùng → ảnh 360 toàn màn hình → thanh liên hệ dưới
 * ===================================================================== */

:root {
  --blue: #0b4fa8;
  --blue-2: #1273de;
  --orange: #ff9f1c;
  --ink: #0f1c2e;
  --white: #fff;
  --head-h: 56px;     /* chiều cao thanh xanh */
  --foot-h: 56px;     /* chiều cao thanh liên hệ */
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a1626; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }

/* ---------------------------------------------------------------------
 * 1. Ảnh 360 và các lớp phủ
 * ------------------------------------------------------------------- */
#pano, #routes { position: absolute; inset: 0; width: 100%; height: 100%; }
#pano { touch-action: none; cursor: grab; }
#pano:active { cursor: grabbing; }
body.admin-pick #pano { cursor: crosshair; }
#routes { pointer-events: none; }

#pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* Tàu metro */
#train, .train-sprite {
  position: absolute; left: 0; top: 0;
  pointer-events: none; display: none;
  transform-origin: center;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.45));
  will-change: transform;
}

/* ---------------------------------------------------------------------
 * 2. Ghim
 * ------------------------------------------------------------------- */
.pin {
  position: absolute; left: 0; top: 0;
  pointer-events: auto;
  background: none; border: 0; padding: 0 0 7px; /* 7px = phần mũi nhọn của giọt nước */
  will-change: transform;
}
/* Hình giọt nước: vuông bo góc, xoay -45° cho mũi nhọn chỉ xuống */
.pin-dot {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--blue-2); border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
}
.pin-ico { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.pin-label {
  display: none; position: absolute; left: 50%; top: 100%; margin-top: 2px;
  transform: translateX(-50%);
  background: rgba(10,22,38,.82); color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.pin.show-label .pin-label, .pin:hover .pin-label { display: block; }

.pin-project { padding-bottom: 10px; }
.pin-project .pin-dot {
  width: 44px; height: 44px; background: #e53935;
  animation: pulse 1.8s infinite;
}
.pin-project .pin-ico { font-size: 22px; }
.pin-project .pin-label { background: #e53935; font-size: 13px; }
.pin.selected .pin-dot { outline: 3px solid var(--orange); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(229,57,53,.6), 0 3px 8px rgba(0,0,0,.45); }
  70%  { box-shadow: 0 0 0 16px rgba(229,57,53,0), 0 3px 8px rgba(0,0,0,.45); }
  100% { box-shadow: 0 0 0 0 rgba(229,57,53,0), 0 3px 8px rgba(0,0,0,.45); }
}

/* ---------------------------------------------------------------------
 * 3. Thanh xanh trên cùng
 * ------------------------------------------------------------------- */
#top {
  position: absolute; left: 0; right: 0; top: 0; min-height: var(--head-h);
  background: linear-gradient(90deg, var(--blue), var(--blue-2));
  color: #fff; display: flex; align-items: center; gap: 20px;
  padding: 6px 16px; box-shadow: 0 2px 10px rgba(0,0,0,.35); z-index: 5;
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .5px; }
.brand p { margin: 1px 0 0; font-size: 12px; opacity: .85; }
#tabs { margin-left: auto; display: flex; gap: 4px; overflow-x: auto; }
#tabs button {
  background: transparent; color: #fff; border: 0; padding: 8px 14px;
  border-radius: 999px; font-weight: 600; font-size: 14px; white-space: nowrap;
}
#tabs button.on { background: rgba(255,255,255,.22); }
#tabs button:hover { background: rgba(255,255,255,.16); }

/* Nút chọn nhanh góc nhìn */
#views {
  position: absolute; left: 12px; top: calc(var(--head-h) + 12px);
  display: flex; flex-wrap: wrap; gap: 6px; z-index: 4; max-width: calc(100% - 90px);
}
#views button {
  background: rgba(255,255,255,.92); border: 0; border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
#views button.on { background: var(--orange); }

/* ---------------------------------------------------------------------
 * 4. Công cụ, bảng lớp, thẻ thông tin
 * ------------------------------------------------------------------- */
#tools {
  position: absolute; right: 12px; top: calc(var(--head-h) + 12px);
  display: flex; flex-direction: column; gap: 8px; z-index: 4;
}
#tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 0; font-size: 18px;
  background: rgba(255,255,255,.94); box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

#layers {
  position: absolute; right: 62px; top: calc(var(--head-h) + 12px); z-index: 6;
  background: #fff; border-radius: var(--radius); padding: 12px 14px; min-width: 230px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
#layers h3 { margin: 0 0 8px; font-size: 14px; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; cursor: pointer; }
.layer-row input { width: 18px; height: 18px; accent-color: var(--blue-2); }

#info {
  position: absolute; left: 12px; bottom: calc(var(--foot-h) + 54px); z-index: 4;
  width: min(360px, calc(100% - 24px)); max-height: 46vh; overflow: auto;
  background: #fff; border-radius: var(--radius); padding: 14px 16px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
#info h3 { margin: 0 24px 6px 0; font-size: 17px; }
#info p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; }
#info img { width: 100%; border-radius: 8px; margin-top: 8px; cursor: zoom-in; }
.info-close {
  position: absolute; right: 8px; top: 6px; border: 0; background: none;
  font-size: 24px; line-height: 1; color: #667;
}
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; color: #8a5a00;
  background: #ffe9b8; padding: 2px 8px; border-radius: 999px;
}
.info-actions { margin-top: 12px; }

#disclaimer {
  position: absolute; left: 0; right: 0; bottom: calc(var(--foot-h) + 6px); z-index: 3;
  margin: 0; padding: 4px 14px; text-align: center; font-size: 11px; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.9); pointer-events: none;
}

/* ---------------------------------------------------------------------
 * 5. Thanh liên hệ dưới cùng
 * ------------------------------------------------------------------- */
#contact {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--foot-h); z-index: 5;
  display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10,22,38,.88); backdrop-filter: blur(6px);
}
.c-btn {
  flex: 1; max-width: 220px; text-align: center; text-decoration: none; border: 0;
  padding: 10px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; color: #fff;
  white-space: nowrap;
}
.c-quote { background: #e53935; }
.c-zalo  { background: #0068ff; }
.c-call  { background: #1fa34a; }
.c-mess  { background: #7b3fe4; }

#adminLink {
  position: absolute; left: 8px; bottom: calc(var(--foot-h) + 28px); z-index: 2;
  background: none; border: 0; color: rgba(255,255,255,.45); font-size: 11px;
}

/* ---------------------------------------------------------------------
 * 6. Nút chung, cửa sổ nổi, form
 * ------------------------------------------------------------------- */
.btn-primary {
  background: var(--blue-2); color: #fff; border: 0; border-radius: 999px;
  padding: 11px 22px; font-weight: 700; font-size: 15px;
}
.btn-primary:disabled { opacity: .6; }

.modal {
  position: absolute; inset: 0; z-index: 20; background: rgba(5,12,22,.6);
  display: grid; place-items: center; padding: 14px;
}
.modal.dark { background: rgba(0,0,0,.9); }
.modal-box {
  position: relative; background: #fff; border-radius: 16px; padding: 22px 22px 24px;
  width: min(420px, 100%); max-height: 90vh; overflow: auto;
}
.modal-box.wide { width: min(900px, 100%); }
.modal-box h2 { margin: 0 0 4px; font-size: 20px; }
.muted { margin: 0 0 14px; color: #5b6b80; font-size: 14px; }
.modal-close {
  position: absolute; right: 10px; top: 6px; border: 0; background: none;
  font-size: 28px; line-height: 1; color: #667;
}
.modal.dark .modal-close { color: #fff; z-index: 2; }
#lightboxImg { max-width: 96vw; max-height: 92vh; border-radius: 6px; }

#quoteForm label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
#quoteForm input, #quoteForm textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid #c8d3e0; border-radius: 10px; font-weight: 400; font-size: 15px;
}
#quoteForm input:focus, #quoteForm textarea:focus { outline: 2px solid var(--blue-2); border-color: transparent; }
#quoteForm .btn-primary { width: 100%; }
.form-msg { min-height: 18px; margin: 0 0 10px; font-size: 13px; }
.form-msg.err { color: #c62828; }
.form-msg.ok { color: #1b7f3b; }

#galleryGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
#galleryGrid figure { margin: 0; }
#galleryGrid img { width: 100%; border-radius: 8px; cursor: zoom-in; display: block; }
#galleryGrid figcaption { font-size: 13px; text-align: center; margin-top: 4px; }

/* ---------------------------------------------------------------------
 * 7. Màn hình chờ + hướng dẫn + thông báo
 * ------------------------------------------------------------------- */
#loading {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #12335e, #07101d);
  color: #fff; transition: opacity .5s;
}
#loading.hide { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; width: min(320px, 80%); }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2); border-top-color: var(--orange);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadText { margin: 0 0 12px; font-size: 14px; letter-spacing: 1px; }
.bar { height: 5px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--orange); transition: width .2s; }

#intro {
  position: absolute; inset: 0; z-index: 25; display: grid; place-items: center;
  background: rgba(5,12,22,.62); padding: 16px;
}
.intro-box {
  background: #fff; border-radius: 18px; padding: 26px 24px; width: min(420px, 100%); text-align: center;
}
.intro-box h2 { margin: 0 0 10px; }
.intro-box p { margin: 0 0 18px; font-size: 14px; line-height: 1.6; color: #44546a; }

#toast {
  position: absolute; left: 50%; bottom: calc(var(--foot-h) + 70px); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .3s;
  background: rgba(10,22,38,.92); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------------
 * 8. Bảng quản trị
 * ------------------------------------------------------------------- */
#admin {
  position: absolute; right: 0; top: var(--head-h); bottom: var(--foot-h); width: min(320px, 92vw);
  z-index: 15; background: #fff; overflow: auto; padding: 12px 14px 20px;
  box-shadow: -4px 0 18px rgba(0,0,0,.35); font-size: 13px;
}
#admin .ad-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
#admin .ad-head button { border: 0; background: none; font-size: 26px; line-height: 1; }
#admin section { border-top: 1px solid #e3e9f1; margin-top: 12px; padding-top: 10px; }
#admin h4 { margin: 0 0 8px; font-size: 13px; }
#admin label { display: block; font-weight: 600; margin-bottom: 8px; }
#admin label.inline { display: flex; gap: 6px; align-items: center; font-weight: 500; }
#admin input[type=text], #admin input[type=tel], #admin input[type=url], #admin select, #admin textarea {
  display: block; width: 100%; margin-top: 3px; padding: 7px 9px; border: 1px solid #c8d3e0; border-radius: 8px;
}
#admin input[type=range] { width: 100%; }
#admin button:not(.ad-head button) {
  padding: 7px 12px; border-radius: 8px; border: 1px solid #b9c6d8; background: #f2f6fb; margin: 2px 4px 2px 0;
}
#admin button.primary { background: var(--blue-2); color: #fff; border-color: var(--blue-2); }
#admin button.danger { color: #c62828; border-color: #e7b3b3; }
#admin .row { display: flex; flex-wrap: wrap; }
#admin .hint { color: #5b6b80; margin: 6px 0 0; line-height: 1.45; }
#admin code { background: #eef2f7; padding: 1px 4px; border-radius: 4px; }

/* ---------------------------------------------------------------------
 * 9. Điện thoại
 * ------------------------------------------------------------------- */
@media (max-width: 700px) {
  :root { --head-h: 92px; --foot-h: 58px; }
  #top { flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px 4px; }
  .brand h1 { font-size: 15px; }
  #tabs { margin-left: -8px; width: 100%; }
  #tabs button { padding: 6px 12px; font-size: 13px; }
  #views button { padding: 6px 11px; font-size: 12px; }
  .c-btn { padding: 10px 6px; font-size: 13px; }
  #layers { right: 12px; top: calc(var(--head-h) + 12px + 190px); }
  #disclaimer { font-size: 10px; }
}

/* Nút kéo thả các điểm tuyến trong chế độ Admin */
#routeHandles { position:absolute; inset:0; z-index:8; pointer-events:none; overflow:hidden; }
.route-handle {
  position:absolute; left:0; top:0; width:26px; height:26px;
  display:grid; place-items:center; padding:0; margin:0;
  border:2px solid #fff; border-radius:50%; background:#00bfe8;
  color:#062b3a; font-size:11px; font-weight:800;
  box-shadow:0 1px 7px rgba(0,0,0,.65); cursor:grab;
  pointer-events:auto; touch-action:none; user-select:none;
}
.route-handle:active { cursor:grabbing; background:#ffcc00; transform-origin:center; }
body.admin-pick #routeHandles { pointer-events:none; }
body.admin-pick #routeHandles .route-handle { pointer-events:auto; }
