/**
 * Multi-size batch ordering: "Select variants" panel + "View my designs" list.
 *
 * Shared by Simple and Advance builders. Opt-in per product (batch mode).
 *
 * @package CustomProductBuilderProWC
 */

/* ---------- Panel container ---------- */
.cpbpwc-batch-panel {
    font-family: var(--cpb-font-sans);
    color: #1e293b;
    box-sizing: border-box;
}
.cpbpwc-batch-panel *,
.cpbpwc-batch-panel *::before,
.cpbpwc-batch-panel *::after {
    box-sizing: border-box;
}

.cpbpwc-batch-panel__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 14px;
    color: #1e293b;
}

.cpbpwc-batch-panel__section {
    margin-bottom: 18px;
}

.cpbpwc-batch-panel__heading {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 4px;
    color: #334155;
}

.cpbpwc-batch-panel__sublabel {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    margin: 0 0 10px;
}

/* ---------- Color swatches ---------- */
.cpbpwc-batch-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.cpbpwc-batch-color {
    width: auto;
    min-width: 52px;
    max-width: 104px;
    min-height: 52px;
    height: auto;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    padding: 4px 6px 3px;
    background: #fff;
    position: relative;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.cpbpwc-batch-color:hover {
    transform: translateY(-1px);
    border-color: #cbd5e1;
}

.cpbpwc-batch-color.is-selected {
    border-color: #6d28d9;
    box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.18);
}

.cpbpwc-batch-color__swatch {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.cpbpwc-batch-color__code {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cpbpwc-batch-color.is-selected .cpbpwc-batch-color__code {
    color: #6d28d9;
}

.cpbpwc-batch-color__tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
    z-index: 5;
}
.cpbpwc-batch-color:hover .cpbpwc-batch-color__tooltip {
    opacity: 1;
}

/* ---------- Size quantity grid ---------- */
.cpbpwc-batch-sizes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.cpbpwc-batch-sizes--single {
    grid-template-columns: 1fr;
    max-width: 140px;
}

.cpbpwc-batch-sizes--single.cpbpwc-batch-sizes--with-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    max-width: none;
}

.cpbpwc-batch-sizes--single.cpbpwc-batch-sizes--with-cta .cpbpwc-batch-size {
    flex: 0 0 100px;
    max-width: 120px;
}

.cpbpwc-batch-cart-slot {
    flex: 1 1 180px;
    min-width: 0;
}

.cpbpwc-batch-cart-slot .single_add_to_cart_button,
.cpbpwc-batch-cart-slot .cpbpwc-customize-redirect {
    width: 100%;
    margin: 0;
    text-align: center;
    box-sizing: border-box;
}

.cpbpwc-batch-footer .cpbpwc-batch-cart-slot {
    flex: 1 1 auto;
    max-width: 280px;
    margin-left: auto;
}

.cpbpwc-batch-size {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cpbpwc-batch-size__label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-align: center;
}

.cpbpwc-batch-size__input {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    background: #fff;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.cpbpwc-batch-size__input:focus {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 2px rgba(109, 40, 217, 0.18);
}
/* Hide native number spinners for a cleaner look */
.cpbpwc-batch-size__input::-webkit-outer-spin-button,
.cpbpwc-batch-size__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cpbpwc-batch-size__input {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ---------- Price + actions row ---------- */
.cpbpwc-batch-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.cpbpwc-batch-empty-note {
	margin: 0 0 8px;
	color: #6b7280;
	font-size: 13px;
}

.cpbpwc-batch-price {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cpbpwc-batch-price__label {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
}
.cpbpwc-batch-price__value {
    font-size: 22px;
    font-weight: 800;
    color: #0d9488;
    line-height: 1.1;
}

.cpbpwc-batch-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.cpbpwc-batch-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
    font-family: inherit;
}
.cpbpwc-batch-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.cpbpwc-batch-btn--primary {
    background: #6d28d9;
    color: #fff;
}
.cpbpwc-batch-btn--primary:hover:not(:disabled) {
    background: #5b21b6;
}
.cpbpwc-batch-btn--secondary {
    background: #ede9fe;
    color: #6d28d9;
}
.cpbpwc-batch-btn--secondary:hover:not(:disabled) {
    background: #ddd6fe;
}
.cpbpwc-batch-btn.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

.single_add_to_cart_button.cpbpwc-view-designs-btn.is-loading,
.single_add_to_cart_button.cpbpwc-view-designs-btn.cpbpwc-processing {
    pointer-events: none;
    opacity: 0.72;
    cursor: wait;
}

.single_add_to_cart_button.cpbpwc-view-designs-btn:disabled,
.single_add_to_cart_button.cpbpwc-view-designs-btn.disabled {
    pointer-events: none !important;
    cursor: not-allowed !important;
    opacity: 0.55 !important;
}

/* ---------- View my designs list ---------- */
.cpbpwc-batch-designs {
    margin-top: 22px;
    border-top: 2px solid #f1f5f9;
    padding-top: 16px;
}

.cpbpwc-batch-designs__title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cpbpwc-batch-designs__count {
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
}

.cpbpwc-batch-designs__empty {
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
    padding: 16px 0;
    text-align: center;
}

.cpbpwc-batch-design-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}
.cpbpwc-batch-design-row.is-saved {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.cpbpwc-batch-design-row__thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cpbpwc-batch-design-row__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cpbpwc-batch-design-row__thumb-placeholder {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    line-height: 1.2;
}

.cpbpwc-batch-design-row__info {
    flex: 1 1 auto;
    min-width: 0;
}
.cpbpwc-batch-design-row__name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 2px;
}
.cpbpwc-batch-design-row__meta {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}
.cpbpwc-batch-design-row__price {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 2px;
}
.cpbpwc-batch-design-row__thumb.cpbpwc-batch-row-preview {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
}
.cpbpwc-batch-design-row__thumb.cpbpwc-batch-row-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cpbpwc-batch-design-row__swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid #cbd5e1;
    vertical-align: middle;
    margin-right: 4px;
}

.cpbpwc-batch-design-row__actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}
.cpbpwc-batch-design-row__action {
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.cpbpwc-batch-design-row__action--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
}
.cpbpwc-batch-design-row__action--icon .cpbpwc-batch-icon {
    display: block;
}
.cpbpwc-batch-design-row__action:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.cpbpwc-batch-design-row__action--save {
    color: #0d9488;
    border-color: #99f6e4;
}
.cpbpwc-batch-design-row__action--save:hover {
    background: #f0fdfa;
}
.cpbpwc-batch-design-row__action--cart {
    color: #475569;
    border-color: #e2e8f0;
}
.cpbpwc-batch-design-row__action--cart:hover {
    color: #6d28d9;
    background: #f5f3ff;
    border-color: #ddd6fe;
}
.cpbpwc-batch-design-row__action--delete {
    color: #64748b;
    border-color: #e2e8f0;
}
.cpbpwc-batch-design-row__action--delete:hover {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}
.cpbpwc-batch-design-row__action.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.cpbpwc-batch-designs__addall {
    margin-top: 12px;
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

/* ---------- Notice ---------- */
.cpbpwc-batch-notice {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    display: none;
}
.cpbpwc-batch-notice.is-visible {
    display: block;
}
.cpbpwc-batch-notice--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.cpbpwc-batch-notice--success {
    background: #f0fdf4;
    color: #047857;
    border: 1px solid #bbf7d0;
}

/* ---------- Preview modal (per design) ---------- */
.cpbpwc-batch-preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 24px;
}
.cpbpwc-batch-preview-modal.is-open {
    display: flex;
}
.cpbpwc-batch-preview-modal__content {
    background: #0f172a;
    border-radius: 12px;
    padding: 20px;
    max-width: 520px;
    width: 100%;
    color: #fff;
}
.cpbpwc-batch-preview-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.cpbpwc-batch-preview-modal__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}
.cpbpwc-batch-preview-modal__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.cpbpwc-batch-preview-modal__img {
    width: 100%;
    border-radius: 8px;
    display: block;
    background: #1e293b;
}
.cpbpwc-batch-preview-modal__caption {
    margin-top: 12px;
    font-size: 12px;
    color: #cbd5e1;
    text-align: center;
}

/* ---------- Advance builder sidebar placement ---------- */
.cpbpwc-advance-container .cpbpwc-batch-panel {
    padding: 16px;
    background: #fff;
    border-radius: 10px;
    margin: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Fixed-width right sidebar: left to grow, the grid took most of the row
   and squeezed the design canvas into a small box. */
.cpbpwc-advance-container > .cpbpwc-batch-panel {
    flex: 0 0 340px;
    width: 340px;
    max-width: 340px;
    box-sizing: border-box;
    align-self: flex-start;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    margin: 12px 12px 12px 0;
}

@media (max-width: 900px) {
    /* Phones/tablets: the builder is one column of fixed height. Let the grid
       shrink and scroll so it never squeezes the tool menu (tabs) to 0px. */
    .cpbpwc-advance-container > .cpbpwc-batch-panel {
        flex: 0 1 auto;
        width: auto;
        max-width: none;
        min-height: 0;
        align-self: stretch;
        max-height: 30vh;
        margin: 8px 12px 12px;
        order: 3;
    }

    .cpbpwc-advance-container:has(> .cpbpwc-batch-panel) > .cpbpwc-options-container {
        min-height: 230px;
    }
}

/* ---------- Simple builder: panel in product summary (below title/price) ---------- */
.cpbpwc-variations-grid-mount {
    margin: 0 0 1.25em;
    clear: both;
    min-height: 220px;
}

.cpbpwc-batch-panel-skeleton {
    padding: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-sizing: border-box;
}

.cpbpwc-batch-panel-skeleton.cpbpwc-skeleton-hiding {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cpbpwc-batch-skeleton__title {
    display: block;
    width: 42%;
    height: 18px;
    margin-bottom: 14px;
    border-radius: 6px;
}

.cpbpwc-batch-skeleton__label {
    display: block;
    width: 28%;
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.cpbpwc-batch-skeleton__colors {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cpbpwc-batch-skeleton__color {
    width: 44px;
    height: 44px;
    border-radius: 8px;
}

.cpbpwc-batch-skeleton__sizes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.cpbpwc-batch-skeleton__size {
    width: 100%;
    height: 52px;
    border-radius: 6px;
}

.cpbpwc-batch-skeleton__footer {
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.cpbpwc-batch-skeleton__price {
    display: block;
    width: 55%;
    height: 28px;
    border-radius: 6px;
}

.cpbpwc-batch-summary-wrap {
    margin: 0;
    padding: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

/* Legacy: panel above canvas (fallback) ---------- */
.cpbpwc-batch-simple-wrap {
    margin: 18px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

@media (max-width: 600px) {
    .cpbpwc-batch-sizes {
        grid-template-columns: repeat(2, 1fr);
    }
    .cpbpwc-batch-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .cpbpwc-batch-actions {
        justify-content: stretch;
    }
    .cpbpwc-batch-btn {
        flex: 1 1 0;
    }
}

/* ---------- View my designs modal ---------- */
.cpbpwc-designs-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
}
.cpbpwc-designs-modal.is-open {
    display: flex;
}
.cpbpwc-designs-modal__dialog {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: min(86vh, 720px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
    font-family: var(--cpb-font-sans);
}
.cpbpwc-designs-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
}
.cpbpwc-designs-modal__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}
.cpbpwc-designs-modal__close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}
.cpbpwc-designs-modal__list {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
}
.cpbpwc-designs-modal__list .cpbpwc-batch-design-row {
    margin-bottom: 10px;
}
.cpbpwc-designs-modal__footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid #e2e8f0;
}
.cpbpwc-designs-modal__footer .cpbpwc-batch-btn {
    flex: 1 1 0;
    border: none;
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.cpbpwc-batch-design-row.is-saved {
    opacity: 0.72;
}

/* Hide default WooCommerce variation dropdowns only (keep qty + Add to cart). */
body.cpbpwc-variations-grid-active table.variations,
body.cpbpwc-variations-grid-active .variations_form .variations {
    display: none !important;
}

body.cpbpwc-variations-grid-active form.variations_form .single_variation_wrap,
body.cpbpwc-variations-grid-active .woocommerce-variation-add-to-cart,
body.cpbpwc-variations-grid-active .variations_button,
body.cpbpwc-variations-grid-active form.variations_form .cart {
    display: block !important;
    visibility: visible !important;
}

body.cpbpwc-variations-grid-active form.variations_form .single_add_to_cart_button {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Quantity lives in the grid; hide duplicate Woo qty and empty add-to-cart row. */
body.cpbpwc-variations-grid-active .woocommerce-variation-add-to-cart .quantity,
body.cpbpwc-grid-cart-relocated .woocommerce-variation-add-to-cart .quantity {
    display: none !important;
}

body.cpbpwc-grid-cart-relocated .woocommerce-variation-add-to-cart:not(:has(.single_add_to_cart_button)) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
}

body.cpbpwc-variations-grid-active form.cart:not(.variations_form) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

body.cpbpwc-variations-grid-active form.cart:not(.variations_form) .quantity {
    margin: 0;
}

body.cpbpwc-variations-grid-active form.cart:not(.variations_form) .single_add_to_cart_button {
    flex: 1 1 160px;
    margin: 0;
}

/* Sold-out sizes: greyed, struck-through label and a short note. */
.cpbpwc-batch-size.is-out-of-stock {
    cursor: not-allowed;
}
.cpbpwc-batch-size.is-out-of-stock .cpbpwc-batch-size__label {
    color: #94a3b8;
    text-decoration: line-through;
}
.cpbpwc-batch-size__input:disabled {
    background: repeating-linear-gradient(-45deg, #f1f5f9, #f1f5f9 4px, #e2e8f0 4px, #e2e8f0 8px);
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}
.cpbpwc-batch-size__note {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    color: #b91c1c;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Advanced builder top bar: grid quantity and total beside the unit price. */
.cpbpwc-grid-header-total {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
@media (max-width: 600px) {
    .cpbpwc-grid-header-total {
        margin-left: 4px;
        padding: 3px 8px;
        font-size: 12px;
    }
}
