/* smart-map.css */
.smartmap-topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.tab-btn.active {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  border-color: rgba(59, 130, 246, 0.65);
}

.kv-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.kv-row input {
  flex: 1;
  min-width: 260px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  outline: none;
}
.hint {
  font-size: 12px;
  color: var(--muted);
}
.hint.ok {
  color: #16a34a;
}
.hint.warn {
  color: #f59e0b;
}

.indicator-bar {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}
html.dark .indicator-bar {
  background: rgba(15, 23, 42, 0.6);
}

.indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
.indicator:hover {
  transform: translateY(-1px);
}
.indicator.active {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.65);
}
.indicator.muted {
  opacity: 0.45;
}

.indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
}
.indicator .label {
  font-size: 12px;
  font-weight: 800;
}
.indicator .indicator-count {
  font-size: 12px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.smartmap-mapwrap {
  margin-top: 12px;
  position: relative; /* ✅關鍵：讓 drawer 以地圖區為定位容器 */
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #e5e7eb;
  height: 640px;
}

.smartmap-mapbadge {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
}
html.dark .smartmap-mapbadge {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.2);
}

#googleWrap, #tilesWrap {
  width: 100%;
  height: 100%;
}
#googleMap, #leafletMap {
  width: 100%;
  height: 100%;
}

/* ✅ Drawer：限制在 mapwrap 內，不再 fixed 全頁 */
.left-drawer {
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: 320px;
  max-width: calc(100% - 24px);
  z-index: 30;

  display: none; /* 預設關閉 */
  flex-direction: column;

  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}

.left-drawer.open {
  display: flex;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
}
.drawer-title .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.drawer-body {
  padding: 12px;
  overflow: auto;
}

.deviceTooltip {
    background: #ffffff;
    color: #334155;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
}
.field strong { font-size: 12px; color: var(--muted); }
.field span { font-size: 13px; font-weight: 800; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.status-badge.ok { background: rgba(16, 185, 129, 0.14); }
.status-badge.bad { background: rgba(239, 68, 68, 0.14); }
.status-badge.off { background: rgba(148, 163, 184, 0.18); }

.dim-box {
  margin-top: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  padding: 12px;
  background: rgba(148, 163, 184, 0.08);
}
.dim-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#dimSlider {
  width: 100%;
}

.dim-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.dim-actions .btn {
  flex: 1;
}

.indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 10px;
  border: 1.5px solid #d1d5db;
  box-sizing: border-box;
}

/* gateway */
.indicator-dot--gateway-normal {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

.indicator-dot--gateway-abnormal {
  background: #8b5cf6;
  border-color: #fa1717;
}

.indicator-dot--gateway-offline {
  background: #ffffff;
  border-color: #8b5cf6;
}

/* controller */
.indicator-dot--controller-normal {
  background: #f97316;
  border-color: #f97316;
}

.indicator-dot--controller-abnormal {
  background: #f97316;
  border-color: #fa1717;
}

.indicator-dot--controller-offline {
  background: #ffffff;
  border-color: #f97316;
}

/* 手機版調整 */
@media (max-width: 900px) {
  .left-drawer {
    left: 12px;
    right: 12px;
    width: auto;
    top: auto;
    bottom: 12px;
    height: 52%;
  }
}

/* Camera marker styles */
.camera-marker {
  background: transparent !important;
  border: none !important;
}

.camera-marker div {
  pointer-events: none;
}

/* 放大 Leaflet 地圖文字 */
#leafletMap {
  font-family: system-ui, -apple-system, sans-serif;
}

/* 放大 Leaflet 控件文字 */
.leaflet-container {
  font-size: 14px !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  font-size: 16px !important;
  line-height: 26px !important;
}

/* 標籤與文字放大 */
.leaflet-popup-content {
  font-size: 14px !important;
}

.leaflet-control-attribution {
  font-size: 12px !important;
}

/* 圖層提示 */
.leaflet-tooltip {
  font-size: 13px !important;
}

.indicator.inactive {
  opacity: 0.45;
  filter: grayscale(0.15);
}

.indicator {
  transition: opacity .18s ease, transform .18s ease, filter .18s ease;
}