/* ============================================================
   西宁支线 · 管道巡护可视化 —— 汇报演示大屏样式
   深色底 + 克制动效；风险类暖色 / 巡护资源类冷色
   ============================================================ */

:root {
  --bg:          #0b1220;
  --panel:       rgba(15, 23, 42, .86);
  --panel-line:  rgba(148, 163, 184, .22);
  --panel-hi:    rgba(148, 163, 184, .38);
  --text:        #e2e8f0;
  --text-dim:    #94a3b8;

  --risk:        #e5484d;   /* 第三方施工 */
  --risk-2:      #f97316;   /* 地灾 */
  --hca:         #eab308;   /* 高后果区 */
  --cam:         #38bdf8;   /* 视频监控 */
  --drone:       #2dd4bf;   /* 无人机 */
  --fiber:       #22d3ee;   /* 振动光纤 */
  --overview:    #a78bfa;   /* 总览 */
  --pipe:        #7c8da6;   /* 管线基础色 */
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  overflow: hidden;
}

#map { position: absolute; inset: 0; z-index: 0; background: #0d1526; }

/* Leaflet 自身控件隐藏（我们用自绘按钮） */
.leaflet-control-attribution { display: none !important; }

/* ---------- 顶部标题栏 ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(11,18,32,.92) 0%, rgba(11,18,32,.55) 70%, rgba(11,18,32,0) 100%);
  pointer-events: none;
}
#topbar button { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 8px; height: 38px; border-radius: 4px;
  background: linear-gradient(180deg, var(--fiber), var(--cam));
  box-shadow: 0 0 14px rgba(34,211,238,.55);
}
.brand-text h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand-text p  { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); letter-spacing: .3px; }

.ghost-btn {
  padding: 8px 16px; font-size: 13px; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 8px; cursor: pointer; transition: .18s;
  font-family: inherit;
}
.ghost-btn:hover { border-color: var(--panel-hi); background: rgba(30,41,59,.95); }

/* ---------- 右侧图层按钮组 ---------- */
#layer-buttons {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  z-index: 1200; display: flex; flex-direction: column; gap: 9px;
}
.layer-btn {
  display: flex; align-items: center; gap: 10px;
  width: 176px; padding: 11px 14px;
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s;
  backdrop-filter: blur(6px);
}
.layer-btn:hover { border-color: var(--panel-hi); transform: translateX(-3px); }
.layer-btn .dot {
  width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto;
  background: var(--accent, var(--text-dim));
  opacity: .45; transition: .18s;
}
.layer-btn .ico { flex: 0 0 auto; width: 18px; height: 18px; opacity: .75; transition: .18s; }
.layer-btn .ico svg { width: 100%; height: 100%; display: block; }
.layer-btn .lbl { flex: 1 1 auto; text-align: left; white-space: nowrap; }

.layer-btn.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
              0 4px 18px color-mix(in srgb, var(--accent) 22%, transparent);
}
.layer-btn.on .dot { opacity: 1; box-shadow: 0 0 10px var(--accent); }
.layer-btn.on .ico { opacity: 1; }

.layer-btn.sep { margin-top: 10px; }
.layer-btn.sep::before {
  content: ""; position: absolute; left: 12px; right: 12px;
  margin-top: -21px; height: 1px; background: var(--panel-line);
}

/* ---------- 左下角数据列表 ---------- */
#datalist {
  position: absolute; left: 20px; bottom: 20px; z-index: 1200;
  width: 330px; max-height: 46vh;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; backdrop-filter: blur(8px);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--panel-line);
  background: rgba(2,6,23,.35);
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .4px; }
#datalist-count { font-size: 12px; color: var(--text-dim); }

#datalist-body { overflow-y: auto; padding: 6px; }
#datalist-body::-webkit-scrollbar { width: 6px; }
#datalist-body::-webkit-scrollbar-thumb { background: rgba(148,163,184,.3); border-radius: 3px; }

.empty { margin: 0; padding: 18px 12px; color: var(--text-dim); font-size: 13px; text-align: center; }

/* 总览态的分组小标题 */
.group-head {
  padding: 11px 10px 5px;
  margin-top: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-line);
}
.group-head:first-child { margin-top: 0; border-top: none; }

.row {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  transition: background .15s;
  animation: rowIn .22s ease both;
}
.row:hover { background: rgba(148,163,184,.13); }
.row .bullet {
  flex: 0 0 auto; width: 8px; height: 8px; margin-top: 5px;
  border-radius: 2px; background: var(--accent, var(--text-dim));
}
.row .body { min-width: 0; flex: 1 1 auto; }
.row .t1 { font-size: 13px; line-height: 1.35; }
.row .t2 { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }
.row .stake {
  flex: 0 0 auto; font-size: 11px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.row .sev-high { color: #fca5a5; }
.row .sev-medium { color: #fcd34d; }

@keyframes rowIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- 图例 ---------- */
#legend {
  position: absolute; right: 20px; bottom: 20px; z-index: 1200;
  display: flex; flex-direction: column; gap: 7px;
  padding: 11px 13px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 10px; backdrop-filter: blur(8px);
  font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .25s;
}
#legend.show { opacity: 1; }
#legend .lg { display: flex; align-items: center; gap: 8px; }
#legend .lg i {
  width: 16px; height: 4px; border-radius: 2px; display: inline-block;
  background: var(--c, var(--text-dim));
}
#legend .lg.mk i { width: 10px; height: 10px; border-radius: 3px; transform: rotate(45deg); }

/* ---------- 载入提示 ---------- */
#loading {
  position: absolute; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-dim); font-size: 14px;
  transition: opacity .5s; letter-spacing: .5px;
}
#loading.hide { opacity: 0; pointer-events: none; }

/* ============================================================
   地图标记与动效
   ============================================================ */

/* 五角星（第三方施工）—— 红色闪烁 */
.mk-star svg { width: 100%; height: 100%; display: block; }
.mk-star svg path {
  fill: var(--risk);
  stroke: #fff5f5; stroke-width: 1.1;
  animation: blinkStar 1.1s ease-in-out infinite;
}
@keyframes blinkStar {
  0%, 100% { opacity: 1;    filter: drop-shadow(0 0 3px rgba(229,72,77,.9)); }
  50%      { opacity: .35;  filter: drop-shadow(0 0 12px rgba(229,72,77,1)); }
}

/* 菱形（地灾 / 防汛）—— 闪烁 */
.mk-diamond svg { width: 100%; height: 100%; display: block; }
.mk-diamond svg path {
  fill: var(--risk-2);
  stroke: #fff7ed; stroke-width: 1.1;
  animation: blinkDiamond 1.35s ease-in-out infinite;
}
.mk-diamond.flood svg path { fill: #0ea5e9; }
@keyframes blinkDiamond {
  0%, 100% { opacity: 1;   filter: drop-shadow(0 0 3px rgba(249,115,22,.85)); }
  50%      { opacity: .35; filter: drop-shadow(0 0 11px rgba(249,115,22,1)); }
}

/* 摄像头 */
.mk-cam svg { width: 100%; height: 100%; display: block; }
.mk-cam svg path { fill: var(--cam); stroke: #082f49; stroke-width: .8; }

/* 无人机机巢 */
.mk-dock svg { width: 100%; height: 100%; display: block; }
.mk-dock svg path { fill: var(--drone); stroke: #042f2e; stroke-width: .8; }
.mk-dock::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 1.5px solid var(--drone); opacity: .55;
  animation: ping 2.1s cubic-bezier(0,0,.2,1) infinite;
}
@keyframes ping {
  0%   { transform: scale(.55); opacity: .7; }
  80%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* 摄像头覆盖扇形 */
.cover-sector {
  animation: sectorIn .45s ease both;
}
@keyframes sectorIn { from { opacity: 0; } to { opacity: 1; } }

/* 高后果区「方块阴影」—— 沿管线的断续宽带，闪烁突出 */
.hca-band {
  stroke-linecap: butt;
  animation: hcaIn .45s ease both, hcaBlink 1.9s ease-in-out infinite;
}
@keyframes hcaIn { from { opacity: 0; } to { opacity: 1; } }
/* 大面积闪烁放慢到 1.9s，投屏上不晃眼；用 stroke-opacity 以免影响元素其他属性 */
@keyframes hcaBlink {
  0%, 100% { stroke-opacity: .78; }
  50%      { stroke-opacity: .26; }
}

/* 无人机航线虚线 —— 流动 */
.drone-route {
  stroke-linecap: round;
  animation: dashFlow 2.4s linear infinite;
}
@keyframes dashFlow { to { stroke-dashoffset: -54; } }

/* 振动光纤 —— 管线加亮 + 呼吸脉冲 */
.fiber-glow {
  filter: drop-shadow(0 0 6px rgba(34,211,238,.95));
  animation: fiberPulse 2.6s ease-in-out infinite;
}
@keyframes fiberPulse {
  0%, 100% { opacity: .68; }
  50%      { opacity: 1; }
}
.fiber-dot {
  animation: fiberDot 2.6s ease-in-out infinite;
}
@keyframes fiberDot {
  0%, 100% { opacity: .18; r: 2.4; }
  50%      { opacity: .95; r: 3.6; }
}

/* 图层淡入（Leaflet 覆盖层容器） */
.leaflet-overlay-pane svg, .leaflet-marker-icon { transition: opacity .25s; }
.layer-fade-out { opacity: 0 !important; }

/* 桩号标签 */
.stake-label {
  font-size: 10.5px; color: #cbd5e1; white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.stake-tick {
  width: 5px; height: 5px; border-radius: 50%;
  background: #cbd5e1; box-shadow: 0 0 4px #000;
}

/* Tooltip 统一风格 */
.leaflet-tooltip.kx-tip {
  background: rgba(2,6,23,.94); border: 1px solid var(--panel-line);
  color: var(--text); font-size: 12.5px; padding: 6px 9px; border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.leaflet-tooltip.kx-tip::before { display: none; }

/* 定位高亮 */
@keyframes locateFlash {
  0%   { transform: scale(.4); opacity: .95; }
  100% { transform: scale(2.6); opacity: 0; }
}
.locate-ring {
  border-radius: 50%; border: 3px solid #fff;
  animation: locateFlash .85s ease-out 2;
  pointer-events: none;
}

/* 投屏适配：4K 下整体放大 */
@media (min-width: 2500px) {
  .brand-text h1 { font-size: 26px; }
  .brand-text p  { font-size: 15px; }
  .layer-btn { width: 220px; font-size: 17px; padding: 14px 18px; }
  #datalist { width: 420px; max-height: 50vh; }
  .row .t1 { font-size: 16px; }
  .row .t2 { font-size: 14px; }
  #legend { font-size: 15px; }
}
