/**
 * Drag & Drop Styles
 * Visual feedback for drag & drop operations
 */

/* File Drop Overlay */
.file-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: all 0.3s ease;
}

.file-drop-overlay.active {
    display: flex;
    animation: fadeInScale 0.3s ease;
}

.drop-zone-content {
    text-align: center;
    color: white;
    transform: translateY(-50px);
}

.drop-icon {
    font-size: 120px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.drop-zone-content h2 {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.drop-zone-content p {
    font-size: 18px;
    opacity: 0.9;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Draggable Elements */
.draggable {
    cursor: move;
    transition: box-shadow 0.2s ease;
}

.draggable:hover {
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.dragging {
    opacity: 0.7;
    cursor: grabbing !important;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
    transition: all 0.1s ease;
}

/* Drag Handles */
.drag-handle {
    cursor: grab;
    padding: 5px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.drag-handle:hover {
    background: rgba(102, 126, 234, 0.2);
}

.drag-handle:active {
    cursor: grabbing;
    background: rgba(102, 126, 234, 0.3);
}

/* Text Box Drag Handle (already in app.js but enhanced) */
.text-box-handle {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: all 0.2s ease;
}

.text-box-handle:hover {
    transform: translateX(-50%) scale(1.2);
    background: #5568d3;
}

.text-box-handle:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.1);
}

.text-box-handle::before {
    content: '⋮⋮';
    font-weight: bold;
}

/* Drop Target Highlight */
.drop-target {
    position: relative;
    transition: all 0.2s ease;
}

.drop-target-active {
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed #667eea;
    box-shadow: inset 0 0 20px rgba(102, 126, 234, 0.2);
}

.drop-target-active::after {
    content: '📎 ছেড়ে দিন | Drop Here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(102, 126, 234, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    pointer-events: none;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

/* Alignment Guides */
.alignment-guides {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 999;
    display: none;
}

.guide-line {
    position: absolute;
    background: #667eea;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.guide-line.guide-vertical {
    width: 1px;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

.guide-line.guide-horizontal {
    height: 1px;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

/* Page Reordering */
.thumbnail-item {
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: grab;
}

.thumbnail-item:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.thumbnail-item.dragging-page {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(0.95);
}

.thumbnail-item.drag-over {
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Grid Overlay (when snap-to-grid is enabled) */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 9px, rgba(102, 126, 234, 0.1) 9px, rgba(102, 126, 234, 0.1) 10px),
        repeating-linear-gradient(90deg, transparent, transparent 9px, rgba(102, 126, 234, 0.1) 9px, rgba(102, 126, 234, 0.1) 10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-overlay.active {
    opacity: 1;
}

/* Drag & Drop Toolbar */
.drag-drop-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    z-index: 100;
    transition: all 0.3s ease;
}

.drag-drop-toolbar.hidden {
    transform: translateX(150%);
}

.drag-drop-toolbar button {
    padding: 10px 15px;
    border: none;
    background: #f0f0f0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.drag-drop-toolbar button:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.drag-drop-toolbar button.active {
    background: #667eea;
    color: white;
}

.drag-drop-toolbar button:active {
    transform: translateY(0);
}

/* Image Drop on Canvas */
#pdfCanvas.drop-target-active,
#textOverlay.drop-target-active {
    outline: 3px dashed #667eea;
    outline-offset: -3px;
}

/* Snap Indicator */
.snap-indicator {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 101;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.snap-indicator.visible {
    opacity: 1;
}

/* Draggable Image Element */
.image-element {
    position: absolute;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
    cursor: move;
}

.image-element:hover {
    border-color: #667eea;
}

.image-element.selected {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.image-element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 50%;
    z-index: 10;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.e { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.resize-handle.w { left: -5px; top: 50%; transform: translateY(-50%); cursor: w-resize; }

/* Mobile Optimizations - DISABLED FOR PC ONLY */
/*
@media (max-width: 768px) {
    .drop-zone-content h2 {
        font-size: 24px;
    }
    
    .drop-icon {
        font-size: 80px;
    }
    
    .drag-drop-toolbar {
        bottom: 10px;
        right: 10px;
        left: 10px;
        justify-content: space-between;
    }
    
    .drag-drop-toolbar button {
        flex: 1;
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .text-box-handle {
        width: 32px;
        height: 32px;
        top: -16px;
    }
    
    .resize-handle {
        width: 14px;
        height: 14px;
    }
}
*/

/* Touch-specific enhancements - DISABLED FOR PC ONLY */
/*
@media (hover: none) and (pointer: coarse) {
    .text-box-handle {
        display: flex !important;
        opacity: 0.7;
    }
    
    .text-box.selected .text-box-handle {
        opacity: 1;
    }
    
    .resize-handle {
        width: 16px;
        height: 16px;
    }
}
*/

/* Animation for dropped elements */
@keyframes dropAnimation {
    0% {
        transform: scale(0) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.element-dropped {
    animation: dropAnimation 0.4s ease;
}

/* Loading state for drag operations */
.drag-loading {
    position: relative;
    pointer-events: none;
}

.drag-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Success feedback */
.drop-success {
    animation: dropSuccess 0.6s ease;
}

@keyframes dropSuccess {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(102, 234, 126, 0.5);
    }
}

/* Error feedback */
.drop-error {
    animation: dropError 0.6s ease;
}

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

/* Context menu for draggable elements */
.drag-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    padding: 5px 0;
    z-index: 10000;
    min-width: 150px;
    display: none;
}

.drag-context-menu.active {
    display: block;
    animation: fadeInScale 0.2s ease;
}

.drag-context-menu-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.drag-context-menu-item:hover {
    background: #f0f0f0;
}

.drag-context-menu-item:active {
    background: #e0e0e0;
}

.drag-context-menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 5px 0;
}

/* Hide all touch handles and drag points on mobile/touch devices */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
    .text-box-handle,
    .drag-handle,
    .resize-handle {
        display: none !important;
    }
    
    .text-box:hover .text-box-handle,
    .text-box.selected .text-box-handle,
    .selected .resize-handle {
        display: none !important;
    }
}
