/* Modern Drag and Drop Styles */

/* Base draggable item styles */
.tree-item[draggable="true"] {
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
}

.tree-item[draggable="true"]:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Active dragging state */
.tree-item.dragging {
    opacity: 0.6;
    transform: rotate(3deg) scale(0.95);
    z-index: 1000;
    box-shadow: 0 8px 16px rgba(79, 108, 247, 0.3);
    border: 2px solid rgba(79, 108, 247, 0.4);
    background: linear-gradient(135deg, rgba(79, 108, 247, 0.1) 0%, rgba(59, 95, 226, 0.05) 100%);
}

/* Drag over states */
.tree-item.drag-over {
    background-color: rgba(79, 108, 247, 0.08);
    transform: translateX(5px);
}

.tree-item.drag-over-folder {
    background: linear-gradient(135deg, rgba(79, 108, 247, 0.15) 0%, rgba(59, 95, 226, 0.1) 100%);
    border: 2px dashed rgba(79, 108, 247, 0.6);
    border-radius: 8px;
    transform: translateX(5px) scale(1.02);
    box-shadow: 0 4px 12px rgba(79, 108, 247, 0.2);
    position: relative;
    animation: pulse-border 1.5s ease-in-out infinite;
}

/* Folder drop zone indicator */
.tree-item.folder.drag-over-folder::before {
    content: "📥";
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    animation: bounce-folder 0.8s ease-in-out infinite;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(79, 108, 247, 0.3));
}

.tree-item.folder.drag-over-folder::after {
    content: attr(data-drop-text);
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: rgba(79, 108, 247, 0.8);
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
    animation: fade-in-out 2s ease-in-out infinite;
}

/* Enhanced file and folder emojis during drag */
.tree-item.dragging .emoji-icon {
    animation: wiggle-emoji 0.3s ease-in-out infinite;
    transform: scale(1.2);
    filter: brightness(1.3) drop-shadow(0 3px 6px rgba(79, 108, 247, 0.4));
}

/* Drag ghost improvements */
.tree-item.dragging span {
    color: rgba(79, 108, 247, 0.9);
    font-weight: 500;
}

/* Drop zone highlighting for root */
.tree-container.drag-over-root {
    background: linear-gradient(135deg, rgba(79, 108, 247, 0.03) 0%, rgba(59, 95, 226, 0.02) 100%);
    border-radius: 8px;
    position: relative;
}

.tree-container.drag-over-root::before {
    content: "💼 " attr(data-main-drop-text);
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 12px;
    color: rgba(79, 108, 247, 0.7);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 15px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    animation: slide-in-right 0.3s ease-out;
    border: 1px solid rgba(79, 108, 247, 0.2);
    box-shadow: 0 2px 8px rgba(79, 108, 247, 0.1);
}

/* Smooth animations */
@keyframes pulse-border {
    0%, 100% {
        border-color: rgba(79, 108, 247, 0.6);
        box-shadow: 0 4px 12px rgba(79, 108, 247, 0.2);
    }
    50% {
        border-color: rgba(79, 108, 247, 0.8);
        box-shadow: 0 6px 16px rgba(79, 108, 247, 0.3);
    }
}

@keyframes bounce-folder {
    0%, 100% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(1.2);
    }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

@keyframes fade-in-out {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes slide-in-right {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Improved visual feedback for valid/invalid drop targets */
.tree-item.invalid-drop-target {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.1) 0%, rgba(192, 57, 43, 0.05) 100%);
    border: 2px dashed rgba(231, 76, 60, 0.4);
    cursor: not-allowed;
}

.tree-item.invalid-drop-target::after {
    content: attr(data-invalid-text);
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: rgba(231, 76, 60, 0.8);
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tree-item[draggable="true"]:hover {
        transform: none;
    }
    
    .tree-item.drag-over-folder::after {
        display: none;
    }
    
    .tree-container.drag-over-root::before {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* Enhanced selection state during drag operations */
.tree-item.selected.dragging {
    background: linear-gradient(135deg, rgba(79, 108, 247, 0.2) 0%, rgba(59, 95, 226, 0.15) 100%);
}

/* Loading state for async operations */
.tree-item.moving {
    position: relative;
    pointer-events: none;
}

.tree-item.moving::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(79, 108, 247, 0.2), transparent);
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Success animation after successful move */
.tree-item.move-success {
    animation: success-flash 0.6s ease-out;
}

@keyframes success-flash {
    0% {
        background-color: rgba(46, 204, 113, 0.3);
        transform: scale(1.05);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}