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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #F7F4EF 0%, #E7E1D7 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* 导航栏后的内容区域使用flex居中 */
body > .page-container {
    min-height: calc(100vh - 50px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 页面容器 */
.page-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 20px;
    width: 100%;
}

/* 头部样式 */
.header {
    text-align: center;
    background: white;
    padding: 50px 40px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 32px;
    color: #1F2421;
    margin-bottom: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.header .subtitle {
    font-size: 15px;
    color: #5C635D;
    font-weight: 300;
}

/* 搜索区域 */
.search-section {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.search-box {
    display: flex;
    gap: 15px;
    max-width: 100%;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #E7E1D7;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: #C4612F;
    box-shadow: 0 0 0 3px rgba(196, 97, 47, 0.1);
}

.depth-select {
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #E7E1D7;
    border-radius: 12px;
    outline: none;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 100px;
}

.depth-select:focus {
    border-color: #C4612F;
    box-shadow: 0 0 0 3px rgba(196, 97, 47, 0.1);
}

.search-box button {
    padding: 15px 40px;
    background: #C4612F;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(196, 97, 47, 0.3);
}

.search-box button:hover {
    background: #A94E22;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(196, 97, 47, 0.4);
}

.search-box button:active {
    transform: translateY(0);
}

.search-box button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.search-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #5C635D;
    font-weight: 300;
}

/* 结果区域 */
.result-section {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 500px;
    position: relative;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: #5C635D;
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
}

/* 错误状态 */
.error-state {
    text-align: center;
    padding: 100px 20px;
    color: #f56c6c;
}

.error-state .error-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.error-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

.error-state button {
    padding: 10px 30px;
    background: #C4612F;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

/* 树形图容器 */
.tree-container {
    overflow: auto;
    padding: 20px 0;
    position: relative;
    cursor: grab;
    user-select: none;
    min-height: 100vh;
}

.tree-container:active {
    cursor: grabbing;
}

/* 全屏模式样式 */
.tree-container:fullscreen {
    background: white;
    padding: 40px;
}

.tree-container:-webkit-full-screen {
    background: white;
    padding: 40px;
}

.tree-container:-moz-full-screen {
    background: white;
    padding: 40px;
}

.tree-container:-ms-fullscreen {
    background: white;
    padding: 40px;
}

/* 树形图包裹层 - 支持缩放 */
.tree-wrapper {
    display: inline-block;
    min-width: 100%;
    transform-origin: top left;
    padding: 40px;
    /* 提高渲染质量 - 防止缩放后模糊 */
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    text-rendering: geometricPrecision;
    /* 强制使用更清晰的缩放算法 */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
}

/* 树形结构 */
.tree-level {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.tree-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.tree-children {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
    position: relative;
}

/* 从父节点向下的竖线 */
.connector-v {
    width: 2px;
    height: 20px;
    background: #C4612F;
    margin: 3px 0 0 0;
    position: relative;
}

/* 使用伪元素画横线+竖线到子节点 */
.tree-children > .tree-branch {
    position: relative;
}

/* 左子节点：从父节点中心向左下画线 */
.tree-children > .tree-branch:first-child::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: calc(50% + 20px);
    height: 2px;
    background: #C4612F;
    transform-origin: left center;
}

/* 左子节点：竖线向下 */
.tree-children > .tree-branch:first-child::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #C4612F;
    transform: translateX(-50%);
}

/* 右子节点：从父节点中心向右下画线 */
.tree-children > .tree-branch:last-child::before {
    content: '';
    position: absolute;
    top: -20px;
    right: 50%;
    width: calc(50% + 20px);
    height: 2px;
    background: #C4612F;
    transform-origin: right center;
}

/* 右子节点：竖线向下 */
.tree-children > .tree-branch:last-child::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #C4612F;
    transform: translateX(-50%);
}

/* 如果只有一个子节点，直接向下 */
.tree-children > .tree-branch:only-child::before {
    display: none;
}

.tree-children > .tree-branch:only-child::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #C4612F;
    transform: translateX(-50%);
}


/* 节点卡片 - 固定高度统一布局 */
.tree-node {
    background: white;
    border: 2px solid #E7E1D7;
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 120px;
    max-width: 120px;
    min-height: 85px;
    max-height: 85px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: all 0.3s;
    position: relative;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* 提高文字渲染质量 - 使用亚像素抗锯齿 */
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    text-rendering: geometricPrecision;
    /* 防止模糊 - 强制创建独立合成层 */
    will-change: transform;
    isolation: isolate;
}

.tree-node:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 10;
}

/* 根节点特殊样式 */
.tree-node.root {
    border-color: #C4612F;
    border-width: 2px;
    background: #FBF9F5;
}

/* 已成团节点 */
.tree-node.completed {
    border-color: #67C23A;
}

/* 空位节点 */
.tree-node.empty {
    background: #f9f9f9;
    border: 2px dashed #ccc;
    text-align: center;
    justify-content: center;
}

.tree-node.empty:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 节点姓名 */
.node-name {
    font-size: 15px;
    font-weight: bold;
    color: #1F2421;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    width: 100%;
}

/* 节点手机号 */
.node-phone {
    font-size: 12px;
    color: #5C635D;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    width: 100%;
}

/* 级别标签 */
.node-level {
    display: inline-block;
    background: #C4612F;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}

/* 状态标签 */
.node-status {
    font-size: 12px;
    color: #5C635D;
    display: inline-block;
    margin-left: 3px;
    font-weight: bold;
}

.node-status.completed {
    color: #67C23A;
}

/* 加入时间 */
.node-time {
    font-size: 11px;
    color: #909399;
    display: block;
    width: 100%;
    text-align: center;
}

/* 位置标签（右上角）*/
.position-tag {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #F2E3D6;
    color: #C4612F;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
}

/* 用户ID标签（左上角）*/
.user-id-tag {
    position: absolute;
    top: -10px;
    left: -10px;
    background: #E7E1D7;
    color: #5C635D;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
}

/* 节点信息行 */
.node-row {
    margin-bottom: 3px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.node-row:last-child {
    margin-bottom: 0;
}

/* 姓名行 - 左右布局 */
.node-name-row {
    justify-content: space-between;
}

/* 底部行 - 居中 */
.node-bottom-row {
    justify-content: center;
}

.node-row:last-child {
    margin-bottom: 0;
}

.node-name-row {
    text-align: center;
}

.node-bottom-row {
    text-align: center;
}

/* 缩放控制按钮 */
.zoom-controls {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.zoom-btn {
    width: 45px;
    height: 45px;
    background: white;
    border: 2px solid #E7E1D7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    color: #C4612F;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.zoom-btn:hover {
    background: #C4612F;
    color: white;
    transform: scale(1.1);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-level {
    text-align: center;
    font-size: 12px;
    color: #5C635D;
    margin-top: 5px;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #C4612F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: #5C635D;
    font-size: 13px;
    margin-top: 40px;
    font-weight: 300;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .page-container {
        padding: 20px 15px;
    }

    .header {
        padding: 40px 30px;
    }

    .header h1 {
        font-size: 24px;
    }

    .header .subtitle {
        font-size: 13px;
    }

    .search-section {
        padding: 25px 20px;
    }

    .search-box {
        flex-direction: column;
        max-width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .depth-select {
        width: 100%;
    }

    .search-box button {
        width: 100%;
    }

    /* 手机端节点 */
    .tree-node {
        min-width: 90px;
        max-width: 90px;
        min-height: 70px;
        max-height: 70px;
        padding: 5px 6px;
        font-size: 10px;
    }

    .node-name {
        font-size: 12px;
    }

    .node-phone {
        font-size: 9px;
    }

    .node-level {
        padding: 1px 4px;
        font-size: 8px;
    }

    .node-time {
        font-size: 8px;
    }

    .position-tag {
        font-size: 7px;
        padding: 1px 3px;
    }

    .tree-children {
        gap: 20px;
        margin-top: 15px;
    }

    .connector-v {
        height: 15px;
        width: 2px;
    }

    /* 手机端连接线 */
    .tree-children > .tree-branch:first-child::before {
        width: calc(50% + 15px);
    }

    .tree-children > .tree-branch:last-child::before {
        width: calc(50% + 15px);
    }

    .tree-children > .tree-branch::after {
        height: 15px;
        top: -15px;
    }

    /* 手机端缩放按钮 */
    .zoom-controls {
        bottom: 60px;
        right: 10px;
    }

    .zoom-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .zoom-level {
        font-size: 11px;
    }
}

/* 平板端适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .tree-node {
        min-width: 95px;
        max-width: 95px;
        min-height: 70px;
        max-height: 70px;
        padding: 5px 7px;
    }

    .tree-children {
        gap: 25px;
    }
}

/* 大屏幕优化 */
@media (min-width: 1400px) {
    .page-container {
        max-width: 1600px;
    }

    .tree-node {
        min-width: 105px;
        max-width: 105px;
        min-height: 70px;
        max-height: 70px;
        padding: 7px 9px;
    }

    .tree-children {
        gap: 35px;
    }
}

/* 滚动条样式 */
.tree-container::-webkit-scrollbar {
    height: 8px;
}

.tree-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tree-container::-webkit-scrollbar-thumb {
    background: #C4612F;
    border-radius: 4px;
}

.tree-container::-webkit-scrollbar-thumb:hover {
    background: #A94E22;
}
