/* ── Customer personalization widget (drag-to-position text on product image) ──
   Shared by the frontend product/cart pages and the backend order pages (via
   resources/views/shared/design-preview.blade.php's readonly viewer) — kept
   in its own file, separate from the frontend-only custom.css, specifically
   so the backend admin theme can load just this widget's styles without
   pulling in hundreds of unrelated storefront-only rules. */
:root {
    /* Fallback only for pages that don't already define this Bootstrap
       variable (the backend admin theme doesn't) — accent color only, no
       effect on layout/positioning if it were ever missing. */
    --personalizer-accent: var(--bs-primary, #76ACCD);
}
.personalizer-widget {
    border: 1px solid #e9ecef;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 20px rgba(20, 30, 60, .06);
}
/* Read-only viewer (order pages): just the stage, styled as a compact
   thumbnail rather than the full editor card (no controls exist to fill the
   rest of the card, so the card chrome/padding would otherwise look odd). */
.personalizer-widget-readonly {
    border: none;
    box-shadow: none;
    max-width: 160px;
}
.personalizer-widget-readonly .personalizer-stage-wrap {
    background: none;
    padding: 0;
}
.personalizer-stage-wrap {
    background: linear-gradient(180deg, #f3f6fb 0%, #eef2f8 100%);
    padding: 14px;
}
.personalizer-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    box-shadow: inset 0 0 0 1px #e9edf3;
}
/* !important guards against plain-tag rules elsewhere (e.g. ".cart-item-card img")
   that would otherwise win by specificity since this widget can be nested inside them. */
.personalizer-stage img.personalizer-stage-img {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: contain !important;
    pointer-events: none !important;
    background: none !important;
    border-radius: 0 !important;
    flex-shrink: initial !important;
}
.personalizer-drag-box {
    position: absolute;
    border: none;
    background: transparent;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
}
.personalizer-drag-text {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}
.personalizer-controls {
    padding: 16px;
    border-top: 1px solid #eef0f4;
    background: #fff;
}
.personalizer-controls .form-label {
    font-weight: 600;
    color: #333;
}
.personalizer-controls .form-control,
.personalizer-controls .form-select {
    border-color: #e2e6ee;
}
.personalizer-controls .form-control:focus,
.personalizer-controls .form-select:focus {
    border-color: var(--personalizer-accent);
    box-shadow: 0 0 0 0.15rem rgba(118,172,205,.2);
}
.personalizer-controls .form-range {
    accent-color: var(--personalizer-accent);
}
.personalizer-hint {
    display: flex;
    align-items: center;
    gap: 6px;
}
.personalizer-hint::before {
    content: "✋";
    font-size: 13px;
}

/* Charm image positioned on the stage (independent box from the text drag-box) */
.personalizer-charm-box {
    position: absolute;
    pointer-events: none;
    display: none;
}
.personalizer-charm-box img.personalizer-charm-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: none !important;
    pointer-events: none !important;
}

/* Charm picker — custom dropdown so each option can show an image thumbnail
   (a native <select> can't render <img> inside its options). */
.personalizer-charm-picker { position: relative; }
.personalizer-charm-toggle {
    background: #fff;
    text-align: left;
    cursor: pointer;
}
.personalizer-charm-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.personalizer-charm-toggle-label img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 4px;
    background: #f8f9fa;
    flex-shrink: 0;
}
.personalizer-charm-toggle-arrow { color: #888; font-size: 11px; flex-shrink: 0; }
.personalizer-charm-dropdown {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 6px;
}
.personalizer-charm-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.personalizer-charm-option:hover { background: #f3f6fb; }
.personalizer-charm-option img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    background: #f8f9fa;
    border-radius: 6px;
    flex-shrink: 0;
}
.personalizer-charm-option-none { color: #888; font-style: italic; }

/* ── Photo upload slots (products that require the customer's own photo(s)) ── */
.personalizer-photo-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.personalizer-photo-slot { width: 78px; }
.personalizer-photo-slot-inner {
    position: relative;
    width: 78px;
    height: 78px;
    border: 2px dashed #cfd6e0;
    border-radius: 10px;
    background: #f8f9fb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s, background .15s;
}
.personalizer-photo-slot-inner:hover { border-color: var(--personalizer-accent); background: #f0f5fa; }
.personalizer-photo-plus { font-size: 22px; line-height: 1; color: var(--personalizer-accent); font-weight: 300; }
.personalizer-photo-label { font-size: 10px; color: #888; margin-top: 2px; }
.personalizer-photo-slot-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.personalizer-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    color: #fff;
    border: none;
    line-height: 1;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.personalizer-photo-remove:hover { background: rgba(220,53,69,.85); }
.personalizer-photo-slot.is-uploading .personalizer-photo-slot-inner { cursor: wait; }
.personalizer-photo-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #d8dee6;
    border-top-color: var(--personalizer-accent);
    border-radius: 50%;
    animation: personalizer-photo-spin .7s linear infinite;
}
@keyframes personalizer-photo-spin {
    to { transform: rotate(360deg); }
}
