/* 自定义工具类 */
.button-primary {
    background-color: #4361ee;
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-primary:hover {
    background-color: rgba(67, 97, 238, 0.9);
}

.button-primary:focus {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.5);
}

.button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-secondary {
    background-color: #e5e7eb;
    color: #1f2937;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-secondary:hover {
    background-color: #d1d5db;
}

.button-secondary:focus {
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.5);
}

.button-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.op-arrow {
    width: 44px;
    height: 44px;
    border: 2px solid #4361ee;
    border-radius: 50%;
    background: white;
    color: #4361ee;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.op-arrow:hover {
    background: #4361ee;
    color: white;
}

.op-arrow:disabled {
    border-color: #a0aec0;
    color: #a0aec0;
    cursor: not-allowed;
}

/* 可视化区域 */
.list-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.node-wrapper {
    position: absolute;
    width: 120px;
    height: 120px;
    transition: all 0.5s ease;
    z-index: 10;
}

.node-box {
    position: absolute;
    left: 0;
    top: 0;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
    background: #4cc9f0;
    border: 2px solid #4361ee;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, color 0.3s ease;
    z-index: 10;
}

.node-box.active {
    background: #f72585;
    border-color: #d61c77;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(247, 37, 133, 0.2);
}

.node-box.new {
    background: #2ecc71;
    border-color: #27ae60;
    animation: popIn 0.4s ease;
}

.node-box.staging {
    background: #fde68a;
    border: 2px dashed #f59e0b;
    color: #92400e;
}

.node-box.delete {
    background: #e63946;
    border-color: #c1121f;
    animation: fadeOut 0.4s ease forwards;
}

.node-box.null-node {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #9ca3af;
}

#nodesLayer {
    z-index: 10;
}

#arrowsLayer {
    z-index: 15;
    pointer-events: none;
}

.pointer-labels {
    position: absolute;
    top: -34px;
    left: 0;
    width: 80px;
    display: flex;
    justify-content: center;
    gap: 4px;
}

.pointer-label {
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
    z-index: 15;
}

.pointer-label.head { background: #7c3aed; }
.pointer-label.p { background: #4361ee; }
.pointer-label.q { background: #f72585; }
.pointer-label.t { background: #f59e0b; }

/* 隐藏旧版节点包装器内部的箭头 */
.node-wrapper .arrow-line {
    display: none !important;
}

/* 箭头层中的箭头 */
#arrowsLayer .arrow-line {
    position: absolute;
    height: 5px;
    background: linear-gradient(90deg, #4361ee 0%, #3a0ca3 100%);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transition: opacity 0.35s ease;
    opacity: 1;
    box-shadow: 0 0 6px rgba(67, 97, 238, 0.45);
}

#arrowsLayer .arrow-line.removing {
    opacity: 0 !important;
}

#arrowsLayer .arrow-line.level-1 {
    background: linear-gradient(90deg, #f72585 0%, #b5179e 100%);
    box-shadow: 0 0 6px rgba(247, 37, 133, 0.45);
}

#arrowsLayer .arrow-line.level-1 .fa-arrow-right {
    color: #f72585;
}

#arrowsLayer .arrow-line .fa-arrow-right {
    color: #3a0ca3;
    font-size: 18px;
    transform: translateX(5px);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.7));
}

/* 代码面板 */
.code-panel {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 12px;
    padding: 16px 20px;
    font-family: 'Consolas', 'Roboto Mono', monospace;
    font-size: 14px;
    overflow-x: auto;
    line-height: 1.6;
}

.code-line {
    padding: 2px 0;
    padding-left: 12px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-line.active {
    background: rgba(247, 37, 133, 0.2);
    border-left: 3px solid #f72585;
}

.code-comment { color: #6a9955; }
.code-keyword { color: #569cd6; }
.code-function { color: #dcdcaa; }
.code-variable { color: #9cdcfe; }
.code-operator { color: #d4d4d4; }

/* 说明文字 */
.help-text {
    background: #eff6ff;
    border-left: 4px solid #4361ee;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: #1e40af;
    line-height: 1.5;
}

/* 页脚 */
.page-footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    border-top: 1px solid #e1e4e8;
    font-size: 14px;
    background: #f9fafb;
}

.page-footer a {
    color: #4361ee;
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

/* 动画 */
@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.5); }
}

/* 响应式 */
@media (max-width: 640px) {
    #listViz {
        overflow-x: auto;
        overflow-y: hidden;
    }
    .node-wrapper {
        width: 60px;
        height: 60px;
    }
    .node-box {
        width: 48px;
        height: 48px;
        font-size: 13px;
    }
    .node-box.active {
        box-shadow: 0 0 0 3px rgba(247, 37, 133, 0.2);
    }
    .pointer-labels {
        top: -26px;
        width: 48px;
        gap: 2px;
    }
    .pointer-label {
        font-size: 9px;
        padding: 1px 4px;
    }
    #arrowsLayer .arrow-line {
        height: 4px;
    }
    #arrowsLayer .arrow-line .fa-arrow-right {
        font-size: 14px;
    }
    .code-panel {
        padding: 12px;
        font-size: 12px;
    }
}
