/**
 * 拖拽排序样式
 * 用于卡片视图的拖拽排序功能
 * 原因：外置内联样式，优化首屏加载性能
 * 相关文件：views/stats/card.html
 */

/* 拖拽手柄样式 - 默认隐藏，开启拖拽模式后显示 */
.drag-handle {
    display: none;
    min-width: 20px;
    min-height: 20px;
    padding: 4px;
    align-items: center;
    justify-content: center;
}

/* 拖拽模式开启时显示手柄 */
.drag-mode-enabled .drag-handle {
    display: flex;
    opacity: 0.3; /* 默认稍微可见，方便用户发现 */
}

.drag-mode-enabled .server-card:hover .drag-handle {
    opacity: 0.7; /* hover 时更明显 */
}

.drag-mode-enabled .server-card.sortable-chosen .drag-handle,
.drag-mode-enabled .server-card.sortable-drag .drag-handle {
    opacity: 1 !important;
    cursor: grabbing !important;
}

/* 拖拽禁用时的提示 - 使用伪元素简化 */
.drag-disabled {
    cursor: not-allowed !important;
    position: relative;
}

.drag-disabled:hover::after {
    content: '拖拽已禁用';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* 拖拽动画增强 */
.sortable-ghost {
    opacity: 0.5;
    background: rgba(99, 102, 241, 0.08);
    border: 2px dashed rgba(99, 102, 241, 0.6);
}

.sortable-drag {
    opacity: 0.95 !important;
    transform: scale(1.01);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: none !important; /* 拖拽时禁用过渡，避免延迟感 */
}

/* 拖拽手柄旋转样式 */
.drag-handle i {
    transform: rotate(90deg) !important;
    pointer-events: none; /* 确保点击命中 .drag-handle 本身，避免事件停留在图标元素上导致 Sortable handle 匹配失败 */
}

.sortable-chosen {
    opacity: 0.8;
}

/* 拖拽时的过渡动画 - 调整为不影响拖拽的属性 */
.server-card {
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* 拖拽时禁用过渡效果，避免抖动 */
.dragging-active .server-card {
    transition: none;
}

/* 拖拽交互反馈样式 */
.server-card.drop-target {
    background-color: rgba(99, 102, 241, 0.1) !important;
    border: 2px solid rgba(99, 102, 241, 0.5) !important;
    /* 移除transform避免抖动 */
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    /* 添加过渡效果使变化更平滑 */
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.server-card.dragging-item {
    opacity: 0.95;
    transform: scale(1.01);
    z-index: 1000;
    transition: none !important;
}

/* 交换动画 */
.server-card.swap-animation {
    animation: swapPulse 0.3s ease-in-out;
}

@keyframes swapPulse {
    0% {
        background-color: transparent;
        opacity: 1;
    }
    50% {
        background-color: rgba(99, 102, 241, 0.15);
        opacity: 0.9;
    }
    100% {
        background-color: transparent;
        opacity: 1;
    }
}

/* 拖拽时的指针 */
.dragging-active .server-card {
    cursor: grab;
}

.dragging-active .server-card.sortable-drag {
    cursor: grabbing !important;
}

/* Swap 插件 - 交换目标高亮样式 */
.sortable-swap-highlight {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border: 2px dashed rgba(99, 102, 241, 0.6) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: scale(0.98);
    transition: all 0.15s ease-out;
}

/* 交换完成动画 */
@keyframes swapComplete {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.02);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.server-card.swap-complete {
    animation: swapComplete 0.25s ease-out;
}
