/* Storefront upsell (docs/manual-upselling/05-storefront-ui-and-js.md). Loaded on every storefront page;
   every rule is scoped to an upsell class or id. Logical properties keep LTR and RTL layouts right. */

/* ---------------------------------------------------------------- Carousel */
.upsell-section {
    margin: 16px 0;
    padding-inline: 25px;
    text-align: start;
}

.theme-container .upsell-section {
    padding-inline: 0;
}

/* Same dashed separator as the option groups of the product page. */
.product-info .upsell-section,
.theme-container .upsell-section {
    padding-top: 16px;
    border-top: 1px dashed #cecfd6;
}

.upsell-header {
    margin-bottom: 10px;
}

.upsell-headline {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #000;
}

.upsell-description {
    margin: 4px 0 0;
    font-size: 13px;
    color: #898d99;
}

/* The track runs to the screen edges, so a half-visible card says "swipe" instead of looking cut off. */
.upsell-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin-inline: -25px;
    padding-inline: 25px;
    padding-bottom: 4px;
    scroll-padding-inline: 25px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.upsell-track::-webkit-scrollbar {
    display: none;
}

/* A mouse cannot swipe. */
@media (hover: hover) and (pointer: fine) {
    .upsell-track {
        scrollbar-width: auto;
    }

    .upsell-track::-webkit-scrollbar {
        display: block;
        height: 6px;
    }

    .upsell-track::-webkit-scrollbar-track {
        margin-inline: 25px;
    }

    .upsell-track::-webkit-scrollbar-thumb {
        border-radius: 3px;
        background: #cecfd6;
    }

    /* Firefox has no scrollbar pseudo-elements. */
    @supports (-moz-appearance: none) {
        .upsell-track {
            scrollbar-width: thin;
            scrollbar-color: #cecfd6 transparent;
        }
    }
}

.upsell-card {
    display: flex;
    flex: 0 0 156px;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    scroll-snap-align: start;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.upsell-image {
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-bottom: 1px solid #dee2e6;
}

.upsell-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upsell-name {
    display: -webkit-box;
    overflow: hidden;
    min-height: 36px;
    margin: 8px 10px 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 18px;
    color: #000;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Colours of the menu list: a discounted price is red, the old one grey. */
.upsell-price {
    display: flex;
    flex-wrap: wrap;
    column-gap: 6px;
    margin: 0 10px 8px;
    font-size: 13px;
    font-weight: 500;
    color: #000;
}

/* Each price keeps its own text direction: in Arabic, "from EGP 30" would otherwise merge with the
   struck-through number after it and read as "from 60". */
.upsell-price-now,
.upsell-price-before {
    unicode-bidi: isolate;
}

.upsell-price.has-discount .upsell-price-now {
    color: #c40000;
}

.upsell-price-before {
    color: #898d99;
}

/* Same visual order as the menu list: the current price on the left of the old one. */
html[lang="ar"] .upsell-price {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.upsell-actions {
    margin: auto 10px 10px;
}

/* The tinted brand look of the active category chip. */
.upsell-add-btn,
.upsell-stepper,
.upsell-complex-state {
    width: 100%;
    height: 36px;
    border: 1px solid var(--main_color);
    border-radius: 6px;
    background: color-mix(in srgb, var(--main_color) 10%, #fff);
}

.upsell-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--main_color);
}

.upsell-add-btn:active {
    background: var(--main_color);
    color: #fff;
}

.upsell-round-btn {
    display: inline-flex;
    flex: 0 0 28px;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--main_color);
    border-radius: 50%;
    background: var(--main_color);
    font-size: 11px;
    color: #fff;
}

.upsell-minus,
.upsell-undo {
    background: #fff;
    color: var(--main_color);
}

.upsell-stepper,
.upsell-complex-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 0 3px;
}

.upsell-qty {
    font-size: 14px;
    font-weight: 700;
    color: #000;
}

/* One row, same height as the other states: undo, "Added (N)", add another. */
.upsell-complex-state {
    gap: 2px; /* tighter than the stepper, to leave the label room */
}

.upsell-complex-state .upsell-round-btn {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
}

.upsell-complex-buttons {
    display: contents;
}

.upsell-undo {
    order: 1;
}

.upsell-added-badge {
    flex: 1;
    min-width: 0;
    order: 2;
    font-size: 11px;
    font-weight: 700;
    line-height: 13px;
    text-align: center;
    color: var(--main_color);
}

.upsell-added-badge i {
    margin: 0;
}

.upsell-add-more {
    order: 3;
}

.upsell-card.is-busy .upsell-actions {
    opacity: 0.55;
}

.upsell-card button:disabled {
    cursor: progress;
}

@media (min-width: 576px) {
    .upsell-card {
        flex-basis: 168px;
    }
}

/* The product page: keep the carousel clear of the fixed quantity and add-to-basket bar (P13). */
.product-info.has-upsell {
    padding-bottom: 190px;
}

/* ---------------------------------------------------------------- Options sheet */
.upsell-sheet {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    max-height: 85dvh;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
    background: #fff;
    text-align: start;
}

.upsell-sheet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #e9ecef;
}

.upsell-sheet-header img {
    width: 52px;
    height: 52px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    object-fit: cover;
}

.upsell-sheet-header h5 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #000;
}

.upsell-sheet-close {
    display: inline-flex;
    flex: 0 0 34px;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #eef0f3;
    color: #000;
}

.upsell-sheet-close i,
.upsell-round-btn i {
    margin: 0;
}

#upsellOptionsForm {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.upsell-sheet-body {
    min-height: 0;
    overflow-y: auto;
}

.upsell-sheet-body .checks-area:first-of-type {
    border-top: 0;
}

#upsellOptionsError {
    flex-direction: column;
    align-items: flex-start;
    margin: 12px 25px;
    border-radius: 8px;
    font-size: 13px;
}

#upsellOptionsBody > br {
    display: none;
}

#upsellOptionsBody .check-row {
    align-items: center;
}

#upsellOptionsBody .custom-radio {
    margin-bottom: 0;
}

#upsellOptionsBody .upsell-has-error .title {
    color: #dc3545;
}

.upsell-sheet-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid #e9ecef;
}

.upsell-sheet-quantity {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* The quantity buttons of the product page. */
.upsell-sheet-quantity .upsell-round-btn {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    border: 1px solid #e4e5ec;
    border-radius: 8px;
    background: #f8f9fa;
    font-size: 13px;
    color: #495057;
}

.upsell-modal-qty {
    min-width: 28px;
    font-weight: 700;
    text-align: center;
    color: #000;
}

#upsellModalAddBtn {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
    padding: 8px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--main_color);
    font-size: 15px;
    font-weight: 500;
    color: #fff;
}

/* With no price yet, the label sits in the middle like the product page's button. */
#upsellModalAddBtn .upsell-modal-price:empty {
    display: none;
}

#upsellModalAddBtn:has(.upsell-modal-price:empty) {
    justify-content: center;
}

#upsellModalAddBtn:disabled {
    opacity: 0.6;
}

@media (min-width: 768px) {
    #upsell_options_modal {
        align-items: center;
    }

    #upsell_options_modal .upsell-sheet {
        margin: 0 20px;
        border-radius: 20px;
    }
}

/* ---------------------------------------------------------------- Toast */
.upsell-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 1090;
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    border-radius: 24px;
    background: #212529;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    color: #fff;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.upsell-toast.is-error {
    background: #b02a37;
}

.upsell-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- Checkout payment lock (R19) */
/* Visual and pointer block only; checkout.js also stops guest events while this class is on. */
.upsell-payment-locked {
    position: relative;
    pointer-events: none;
}

.upsell-payment-locked > * {
    opacity: 0.45;
}

/* The label covers the dimmed pay button, in the brand colour. It has the button's height and sits at
   the bottom, because the embedded form's button adds a top margin inside #payActions. */
#payActions.upsell-payment-locked::after {
    content: attr(data-lock-label);
    position: absolute;
    inset: auto 0 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--main_color);
    border-radius: 6px;
    background: color-mix(in srgb, var(--main_color) 10%, #fff);
    font-size: 14px;
    font-weight: 700;
    color: var(--main_color);
}

#payActions.upsell-payment-locked::before {
    content: "";
    position: absolute;
    bottom: 16px;
    inset-inline-start: 16px;
    z-index: 1;
    width: 18px;
    height: 18px;
    border: 2px solid var(--main_color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: upsell-spin 0.8s linear infinite;
}

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