/**
 * @author andy
 * @email andyworkbase@gmail.com
 * @team MageCloud
 * @package MageCloud_MiniCartEnhancements
 */

/* ------------------------------------------------------------------
 * Drawer width
 * --mc-minicart-width is only printed when the module is enabled, so
 * the 280px fallback keeps the theme's original drawer when it is off.
 * ------------------------------------------------------------------ */
#offCanvasRight.position-right {
    width: var(--mc-minicart-width, 280px);
    max-width: 100%;
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
}

#offCanvasRight.position-right.is-open {
    -webkit-transform: none;
    transform: none;
}

@media (max-width: 639.98px) {
    #offCanvasRight.position-right {
        width: 100%;
    }
}

/* ------------------------------------------------------------------
 * Line items
 * ------------------------------------------------------------------ */
.minicart-items .product-item {
    position: relative;
}

.minicart-items .product-item-pricing.mc-has-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin: .5rem 0;
}

.minicart-items .details-qty.mc-has-stepper {
    display: block;
}

.minicart-items .details-qty.mc-has-stepper:after {
    content: none;
}

.minicart-items .mc-has-stepper + .price-container,
.minicart-items .mc-has-stepper + .subtotal {
    margin-left: auto;
}

/* Stepper */
.mc-qty-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #c4c4c4;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
}

.mc-qty-stepper .mc-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #f5f5f5;
    color: #333;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.mc-qty-stepper .mc-qty-btn:hover,
.mc-qty-stepper .mc-qty-btn:focus-visible {
    background: #e6e6e6;
}

.mc-qty-stepper .mc-qty-btn:focus-visible,
.mc-qty-stepper .mc-qty-input:focus-visible {
    outline: 2px solid #01badc;
    outline-offset: -2px;
}

.mc-qty-stepper .mc-qty-btn[disabled] {
    cursor: default;
    opacity: .5;
}

.mc-qty-stepper .mc-qty-input {
    width: 3rem;
    height: 44px;
    margin: 0;
    padding: 0 .25rem;
    border: 0;
    border-left: 1px solid #c4c4c4;
    border-right: 1px solid #c4c4c4;
    border-radius: 0;
    box-shadow: none;
    color: #333;
    font-size: 1rem; /* 16px stops iOS zooming on focus */
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.mc-qty-stepper .mc-qty-input::-webkit-outer-spin-button,
.mc-qty-stepper .mc-qty-input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

/* Loading state while a qty update is in flight */
.minicart-items .product-item.mc-is-updating > .product {
    opacity: .5;
    pointer-events: none;
}

.minicart-items .product-item.mc-is-updating:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #c4c4c4;
    border-top-color: #01badc;
    border-radius: 50%;
    animation: mc-minicart-spin .7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .minicart-items .product-item.mc-is-updating:after {
        animation-duration: 2s;
    }
}

/* ------------------------------------------------------------------
 * Totals breakdown (footer)
 * ------------------------------------------------------------------ */
.minicart-wrapper .offcanvas-footer .mc-minicart-totals {
    margin-bottom: 1rem;
    color: #333;
    font-size: .875rem;
}

.mc-minicart-totals .mc-totals-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: .2rem 0;
}

.mc-minicart-totals .mc-totals-row .value {
    white-space: nowrap;
}

.mc-minicart-totals .mc-totals-discount {
    color: #2e7d32;
}

.mc-minicart-totals .mc-discount-code {
    font-weight: 400;
    word-break: break-all;
}

.mc-minicart-totals .mc-totals-total {
    margin-top: .25rem;
    padding-top: .5rem;
    border-top: 1px solid #c4c4c4;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}

.mc-minicart-totals .mc-totals-note {
    margin: .25rem 0 0;
    color: #666;
    font-size: .75rem;
    text-align: right;
}
