/* ═══════════════════════════════════════════════════════════
   IN-PLACE EDITOR — mouse-only direct manipulation
   ═══════════════════════════════════════════════════════════ */

/* Image frame must position the canvas + toolbar */
#lpImageFrame {
    position: relative;
}

/* Canvas takes the place of the original <img>, same display box */
#lpResultCanvas {
    display: block;
    border-radius: 12px;
    cursor: default;
    touch-action: none;
}

/* Loader pill (during AI layer extraction) */
.ml-inplace-loader {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 60;
    color: #fff;
}
.ml-inplace-loader .ml-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mlspin .9s linear infinite;
}
.ml-inplace-loader .ml-loader-text {
    font-weight: 700;
    font-size: 13px;
}
.ml-inplace-loader .ml-loader-sub {
    font-size: 11px;
    opacity: 0.75;
}
@keyframes mlspin { to { transform: rotate(360deg); } }

/* ── Floating glassmorphic mini-toolbar ────────────────────── */
.ml-floating-toolbar {
    position: absolute;
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18), 0 1px 2px rgba(0,0,0,.06);
    transform: translate(-50%, calc(-100% - 10px));
    user-select: none;
    pointer-events: auto;
    animation: mlPop .12s ease-out;
    white-space: nowrap;
}
@keyframes mlPop {
    from { opacity: 0; transform: translate(-50%, calc(-100% - 4px)) scale(0.9); }
    to   { opacity: 1; transform: translate(-50%, calc(-100% - 10px)) scale(1); }
}
.ml-floating-toolbar button {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    font-weight: 700;
    font-family: inherit;
    transition: background .12s, transform .08s;
}
.ml-floating-toolbar button:hover { background: rgba(15, 23, 42, 0.08); }
.ml-floating-toolbar button:active { transform: scale(0.92); }
.ml-floating-toolbar .ml-sep {
    width: 1px;
    height: 18px;
    background: rgba(15, 23, 42, 0.12);
    margin: 0 3px;
}
.ml-floating-toolbar .ml-danger { color: #dc2626; }
.ml-floating-toolbar .ml-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.15);
    pointer-events: none;
}
.ml-hidden-color {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ── Right-click context menu ──────────────────────────────── */
.ml-ctx-menu {
    position: fixed;
    z-index: 90;
    min-width: 180px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.22);
    padding: 6px;
    font-size: 13px;
    user-select: none;
    animation: mlPop .1s ease-out;
}
.ml-ctx-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: #0f172a;
    text-align: right;
}
.ml-ctx-menu button:hover { background: #f3f4f6; }
.ml-ctx-menu button.ml-danger { color: #dc2626; }
.ml-ctx-menu button.ml-danger:hover { background: #fef2f2; }
.ml-ctx-menu .ml-kbd {
    font-size: 10px;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
}

/* ── Edit-mode action cluster (replaces ✨ تعديل مباشر button) ── */
.lp-edit-cluster {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    padding: 4px;
}
.lp-edit-cluster button {
    height: 30px;
    min-width: 30px;
    padding: 0 10px;
    border: none;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background .12s;
}
.lp-edit-cluster button:hover { background: rgba(15, 23, 42, 0.08); }
.lp-edit-cluster button:disabled { opacity: 0.35; cursor: not-allowed; }
.lp-edit-cluster .ml-save {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    padding: 0 14px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}
.lp-edit-cluster .ml-save:hover { background: linear-gradient(135deg, #059669, #047857); }
.lp-edit-cluster .ml-cancel { color: #64748b; }

/* Touch-device enlargement of Fabric corner handles is handled in JS */
@media (pointer: coarse) {
    .ml-floating-toolbar button { width: 36px; height: 36px; font-size: 16px; }
    .lp-edit-cluster button { height: 36px; min-width: 36px; font-size: 14px; }
}
