/* ==========================================================================
   Generation Page - Product Modal Styles (Studio Workflow)
   ========================================================================== */

/* --- Main Checkout Modal --- */
.gen-checkout-modal {
    display: none;
    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;
}

.gen-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;
}

.gen-checkout-modal__content--full {
    grid-template-columns: 1fr;
    max-width: 1200px;
}

.gen-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;
}

.gen-checkout-modal__image-container {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

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

.gen-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;
}

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

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

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

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

.gen-checkout-modal__details {
    display: flex;
    flex-direction: column;
}

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

.gen-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 --- */
.gen-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

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

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

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

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

/* --- Totals & Actions --- */
.gen-total-summary {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

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

.gen-checkout-modal__actions {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* --- Product Grid inside Modal --- */
.gen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.gen-product-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    /* overflow: hidden; */ /* Removed to allow dropdown to overflow */
    display: flex;
    flex-direction: column;
}

.gen-product-card__image-container {
    position: relative;
    width: 100%;
    height: 250px;
    background-color: #f0f0f0;
    overflow: hidden; /* Added to maintain rounded corners on image */
    border-radius: 8px 8px 0 0;
}

.gen-product-card__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gen-product-card__info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.gen-product-card__name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.gen-product-card__price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.gen-variant-selector {
    margin-bottom: 1rem;
}

.gen-variant-option {
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.gen-variant-option input {
    display: none;
}

.gen-variant-option span {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.gen-variant-option input:checked + span {
    background-color: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Custom Select Dropdown Styles for Modal */
.gen-custom-select {
    position: relative;
    width: 100%;
}

.gen-custom-select__trigger {
    width: 100%;
    height: auto;
    background-color: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gen-custom-select__trigger:hover {
    border-color: var(--color-primary-light);
}

.gen-custom-select__trigger:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.gen-custom-select__options {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    padding: var(--space-xs) 0;
    list-style: none;
    z-index: 1001; /* Higher z-index for modal context */
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.gen-custom-select.open .gen-custom-select__options {
    display: block; /* Show when open */
}

.gen-custom-select.open-upward .gen-custom-select__options {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

.gen-custom-select__option {
    padding: var(--space-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.gen-custom-select__option:hover {
    background-color: #f1f3f5;
}

.gen-custom-select__option.is-selected {
    background-color: var(--color-primary);
    color: white;
    font-weight: var(--font-weight-bold);
}

/* --- Cropping Modal --- */
.gen-crop-modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.gen-crop-modal__content {
    background-color: #fff;
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    text-align: center;
}

.gen-crop-modal__image-container {
    margin: 1.5rem 0;
    max-height: 50vh;
}

.gen-crop-modal__image-container img {
    max-width: 100%;
}

.gen-crop-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

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