/* 容器布局 */
#container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* 侧边栏 */
#sidebar {
    width: 180px;
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    overflow: hidden; /* 防止侧边栏整体滚动，只让图标区域滚动 */
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 导入 / 导出按钮容器 */
.sidebar-top .button-row {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

/* 导入 / 导出按钮 */
.sidebar-top button {
    flex: 1;
    height: 36px;
    font-size: 14px;
    background: #2b2b2b;
    color: #ddd;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
}

.sidebar-top button:hover {
    background: #3a3a3a;
}

.sidebar-top button:active {
    background: #4da3ff;
    color: #fff;
}

/* 图标栏滚动区域 */
#icon-buttons-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    /* 防止滚动事件冒泡到地图 */
    touch-action: pan-y;
}

/* 自定义滚动条样式 */
#icon-buttons-container::-webkit-scrollbar {
    width: 6px;
}

#icon-buttons-container::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

#icon-buttons-container::-webkit-scrollbar-thumb {
    background: #4da3ff;
    border-radius: 3px;
}

#icon-buttons-container::-webkit-scrollbar-thumb:hover {
    background: #5db0ff;
}

/* 图标类别标题 */
.icon-category-title {
    font-size: 12px;
    font-weight: bold;
    color: #4da3ff;
    padding: 8px 6px 4px 6px;
    margin-top: 8px;
    border-bottom: 1px solid rgba(77, 163, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.icon-category-title:first-child {
    margin-top: 0;
}

.icon-category-title:hover {
    background: rgba(77, 163, 255, 0.05);
}

/* 折叠/展开按钮 */
.category-collapse-btn {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #4da3ff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.category-collapse-btn:hover {
    color: #5db0ff;
    transform: scale(1.1);
}

.category-collapse-btn.expanded {
    transform: rotate(0deg);
}

.category-collapse-btn.collapsed {
    transform: rotate(-90deg);
}

.category-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #4da3ff;
    flex-shrink: 0;
}

.category-label {
    flex: 1;
}

/* 类别图标容器 */
.category-icons-container {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.category-icons-container.expanded {
    max-height: 5000px; /* 足够大的值以容纳所有图标 */
    opacity: 1;
}

.category-icons-container.collapsed {
    max-height: 0;
    opacity: 0;
}

/* 侧栏图标设置 */
.icon-btn {
    width: 100%;
    min-height: 24px;  /* 减小高度以适应更小的图标 */
    display: flex;
    flex-direction: row;
    align-items: center;  /* 改为垂直居中 */
    gap: 6px;  /* 减小间距 */
    padding: 4px;  /* 减小内边距 */
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;  /* 减小底部间距 */
}

.icon-btn:hover {
    background: rgba(77, 163, 255, 0.1);
}

.icon-btn img {
    width: 16px;  /* 缩小到原来的1/3 (48px / 3 = 16px) */
    height: 16px; /* 缩小到原来的1/3 (48px / 3 = 16px) */
    object-fit: contain;
    flex-shrink: 0;
}

.icon-btn-content {
    flex: 1;
    display: flex;
    flex-direction: row;  /* 改为横向排列 */
    align-items: center;  /* 垂直居中 */
    gap: 6px;  /* 减小间距 */
    min-width: 0;
}

.icon-btn-row1 {
    display: none;  /* 不再需要，checkbox移到主行 */
}

.icon-btn-row2 {
    display: none;  /* 不再需要，label和count移到主行 */
}

.icon-label {
    font-size: 11px;  /* 稍微减小字体 */
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;  /* 允许缩小 */
    flex: 1;
}

.icon-count {
    font-size: 10px;  /* 稍微减小字体 */
    color: #4da3ff;
    background: rgba(77, 163, 255, 0.2);
    padding: 1px 4px;  /* 减小内边距 */
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
    font-weight: bold;
    flex-shrink: 0;  /* 防止数量被压缩 */
}

.icon-checkbox {
    width: 14px;  /* 稍微减小checkbox尺寸 */
    height: 14px;
    cursor: pointer;
    accent-color: #4da3ff;
    flex-shrink: 0;
}

.icon-btn.selected {
    border-color: #4da3ff;
}

/* 地图容器 */
#map {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #111;
}

/* 基础样式 */
html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

/* 坐标栏 */
#coord-bar {
    font-size: 40px;
    height: 32px;
    background: #222;
    color: #ddd;
    padding: 25px 300px;
    font-family: monospace;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#coord-display {
    flex: 1;
}

#mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

#username-select {
    padding: 6px 10px;
    font-size: 14px;
    background: #333;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    width: 120px;
    font-family: system-ui, sans-serif;
    cursor: pointer;
}

#username-select:focus {
    outline: none;
    border-color: #4da3ff;
    background: #3a3a3a;
}

#username-select option {
    background: #333;
    color: #ddd;
}

.mode-btn {
    padding: 8px 16px;
    font-size: 16px;
    background: #333;
    color: #ddd;
    border: 2px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: #444;
    border-color: #666;
}

.mode-btn.active {
    background: #4da3ff;
    color: #fff;
    border-color: #4da3ff;
}

.mode-btn.active:hover {
    background: #5db0ff;
    border-color: #5db0ff;
}

/* 标记弹窗 */
.marker-popup {
    width: 320px;
    font-family: system-ui, sans-serif;
}

/* 创建者信息 */
.marker-creator {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #333;
}

/* 文本框 */
.marker-textarea {
    width: 100%;
    height: 160px;
    font-size: 22px;
    line-height: 1.4;
    padding: 10px;
    resize: vertical;
    box-sizing: border-box;
}

.marker-textarea[readonly] {
    background: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

.marker-popup.readonly-mode .marker-actions {
    display: none;
}

/* 按钮区域 */
.marker-actions {
    margin-top: 12px;
    text-align: right;
}

.marker-actions button {
    font-size: 24px;
}

/* 标记图标包装 */
.marker-icon-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    /* 防止挡住点击 */
    position: relative;
}

.marker-icon-wrap img {
    width: 48px;
    height: 48px;
    display: block;
    flex-shrink: 0;
}

.marker-label {
    margin-top: 2px;
    font-size: 12px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.2;
    flex-shrink: 0;
}

/* 路径标记样式 */
.path-marker-icon {
    background: transparent !important;
    border: none !important;
    width: 24px !important;
    height: 24px !important;
    text-align: center !important;
    line-height: 24px !important;
}

.path-marker-icon .path-marker-label {
    width: 24px !important;
    height: 24px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    font-weight: bold !important;
    color: #fff !important;
    border-radius: 50% !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    line-height: 20px !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    vertical-align: middle !important;
}

.path-marker-start {
    background: #4da3ff !important;
}

.path-marker-end {
    background: #ffd700 !important;  /* 黄色终点标记 */
}

/* 自定义比例尺样式 */
.leaflet-control-scale {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 11px;
    line-height: 1.4;
    color: #333;
    white-space: nowrap;
    margin-top: 10px;  /* 与缩放控件保持间距 */
    margin-left: 50px;  /* 为缩放控件留出空间，放在缩放控件右边 */
}

.scale-line {
    border: 2px solid #333;
    border-top: none;
    height: 0;
    position: relative;
    margin-top: 2px;
}

.scale-line span {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 4px;
    font-weight: bold;
    text-shadow: 0 0 2px white, 0 0 2px white;
}

