/* =========================================================
   Custom Phone Case Designer – Frontend styles
   ========================================================= */

.cpcd-designer {
    --cpcd-ink: #172033;
    --cpcd-muted: #697386;
    --cpcd-line: #dfe3ea;
    --cpcd-accent: #5b45e0;
    float: left;
    width: 48%;
    clear: none;
    margin: 0 0 24px;
    color: var(--cpcd-ink);
    box-sizing: border-box;
    display: grid !important;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(22px, 3vw, 42px);
    align-items: start;
}

@media (max-width: 768px) {
    .cpcd-designer {
        float: none;
        width: 100%;
        margin-bottom: 28px;
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
    }
}

@media (min-width: 769px) and (max-width: 980px) {
    .cpcd-designer {
        grid-template-columns: minmax(0, 1fr);
    }
}

.cpcd-designer .cpcd-preview-wrap {
    position: relative;
    width: auto;
    min-width: 0;
    padding: 32px 18px 14px;
    border-radius: 16px;
    background: linear-gradient(145deg, #f3f4f7, #e8ebf0);
    text-align: center;
    overflow: hidden;
}

.cpcd-designer .cpcd-preview-label {
    position: absolute;
    top: 13px;
    left: 15px;
    padding: 4px 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.85);
    color: #616a79;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.cpcd-designer .cpcd-stage {
    position: relative;
    width: 100%;
    max-width: 460px;
    min-width: 0;
    aspect-ratio: 9 / 19;
    margin: 8px auto 0;
    border-radius: 12px;
    background: #f4f5f8;
    overflow: hidden;
    display: block;
    transition: aspect-ratio 0.25s ease;
}

.cpcd-designer .cpcd-stage .cpcd-bg,
.cpcd-designer .cpcd-stage .cpcd-mockup,
.cpcd-designer .cpcd-stage .cpcd-custom-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
}

.cpcd-designer .cpcd-stage .cpcd-bg     { z-index: 1; object-fit: cover; }
.cpcd-designer .cpcd-stage .cpcd-custom-preview { z-index: 2; object-fit: contain; padding: 7%; box-sizing: border-box; }
.cpcd-designer .cpcd-stage .cpcd-mockup { z-index: 4; object-fit: contain; }

.cpcd-designer .cpcd-custom-text-preview {
    position: absolute;
    z-index: 3;
    left: 9%;
    right: 9%;
    bottom: 6%;
    color: #222;
    font-size: clamp(12px, 2vw, 22px);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
}

.cpcd-designer .cpcd-custom-text-preview[hidden] { display: none; }

.cpcd-designer .cpcd-stage .cpcd-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #7a8496;
    font-weight: 600;
    padding: 24px;
    text-align: center;
    font-size: 14px;
}

.cpcd-designer .cpcd-spinner {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 3;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(2px);
}

.cpcd-designer .cpcd-spinner[hidden] { display: none; }

.cpcd-designer .cpcd-spinner span {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(91, 69, 224, 0.2);
    border-top-color: var(--cpcd-accent);
    border-radius: 50%;
    animation: cpcd-spin 0.8s linear infinite;
    display: block;
}

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

.cpcd-designer .cpcd-caption {
    margin: 10px 0 0;
    color: #626b79;
    font-size: 12px;
    font-weight: 700;
    min-height: 1em;
}

.cpcd-designer .cpcd-controls {
    width: auto;
    min-width: 0;
    margin-top: 0;
}

.cpcd-designer .cpcd-label {
    display: block;
    margin: 0 0 8px;
    font-weight: 750;
    color: var(--cpcd-ink);
}

.cpcd-designer .cpcd-hint {
    margin: 6px 0 0;
    color: var(--cpcd-muted);
    font-size: 12px;
}

.cpcd-designer .cpcd-custom-fields {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--cpcd-line);
}

.cpcd-designer .cpcd-custom-title {
    margin: 0 0 14px;
    color: var(--cpcd-ink);
    font-size: 16px;
    font-weight: 800;
}

.cpcd-designer .cpcd-custom-image {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 10px;
    padding: 8px;
    border: 1px solid #cfd4de;
    border-radius: 9px;
    background: #fff;
    box-sizing: border-box;
}

.cpcd-designer .cpcd-custom-image-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
}

.cpcd-designer .cpcd-custom-image-row[hidden] { display: none; }

.cpcd-designer .cpcd-custom-image-preview {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border: 1px solid var(--cpcd-line);
    border-radius: 7px;
    background: #fff;
}

.cpcd-designer .cpcd-custom-text {
    display: block;
    width: 100%;
    min-height: 80px;
    resize: vertical;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cfd4de;
    border-radius: 9px;
    background: #fff;
    color: var(--cpcd-ink);
    font: inherit;
}

.cpcd-designer .cpcd-empty {
    padding: 12px;
    background: #fff7ed;
    color: #7c3a03;
    border-radius: 8px;
    font-size: 13px;
}

.cpcd-designer .cpcd-status {
    min-height: 22px;
    margin-top: 8px;
    color: var(--cpcd-muted);
    font-size: 13px;
    font-weight: 650;
}

/* Select2 overrides */
.cpcd-designer .select2-container--default .select2-selection--single {
    min-height: 46px;
    border: 1px solid #cfd4de;
    border-radius: 9px;
    background: #fff;
    display: flex;
    align-items: center;
}
.cpcd-designer .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--cpcd-ink);
    padding-left: 12px;
    font-size: 14px;
    line-height: 1.4;
}
.cpcd-designer .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
    right: 8px;
}

/* Buy Now button */
form.cart .cpcd-buy-now-btn {
    margin-left: 8px;
    background: #151923;
    border-color: #151923;
    color: #fff;
}

/* Cart / checkout thumbnail */
.cpcd-cart-thumb { object-fit: contain; }
