/* Insert Image Module Styles */

/* Overlay */
#insert-image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1600;
    pointer-events: none;
}

/* Control Box */
#insert-image-box {
    position: absolute;
    border: 2px solid var(--theme-color);
    pointer-events: all;
    cursor: move;
    box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.1);
    transform-origin: center center;
    background-color: rgba(255, 255, 255, 0.1); /* Slight background to indicate selection area */
}

/* Resize Handles */
#insert-image-box .resize-handle {
    position: absolute;
    background-color: var(--theme-color);
    border: 2px solid white;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    pointer-events: all;
    z-index: 10;
}

#insert-image-box .resize-handle.top-left {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

#insert-image-box .resize-handle.top-right {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

#insert-image-box .resize-handle.bottom-left {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

#insert-image-box .resize-handle.bottom-right {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

#insert-image-box .resize-handle.top {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

#insert-image-box .resize-handle.bottom {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

#insert-image-box .resize-handle.left {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

#insert-image-box .resize-handle.right {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* Rotation Handle */
#insert-image-box .rotate-handle {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    background-color: var(--theme-color);
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    pointer-events: all;
    z-index: 10;
}

#insert-image-box .rotate-handle:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#insert-image-box .rotate-handle:active {
    cursor: grabbing;
}

#insert-image-box .rotate-handle::after {
    content: '';
    position: absolute;
    top: 36px; /* connect to box */
    left: 50%;
    width: 2px;
    height: 20px; /* distance to box edge roughly */
    background-color: var(--theme-color);
    transform: translateX(-50%);
    pointer-events: none;
}

/* Toolbar */
#insert-image-box .image-controls-toolbar {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 10px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: all;
    z-index: 10;
}

#insert-image-box .image-control-btn {
    width: var(--touch-target-size);
    height: var(--touch-target-size);
    border: none;
    border-radius: 10px;
    background-color: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #333;
}

#insert-image-box .image-control-btn:hover {
    background-color: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#insert-image-box .image-control-btn:active {
    transform: translateY(0);
}

#insert-image-box .image-done-btn {
    background-color: #34C759;
    color: white;
}

#insert-image-box .image-done-btn:hover {
    background-color: #28A745;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 199, 89, 0.3);
}

#insert-image-box .image-cancel-btn {
    background-color: #FF3B30;
    color: white;
}

#insert-image-box .image-cancel-btn:hover {
    background-color: #E02020;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 59, 48, 0.3);
}

/* Flip Handles for Insert Image */
#insert-image-box .flip-handle {
    position: absolute;
    top: -40px;
    width: 32px;
    height: 32px;
    background-color: var(--theme-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    pointer-events: all;
    z-index: 10;
}

#insert-image-box .flip-handle.flip-horizontal {
    left: calc(50% + 50px);
    transform: translateX(-50%);
}

#insert-image-box .flip-handle.flip-vertical {
    left: calc(50% + 90px);
    transform: translateX(-50%);
}

#insert-image-box .flip-handle:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#insert-image-box .flip-handle:active {
    transform: translateX(-50%) scale(0.95);
}

#insert-image-box .flip-handle.active {
    background-color: #34C759;
}

#insert-image-box .flip-handle::after {
    content: '';
    position: absolute;
    top: 32px;
    left: 50%;
    width: 2px;
    height: 12px;
    background-color: var(--theme-color);
    transform: translateX(-50%);
    pointer-events: none;
}

#insert-image-box .flip-handle.active::after {
    background-color: #34C759;
}


/* Insert Image Responsive Styles */
@media (max-width: 480px) {
    #insert-image-modal .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .image-source-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .image-source-tab {
        padding: 8px 12px;
        font-size: 12px;
        min-height: var(--touch-target-size);
    }
    
    .image-upload-zone {
        padding: 20px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .image-source-tab {
        min-height: var(--touch-target-size);
    }
    
    .image-upload-btn,
    .image-action-btn {
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
    }
}
