/**
 * Draggable Elements Styles
 * Styles for images, shapes, stamps, and other canvas elements
 */

/* Element Toolbar */
.element-toolbar {
    position: fixed;
    background: white;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: none;
    gap: 5px;
    z-index: 10000;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.element-toolbar .btn-small {
    padding: 6px 12px;
    border: none;
    background: #f5f5f5;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.element-toolbar .btn-small:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

/* Image Elements */
.image-element {
    position: absolute;
    border: 2px solid transparent;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: move;
    min-width: 50px;
    min-height: 50px;
}

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

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

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

/* Shape Elements */
.shape-element {
    position: absolute;
    cursor: move;
    transition: all 0.2s ease;
    min-width: 50px;
    min-height: 50px;
}

.shape-element:hover {
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.shape-element.selected {
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

/* Stamp Elements */
.stamp-element {
    position: absolute;
    cursor: move;
    user-select: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.1));
}

.stamp-element:hover {
    filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.5));
    transform: scale(1.1) !important;
}

.stamp-element.selected {
    filter: drop-shadow(0 0 15px rgba(102, 126, 234, 0.7));
}

/* Sticker Elements */
.sticker-element {
    position: absolute;
    cursor: move;
    user-select: none;
    transition: all 0.2s ease;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.1));
}

.sticker-element:hover {
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.5));
    transform: scale(1.15);
}

.sticker-element.selected {
    filter: drop-shadow(0 0 12px rgba(102, 126, 234, 0.7));
}

/* Add Element Modal */
.add-element-modal {
    padding: 20px;
}

.add-element-modal h3 {
    margin-bottom: 20px;
    color: #333;
}

.upload-area {
    margin: 20px 0;
}

.upload-label {
    display: block;
    padding: 40px;
    border: 2px dashed #ccc;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.upload-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.upload-text strong {
    color: #333;
    font-size: 16px;
}

.upload-text small {
    color: #666;
    font-size: 14px;
}

/* Shape Selector */
.shape-selector {
    margin: 20px 0;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.shape-btn {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.shape-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.shape-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-preview.rectangle {
    border: 3px solid #667eea;
    border-radius: 5px;
}

.shape-preview.circle {
    border: 3px solid #667eea;
    border-radius: 50%;
}

.shape-preview.line {
    width: 80px;
    height: 3px;
    background: #667eea;
}

.shape-preview.arrow {
    width: 0;
    height: 0;
    border-left: 40px solid #667eea;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
}

.shape-btn span {
    font-size: 13px;
    color: #666;
}

/* Shape Options */
.shape-options {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 15px;
    align-items: center;
}

.shape-options label {
    font-size: 14px;
    color: #666;
}

.shape-options input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    cursor: pointer;
}

.shape-options input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
}

.shape-options input[type="range"] {
    width: 100%;
}

/* Stamp Selector */
.stamp-selector {
    margin: 20px 0;
}

.stamp-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.stamp-btn {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stamp-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.2);
}

.stamp-emoji {
    font-size: 32px;
    transform: rotate(-15deg);
}

.stamp-text {
    font-size: 13px;
    color: #666;
    text-align: left;
}

/* Sticker Selector */
.sticker-selector {
    margin: 20px 0;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.sticker-btn {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.2);
}

/* Modal Hint */
.modal-hint {
    margin-top: 20px;
    padding: 15px;
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    border-radius: 5px;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
}

/* Elements Section in Sidebar */
#elementsSection {
    margin-top: 20px;
}

#elementsSection h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

#elementsSection .btn-block {
    width: 100%;
    margin-bottom: 8px;
}

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

.resize-handle:hover {
    transform: scale(1.3);
    background: #667eea;
}

.selected .resize-handle {
    display: block;
}

/* Mobile Optimizations - DISABLED FOR PC ONLY */
/*
@media (max-width: 768px) {
    .element-toolbar {
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 80px;
        width: auto;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .shape-grid {
        grid-template-columns: 1fr;
    }
    
    .stamp-grid {
        grid-template-columns: 1fr;
    }
    
    .sticker-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .resize-handle {
        width: 14px;
        height: 14px;
    }
    
    .shape-options {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .shape-options label {
        margin-bottom: -5px;
    }
}
*/

/* Touch devices - DISABLED FOR PC ONLY */
/*
@media (hover: none) and (pointer: coarse) {
    .resize-handle {
        width: 16px;
        height: 16px;
        display: block;
        opacity: 0.5;
    }
    
    .selected .resize-handle {
        opacity: 1;
    }
    
    .image-element,
    .shape-element,
    .stamp-element,
    .sticker-element {
        border-width: 2px;
    }
}
*/

/* Scrollbar styling for selectors */
.stamp-grid::-webkit-scrollbar,
.sticker-grid::-webkit-scrollbar {
    width: 8px;
}

.stamp-grid::-webkit-scrollbar-track,
.sticker-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.stamp-grid::-webkit-scrollbar-thumb,
.sticker-grid::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.stamp-grid::-webkit-scrollbar-thumb:hover,
.sticker-grid::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Loading state for elements */
.element-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.element-loading::after {
    content: '⏳';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Element badge (shows element type) */
.element-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    display: none;
    z-index: 11;
}

.selected .element-badge {
    display: block;
}

/* Hide resize handles on mobile/touch devices */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
    .resize-handle,
    .text-box-handle,
    .drag-handle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    .image-element .resize-handle,
    .shape-element .resize-handle,
    .stamp-element .resize-handle,
    .sticker-element .resize-handle {
        display: none !important;
    }
}
