/* ==========================================================================
   Product Checkout Modal Styles
   ========================================================================== */

.prd-checkout-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
}

.prd-checkout-modal__content {
    background-color: #fff;
    margin: auto;
    padding: 3rem;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 900px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    position: relative;
}

.prd-checkout-modal__close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--color-text-muted);
    cursor: pointer;
    background: none;
    border: none;
}

/* Left Column: Image */
.prd-checkout-modal__image-container {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative; /* For overlay positioning */
    display: flex;
    flex-direction: column;
    /* Hug the preview content instead of stretching to the form's height,
       so the loading pill and actions sit right under the image */
    align-self: start;
}

.prd-checkout-modal__image {
    width: 100%;
    height: auto;
    display: block;
}

.prd-checkout-modal__image-actions {
    text-align: center;
    margin-top: 1rem;
}

/* Loading overlay for image */
.prd-checkout-modal__loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 10;
    padding: 1rem;
}

.prd-checkout-modal__loading-overlay.active {
    display: flex;
}

/* The actions row sits under the translucent overlay and would bleed through
   while the preview is generating — keep it hidden until a preview is visible */
.prd-checkout-modal__loading-overlay.active:not(.has-local-preview) ~ .prd-checkout-modal__image-actions {
    visibility: hidden;
}

/* Once the instant local preview has rendered, drop the white veil to a
   compact status pill so the preview stays fully visible underneath */
.prd-checkout-modal__loading-overlay.active.has-local-preview {
    background-color: transparent;
    justify-content: flex-end;
    pointer-events: none;
}

/* !important: showMockupLoading() sets an inline display on the spinner */
.prd-checkout-modal__loading-overlay.has-local-preview .prd-checkout-modal__spinner {
    display: none !important;
}

.prd-checkout-modal__loading-overlay.has-local-preview .prd-checkout-modal__loading-text {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    /* Clear the actions row below the image so the pill sits as a chip
       on the bottom edge of the preview itself */
    margin-bottom: 4.5rem;
}

.prd-checkout-modal__loading-overlay.has-local-preview .prd-checkout-modal__error-container {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 4.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Spinner styles */
.prd-checkout-modal__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: prd-spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes prd-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.prd-checkout-modal__loading-text {
    color: var(--color-text);
    font-weight: var(--font-weight-bold);
    text-align: center;
}

/* Multi-view mockup carousel (flat / lifestyle views) */
.prd-checkout-modal__views {
    display: none;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.prd-checkout-modal__views.is-visible {
    display: flex;
}

.prd-checkout-modal__views img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.prd-checkout-modal__views img:hover {
    border-color: #ccc;
}

.prd-checkout-modal__views img.is-selected {
    border-color: var(--color-primary, #e05a00);
}

/* Error container styles */
.prd-checkout-modal__error-container {
    text-align: center;
    color: var(--color-danger);
}

.prd-checkout-modal__error-container p {
    margin-bottom: 1rem;
    font-weight: var(--font-weight-bold);
}

/* Right Column: Details */
.prd-checkout-modal__details {
    display: flex;
    flex-direction: column;
}

.prd-checkout-modal__product-info h2 {
    margin-top: 0;
    font-size: 1.75rem;
}

.prd-checkout-modal__product-info p {
    font-size: 1.25rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    margin-bottom: 1.5rem;
}

/* Form Styles */
.prd-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.prd-form__group {
    flex: 1 1 100%;
}

.prd-form__group--half {
    flex: 1 1 calc(50% - 0.5rem);
}

.prd-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: var(--font-weight-bold);
}

.prd-form input,
.prd-form select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

/* Shipping & Totals */
#shippingRatesContainer {
    margin-top: 1.5rem;
}

#shippingRatesList ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#shippingRatesList li {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.prd-total-summary {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.prd-total-summary p {
    display: flex;
    justify-content: space-between;
    margin: 0.5rem 0;
}

/* Actions */
.prd-checkout-modal__actions {
    margin-top: auto; /* Pushes to the bottom */
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .prd-checkout-modal__content {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }
}
