/* Image Cropper Modal Styles */
.image-cropper-modal { z-index: 1080; }
.image-cropper-modal .modal-dialog {
    max-width: 900px;
    margin: 1.5rem auto;
}

.image-cropper-modal .modal-content {
    background-color: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.image-cropper-modal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.85rem 1.25rem;
    background: #0f172a;
}

.image-cropper-modal .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.85rem 1.25rem;
    background: #0f172a;
}

.image-cropper-toolbar {
    background: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.6rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.crop-viewport-wrapper {
    background: #0b0f19;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 1.25rem;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    flex: 0 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.crop-stage img {
    display: block;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Crop Box */
.crop-box {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    touch-action: none;
    z-index: 10;
    /* Massive box-shadow dims the outside area to create the mask */
    box-shadow: 0 0 0 9999px rgba(11, 15, 25, 0.72);
    border: 2px dashed #10b981;
    transition: border-radius 0.2s ease, border-color 0.2s ease;
}

.crop-box:hover,
.crop-box:focus {
    border-color: #34d399;
}

/* Rectangle Shape */
.crop-box.shape-rect {
    border-radius: 4px;
}

/* Rounded / Oval Shape */
.crop-box.shape-round {
    border-radius: 50%;
}

/* Grid overlay inside the box */
.crop-box-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    overflow: hidden;
}

.crop-box-grid::before,
.crop-box-grid::after {
    content: '';
    position: absolute;
    box-sizing: border-box;
}

.crop-box-grid::before {
    top: 33.333%;
    bottom: 33.333%;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.35);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
}

.crop-box-grid::after {
    left: 33.333%;
    right: 33.333%;
    top: 0;
    bottom: 0;
    border-left: 1px dashed rgba(255, 255, 255, 0.35);
    border-right: 1px dashed rgba(255, 255, 255, 0.35);
}

/* Resize Handles */
.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 2.5px solid #059669;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    z-index: 20;
    touch-action: none;
}

/* Large hit target for fingers on mobile devices */
.crop-handle::before {
    content: '';
    position: absolute;
    top: -12px;
    left: -12px;
    right: -12px;
    bottom: -12px;
}

.crop-box.shape-round .crop-handle {
    border-radius: 50%;
}

/* Handle Positions */
.crop-handle[data-handle="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle[data-handle="n"]  { top: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.crop-handle[data-handle="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle[data-handle="e"]  { top: calc(50% - 7px); right: -7px; cursor: ew-resize; }
.crop-handle[data-handle="se"] { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-handle[data-handle="s"]  { bottom: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.crop-handle[data-handle="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle[data-handle="w"]  { top: calc(50% - 7px); left: -7px; cursor: ew-resize; }

/* Edge drag zones (allows user to grab any side directly) */
.crop-edge {
    position: absolute;
    z-index: 15;
    touch-action: none;
}
.crop-edge[data-edge="n"] { top: -6px; left: 10px; right: 10px; height: 12px; cursor: ns-resize; }
.crop-edge[data-edge="s"] { bottom: -6px; left: 10px; right: 10px; height: 12px; cursor: ns-resize; }
.crop-edge[data-edge="w"] { left: -6px; top: 10px; bottom: 10px; width: 12px; cursor: ew-resize; }
.crop-edge[data-edge="e"] { right: -6px; top: 10px; bottom: 10px; width: 12px; cursor: ew-resize; }

/* Mobile optimization */
@media (max-width: 576px) {
    .image-cropper-modal .modal-dialog {
        margin: 0.5rem;
    }
    .crop-viewport-wrapper {
        min-height: 0;
        padding: 1.25rem;
    }
    .crop-handle {
        width: 18px;
        height: 18px;
        border-width: 3px;
    }
    .crop-handle[data-handle="nw"] { top: -9px; left: -9px; }
    .crop-handle[data-handle="n"]  { top: -9px; left: calc(50% - 9px); }
    .crop-handle[data-handle="ne"] { top: -9px; right: -9px; }
    .crop-handle[data-handle="e"]  { top: calc(50% - 9px); right: -9px; }
    .crop-handle[data-handle="se"] { bottom: -9px; right: -9px; }
    .crop-handle[data-handle="s"]  { bottom: -9px; left: calc(50% - 9px); }
    .crop-handle[data-handle="sw"] { bottom: -9px; left: -9px; }
    .crop-handle[data-handle="w"]  { top: calc(50% - 9px); left: -9px; }
}
