/**
 * GeoJSON Loader - 图层管理样式
 * 提供图层面板、复选框、弹窗等样式
 */

/* ========== 全选行样式 ========== */
#selectAllRow {
  display: flex;
  align-items: center;
  padding: 7px 12px 5px;
  border-bottom: 1px solid #e0e8e0;
  margin-bottom: 6px;
  gap: 8px;
}

#selectAllRow span {
  font-size: 12px;
  color: #444;
  font-weight: 600;
  flex: 1;
  user-select: none;
}

/* ========== 通用复选框样式 ========== */
.layer-item input[type="checkbox"],
.group-select-all,
#selectAllLayers {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid #ccc;
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  outline: none;
  background: #fff;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.layer-item input[type="checkbox"]:checked,
.group-select-all:checked,
#selectAllLayers:checked {
  border-color: transparent;
}

.layer-item input[type="checkbox"]:checked::after,
.group-select-all:checked::after,
#selectAllLayers:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
}

/* 半选状态 */
.group-select-all.indeterminate,
#selectAllLayers.indeterminate {
  border-color: transparent;
  background: #aaccaa;
}

.group-select-all.indeterminate::after,
#selectAllLayers.indeterminate::after {
  content: "−";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
}

#selectAllLayers:checked {
  background: #5a9a5a;
}

.group-select-all:checked {
  background: #6aaa6a;
}

.layer-item input[type="checkbox"]:checked {
  background: var(--layer-color, #4caf50);
}

/* ========== 图层组样式 ========== */
.layer-group {
  margin-bottom: 4px;
}

.layer-group-header {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  cursor: pointer;
  background: #f0f7f0;
  border-radius: 4px;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: #3a7a3a;
  transition: background 0.15s;
  gap: 5px;
}

.layer-group-header:hover {
  background: #e2f0e2;
}

.layer-group-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
  color: #88aa88;
  flex-shrink: 0;
}

.layer-group-arrow.open {
  transform: rotate(90deg);
}

.layer-group-name {
  flex: 1;
}

.layer-group-children {
  overflow: hidden;
  transition: max-height 0.25s ease;
  max-height: 0;
}

.layer-group-children.open {
  max-height: 600px;
}

/* ========== 图层项样式 ========== */
.layer-item {
  display: flex;
  align-items: center;
  padding: 5px 10px 5px 22px;
  margin: 1px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.layer-item:hover {
  background: #f5f5f5;
}

.layer-item label {
  flex: 1;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 6px;
}

/* ========== 图层状态指示器 ========== */
.layer-status {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #ddd;
  transition: all 0.3s ease;
}

.layer-status[data-status="idle"] {
  background: #ddd;
}

.layer-status[data-status="loading"] {
  background: #4a90d9;
  animation: status-pulse 1s infinite;
}

.layer-status[data-status="loaded"] {
  background: #5a9a5a;
}

.layer-status[data-status="error"] {
  background: #d9534f;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

/* ========== 定位按钮 ========== */
.layer-locate-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  font-size: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  margin-left: 2px;
  transition:
    color 0.15s,
    background 0.15s;
}

.layer-locate-btn:hover {
  color: #3a7a3a;
  background: #e2f0e2;
}

/* ========== 弹窗样式 ========== */
.feature-popup {
  font-size: 12px;
  line-height: 1.7;
  min-width: 160px;
  max-width: 280px;
  max-height: 300px;
  overflow-y: auto;
}

.feature-popup table {
  width: 100%;
  border-collapse: collapse;
}

.feature-popup td {
  padding: 2px 4px;
  vertical-align: top;
}

.feature-popup td:first-child {
  color: #888;
  white-space: nowrap;
  padding-right: 8px;
}

.feature-popup td:last-child {
  color: #222;
  word-break: break-all;
}

.feature-popup tr:nth-child(even) td {
  background: #f9f9f9;
}

/* ========== 用户上传图层区域 ========== */
#userLayerGroup {
  margin-top: 8px;
  border-top: 1px dashed #ccc;
  padding-top: 6px;
}

#userLayerGroup > div:first-child {
  font-size: 12px;
  color: #888;
  padding: 0 10px 4px;
}

/* ========== 图层组加载状态指示器 ========== */
.group-status {
  flex-shrink: 0;
  font-size: 11px;
  margin-right: 4px;
  min-width: 16px;
  text-align: center;
  color: #888;
  transition: all 0.3s ease;
}

.group-status[data-status="loading"] {
  color: #4a90d9;
  animation: status-pulse 1s infinite;
}

.group-status[data-status="loaded"] {
  color: #5a9a5a;
}

.group-status[data-status="partial"] {
  color: #f0ad4e;
}

.group-status[data-status="error"] {
  color: #d9534f;
}

/* ========== 颜色设置按钮 ========== */
.layer-color-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  font-size: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  margin-left: 2px;
  transition:
    color 0.15s,
    background 0.15s;
}

.layer-color-btn:hover {
  color: #cc7722;
  background: #fff3e0;
}

/* ========== 颜色设置弹窗 ========== */
.color-modal-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  min-width: 320px;
  max-width: 400px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.color-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f0f7f0;
  border-bottom: 1px solid #d0e0d0;
  font-size: 14px;
  font-weight: 600;
  color: #3a7a3a;
}

.color-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 0 4px;
}

.color-modal-close:hover {
  color: #c44;
}

.color-modal-body {
  padding: 14px 16px;
}

.color-mode-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #444;
  padding: 4px 0;
}

.color-mode-option input[type="radio"] {
  width: 14px;
  height: 14px;
  accent-color: #4a8c4a;
  cursor: pointer;
}

.color-mode-option span {
  user-select: none;
}

.color-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* ========== 站点标签样式 ========== */
/* 站点图标容器 */
.station-icon-container {
  background: transparent;
  border: none;
}

/* 组合标记：圆点 + 标签 */
.station-marker-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none; /* 让点击穿透到 marker 本身 */
}

/* 站点圆点 */
.station-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid;
  border-color: inherit;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

/* 站点标签文字 */
.station-label {
  color: #222;
  font-size: 10px;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: rgba(255, 255, 255, 0.88);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  /* 四方向白色描边 */
  text-shadow:
    1px 1px 0 #fff,
    -1px 1px 0 #fff,
    1px -1px 0 #fff,
    -1px -1px 0 #fff;
  transition: opacity 0.2s;
}

/* 缩放级别不足时隐藏标签 */
.station-label.hidden {
  opacity: 0;
  width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

/* ========== 聚类样式 ========== */
.cluster-marker {
  background: transparent;
}

.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-family: Arial, sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 2px solid white;
}

.cluster-small {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.cluster-medium {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.cluster-large {
  width: 46px;
  height: 46px;
  font-size: 14px;
}
