/* Crop Image tool — page-scoped styles */
.drop-zone {
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragover {
    background-color: #eef5ff !important;
    border-color: var(--bs-primary, #0d6efd) !important;
    outline: none;
}

.crop-tap {
    min-height: 44px;
}

.crop-viewport {
    position: relative;
    width: 100%;
    min-height: 280px;
    height: min(70vh, 640px);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    background: #111;
}

.crop-viewport:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Positioned by JS: left/top/width/height in viewport pixels */
.crop-preview-container {
    position: absolute;
    line-height: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#stageImage {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.crop-rectangle {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
    pointer-events: auto;
    box-sizing: border-box;
}

.resize-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid var(--bs-primary, #0d6efd);
    border-radius: 3px;
    z-index: 3;
    pointer-events: auto;
    touch-action: none;
}

.resize-handle.nw { top: -9px; left: -9px; cursor: nwse-resize; }
.resize-handle.ne { top: -9px; right: -9px; cursor: nesw-resize; }
.resize-handle.sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.resize-handle.se { bottom: -9px; right: -9px; cursor: nwse-resize; }
.resize-handle.n { top: -9px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle.s { bottom: -9px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle.e { right: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.resize-handle.w { left: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.crop-result-preview {
    max-height: 320px;
    background:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

@media (max-width: 575.98px) {
    .resize-handle {
        width: 22px;
        height: 22px;
    }

    .crop-viewport {
        min-height: 240px;
        height: min(60vh, 480px);
    }
}
