/**
 * Shopping cart popups: "added to cart" (.order-popup-wrapper) and "request offer" (.request-popup-wrapper)
 * Templates: app/Templates/woocommerce/includes/request/, loaded by Libs/WooCommerce/ProductPage
 *
 * Theme independent:
 * - everything is scoped to .shop_ls-popup and resets what a theme may set (fonts, buttons, inputs, lists)
 * - no Bootstrap / theme classes; `hide` (popup) and `hidden` (elements) toggled by orders.js are defined here
 * - colors / sizes are CSS variables, a theme can override them on .shop_ls-popup
 *
 * Open / close animation: the popup stays in the layout (no display: none), `.hide` fades it out.
 */

.shop_ls-popup {
    --shop_ls-accent: #7b599b;
    --shop_ls-accent-hover: #664a81;
    --shop_ls-text: #212529;
    --shop_ls-muted: #6c757d;
    --shop_ls-border: #dee2e6;
    --shop_ls-surface: #ffffff;
    --shop_ls-backdrop: rgba(17, 17, 17, 0.55);
    --shop_ls-radius: 8px;
    --shop_ls-duration: 220ms;
    --shop_ls-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---- Reset inside the popup: theme styles must not leak in ---- */

.shop_ls-popup,
.shop_ls-popup *,
.shop_ls-popup *::before,
.shop_ls-popup *::after {
    box-sizing: border-box;
}

.shop_ls-popup :where(div, span, p, ol, li, dl, dt, dd, b, small, label, form, img, a, button, input) {
    margin: 0;
    padding: 0;
    border: 0;
    float: none;
    text-transform: none;
    letter-spacing: normal;
    text-shadow: none;
    box-shadow: none;
    background: none;
    min-height: 0;
    max-height: none;
    font: inherit;
    color: inherit;
}

.shop_ls-popup :where(ol, li) {
    list-style: none;
}

.shop_ls-popup :where(li)::before,
.shop_ls-popup :where(li)::marker {
    content: none;
}

/* ---- Backdrop + dialog ---- */

.shop_ls-popup.wpg-popup-wrapper {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 16px;
    margin: 0;
    width: auto;
    height: auto;
    background: var(--shop_ls-backdrop);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--shop_ls-text);
    text-align: left;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--shop_ls-duration) var(--shop_ls-ease), visibility 0s linear 0s;
}

/* orders.js toggles `hide`: fade out instead of display: none (theme `.hide { display: none !important }` is overridden) */
.shop_ls-popup.wpg-popup-wrapper.hide {
    display: flex !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--shop_ls-duration) var(--shop_ls-ease), visibility 0s linear var(--shop_ls-duration);
}

.shop_ls-popup .shop_ls-popup__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 24px 28px;
    background: var(--shop_ls-surface);
    border-radius: var(--shop_ls-radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    transform: translateY(0) scale(1);
    transition: transform var(--shop_ls-duration) var(--shop_ls-ease);
}

.shop_ls-popup.hide .shop_ls-popup__dialog {
    transform: translateY(16px) scale(0.98);
}

/* ---- Header ---- */

.shop_ls-popup .shop_ls-popup__header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-right: 32px;
}

.shop_ls-popup .shop_ls-popup__title {
    display: block;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.shop_ls-popup .shop_ls-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    color: var(--shop_ls-muted);
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.shop_ls-popup .shop_ls-popup__close:hover,
.shop_ls-popup .shop_ls-popup__close:focus-visible {
    background: #f1f3f5;
    color: var(--shop_ls-text);
    outline: none;
}

/* ---- Body / product summary ---- */

.shop_ls-popup .shop_ls-popup__body {
    display: block;
    margin: 20px 0 24px;
}

.shop_ls-popup .shop_ls-popup__product {
    display: flex;
    align-items: center;
    gap: 16px;
}

.shop_ls-popup .shop_ls-popup__image {
    flex: 0 0 96px;
}

.shop_ls-popup .shop_ls-popup__image img {
    display: block;
    width: 96px;
    height: 96px;
    max-width: none;
    object-fit: contain;
    border: 1px solid var(--shop_ls-border);
    border-radius: 6px;
    background: #fff;
}

.shop_ls-popup .shop_ls-popup__info {
    flex: 1 1 auto;
    min-width: 0;
}

.shop_ls-popup .shop_ls-popup__name {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.shop_ls-popup .shop_ls-popup__details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    font-size: 13px;
}

.shop_ls-popup .shop_ls-popup__details > div {
    display: flex;
    gap: 6px;
}

.shop_ls-popup .shop_ls-popup__details dt {
    font-weight: 600;
    color: var(--shop_ls-muted);
}

.shop_ls-popup .shop_ls-popup__details dt::after {
    content: ":";
}

.shop_ls-popup .shop_ls-popup__details dd small {
    color: var(--shop_ls-muted);
    font-size: 12px;
}

/* ---- Footer / buttons ---- */

.shop_ls-popup .shop_ls-popup__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.shop_ls-popup .shop_ls-popup__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.shop_ls-popup .shop_ls-popup__btn:active {
    transform: translateY(1px);
}

.shop_ls-popup .shop_ls-popup__btn:focus-visible {
    outline: 2px solid var(--shop_ls-accent);
    outline-offset: 2px;
}

.shop_ls-popup .shop_ls-popup__btn--primary {
    background: var(--shop_ls-accent);
    border-color: var(--shop_ls-accent);
    color: #fff;
}

.shop_ls-popup .shop_ls-popup__btn--primary:hover {
    background: var(--shop_ls-accent-hover);
    border-color: var(--shop_ls-accent-hover);
    color: #fff;
}

.shop_ls-popup .shop_ls-popup__btn--secondary {
    background: #fff;
    border-color: var(--shop_ls-border);
    color: var(--shop_ls-text);
}

.shop_ls-popup .shop_ls-popup__btn--secondary:hover {
    background: #f8f9fa;
    color: var(--shop_ls-text);
}

/* Cart popup: orders.js toggles request-mode */
.shop_ls-popup:not(.request-mode) .go-to-order,
.shop_ls-popup.request-mode .go-to-cart {
    display: none !important;
}

/* orders.js toggles `hidden` (Bootstrap 3 class, missing in Bootstrap 5 themes) */
.shop_ls-popup .hidden {
    display: none !important;
}

/* Button loading state: orders.js puts <span class="loading"></span> into the clicked button */
.shop_ls-popup .loading,
.shop_ls-popup .shop_ls-popup__spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: shop_ls-spin 700ms linear infinite;
}

.shop_ls-popup .shop_ls-popup__spinner {
    width: 28px;
    height: 28px;
    margin: 8px auto 0;
    color: var(--shop_ls-accent);
}

.shop_ls-popup .shop_ls-popup__spinner:not(.hidden) {
    display: block;
}

/* ---- Request steps ---- */

.shop_ls-popup .shop_ls-popup__steps {
    display: grid;
    gap: 16px;
}

.shop_ls-popup .wpg-step {
    display: grid;
    grid-template-columns: 40px 1fr;
    column-gap: 14px;
    align-items: start;
}

.shop_ls-popup .wpg-step__icon span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ced4da;
    color: #fff;
    font-weight: 700;
    transition: background-color var(--shop_ls-duration) var(--shop_ls-ease), transform var(--shop_ls-duration) var(--shop_ls-ease);
}

.shop_ls-popup .wpg-step.active .wpg-step__icon span {
    background: var(--shop_ls-accent);
    transform: scale(1.05);
}

.shop_ls-popup .wpg-step__label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-height: 40px;
    color: var(--shop_ls-muted);
}

.shop_ls-popup .wpg-step__label b {
    font-weight: 700;
    color: var(--shop_ls-text);
}

.shop_ls-popup .wpg-step .edit-step {
    color: var(--shop_ls-accent);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

/* Active step: content instead of the label */
.shop_ls-popup .wpg-step__content,
.shop_ls-popup .wpg-step.active .wpg-step__label {
    display: none;
}

.shop_ls-popup .wpg-step.active .wpg-step__content {
    display: block;
    grid-column: 2;
    animation: shop_ls-step-in var(--shop_ls-duration) var(--shop_ls-ease);
}

/* ---- Email field ---- */

.shop_ls-popup .shop_ls-popup__field {
    display: grid;
    gap: 6px;
    max-width: 360px;
}

.shop_ls-popup .shop_ls-popup__field label {
    font-size: 13px;
    font-weight: 600;
}

.shop_ls-popup .shop_ls-popup__field input {
    display: block;
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--shop_ls-border);
    border-radius: 6px;
    background: #fff;
    font-size: 15px;
    color: var(--shop_ls-text);
    transition: border-color 150ms ease, box-shadow 150ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.shop_ls-popup .shop_ls-popup__field input:focus {
    border-color: var(--shop_ls-accent);
    box-shadow: 0 0 0 3px rgba(123, 89, 155, 0.2);
    outline: none;
}

/* ---- Animations ---- */

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

@keyframes shop_ls-step-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .shop_ls-popup,
    .shop_ls-popup * {
        transition-duration: 1ms !important;
        animation-duration: 1ms !important;
    }
}

/* ---- Small screens ---- */

@media (max-width: 600px) {
    .shop_ls-popup .shop_ls-popup__dialog {
        padding: 20px 16px;
    }

    .shop_ls-popup .shop_ls-popup__product {
        flex-direction: column;
        text-align: center;
    }

    .shop_ls-popup .shop_ls-popup__details {
        justify-content: center;
    }

    .shop_ls-popup .shop_ls-popup__footer {
        flex-direction: column-reverse;
    }

    .shop_ls-popup .shop_ls-popup__btn {
        width: 100%;
    }

    .shop_ls-popup .wpg-step {
        grid-template-columns: 32px 1fr;
    }

    .shop_ls-popup .wpg-step__icon span {
        width: 32px;
        height: 32px;
    }

    .shop_ls-popup .wpg-step__label {
        min-height: 32px;
    }
}

/* ---- Cart buttons on the product page: loading state ----
 * orders.js disables the clicked button and replaces its content with <span class="loading"></span>
 * until the AJAX response (.wspsc_add_cart_add_to_cart_submit, .wspsc_add_cart_request_submit)
 */

.wspsc_add_cart_add_to_cart_submit,
.wspsc_add_cart_request_submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
    transition: opacity 150ms ease, transform 100ms ease;
}

.wspsc_add_cart_add_to_cart_submit:active:not(:disabled),
.wspsc_add_cart_request_submit:active:not(:disabled) {
    transform: translateY(1px);
}

.wspsc_add_cart_add_to_cart_submit:disabled,
.wspsc_add_cart_request_submit:disabled {
    cursor: progress;
    opacity: 0.85;
}

.wspsc_add_cart_add_to_cart_submit .loading,
.wspsc_add_cart_request_submit .loading {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    margin: 0.1em 0;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: shop_ls-spin 700ms linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    .wspsc_add_cart_add_to_cart_submit .loading,
    .wspsc_add_cart_request_submit .loading {
        animation-duration: 1.5s;
    }
}

/* ---- Cart buttons layout: both buttons in one line under the price ----
 * .compo > .wp_request_button_wrapper (add to cart form) + #requestOfferButton > .wp_cart_button_wrapper (request form)
 * Look comes from the theme: buttons have single_add_to_cart_button button alt (ProductPage::withThemeButtonClasses())
 */

.compo {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 0 0 1em;
}

.compo > .wp_request_button_wrapper,
.compo > #requestOfferButton {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
}

.compo .wp_cart_button_wrapper,
.compo form {
    display: flex !important;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    float: none;
}

.compo .wspsc_add_cart_add_to_cart_submit,
.compo .wspsc_add_cart_request_submit {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    margin: 0;
    float: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Too narrow for two buttons: one under the other */
@media (max-width: 420px) {
    .compo > .wp_request_button_wrapper,
    .compo > #requestOfferButton {
        flex-basis: 100%;
    }
}
