/* ==========================================================================
   Product Customiser — Frontend Styles
   ========================================================================== */

.pcs-customise-wrap {
    margin: 0 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Customise button
   -------------------------------------------------------------------------- */

.pcs-open-editor {
    --pcs-btn-from: #6366f1;
    --pcs-btn-to: #2563eb;
    --pcs-btn-shadow: rgba(37, 99, 235, 0.3);

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    padding: 0.45em 0.95em;
    min-height: 0;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    color: #ffffff !important;
    text-decoration: none !important;
    text-transform: none;
    background: linear-gradient(135deg, var(--pcs-btn-from) 0%, var(--pcs-btn-to) 100%);
    background-size: 100% 100%;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow:
        0 2px 6px var(--pcs-btn-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition:
        transform 0.18s ease,
        box-shadow 0.25s ease,
        filter 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
    width: auto;
}

.pcs-open-editor:hover,
.pcs-open-editor:focus-visible {
    transform: translateY(-1px);
    box-shadow:
        0 4px 12px var(--pcs-btn-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    filter: brightness(1.05);
    color: #ffffff !important;
}

.pcs-open-editor:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.45);
    outline-offset: 2px;
}

.pcs-open-editor:active {
    transform: translateY(0);
    box-shadow:
        0 3px 8px var(--pcs-btn-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Smaller, neutral variant used inline inside cart line item meta. */
.pcs-open-editor.pcs-open-editor--inline {
    --pcs-btn-from: #475569;
    --pcs-btn-to: #1e293b;
    --pcs-btn-shadow: rgba(30, 41, 59, 0.25);
    padding: 0.3em 0.7em;
    font-size: 0.72rem;
    border-radius: 5px;
    margin-left: 0.25em;
}

.pcs-open-editor.is-loading {
    cursor: wait;
    opacity: 0.85;
}

.pcs-open-editor.pcs-needs-variation[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
    filter: grayscale(0.4);
}

.pcs-open-editor.pcs-needs-variation:not([disabled]) {
    opacity: 1;
    filter: none;
}

.pcs-variation-hint {
    display: inline-block;
    font-size: 0.82em;
    color: #b45309;
    font-weight: 500;
    padding: 0.25em 0.6em;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
}

.pcs-variation-hint.is-hidden {
    display: none;
}

.pcs-open-editor .pcs-btn-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.pcs-open-editor .pcs-btn-label {
    white-space: nowrap;
}

.pcs-open-editor.is-loading .pcs-btn-icon {
    animation: pcs-spin 0.9s linear infinite;
}

@keyframes pcs-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Soft shimmer on hover */
.pcs-open-editor::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        120deg,
        transparent 30%,
        rgba(255, 255, 255, 0.18) 50%,
        transparent 70%
    );
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.pcs-open-editor:hover::after {
    transform: translateX(100%);
}

/* --------------------------------------------------------------------------
   Status / price labels
   -------------------------------------------------------------------------- */

.pcs-design-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-size: 0.9em;
    font-weight: 600;
    color: #16a34a;
    padding: 0.45em 0.8em;
    background: rgba(22, 163, 74, 0.1);
    border-radius: 999px;
}

.pcs-design-status::before {
    content: "✓";
    font-weight: 700;
}

.pcs-design-status.pcs-error {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.pcs-design-status.pcs-error::before {
    content: "!";
}

.pcs-customisation-price-live {
    display: inline-block;
    font-size: 0.95em;
    color: #1e3a8a;
    font-weight: 700;
    margin: 0 0 0.75rem;
    padding: 0.45em 0.85em;
    background: rgba(37, 99, 235, 0.08);
    border-left: 3px solid #2563eb;
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Editor modal (iframe overlay)
   -------------------------------------------------------------------------- */

.pcs-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.pcs-modal.is-open {
    opacity: 1;
}

.pcs-modal__inner {
    position: relative;
    flex: 1;
    margin: clamp(0px, 2vw, 32px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.97);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.pcs-modal.is-open .pcs-modal__inner {
    transform: scale(1);
}

.pcs-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #f8fafc;
    flex-shrink: 0;
}

.pcs-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.pcs-modal__title svg {
    width: 18px;
    height: 18px;
}

.pcs-modal__close {
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.45em 0.85em;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    transition: background 0.15s ease, transform 0.15s ease;
    line-height: 1;
}

.pcs-modal__close:hover {
    background: rgba(239, 68, 68, 0.85);
    border-color: rgba(239, 68, 68, 0.85);
    transform: translateY(-1px);
}

.pcs-modal__close svg {
    width: 14px;
    height: 14px;
}

.pcs-modal__body {
    position: relative;
    flex: 1;
    background: #f8fafc;
    overflow: hidden;
}

.pcs-modal__iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #f8fafc;
    display: block;
}

.pcs-modal__loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #475569;
    background: #f8fafc;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.pcs-modal__loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.pcs-modal__spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: pcs-spin 0.85s linear infinite;
}

.pcs-modal__loading-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #334155;
}

/* Body lock when modal open */
body.pcs-modal-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .pcs-modal__inner {
        margin: 0;
        border-radius: 0;
    }

    .pcs-open-editor {
        width: 100%;
    }
}
