/* Unified Drag and Drop Styles */

/* Base drag handle styling */
.drag-handle {
    cursor: grab;
    color: #6c757d;
    font-size: 18px;
    padding: 8px;
    transition: all 0.2s ease;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.drag-handle:hover {
    color: #495057;
    background-color: rgba(108, 117, 125, 0.1);
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Step item during drag */
.step-item.dragging {
    opacity: 0.8;
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border: 2px solid #007bff;
    background-color: #f8f9fa;
    transition: all 0.2s ease;
}

/* Placeholder styling */
.step-placeholder {
    border: 2px dashed #007bff;
    border-radius: 8px;
    margin: 8px 0;
    background-color: rgba(0, 123, 255, 0.05);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.step-placeholder::before {
    content: "Rilascia qui";
    color: #007bff;
    font-size: 14px;
    font-weight: 500;
    opacity: 0.7;
}

/* Dark theme support */
[data-theme="dark"] .step-item.dragging {
    background-color: #2c3e50;
    border-color: #3498db;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .step-placeholder {
    border-color: #3498db;
    background-color: rgba(52, 152, 219, 0.1);
}

[data-theme="dark"] .step-placeholder::before {
    color: #3498db;
}

[data-theme="dark"] .drag-handle {
    color: #adb5bd;
}

[data-theme="dark"] .drag-handle:hover {
    color: #dee2e6;
    background-color: rgba(173, 181, 189, 0.1);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .drag-handle {
        font-size: 20px;
        padding: 12px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .step-placeholder {
        min-height: 80px;
    }
    
    .step-placeholder::before {
        font-size: 16px;
    }
}

/* Prevent text selection during drag */
.step-item.dragging,
.step-item.dragging * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Smooth transitions for reordering */
.step-item {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Disabled state */
.step-item[draggable="false"] .drag-handle {
    cursor: not-allowed;
    opacity: 0.5;
    color: #dc3545;
}

[data-theme="dark"] .step-item[draggable="false"] .drag-handle {
    color: #e74c3c;
}

/* Animation for successful drop */
@keyframes dropSuccess {
    0% {
        transform: scale(1.05);
        background-color: rgba(40, 167, 69, 0.2);
    }
    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

.step-item.drop-success {
    animation: dropSuccess 0.3s ease;
}

/* Error state animation */
@keyframes dropError {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.step-item.drop-error {
    animation: dropError 0.5s ease;
    border-color: #dc3545 !important;
}

/* Loading state during save */
.step-item.saving {
    opacity: 0.7;
    pointer-events: none;
}

.step-item.saving .drag-handle {
    cursor: wait;
}

/* Accessibility improvements */
.drag-handle[aria-label] {
    position: relative;
}

.drag-handle:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

[data-theme="dark"] .drag-handle:focus {
    outline-color: #3498db;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .step-placeholder {
        border-width: 3px;
        border-color: #000;
    }
    
    .step-item.dragging {
        border-width: 3px;
        border-color: #000;
    }
    
    .drag-handle {
        border: 1px solid transparent;
    }
    
    .drag-handle:hover,
    .drag-handle:focus {
        border-color: #000;
        background-color: #fff;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .step-item,
    .step-placeholder,
    .drag-handle {
        transition: none !important;
    }
    
    .step-item.dragging {
        transform: none !important;
    }
    
    .drop-success,
    .drop-error {
        animation: none !important;
    }
}
