/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 头部样式 */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 8px 15px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #3d566e;
}

.btn.primary {
    background-color: #3498db;
}

.btn.primary:hover {
    background-color: #2980b9;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.mode-selector select {
    padding: 5px 10px;
    border-radius: 4px;
    border: none;
    background-color: white;
    color: #333;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* 图片容器 - 修复滚动问题 */
.image-container {
    flex: 1;
    position: relative;
    overflow: auto; /* 确保始终可以滚动 */
    background-color: #2c3e50;
    transition: flex 0.3s ease;
    padding: 10px;
}

/* 图片包装器，用于控制图片在容器中的位置 */
.image-wrapper {
    position: relative;
    display: block;
    margin: 0 auto; /* 水平居中 */
}

/* 原始大小模式 - 修复裁剪问题 */
.image-container.image-original {
    justify-content: flex-start; /* 左上角对齐 */
    align-items: flex-start;
    padding: 0; /* 去掉内边距，确保全图显示 */
}

.image-container.image-original .image-wrapper {
    display: block;
    margin: 0; /* 原始大小模式下不需要居中 */
    width: auto;
    height: auto;
    min-width: min-content;
    min-height: min-content;
}

.image-container.image-original #mainImage {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: none;
}

/* 适应页面模式 */
.image-container.image-fit {
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-container.image-fit .image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-container.image-fit #mainImage {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 标记点容器 - 修复覆盖区域问题 */
.markers-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* 标记点样式 */
.marker {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #e74c3c;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    pointer-events: all;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    font-size: 8px;
    transform: translate(-50%, -50%);
    transition: all 0.2s;
    z-index: 10;
}

.marker.green {
  background-color: #2ecc71;
}

.marker.red {
  background-color: #2e74c3c;
}

.marker:hover {
    background-color: #c0392b;
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 100;
}

.marker.selected {
    background-color: #3498db;
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 100;
}

.marker.dragging {
    z-index: 200;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

/* 右侧面板 - 修复问题2：使用宽度变化而不是transform */
.side-panel {
    width: 250px;
    background-color: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden; /* 收起时隐藏内容 */
    flex-shrink: 0; /* 防止面板被压缩 */
}

/* 修复问题2：收起时宽度为0 */
.side-panel.collapsed {
    width: 0;
}

.panel-header {
    padding: 15px;
    background-color: #34495e;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 200px; /* 确保标题栏在收起时保持宽度 */
}

.panel-header h3 {
    font-size: 1.1rem;
    white-space: nowrap; /* 防止文本换行 */
}

.count {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 200px; /* 确保内容区域最小宽度 */
}

.markers-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.marker-item {
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap; /* 防止文本换行 */
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-item:hover {
    background-color: #e9ecef;
    transform: translateX(-2px);
}

.marker-item.selected {
    background-color: #e3f2fd;
    border-left-color: #3498db;
}

.marker-item .title {
    font-weight: 600;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-item .coordinates {
    font-size: 0.8rem;
    color: #666;
}

.empty-list {
    text-align: center;
    padding: 30px 10px;
    color: #7f8c8d;
}

.empty-list i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #bdc3c7;
}

.hint {
    font-size: 0.8rem;
    margin-top: 5px;
}

.panel-actions {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px; /* 确保按钮区域最小宽度 */
}

/* 详细信息面板 */
.detail-panel {
    position: absolute;
    width: 250px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.detail-header {
    padding: 15px;
    background-color: #3498db;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-header h3 {
    font-size: 1.1rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.save-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.save-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.detail-content {
    padding: 15px;
}

.detail-row {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
}

.detail-label {
    font-weight: 600;
    width: 100px;
    color: #555;
}

.detail-value {
    flex: 1;
    color: #333;
}

#detailDesc {
    margin-top: 5px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* 输出面板 */
.output-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 300px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.output-header {
    padding: 15px;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
/* 输出面板内容 - textarea 样式 */
.output-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9rem;
    background-color: #f8f9fa;
    white-space: pre-wrap;
    word-break: break-all;
    border: none;           /* 移除默认边框 */
    resize: vertical;       /* 允许垂直调整大小（可选） */
    outline: none;          /* 移除焦点轮廓 */
    line-height: 1.5;
    color: #333;
    width: 100%;
    min-height: 200px;      /* 保证至少显示多行 */
}

/* 可选：聚焦时的样式提示 */
.output-content:focus {
    background-color: #fff;
    box-shadow: inset 0 0 0 2px #3498db;
}

/* 加载指示器 */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .controls {
        width: 100%;
        justify-content: space-between;
    }

    .side-panel {
        position: absolute;
        right: 0;
        height: 100%;
        z-index: 100;
    }

    .side-panel.collapsed {
        width: 0;
    }

    .side-panel:not(.collapsed) {
        width: 200px;
    }

    .output-panel {
        width: calc(100% - 40px);
    }
}