/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden; /* 禁止滚动 */
}

body {
    background-color: #000000;
    color: #ffffff;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0; /* 移除默认边距 */
    padding: 0; /* 移除默认内边距 */
}

.container {
    max-width: 1024px;
    width: 100%;
    padding: 20px;
}

/* 标签页样式 */
header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px; /* 标签页与灯泡按钮之间的间距 */
}

.tabs {
    display: flex;
    align-items: center;
    /* 移除间隔，使按钮直接连接 */
    gap: 0;
    border-radius: 20px; /* 药丸形状整体圆角 */
    overflow: hidden;
}

.tab {
    padding: 8px 16px;
    background-color: #e5e7eb;
    border: none;
    /* 移除单独按钮的圆角 */
    border-radius: 0;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

/* 给第一个按钮添加左侧圆角 */
.tab:first-child {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
}

/* 给最后一个按钮添加右侧圆角 */
.tab:last-child {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
}

.tab.active {
    background-color: #3b82f6; /* 从绿色(#10b981)改为蓝色(#3b82f6) */
    color: white;
}

.info-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #555555;
    background-color: #222222;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #dddddd;
}

.info-button:hover {
    background-color: #f3f4f6;
}

/* 控制区域样式 */
.controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.distance-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.label {
    font-weight: 500;
    font-size: 14px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 200px;
}

input[type="range"] {
    flex: 1;
}

#distance-value {
    min-width: 60px;
    font-size: 14px;
}

.reset-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #555555;
    border-radius: 4px;
    background-color: #222222;
    font-size: 14px;
    cursor: pointer;
    color: #dddddd;
}

.reset-button:hover {
    background-color: #f3f4f6;
}

/* 等距离控制 */
.spacing-control {
    margin-bottom: 16px;
}

.spacing-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

/* 移除层叠的容器样式，直接使用大背景 */
.planting-container {
    /* 移除背景色、边框和阴影 */
    padding: 16px;
}

.planting-view {
    display: none;
}

.planting-view.active {
    display: block;
}

/* 植树控制区域 */
.planting-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.add-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background-color: #10b981;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

.add-button:hover {
    background-color: #059669;
}

.toggle-button {
    padding: 8px 16px;
    border: 1px solid #10b981;
    border-radius: 4px;
    background-color: #222222;
    color: #10b981;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s ease;
}

.toggle-button:hover {
    background-color: rgba(240, 253, 244, 0.1);
    color: #10b981;
}

.toggle-button:focus {
    outline: none;
    background-color: #222222;
    color: #10b981;
}

/* 种植模式选择器 */
.planting-mode-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    margin-right: 16px;
}

.mode-label {
    color: #dddddd;
    font-size: 14px;
}

#linear-planting-mode {
    padding: 6px 10px;
    background-color: #222222;
    color: #dddddd;
    border: 1px solid #10b981;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

#linear-planting-mode:focus {
    border-color: #059669;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* 统计数据样式 */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 14px;
    font-weight: 500;
}

.stat-value {
    padding: 4px 12px; /* 增加水平内边距，使形状更加椭圆 */
    border-radius: 20px; /* 增大圆角半径，形成椭圆形状 */
    font-size: 14px;
    font-weight: 500;
    display: inline-block; /* 确保标签宽度适应内容 */
    text-align: center; /* 文本居中 */
}

.stat-value.green {
    background-color: #d1fae5;
    color: #065f46;
}

.stat-value.blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.stat-value.purple {
    background-color: #ede9fe;
    color: #5b21b6;
}

/* 视图区域 */
.view-area {
    position: relative;
    height: 500px;
    margin-bottom: 16px;
    border-radius: 4px;
    /* 移除 overflow: hidden 属性，防止元素被截断 */
    padding: 0 15px; /* 添加左右内边距，确保树木完全显示 */
}

/* 线性植树视图 */
#linear-view {
    position: relative;
}

/* 移除黄色线条样式 */

.tree {
    position: absolute;
    bottom: 116px;
    transform: translateX(-50%);
    cursor: grab;
    z-index: 1;
    user-select: none;
}

.tree.dragging {
    cursor: grabbing;
    z-index: 10;
}

.tree-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 4px 8px;
    background-color: #222222;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 1px 2px rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    color: #dddddd;
}

.tree-delete {
    position: absolute;
    top: calc(100% + 30px); /* 调整位置到树标签下方 */
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #fee2e2;
    color: #b91c1c;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5; /* 确保删除按钮始终显示在前面 */
}

.tree-delete:hover {
    background-color: #fecaca;
}

.distance-label {
    position: absolute;
    bottom: 120px;
    left: 50%; /* 确保使用百分比定位 */
    padding: 2px 6px; /* 减小内边距，使标签缩小 */
    background-color: #dbeafe;
    border-radius: 10px; /* 减小圆角半径 */
    font-size: 10px; /* 减小字体大小 */
    font-weight: 500;
    color: #1e40af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    text-align: center; /* 确保文本居中 */
    white-space: nowrap; /* 防止文本换行 */
    margin-left: 0 !important; /* 清除可能的左边距 */
    margin-right: 0 !important; /* 清除可能的右边距 */
    transform: translateX(-50%) scale(0.85); /* 水平居中并缩放 */
}

/* 环形植树视图 */
#circular-view {
    display: flex;
    justify-content: center;
    align-items: center;
}

#circular-canvas {
    width: 100%;
    height: 100%;
}

.circular-tree {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 1;
    cursor: grab;
}

.circular-tree.dragging {
    cursor: grabbing;
    z-index: 10;
}



/* 对话框 */
.dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.dialog.active {
    display: flex;
}

.dialog-content {
    background-color: #222222;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(255, 255, 255, 0.1);
    color: #dddddd;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.dialog-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

.dialog-body {
    padding: 16px;
}

.info-section {
    margin-top: 16px;
}

.info-section h3 {
    margin-bottom: 8px;
    font-weight: 500;
}

.info-section ul {
    margin-left: 24px;
    font-size: 14px;
    color: #6b7280;
}

.info-note {
    margin-top: 16px;
    padding: 12px;
    background-color: #333333;
    border-radius: 4px;
    font-size: 14px;
    color: #dddddd;
}

.back-button {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 20px);
    left: 20px;
    width: 32px;
    height: 32px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.back-button:hover {
    opacity: 0.8;
    transform: none;
    box-shadow: none;
}

.back-button i {
    color: white;
    font-size: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .distance-control {
        width: 100%;
    }
    
    .slider-container {
        width: 100%;
    }
    
    .planting-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats {
        width: 100%;
    }
}
