/* ===================================================
   Image Editor Modal - Rotate, Crop, 4-Point Perspective
   Premium glassmorphism UI with smooth animations
   =================================================== */

/* --- Editor Modal Overlay --- */
.image-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.image-editor-modal.active {
    opacity: 1;
    pointer-events: all;
}

/* --- Editor Header / Toolbar --- */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.editor-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

.editor-close-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.editor-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: scale(1.05);
}

/* --- Mode Tabs --- */
.editor-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px;
}

.editor-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 9px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.editor-tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.06);
}

.editor-tab.active {
    background: var(--accent-primary, #E8576C);
    color: #fff;
    box-shadow: 0 2px 12px rgba(232, 87, 108, 0.4);
}

.editor-tab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* --- Canvas Area --- */
.editor-canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 16px;
    min-height: 0;
}

.editor-canvas-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.editor-canvas-wrapper canvas {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* --- Crop Overlay (drawn on the crop canvas) --- */
.editor-crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    border-radius: 8px;
}

/* --- Drag Points for 4-Point Crop --- */
.editor-drag-point {
    position: absolute;
    width: 22px;
    height: 22px;
    background: var(--accent-primary, #E8576C);
    border: 3px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(232, 87, 108, 0.5), 0 0 0 4px rgba(232, 87, 108, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: none;
}

.editor-drag-point:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 2px 16px rgba(232, 87, 108, 0.6), 0 0 0 8px rgba(232, 87, 108, 0.15);
}

.editor-drag-point.dragging {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 4px 20px rgba(232, 87, 108, 0.7), 0 0 0 10px rgba(232, 87, 108, 0.2);
    cursor: grabbing;
}

.editor-drag-point::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
}

/* Point labels */
.editor-drag-point[data-corner]::before {
    content: attr(data-label);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}

/* --- Crop Resize Handles (Rectangle Crop) --- */
.editor-crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--accent-primary, #E8576C);
    border-radius: 3px;
    transform: translate(-50%, -50%);
    z-index: 10;
    cursor: pointer;
    touch-action: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

.editor-crop-handle:hover,
.editor-crop-handle.dragging {
    transform: translate(-50%, -50%) scale(1.3);
}

.editor-crop-handle[data-pos="tl"] { cursor: nw-resize; }
.editor-crop-handle[data-pos="tr"] { cursor: ne-resize; }
.editor-crop-handle[data-pos="bl"] { cursor: sw-resize; }
.editor-crop-handle[data-pos="br"] { cursor: se-resize; }
.editor-crop-handle[data-pos="t"]  { cursor: n-resize;  }
.editor-crop-handle[data-pos="b"]  { cursor: s-resize;  }
.editor-crop-handle[data-pos="l"]  { cursor: w-resize;  }
.editor-crop-handle[data-pos="r"]  { cursor: e-resize;  }

/* --- Controls Panel (Bottom) --- */
.editor-controls {
    flex-shrink: 0;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Rotate Controls */
.editor-rotate-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.editor-rotate-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.editor-rotate-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.editor-rotate-btn:active {
    transform: translateY(0);
}

.editor-rotate-btn svg {
    width: 20px;
    height: 20px;
}

/* Slider */
.editor-slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    max-width: 320px;
}

.editor-slider-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    white-space: nowrap;
    min-width: 36px;
    text-align: center;
}

.editor-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.editor-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-primary, #E8576C);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(232, 87, 108, 0.4);
    transition: transform 0.15s ease;
}

.editor-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.editor-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-primary, #E8576C);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(232, 87, 108, 0.4);
}

/* --- Action Buttons (Confirm / Cancel) --- */
.editor-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.editor-btn {
    padding: 10px 28px;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
}

.editor-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.editor-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.editor-btn-confirm {
    background: var(--accent-primary, #E8576C);
    color: #fff;
    box-shadow: 0 4px 16px rgba(232, 87, 108, 0.4);
}

.editor-btn-confirm:hover {
    background: var(--accent-primary-hover, #D64458);
    box-shadow: 0 6px 24px rgba(232, 87, 108, 0.5);
    transform: translateY(-2px);
}

.editor-btn-confirm:active {
    transform: translateY(0);
}

.editor-btn-reset {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 18px;
}

.editor-btn-reset:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* --- Crop Info Hint --- */
.editor-hint {
    text-align: center;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

/* --- Responsive --- */
@media (max-width: 540px) {
    .editor-header {
        padding: 10px 12px;
    }

    .editor-tab {
        padding: 7px 10px;
        font-size: 0.75rem;
    }

    .editor-tab span {
        display: none;
    }

    .editor-canvas-area {
        padding: 8px;
    }

    .editor-canvas-wrapper canvas {
        max-height: calc(100vh - 230px);
    }

    .editor-controls {
        padding: 10px 12px;
        gap: 8px;
    }

    .editor-rotate-btn {
        width: 38px;
        height: 38px;
    }

    .editor-btn {
        padding: 9px 18px;
        font-size: 0.82rem;
    }

    .editor-drag-point {
        width: 28px;
        height: 28px;
    }

    .editor-crop-handle {
        width: 16px;
        height: 16px;
    }
}

/* --- Animations --- */
@keyframes editorSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-editor-modal.active .editor-canvas-wrapper {
    animation: editorSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- Perspective grid guide lines --- */
.editor-guide-line {
    position: absolute;
    background: rgba(232, 87, 108, 0.3);
    pointer-events: none;
    z-index: 5;
}
