/* ====================================================================
   BRUTAL DRAG & DROP - SortableJS Visual Feedback
   Theme-aware drag/drop styling for list reordering & file drops
   ==================================================================== */

/* ====================================================================
   SORTABLE GHOST - Element being dragged (preview)
   Browser native ghost (semi-transparent, can't override fully)
   ==================================================================== */

.sortable-ghost {
    opacity: 1 !important;
    background: var(--io-surface-raised) !important;
    border: 2px solid var(--io-accent) !important;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.5),
        0 0 20px var(--io-accent-glow),
        0 0 40px var(--io-accent-glow) !important;
    cursor: grabbing !important;
    transform: rotate(3deg) scale(1.05) !important;
    z-index: 9999 !important;
    position: relative !important;
    overflow: visible !important;
    pointer-events: none !important;
}

.sortable-ghost * {
    opacity: 1 !important;
    pointer-events: none !important;
}

.sortable-ghost img {
    opacity: 1 !important;
}

/* TRAIL EFFECT - Afterimage blur behind ghost */
.sortable-ghost::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--io-accent-subtle);
    border: 2px solid var(--io-accent);
    border-radius: inherit;
    opacity: 0.3;
    filter: blur(8px);
    transform: translateX(-8px) translateY(4px);
    z-index: -1;
    pointer-events: none;
}

.sortable-ghost::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--io-accent-subtle);
    border-radius: inherit;
    opacity: 0.15;
    filter: blur(16px);
    transform: translateX(-16px) translateY(8px);
    z-index: -2;
    pointer-events: none;
}

/* ====================================================================
   SORTABLE CHOSEN - Element when grab starts (before drag)
   ==================================================================== */

.sortable-chosen {
    background: var(--io-surface-hover) !important;
    border: 2px solid var(--io-accent) !important;
    cursor: grabbing !important;
    opacity: 1 !important;
}

/* ====================================================================
   SORTABLE DRAG - Original element placeholder (left behind)
   ==================================================================== */

.sortable-drag {
    opacity: 0.2 !important;
    background: var(--io-surface-sunken) !important;
    border: 1px dashed var(--io-border-subtle) !important;
    pointer-events: none !important;
}

/* Legacy class name support */
.io-drag-active {
    opacity: 0.2 !important;
    background: var(--io-surface-sunken) !important;
    border: 1px dashed var(--io-border-subtle) !important;
    pointer-events: none !important;
}

/* ====================================================================
   SORTABLE FALLBACK - Custom rendering (fallback mode)
   Only used when forceFallback: true in config
   ==================================================================== */

.sortable-fallback {
    opacity: 1 !important;
    background: var(--io-surface-raised) !important;
    border: 2px solid var(--io-accent) !important;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.6),
        0 0 20px var(--io-accent-glow),
        0 0 40px var(--io-accent-glow) !important;
    cursor: grabbing !important;
    transform: rotate(3deg) scale(1.08) !important;
    z-index: 100000 !important;
    position: fixed !important;
    pointer-events: none !important;
}

.sortable-fallback * {
    opacity: 1 !important;
}

.sortable-fallback img {
    opacity: 1 !important;
}

.sortable-fallback::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--io-accent);
    border-radius: inherit;
    opacity: 0.3;
    filter: blur(12px);
    transform: translateX(-12px) translateY(6px);
    z-index: -1;
    pointer-events: none;
}

.sortable-fallback::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--io-accent);
    border-radius: inherit;
    opacity: 0.15;
    filter: blur(24px);
    transform: translateX(-24px) translateY(12px);
    z-index: -2;
    pointer-events: none;
}

/* ====================================================================
   DRAG HANDLE - Optional grab handle for list items
   ==================================================================== */

.io-drag-handle {
    cursor: grab;
    color: var(--io-text-tertiary);
    transition: color var(--io-transition-fast);
    user-select: none;
    -webkit-user-select: none;
}

.io-drag-handle:hover {
    color: var(--io-accent);
}

.io-drag-handle:active {
    cursor: grabbing;
    color: var(--io-accent-bright);
}

.io-drag-handle i {
    pointer-events: none;
}

/* ====================================================================
   FILE DROP ZONE - Visual feedback for file drag-over
   ==================================================================== */

.io-drop-zone {
    position: relative;
    border: 2px dashed transparent;
    transition: all var(--io-transition-base);
    min-height: 100px;
}

.io-drop-zone-active {
    background: var(--io-accent-subtle);
    border-color: var(--io-accent);
    box-shadow: inset 0 0 20px var(--io-accent-glow);
}

.io-drop-zone::before {
    content: '\f093'; /* fa-upload */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 48px;
    color: var(--io-text-tertiary);
    opacity: 0;
    transition: opacity var(--io-transition-base);
    pointer-events: none;
}

.io-drop-zone-active::before {
    opacity: 0.3;
}

/* ====================================================================
   SORTABLE FILTER - Disable dragging on specific elements
   ==================================================================== */

.io-no-drag {
    cursor: default !important;
}

.sortable-ghost.io-no-drag {
    opacity: 0 !important;
}

/* ====================================================================
   SORTABLE LIST CONTAINER
   ==================================================================== */

.io-sortable-container {
    position: relative;
    min-height: 40px;
    padding: var(--io-space-sm);
}

.io-sortable-container:empty::after {
    content: 'Drop items here';
    display: block;
    text-align: center;
    color: var(--io-text-tertiary);
    font-size: var(--io-text-xs);
    padding: var(--io-space-lg);
    opacity: 0.5;
}

/* ====================================================================
   ANIMATION - Smooth transitions when reordering
   ==================================================================== */

.io-sortable-container > * {
    transition: transform var(--io-transition-base), opacity var(--io-transition-base);
}

.io-sortable-container.sortable-drag > * {
    transition: none !important;
}

/* ====================================================================
   CROSS-CONTAINER DRAGGING
   ==================================================================== */

.io-sortable-group-target {
    outline: 2px dashed var(--io-accent);
    outline-offset: 4px;
}

.io-sortable-group-invalid {
    opacity: 0.3;
    pointer-events: none;
}

/* ====================================================================
   ACCESSIBILITY
   ==================================================================== */

.io-drag-handle:focus-visible {
    outline: 2px solid var(--io-accent);
    outline-offset: 2px;
}

/* ====================================================================
   MOBILE TOUCH IMPROVEMENTS
   ==================================================================== */

@media (hover: none) and (pointer: coarse) {
    .io-drag-handle {
        padding: var(--io-space-sm);
        margin: calc(var(--io-space-sm) * -1);
    }
    
    .io-drag-handle:hover {
        color: var(--io-text-tertiary);
    }
    
    .io-drag-handle:active {
        transform: scale(1.05);
    }
}

/* ====================================================================
   PERFORMANCE - GPU acceleration
   ==================================================================== */

.sortable-ghost,
.sortable-chosen,
.sortable-fallback {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}