/* css/panels.css - 图层面板和图例面板样式 */

/* ==========================================================================
   面板基础结构
   ========================================================================== */
.layers-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 25%;
  min-width: 280px; /* 确保最小可用宽度 */
  height: 100%;
  background-color: #eee; /* 使用灰色背景使图标更清晰 */
  z-index: 900;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.panel-section {
  height: 50%;
  position: relative;
  border-bottom: 1px solid #ddd;
  overflow-y: auto;
}

.panel-section:last-child {
  border-bottom: none; /* 移除最后一个面板的下边框 */
}

/* ==========================================================================
   面板头部样式
   ========================================================================== */
.main-section-header {
  font-size: 18px;
  font-weight: bold;
  color: #0073b7;
  text-align: center;
  padding: 10px 0;
  background-color: #f5f5f5;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 10; /* 相对于面板容器 */
}

/* ==========================================================================
   图层内容样式
   ========================================================================== */
.layers-content {
  height: calc(100% - 50px); /* 调整为正确的头部高度 */
  overflow-y: auto;
  padding: 0 5px;
}

.layer-group {
  border-bottom: 1px solid #eee;
  margin-bottom: 5px;
}

.layer-group:last-child {
  border-bottom: none; /* 移除最后一个组的下边框 */
}

.layer-group-header {
  padding: 8px 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #333;
  font-weight: 500;
  background-color: #f8f9fa;
  transition: background-color 0.2s ease; /* 添加过渡效果 */
}

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

.layer-group-header:focus {
  outline: 2px solid #0073b7;
  outline-offset: -2px;
}

.layer-items {
  padding-left: 15px;
  margin-bottom: 10px;
  background-color: #fdfdfd;
}

.layer-item {
  padding: 5px 0;
  display: flex;
  align-items: center;
}

.layer-item input {
  margin-right: 8px;
}

.layer-item input:focus {
  outline: 2px solid #0073b7;
  outline-offset: 2px;
}

.layer-item label {
  font-size: 13px;
  cursor: pointer;
  flex: 1;
  transition: color 0.2s ease;
}

.layer-item:hover label {
  color: #0073b7;
}

.layer-tools {
  color: #666;
  font-size: 14px;
}

.layer-tools button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #777;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

.layer-tools button:hover {
  background-color: #f0f0f0;
}

.layer-tools button:focus {
  outline: 2px solid #0073b7;
  outline-offset: 1px;
}

/* ==========================================================================
   树形结构样式
   ========================================================================== */
.tree-node {
  margin-left: 0;
}

.tree-node.level-1 {
  margin-left: 20px;
  border-left: 2px solid #e9ecef;
  padding-left: 10px;
}

.tree-node.level-2 {
  margin-left: 40px;
  border-left: 2px solid #dee2e6;
  padding-left: 10px;
}

.tree-node.level-3 {
  margin-left: 60px;
  border-left: 2px solid #ced4da;
  padding-left: 10px;
}

.tree-node.level-4 {
  margin-left: 80px;
  border-left: 2px solid #adb5bd;
  padding-left: 10px;
}

.tree-node-header {
  padding: 4px 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
  border-radius: 2px;
}

.tree-node-header:hover {
  background-color: #f8f9fa;
}

.tree-node-header:focus {
  outline: 2px solid #0073b7;
  outline-offset: -1px;
}

.tree-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  font-size: 12px;
  color: #6c757d;
  cursor: pointer;
  transition: color 0.2s ease;
}

.tree-toggle:hover {
  color: #0073b7;
}

.tree-checkbox {
  margin-right: 8px;
  transform: scale(0.9);
}

.tree-checkbox:focus {
  outline: 2px solid #0073b7;
  outline-offset: 2px;
}

.tree-label {
  font-size: 13px;
  cursor: pointer;
  flex: 1;
  color: #495057;
  transition: color 0.2s ease;
}

.tree-node-header:hover .tree-label {
  color: #0073b7;
}

.tree-node.level-0 .tree-label {
  font-weight: 600;
  color: #212529;
}

.tree-node.level-1 .tree-label {
  font-weight: 500;
  color: #343a40;
}

.tree-node.level-2 .tree-label {
  font-weight: normal;
  color: #495057;
}

.tree-node.level-3 .tree-label {
  font-weight: normal;
  color: #6c757d;
  font-size: 12px;
}

.tree-node.level-4 .tree-label {
  font-weight: normal;
  color: #868e96;
  font-size: 11px;
}

.tree-children {
  display: none;
}

.tree-children.expanded {
  display: block;
}

/* ==========================================================================
   子图层样式（向后兼容）
   ========================================================================== */
.sublayer-item {
  padding: 3px 0 3px 20px;
  display: flex;
  align-items: center;
  background-color: #f9f9f9;
  border-left: 2px solid #dee2e6;
  margin-left: 10px;
  transition: background-color 0.2s ease;
}

.sublayer-item:hover {
  background-color: #f0f8ff;
}

.sublayer-item input {
  margin-right: 6px;
  transform: scale(0.9);
}

.sublayer-item input:focus {
  outline: 2px solid #0073b7;
  outline-offset: 2px;
}

.sublayer-item label {
  font-size: 12px;
  color: #666;
  cursor: pointer;
  flex: 1;
}

.sublayer-group {
  padding-left: 20px;
  margin-top: 3px;
}

.sublayer-toggle {
  color: #0073b7;
  font-size: 12px;
  cursor: pointer;
  margin-left: 20px;
  user-select: none;
  transition: color 0.2s ease;
}

.sublayer-toggle:hover {
  color: #005a8b;
}

.sublayer-toggle:focus {
  outline: 2px solid #0073b7;
  outline-offset: 1px;
}

/* ==========================================================================
   状态样式
   ========================================================================== */
.layer-loading, .loading {
  padding: 10px;
  font-style: italic;
  color: #666;
  font-size: 12px;
  text-align: center;
}

.error-message {
  padding: 10px;
  color: #c00;
  background-color: #fff4f4;
  border: 1px solid #ffebee;
  border-radius: 4px;
  margin: 10px 0;
  font-size: 13px;
}

.success-message {
  padding: 10px;
  color: #2e7d32;
  background-color: #f3e5f5;
  border: 1px solid #e8f5e8;
  border-radius: 4px;
  margin: 10px 0;
  font-size: 13px;
}

/* ==========================================================================
   图例内容样式
   ========================================================================== */
.legend-content {
  height: calc(100% - 50px); /* 调整为正确的头部高度 */
  overflow-y: auto;
  padding: 0 5px;
}

.legend-section {
  padding: 10px 5px 15px;
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.legend-section:last-child {
  border-bottom: none;
}

.legend-header {
  font-size: 15px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
  padding-left: 5px;
}

.tbody {
  display: block;
  padding-left: 10px;
}

.formTable {
  width: 100%;
  border-collapse: collapse;
}

.formTable td {
  padding: 6px 0;
  vertical-align: top;
}

.formTable b {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  color: #333;
}

.formTable table {
  width: 100%;
  margin-top: 5px;
  border-collapse: collapse;
  margin-left: 10px;
}

.formTable table td {
  padding: 3px;
  vertical-align: middle;
}

.formTable table td:first-child {
  width: 30px;
  text-align: center;
}

.formTable img {
  display: block;
  max-width: 100%;
  height: auto; /* 保持图片比例 */
}

/* ==========================================================================
   Bookmarks list styles
   ========================================================================== */
.bookmark-list {
  list-style: none;
  padding: 10px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bookmark-list li {
  list-style: none;
}

.bookmark-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background-color: #fff; /* 简洁的白色背景 */
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  color: #333;
  font-size: 14px;
  transition: background-color 0.2s ease;
  width: 100%;
  text-align: left;
}

.bookmark-btn:hover {
  background-color: #e8f0fe;
  color: #0073b7;
}

.bookmark-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bookmark-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   UN-ASIGN panel styles
   ========================================================================== */
#unasign-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.unasign-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 10px;
  position: relative;
}

.unasign-logo {
  max-width: 35%;
  height: auto;
  margin-top: 10px;
}

.unasign-instructions {
  text-align: center;
  margin: 20px 0;
  font-size: 14px;
}

.unasign-qrcode {
  width: 70%;
  height: auto;
  margin-bottom: 20px;
  max-width: none;
}

.store-buttons {
  position: absolute;
  bottom: 25%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.store-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #000;
  color: #fff;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 16px;
  min-width: 130px;
  justify-content: center;
  white-space: nowrap;
}

.store-btn .store-icon {
  font-size: 16px;
  line-height: 1;
}

/* ==========================================================================
   Download panel styles
   ========================================================================== */
.download-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.download-info {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  text-align: center;
}

.download-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  align-items: center;
}

.download-btn {
  padding: 12px 20px;
  background: #0073b7;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
  width: 100%;
  text-align: center;
}

.download-btn:hover {
  background: #005a8b;
}