/**
 * Drag & Drop Styles
 * Provides visual feedback for drag and drop operations
 */

/* ==================== DRAG PREVIEW ==================== */

.drag-preview {
    will-change: transform, opacity;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.drag-preview-valid {
    filter: drop-shadow(0 4px 12px rgba(46, 204, 113, 0.5));
}

.drag-preview-invalid {
    filter: drop-shadow(0 4px 12px rgba(231, 76, 60, 0.5));
    opacity: 0.5 !important;
}

/* ==================== PALETTE BUTTONS ==================== */

.component-palette-btn {
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.component-palette-btn:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.component-palette-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Prevent text selection during drag */
.component-palette-btn * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ==================== CANVAS DROP ZONES ==================== */

/* Canvas when drag is active */
.diagram-container.drag-active {
    position: relative;
}

.diagram-container.drag-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(52, 152, 219, 0.05);
    border: 2px dashed rgba(52, 152, 219, 0.3);
    pointer-events: none;
    z-index: 1;
    animation: pulse-border 2s ease-in-out infinite;
}

/* Canvas when dragging over it */
.diagram-container.drag-over::before {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.5);
    border-style: solid;
    animation: none;
}

/* Pulse animation for drop zone */
@keyframes pulse-border {
    0%, 100% {
        border-color: rgba(52, 152, 219, 0.3);
    }
    50% {
        border-color: rgba(52, 152, 219, 0.6);
    }
}

/* ==================== DRAG CURSOR STATES ==================== */

/* Global cursor during drag */
body.dragging {
    cursor: grabbing !important;
}

body.dragging * {
    cursor: grabbing !important;
}

/* ==================== DROP FEEDBACK ==================== */

/* Success drop animation */
@keyframes drop-success {
    0% {
        transform: scale(1.2);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.component-group.just-dropped {
    animation: drop-success 0.4s ease-out;
}

/* ==================== MOBILE TOUCH SUPPORT ==================== */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets for mobile */
    .component-palette-btn {
        min-height: 60px;
        padding: 12px;
    }
    
    /* Disable hover effects on touch devices */
    .component-palette-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Show active state on touch */
    .component-palette-btn:active {
        background-color: rgba(52, 152, 219, 0.1);
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Focus states for keyboard navigation */
.component-palette-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.component-palette-btn:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .drag-preview {
        border: 2px solid currentColor;
    }
    
    .diagram-container.drag-active::before {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .component-palette-btn,
    .drag-preview {
        transition: none;
        animation: none;
    }
    
    .diagram-container.drag-active::before {
        animation: none;
    }
}

/* ==================== LOADING STATE ==================== */

.component-palette-btn.loading {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

.component-palette-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(52, 152, 219, 0.3);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== ERROR STATE ==================== */

.drag-preview.error {
    filter: drop-shadow(0 4px 12px rgba(231, 76, 60, 0.7));
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

