/**
 * Image Editor - WhatsApp UX
 * Exact WhatsApp-style image editing experience
 */

#imageEditorModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0b141a;
    z-index: 10000;
    justify-content: center;
    align-items: center;
    overflow: visible;
}

.image-editor-container {
    background: #0b141a;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
}

/* Top Left: Done Button (modal mode) */
.top-left-action {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 100;
}

.btn-done-mode {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-done-mode:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.7);
}

.btn-done-mode i {
    font-size: 14px;
}

/* Top: Tool Icons (horizontal) */
.top-tools {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    z-index: 100;
}

.tool-icon-btn {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tool-icon-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.7);
}

.tool-icon-btn.active {
    background: #00a884;
}

/* Color Palette */
.color-palette {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 28px;
    display: flex;
    gap: 8px;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.color-btn {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.color-btn:active {
    transform: scale(0.9);
}

.color-btn.selected {
    border-color: #ffffff;
    border-width: 4px;
}

.text-background-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.text-background-btn:hover {
    transform: scale(1.1);
}

.text-background-btn:active {
    transform: scale(0.95);
}

.color-picker-trigger {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 16px;
}

/* Crop Controls */
.crop-controls {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 24px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.crop-control-btn {
    width: 48px;
    height: 48px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.crop-control-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
}

/* Canvas container - full screen */
.image-editor-canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0b141a;
    overflow: visible;
    touch-action: auto;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    padding: 20px;
}

@media (min-width: 769px) {
    .image-editor-canvas-container {
        padding: 40px;
    }
}

#imageEditorCanvas {
    background: transparent;
    position: relative;
    z-index: auto;
    pointer-events: auto;
    touch-action: auto;
}

/* Bottom Actions */
.bottom-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}

.bottom-actions > * {
    pointer-events: auto;
}

.image-editor-btn-cancel {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.image-editor-btn-cancel:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.7);
}

.image-editor-btn-save {
    width: 56px;
    height: 56px;
    background: #00a884;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.4);
}

.image-editor-btn-save:active {
    transform: scale(0.9);
    background: #00916f;
}

/* Desktop adjustments */
@media (min-width: 769px) {
    .image-editor-container {
        max-width: 900px;
        max-height: 90vh;
        margin: auto;
        border-radius: 12px;
    }

    .top-tools {
        top: 24px;
        right: 24px;
        gap: 16px;
    }

    .tool-icon-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .tool-icon-btn:hover {
        background: rgba(0, 0, 0, 0.7);
        transform: scale(1.05);
    }

    .tool-icon-btn.active:hover {
        background: #00916f;
    }

    .image-editor-btn-cancel:hover,
    .image-editor-btn-save:hover {
        transform: scale(1.05);
    }

    .btn-done-mode:hover {
        background: rgba(0, 0, 0, 0.7);
        transform: scale(1.02);
    }

    .color-btn:hover {
        transform: scale(1.1);
    }

    .crop-control-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(1.05);
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Prevent text selection during editing */
.image-editor-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Touch feedback */
@media (hover: none) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Fade-in animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.color-palette,
.crop-controls,
.top-left-action {
    animation: fadeIn 0.15s ease-out;
}
