/* ==========================================================================
   GIS Map Modal Styles (from Index.cshtml)
   ========================================================================== */
/* 近滿版：dialog 撐滿視窗、四邊留 16px 邊距；content 撐滿 dialog、body 以 flex 填滿
           （header 之外的剩餘高度），<gis-map> 再由 height:100% 撐滿 body。 */
#modalGisMap .gis-map-dialog {
  max-width: none;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  margin: 16px auto;
}

#modalGisMap .gis-map-dialog .modal-content {
  height: 100%;
}

/* 讓 <gis-map> 撐滿 modal-body：host 預設 display:block 但高度 auto，
           內部 .gis-root 的 height:100% 需要 host 有明確高度，否則塌成 0。 */
#modalGisMap gis-map {
  display: block;
  width: 100%;
  height: 100%;
}

/* 載入遮罩：覆蓋整個 modal-body，置中 spinner + 文字。 */
#modalGisMap .gis-map-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background-color: #f5f6f7;
}

#modalGisMap .gis-map-loading[hidden] {
  display: none;
}

#modalGisMap .gis-map-loading__spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(21, 101, 192, 0.2);
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: gisMapSpin 0.8s linear infinite;
}

#modalGisMap .gis-map-loading__text {
  color: #44494d;
  font-size: 15px;
}

@keyframes gisMapSpin {
  to {
    transform: rotate(360deg);
  }
}


/* ==========================================================================
   Model Editor Styles (from modelEditorPage.html)
   ========================================================================== */

.gis-host {
  display: block;
}

.gis-root {
  position: relative;
  overflow: hidden;
}

.viewDiv {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  z-index: 1;
}

/* ── 子元件 chrome 樣式集中於此 ──
   本元件以 Shadow DOM 渲染；子 .vue 的 <style scoped> 會注入 document <head>，
   無法作用於 shadow root。子元件 DOM 與此處同屬一個 shadow root，故其版面樣式寫在這裡。
   （日後若要樣式與元件共置，可改將子元件命名為 .ce.vue 由 Vue 收集進 shadow root。） */
.placing-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  background-color: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

/* 轉檔中／儲存中遮罩：以原生 Popover API（popover="manual"）升至 top layer，確保壓在同屬
   top layer 的 calcite-popover（如「待儲存」暫存面板）之上——z-index 對 top layer 元素無效。
   以下覆寫 [popover] 的 UA 預設（fit-content 尺寸、auto margin、邊框、背景…），還原為覆蓋整個
   viewport 的置中遮罩；display:flex 僅在 :popover-open 時套用，未開啟時交由 UA 的 display:none。 */
.converting-overlay {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.35);
}

.converting-overlay:popover-open {
  display: flex;
}

.converting-card {
  padding: 24px 32px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.gis-controller {
  position: absolute;
  z-index: 10;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  max-width: 100%;
  height: 96px;
  padding: 0 12px;
  border-radius: 25px;
  background-color: rgba(255, 254, 254, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.gis-controller.is-ready {
  opacity: 1;
  pointer-events: auto;
}

/* 讓控制器置中浮於地圖上方 */
.gis-controller {
  position: absolute;
  z-index: 10;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  max-width: 100%;
  height: 96px;
  padding: 0 12px;
  border-radius: 25px;
  background-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all ease 0.3s;
}

/* 將 calcite-action-pad 的自帶背景與陰影透明化，讓 gis-controller 的外框統一包覆 */
.gis-controller calcite-action-pad {
  --calcite-color-foreground-1: transparent;
  --calcite-ui-foreground-1: transparent;
  background: transparent;
  box-shadow: none;
}

.gis-controller__center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cube-popover {
  --calcite-popover-background-color: rgba(1, 1, 1, 0);
}

.gis-symbol-cubes {
  display: flex;
  flex-wrap: wrap;
  max-width: min(600px, 90vw);
  max-height: min(350px, 50vh);
  overflow: auto;
  align-items: center;
  justify-content: center;
}

.gis-point-symbol-cube {
  width: 80px;
  height: 80px;
  padding: 6px;
  margin: 6px;
  border: 1px solid rgba(255, 254, 254, 0.2);
  border-radius: 12px;
  background-color: rgba(255, 254, 254, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all ease 0.3s;
}

.gis-point-symbol-cube img {
  max-width: 80%;
}

.gis-point-symbol-cube:hover img {
  max-width: 100%;
}

.gis-point-symbol-cube.active {
  background-color: rgba(215, 181, 243, 0.555);
  scale: 1.1;
}

.gis-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 240px;
  height: 200px;
  padding: 8px;
  border: 2px dashed #9aa0a6;
  border-radius: 16px;
  background-color: rgba(255, 254, 254, 0.92);
  color: #5f6368;
  cursor: pointer;
  transition: all ease 0.2s;
}

.gis-upload-dropzone:hover,
.gis-upload-dropzone.dragover {
  border-color: rgba(138, 92, 246, 0.9);
  background-color: rgba(215, 181, 243, 0.25);
}

.gis-upload-dropzone calcite-icon {
  --calcite-icon-color: #5f6368;
  transform: scale(2);
  margin-bottom: 6px;
}

.gis-upload-dropzone__title {
  font-size: 16px;
  font-weight: 500;
}

.gis-upload-dropzone__hint {
  font-size: 13px;
  opacity: 0.7;
}

/* ── 上傳完成（待儲存）面板 ──
   置於 calcite-popover 內，錨定於上傳 icon 正上方；popover 外觀透明只露出卡片。 */
.upload-result-popover {
  --calcite-popover-background-color: transparent;
  --calcite-popover-border-color: transparent;
}

.gis-upload-result {
  box-sizing: border-box;
  width: 380px;
  max-width: 92vw;
  padding: 20px;
  border-radius: 16px;
  background-color: #ffffff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: #2b2f33;
}

.gis-upload-result__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gis-upload-result__ok {
  --calcite-icon-color: #2e9e5b;
  flex: 0 0 auto;
}

.gis-upload-result__title {
  font-size: 18px;
  font-weight: 600;
}

.gis-upload-result__subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: #5f6368;
}

.gis-upload-result__question {
  font-size: 15px;
  font-weight: 600;
}

.gis-upload-result__info {
  border: 1px solid #e6e8eb;
  border-radius: 10px;
  overflow: hidden;
}

.gis-upload-result__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}

.gis-upload-result__row+.gis-upload-result__row {
  border-top: 1px solid #e6e8eb;
}

.gis-upload-result__label {
  flex: 0 0 84px;
  color: #5f6368;
  font-size: 13px;
}

.gis-upload-result__value {
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

.gis-upload-result__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.gis-upload-result__hint {
  font-size: 12px;
  line-height: 1.6;
  color: #80868b;
}

.gis-upload-result__input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e6e8eb;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 500;
  color: #2b2f33;
  background: transparent;
  outline: none;
  transition: border-color 0.15s;
}

.gis-upload-result__input:focus {
  border-color: rgba(138, 92, 246, 0.8);
}

/* 顯示於圖台切換列：label 在左、分段按鈕在右，間距交由面板 flex gap 控制 */
.gis-upload-result__display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gis-upload-result__display-label {
  font-size: 14px;
  font-weight: 500;
  color: #2b2f33;
}

/* 顯示切換採 Bootstrap Info 色系：選中項青底深字、外框保留淡灰細線（僅作用於此分段控制） */
.gis-upload-result__display calcite-segmented-control {
  --calcite-color-brand: #0dcaf0;
  --calcite-segmented-control-color: #055160;
  --calcite-segmented-control-border-color: #dee2e6;
  flex: 0 0 150px;
}

/* 兩個分段等寬：basis 壓 0、不受文字長短影響（蓋過 shadow 內 flex:1 1 auto） */
.gis-upload-result__display calcite-segmented-control-item {
  flex: 1 1 0;
  min-width: 0;
}

/* 儲存按鈕改用 Bootstrap Primary 藍（覆寫 Calcite 品牌色，僅作用於此按鈕） */
.gis-upload-result__save {
  --calcite-color-brand: #0d6efd;
  --calcite-color-brand-hover: #0b5ed7;
  --calcite-color-brand-press: #0a58ca;
}

/* ── 模型管理面板（GisModelManager）──
   固定區塊，浮於工具列正上方、由 GisController 的 modelManageOpen 切換顯示（非 calcite popover）。
   絕對定位以 .gis-root 為包含塊，bottom 設於工具列上方並水平置中；不參與工具列 flex 排版。
   功能/資料流見 data/開發文件/三維模型管理模組.md §3/§4。 */
.gis-model-manage {
  /* 改以 .gis-root 為定位容器（而非 .gis-controller），避免面板在 Modal 中
         被 overflow:hidden 裁切。bottom 留出控制列高度(96px)+間距(28px+12px)。 */
  position: absolute;
  bottom: calc(96px + 28px + 12px);
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  width: 760px;
  max-width: 94vw;
  /* 可用高度 = 容器 − 控制列 − 上下留白，避免頂部被裁切 */
  max-height: calc(100% - 96px - 28px - 12px - 16px);
  padding: 16px 18px;
  border-radius: 16px;
  background-color: #ffffff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #2b2f33;
  z-index: 11;
}

/* 編輯處理中：覆蓋整個面板的半透明遮罩 + 置中 loader（.gis-model-manage 為 position 容器）。 */
.gis-model-manage__overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.6);
}

.gis-model-manage__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gis-model-manage__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
}

/* 「管理者模式」標籤：純視覺標示目前為管理介面。 */
.gis-model-manage__mode {
  padding: 2px 10px;
  border-radius: 999px;
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
  font-size: 12px;
  font-weight: 600;
}

.gis-model-manage__head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 說明橫幅（頂部與底部共用）：淺藍底資訊條。 */
.gis-model-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background-color: rgba(13, 110, 253, 0.06);
  border: 1px solid rgba(13, 110, 253, 0.15);
  font-size: 12.5px;
  line-height: 1.6;
  color: #44494d;
}

.gis-model-banner calcite-icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: #0d6efd;
}

/* 統計卡：四格等寬，純展示（篩選改由下方下拉＋查詢控制）。 */
.gis-model-manage__stats {
  display: flex;
  gap: 8px;
}

.gis-model-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid #e6e8eb;
  border-radius: 10px;
  background-color: #f8f9fa;
}

.gis-model-stat__num {
  font-size: 20px;
  font-weight: 700;
}

.gis-model-stat__label {
  font-size: 12px;
  color: #5f6368;
}

/* 篩選列：名稱／上傳者輸入框＋顯示狀態下拉＋查詢按鈕。 */
.gis-model-filters {
  display: flex;
  gap: 8px;
}

.gis-model-filters__input,
.gis-model-filters__select {
  box-sizing: border-box;
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: #2b2f33;
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s;
}

.gis-model-filters__input:focus,
.gis-model-filters__select:focus {
  border-color: rgba(13, 110, 253, 0.8);
}

.gis-model-filters__search {
  flex: 0 0 auto;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background-color: #0d6efd;
  cursor: pointer;
  transition: background-color 0.15s;
}

.gis-model-filters__search:hover {
  background-color: #0b5ed7;
}

.gis-model-manage__list-title {
  font-size: 14px;
  font-weight: 600;
  color: #2b2f33;
}

/* 清單區：撐滿剩餘高度並可捲動（min-height:0 讓 flex 子項可縮、不溢出面板）。 */
.gis-model-manage__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.gis-model-manage__state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 0;
  font-size: 14px;
  color: #80868b;
}

.gis-model-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 模型卡：每筆一張卡，常駐顯示基本資訊；已移除者灰底。 */
.gis-model-card {
  border: 1px solid #e6e8eb;
  border-radius: 12px;
  padding: 12px 14px;
}

.gis-model-card.is-removed {
  background-color: #f5f6f7;
}

.gis-model-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gis-model-card__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  word-break: break-all;
}

/* 狀態標籤：顯示=綠、不顯示=橘、已移除=紅。 */
.gis-model-card__badge {
  flex: 0 0 auto;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.gis-model-card__badge.is-visible {
  background-color: rgba(46, 158, 91, 0.12);
  color: #2e9e5b;
}

.gis-model-card__badge.is-hidden {
  background-color: rgba(217, 119, 6, 0.14);
  color: #d97706;
}

.gis-model-card__badge.is-removed {
  background-color: rgba(220, 53, 69, 0.12);
  color: #dc3545;
}

/* 常駐基本資訊：兩欄。 */
.gis-model-card__info {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 13px;
  color: #44494d;
}

.gis-model-card__info>div {
  display: flex;
  gap: 8px;
  min-width: 0;
  word-break: break-all;
}

.gis-model-card__k {
  flex: 0 0 64px;
  color: #80868b;
}

.gis-model-card__detail {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background-color: #f8f9fa;
  font-size: 13px;
  line-height: 1.7;
  color: #5f6368;
}

/* 操作按鈕列：icon＋文字，允許換行。 */
.gis-model-card__actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gis-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
}

.gis-model-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gis-model-btn--primary {
  border-color: #0d6efd;
  color: #0d6efd;
}

.gis-model-btn--primary:not(:disabled):hover,
.gis-model-btn--primary.active {
  background-color: rgba(13, 110, 253, 0.08);
}

.gis-model-btn--primary-solid {
  border-color: #0d6efd;
  background-color: #0d6efd;
  color: #ffffff;
}

.gis-model-btn--primary-solid:not(:disabled):hover {
  background-color: #0b5ed7;
}

.gis-model-btn--neutral {
  border-color: #d0d4d8;
  color: #44494d;
}

.gis-model-btn--neutral:not(:disabled):hover {
  background-color: #f1f3f4;
}

.gis-model-btn--danger {
  border-color: #dc3545;
  color: #dc3545;
}

.gis-model-btn--danger:not(:disabled):hover {
  background-color: rgba(220, 53, 69, 0.08);
}

.gis-model-btn--danger-solid {
  border-color: #dc3545;
  background-color: #dc3545;
  color: #ffffff;
}

.gis-model-btn--danger-solid:not(:disabled):hover {
  background-color: #c12c3a;
}

/* 底部：說明橫幅或 inline 移除確認。 */
.gis-model-footer {
  flex: 0 0 auto;
}

.gis-model-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background-color: rgba(220, 53, 69, 0.06);
  border: 1px solid rgba(220, 53, 69, 0.2);
  font-size: 13px;
  color: #44494d;
}

.gis-model-confirm calcite-icon {
  flex: 0 0 auto;
  color: #dc3545;
}

.gis-model-confirm__text {
  flex: 1 1 auto;
  min-width: 0;
}

/* 修正 ArcGIS JS API 模組版與全域 4.24 CSS 版本落差導致的地圖 UI 控制項背景遺失問題 */
.esri-ui .esri-component.esri-widget {
  background-color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.esri-ui calcite-button.esri-widget--button {
  /* 針對 ArcGIS 4.28+ 使用的 calcite-button，由於未載入最新版 esri CSS，
     預設的 neutral 按鈕會是灰色，此處利用 calcite 的 CSS 變數將其改回傳統白色 */
  --calcite-color-foreground-3: #ffffff;
  --calcite-color-foreground-3-hover: #f3f3f3;
  --calcite-color-foreground-3-press: #e2e2e2;
  --calcite-color-text-1: #6e6e6e;
  /* 備用變數，以防不同 calcite 版本 */
  --calcite-color-neutral: #ffffff;
  --calcite-color-neutral-hover: #f3f3f3;
  /* 避免舊版 esri CSS 的 padding 干擾 calcite-button 內部的 Shadow DOM 佈局，導致圖示偏移 */
  padding: 0 !important;
  /* 為了解決 Compass 等 Widget 採用 slotted element 而產生文字留白的問題，將 host 設為 relative */
  position: relative;
}

/* 針對 Compass 的 slotted icon，因為 calcite-button 將其視為文字而套用左右 padding，
   導致 32x32 寬度下圖示被向右擠壓。此處利用 absolute 將圖示強制置中於 host */
.esri-ui calcite-button.esri-widget--button .esri-icon-compass {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0 !important;
}