/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* 容器 */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 主区域 */
.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 面板控制按钮 */
.panel-controls {
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    box-sizing: border-box;
}

/* 画布控制按钮（保存/加载） */
.canvas-controls {
    display: flex;
    gap: 8px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-button {
    background-color: #444;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    margin: 0;
}

.panel-button:hover {
    background-color: #555;
}

.panel-button:active {
    background-color: #666;
}

/* 画布容器 */
.canvas-container {
    flex: 1;
    overflow: auto;
    background-color: white;
    position: relative;
    padding: 0;
    height: 100%;
}

#mindMapCanvas {
    display: block;
    border: 1px solid #eee;
    background-color: white;
}

/* 节点样式 */
.node {
    cursor: pointer;
    transition: all 0.2s;
}

.node text {
    font-family: Arial, sans-serif;
    font-size: 14px;
    fill: black;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.node.selected path:not(.left-semicircle):not(.right-semicircle) {
    /* 移除选中边框效果，使用底部横线替代 */
}

.node:hover path:not(.left-semicircle):not(.right-semicircle) {
    fill: #f0f0f0;
}

/* 半圆点击区域样式 */
.left-semicircle,
.right-semicircle {
    cursor: pointer;
    transition: fill 0.2s;
}

/* 连接线样式 */
.connection {
    fill: none;
    stroke-width: 2px;
}

/* 箭头样式 */
.arrow {
    stroke-width: 1px;
}

/* 折叠/展开图标 */
.toggle-icon {
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    fill: black;
}

/* 样式面板 */
.style-panel {
    width: 250px;
    background-color: #f0f0f0;
    padding: 15px;
    border-left: 1px solid #ddd;
    overflow-y: auto;
    /* 确保PC端保持垂直布局 */
    display: block;
}

/* 画布控制按钮（仅在手机端显示） */
.canvas-controls {
    display: none;
}

.style-panel h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
}

.style-group {
    margin-bottom: 15px;
}

.style-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
}

/* 自定义颜色选择器的颜色样例样式 */
.custom-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 50%;
}

.custom-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.custom-color-picker::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

/* 颜色调色板样式 */
.color-palette {
    display: flex;
    gap: 12px;
    margin-top: 5px;
    padding: 10px;
    background-color: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    min-height: 55px;
    width: 100%;
}

/* 确保调色板内容不会溢出 */
.color-palette {
    overflow: visible;
    box-sizing: border-box;
}

/* 普通颜色样例容器 */
.color-palette .color-swatches-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    grid-template-rows: repeat(2, 18px);
    align-items: center;
    justify-items: center;
    flex-shrink: 1;
    width: 100%;
    min-width: 0;
}

/* 自定义颜色选择器特殊定位 */
.color-palette .custom-color-picker {
    margin-left: auto;
    flex-shrink: 0;
    align-self: center;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-swatch:hover {
    transform: scale(1.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 自定义颜色选择器样式 */
.custom-color-picker {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    padding: 2px;
    flex-shrink: 0;
    max-width: 34px;
    max-height: 34px;
    display: inline-block;
}

.custom-color-picker:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    border-color: #aaa;
}

.style-group input[type="number"] {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.style-group select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
}

/* 响应式设计 */
/* 针对iPhone SE等小屏设备的专门优化 */
@media (max-width: 375px) {
    /* 调整画布容器高度 */
    .canvas-container {
        max-height: 55vh;
    }
    
    /* 调整样式面板高度，确保所有内容可见且不浪费空间 */
    .style-panel {
        height: auto;
        max-height: 35vh;
    }
}

@media (max-width: 768px) {
    .main-area {
        flex-direction: column;
        height: 100vh;
        display: flex;
    }
    
    /* 画布容器 - 上半部分 */
    .canvas-container {
        flex: 1;
        min-height: 50vh;
        max-height: none;
        overflow: hidden;
    }
    
    /* 画布控制按钮 - 仅在手机端显示 */
    .canvas-controls {
        display: flex;
        flex-direction: row;
        justify-content: center;
        padding: 8px;
        gap: 12px;
        background-color: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid #ddd;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    /* 隐藏手机端样式面板中的按钮（已移到画布顶部） */
    .style-panel .panel-controls {
        display: none;
    }
    
    .panel-button {
        padding: 10px 24px;
        font-size: 16px;
    }
    
    /* 样式面板 - 下半部分 */
    .style-panel {
        width: 100%;
        height: auto;
        max-height: none;
        border-left: none;
        border-top: 1px solid #ddd;
        overflow-y: hidden;
        position: relative;
        background-color: #f8f8f8;
        /* 手机端使用网格布局 */
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
        gap: 2px;
        padding: 2px;
        align-content: flex-start;
        flex-shrink: 1;
    }
    
    /* 样式面板标题 - 手机端隐藏，节省空间 */
    .style-panel h3 {
        display: none;
    }
    
    /* 颜色设置组 - 手机端网格项 */
    .style-panel .style-group {
        margin-bottom: 0;
        padding: 2px 3px;
        background-color: white;
        border-radius: 3px;
        border: 1px solid #eee;
        min-height: auto;
        margin: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    /* 字体和字体大小 - 合并为一行 */
    .style-panel .style-group#fontSettings {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 3px;
        padding: 2px 3px;
        align-items: center;
    }
    
    .style-panel .style-group#fontSettings .font-size-group,
    .style-panel .style-group#fontSettings .font-family-group {
        margin-bottom: 0;
        margin-top: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    
    .style-group label {
        font-size: 11px;
        margin-bottom: 1px;
        margin-top: 1px;
        display: block;
        padding: 0;
        line-height: 1.2;
    }
    
    /* 颜色调色板 - 手机端优化 */
    .color-palette {
        flex-direction: row;
        gap: 3px;
        padding: 1px 2px;
        min-height: auto;
        width: 100%;
        margin: 0;
        height: auto;
        align-items: center;
    }
    
    .color-swatches-container {
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
        min-width: 0;
        width: 100%;
        height: auto;
        grid-template-rows: auto;
    }
    
    .color-swatch {
        width: 12px;
        height: 12px;
    }
    
    /* 自定义颜色选择器 - 手机端优化 */
    .custom-color-picker {
        width: 22px;
        height: 22px;
    }
    
    /* 字体大小输入框 - 手机端优化 */
    .style-group input[type="number"] {
        padding: 2px 2px;
        font-size: 11px;
        width: 100%;
        box-sizing: border-box;
        height: 24px;
    }
    
    /* 字体选择下拉框 - 手机端优化 */
    .style-group select {
        padding: 2px 2px;
        font-size: 11px;
        width: 100%;
        box-sizing: border-box;
        height: 24px;
    }
    
    /* 缩略图画布 - 手机端优化 */
    .thumbnail-canvas {
        bottom: 10px;
        left: 10px;
        max-width: 120px;
        max-height: 120px;
    }
}

/* 缩略图画布样式 */
.thumbnail-canvas {
    position: absolute;
    bottom: 20px;
    left: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 100;
    pointer-events: auto;
}

/* 缩略图视口矩形样式 */
.thumbnail-viewport {
    fill: #0066cc;
    fill-opacity: 0.2;
    stroke: none;
    opacity: 0.7;
}

/* 自定义保存弹窗 */
.save-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.save-dialog.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.save-dialog-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
}

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

.save-dialog-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-button:hover {
    background-color: #f0f0f0;
    color: #333;
}

.save-dialog-body {
    padding: 20px;
}

.save-option {
    margin-bottom: 15px;
}

.save-option:last-child {
    margin-bottom: 0;
}

.save-option label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.save-option select,
.save-option input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.save-option select:focus,
.save-option input:focus {
    outline: none;
    border-color: #444;
    box-shadow: 0 0 0 2px rgba(68, 68, 68, 0.1);
}

.save-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background-color: #fafafa;
    border-radius: 0 0 8px 8px;
}

.cancel-button,
.confirm-button {
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-button {
    background-color: white;
    border: 1px solid #ddd;
    color: #555;
}

.cancel-button:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

.confirm-button {
    background-color: #444;
    border: none;
    color: white;
}

.confirm-button:hover {
    background-color: #555;
}

/* 自定义颜色选择器面板样式 */
.custom-color-picker-panel {
    display: none;
    position: absolute;
    background-color: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    width: 200px;
    z-index: 1001;
    font-family: Arial, sans-serif;
    padding: 10px;
    box-sizing: border-box;
}

.custom-color-picker-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* 颜色渐变区域 */
.color-gradient {
    position: relative;
    width: 100%;
    height: 150px;
    margin-bottom: 10px;
    background: linear-gradient(to top, #000000, transparent),
                linear-gradient(to right, #ffffff, #ff0000);
    cursor: crosshair;
}

.color-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: crosshair;
}

.color-picker-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 2;
    top: 0;
    left: 100%;
}

/* 彩虹色条 */
.rainbow-bar {
    position: relative;
    width: 100%;
    height: 20px;
    margin-bottom: 10px;
    background: linear-gradient(to right, 
        #ff0000, #ff7f00, #ffff00, #00ff00, 
        #0000ff, #4b0082, #9400d3);
    cursor: pointer;
}

.rainbow-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.rainbow-picker-dot {
    position: absolute;
    top: -5px;
    width: 2px;
    height: 30px;
    background-color: white;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 2;
    left: 0;
}

/* RGB输入 */
.rgb-inputs {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 5px;
}

.rgb-input {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rgb-input input {
    width: 100%;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    text-align: center;
    margin-bottom: 2px;
}

.rgb-input label {
    font-size: 12px;
    color: #666;
}

/* 颜色预览和关闭按钮 */
.color-preview-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-preview-box {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background-color: #ffffff;
}

.close-button {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-button:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
