/* ============================================================
   Photo Magnets Uploader — pmu-style.css  v5.0.0
   ============================================================ */


/* ── Upload section ───────────────────────────────────── */

#pmu-uploader-section {
    margin: 20px 0 16px;
    padding: 18px 20px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
}

.pmu-section-title {
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 14px;
    color: #222;
}


/* ── Slots ────────────────────────────────────────────── */

#pmu-slots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 14px;
}

.pmu-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    width: 96px;
}

.pmu-slot-preview {
    position: relative;
    width: 88px;
    height: 88px;
    border: 2px dashed #c8c8c8;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pmu-slot-done .pmu-slot-preview {
    border: 2px solid #185440;
    box-shadow: 0 0 0 3px rgba(24,84,64,0.12);
}

.pmu-slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pmu-slot-number {
    font-size: 1.6em;
    font-weight: 700;
    color: #ccc;
    user-select: none;
}

.pmu-slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(0,0,0,0.60);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s;
    z-index: 2;
}

.pmu-slot-remove:hover { background: rgba(200,0,0,0.80); }

.pmu-upload-btn.button {
    font-size: 0.72em !important;
    padding: 5px 8px !important;
    min-height: auto !important;
    width: 88px;
    text-align: center;
}

.pmu-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #eee;
    border-top-color: #185440;
    border-radius: 50%;
    animation: pmu-spin 0.7s linear infinite;
}

@keyframes pmu-spin { to { transform: rotate(360deg); } }

#pmu-status-message {
    font-size: 0.9em;
    font-weight: 600;
    min-height: 1.4em;
    margin: 4px 0 0;
}

.pmu-status-complete { color: #185440; }
.pmu-status-partial  { color: #555; }

@media (max-width: 480px) {
    .pmu-slot     { width: 80px; }
    .pmu-upload-btn.button {font-size: 0.65em !important; }
}


/* ============================================================
   CANVAS EDITOR MODAL
   ============================================================ */

#pmu-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.80);

    /*
     * ★ FIX: z-index must beat Elementor's overlay (999999) AND
     * WooCommerce lightbox (100000). 1000001 is the safe value.
     */
    z-index: 1000001;

    align-items: center;
    justify-content: center;
    padding: 12px;

    /*
     * ★ FIX: The backdrop itself must NOT scroll on mobile.
     * touch-action:none prevents the backdrop from triggering
     * page scroll while the user drags inside the canvas.
     */
    touch-action: none;
}

#pmu-modal.active {
    display: flex;
}

body.pmu-modal-open {
    overflow: hidden;
    /* Prevent iOS rubber-band scrolling while modal is open */
    position: fixed;
    width: 100%;
}

#pmu-modal-inner {
    background: #fff;
    border-radius: 14px;
    padding: 22px 22px 20px;
    width: min(540px, 100%);
    max-height: 96vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.40);
    display: flex;
    flex-direction: column;
    gap: 14px;

    /* Allow the inner box itself to scroll (for very small screens) */
    touch-action: pan-y;
}

/* ── Modal header ─────────────────────────────────────── */

#pmu-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

#pmu-modal-header h3 {
    margin: 0 0 4px;
    font-size: 1.1em;
    color: #111;
}

.pmu-crop-hint {
    font-size: 0.82em;
    color: #888;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pmu-hint-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #222;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
}

.pmu-hint-resize { border-radius: 3px; }

#pmu-modal-close {
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
    /* Ensure the close button is always tappable on mobile */
    min-width: 44px;
    min-height: 44px;
}

#pmu-modal-close:hover { background: #e0e0e0; }


/* ── Canvas wrapper ───────────────────────────────────── */

#pmu-canvas-wrapper {
    position: relative;
    align-self: center;
    width: min(440px, calc(100vw - 56px));
    aspect-ratio: 1 / 1;
    box-shadow: 0 0 0 2px #bbb, 0 4px 18px rgba(0,0,0,0.18);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

#pmu-editor-canvas {
    display: block;
    width: 100%;
    height: 100%;

    /*
     * ★ CRITICAL FIX FOR MOBILE:
     * Without touch-action:none the browser intercepts all touch events
     * on the canvas for scrolling/zooming. The canvas drag/rotate/resize
     * WILL NOT WORK on mobile without this line.
     * We set this in JS too (canvas.style.touchAction = 'none') as a
     * belt-and-suspenders approach.
     */
    touch-action: none;

    cursor: move;
}

#pmu-canvas-border-label {
    position: absolute;
    bottom: -22px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.72em;
    color: #aaa;
    letter-spacing: 0.04em;
    pointer-events: none;
}


/* ── Zoom row ─────────────────────────────────────────── */

#pmu-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 2px;
    margin-top: 10px;
}

.pmu-zoom-btn {
    /* ★ 44px min tap target for mobile accessibility */
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}

.pmu-zoom-btn:hover { background: #e8e8e8; }

/* Make the zoom slider taller / easier to grab on mobile */
#pmu-zoom-slider {
    flex: 1;
    accent-color: #185440;
    cursor: pointer;
    height: 6px;
    /* Larger touch target on mobile */
    padding: 8px 0;
}


/* ── Action buttons ───────────────────────────────────── */

#pmu-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

#pmu-crop-cancel {
    background: #eee;
    border: 1px solid #ccc;
    padding: 10px 22px;
    border-radius: 40px;
    font-size: 0.95em;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s;
}

#pmu-crop-cancel:hover { background: #e0e0e0; }

#pmu-crop-confirm {
    background: #185440;
    color: #fff;
    border: none;
    padding: 10px 26px;
    border-radius: 40px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s;
}

#pmu-crop-confirm:hover:not(:disabled) { background: #0f3a2c; }
#pmu-crop-confirm:disabled { opacity: 0.55; cursor: not-allowed; }


/* ── Mobile-specific modal adjustments ───────────────── */

@media (max-width: 540px) {
    #pmu-modal { padding: 8px; }

    #pmu-modal-inner {
        padding: 16px 14px 14px;
        border-radius: 16px;
        gap: 12px;
    }

    #pmu-canvas-wrapper {
        width: calc(100vw - 44px);
    }

    #pmu-crop-cancel,
    #pmu-crop-confirm {
        padding: 10px 16px;
        font-size: 0.9em;
    }
}


/* ============================================================
   ADMIN ORDER PAGE
   ============================================================ */

.pmu-admin-images {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.pmu-admin-label { margin: 0 0 8px; font-size: 0.9em; }

.pmu-admin-meta {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.82em;
    color: #777;
    font-weight: normal;
}

.pmu-admin-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }

.pmu-admin-thumbs a {
    position: relative;
    display: inline-block;
    text-decoration: none;
}

.pmu-admin-thumbs img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pmu-admin-thumbs a:hover img {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.3);
}

.pmu-img-num {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.4;
}