/* ==========================================================================
   Kondura – Quick add-to-cart
   Product box button, size bottom sheet and "added" toast.
   Loaded after the theme's main + breakpoint CSS files (see Head.cshtml).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Product box – always show a full-width "Add to cart" button
   (list pages, search, manufacturer, home carousel)
   -------------------------------------------------------------------------- */
.product-item .buttons.product-box {
    display: block !important;
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
    overflow: visible !important;
    z-index: auto !important;
    font-size: 0;
}

.product-item .buttons.product-box .square-buttons-wrapper {
    display: block !important;
    width: 100%;
    padding: 0 !important;
    text-align: start;
}

/* the hover-overlay helpers of the theme are not needed for the inline button */
.product-item .buttons.product-box .dummy-link,
.product-item .buttons.product-box .tooltip-text,
.product-item .buttons.product-box .add-to-wishlist-button,
.product-item .buttons.product-box .add-to-compare-list-button {
    display: none !important;
}

.product-item .buttons.product-box .product-box-add-to-cart-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    min-height: 0;
    margin: 0;
    padding: 0 12px;
    border: 1px solid #111;
    border-radius: 6px;
    background: #111 !important;
    background-image: none !important;
    color: #fff !important;
    font-family: 'Poppins', 'Montserrat', Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .2px;
    text-transform: none;
    text-indent: 0;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, opacity .15s ease;
}

.product-item .buttons.product-box .product-box-add-to-cart-button::before {
    content: "";
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='21' r='1'/><circle cx='20' cy='21' r='1'/><path d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/></svg>") center / contain no-repeat;
}

.product-item .buttons.product-box .product-box-add-to-cart-button:hover,
.product-item .buttons.product-box .product-box-add-to-cart-button:focus,
.product-item .buttons.product-box .product-box-add-to-cart-button:active {
    background: #000 !important;
    border-color: #000;
    color: #fff !important;
}

.product-item .buttons.product-box .product-box-add-to-cart-button.is-loading {
    pointer-events: none;
    opacity: .7;
}

.product-item .buttons.product-box .product-box-add-to-cart-button.is-loading::before {
    background: none;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    box-sizing: border-box;
    animation: quick-add-spin .7s linear infinite;
}

/* sold-out boxes (no purchasable variant) keep the "Sold Out" label only */
.product-item .picture.no-stock ~ .details .buttons.product-box {
    display: none !important;
}

@keyframes quick-add-spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   2. Bottom sheet
   -------------------------------------------------------------------------- */
html.quick-add-open,
html.quick-add-open body {
    overflow: hidden;
}

.quick-add-sheet {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    pointer-events: none;
    font-family: 'Poppins', 'Montserrat', Arial, sans-serif;
    color: #111;
    direction: inherit;
}

.quick-add-sheet.is-open {
    visibility: visible;
    pointer-events: auto;
}

.quick-add-sheet__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .25s ease;
}

.quick-add-sheet.is-open .quick-add-sheet__overlay {
    opacity: 1;
}

.quick-add-sheet__panel {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 85vh;
    max-height: 85dvh;
    padding: 6px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}

.quick-add-sheet.is-open .quick-add-sheet__panel {
    transform: translateY(0);
}

.quick-add-sheet__panel.is-dragging {
    transition: none;
}

.quick-add-sheet__handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 10px;
    touch-action: none;
    cursor: grab;
}

.quick-add-sheet__handle span {
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: #d6d6d6;
}

.quick-add-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
}

.quick-add-sheet__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    text-align: start;
    color: #111;
}

.quick-add-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-height: 0;
    margin: 0;
    margin-inline-end: -8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent !important;
    color: #111 !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.quick-add-sheet__close:hover,
.quick-add-sheet__close:focus {
    background: #f2f2f2 !important;
    color: #111 !important;
}

.quick-add-sheet__close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.quick-add-sheet__product {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 18px;
}

.quick-add-sheet__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    background: #fafafa;
}

.quick-add-sheet__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.quick-add-sheet__info {
    min-width: 0;
    text-align: start;
}

.quick-add-sheet__name {
    font-size: 15px;
    line-height: 1.35;
    color: #333;
}

.quick-add-sheet__price {
    margin-top: 2px;
    font-size: 18px;
    font-weight: 700;
    color: #111;
}

.quick-add-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.quick-add-group + .quick-add-group {
    margin-top: 18px;
}

.quick-add-group__label {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    text-align: start;
    color: #666;
}

.quick-add-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 12px;
}

.quick-add-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    box-sizing: border-box;
    height: 52px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0 6px;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    background: #fff !important;
    color: #111 !important;
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    text-transform: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.quick-add-chip:hover,
.quick-add-chip:focus-visible {
    border-color: #111;
    background: #fff !important;
    color: #111 !important;
}

.quick-add-chip.is-selected,
.quick-add-chip.is-selected:hover,
.quick-add-chip.is-selected:focus {
    border-color: #111;
    background: #111 !important;
    color: #fff !important;
}

.quick-add-chip[disabled],
.quick-add-chip[disabled]:hover {
    border-color: #eee;
    background: #fafafa !important;
    color: #b5b5b5 !important;
    text-decoration: line-through;
    cursor: not-allowed;
}

.quick-add-chip.is-busy {
    opacity: .6;
    pointer-events: none;
}

.quick-add-chip__adj {
    font-size: 11px;
    opacity: .7;
}

.quick-add-chip__swatch {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 50%;
}

.quick-add-chip__img {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
}

/* --------------------------------------------------------------------------
   3. "Added to cart" toast
   -------------------------------------------------------------------------- */
.quick-add-toast {
    position: fixed;
    inset-inline: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 100001;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 560px;
    margin: 0 auto;
    padding: 14px 18px;
    border-radius: 12px;
    background: #2e7d32;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    font-family: 'Poppins', 'Montserrat', Arial, sans-serif;
    text-align: start;
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px);
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}

.quick-add-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

.quick-add-toast.is-error {
    background: #c62828;
}

.quick-add-toast__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: #2e7d32;
}

.quick-add-toast.is-error .quick-add-toast__icon {
    color: #c62828;
}

.quick-add-toast__icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.quick-add-toast__icon .quick-add-toast__icon-error,
.quick-add-toast.is-error .quick-add-toast__icon .quick-add-toast__icon-success {
    display: none;
}

.quick-add-toast.is-error .quick-add-toast__icon .quick-add-toast__icon-error {
    display: block;
}

.quick-add-toast__text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.quick-add-toast__title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
}

.quick-add-toast__subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.3;
    opacity: .92;
}

.quick-add-toast__link {
    flex: 0 0 auto;
    color: #fff !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.quick-add-toast.is-error .quick-add-toast__link {
    display: none;
}

/* --------------------------------------------------------------------------
   4. Desktop / tablet: centered dialog instead of a bottom sheet
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
    .quick-add-sheet {
        align-items: center;
        padding: 24px;
    }

    .quick-add-sheet__panel {
        width: 100%;
        max-width: 480px;
        max-height: 80vh;
        padding: 20px 24px 24px;
        border-radius: 16px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
        opacity: 0;
        transform: translateY(24px);
        transition: transform .25s ease, opacity .25s ease;
    }

    .quick-add-sheet.is-open .quick-add-sheet__panel {
        opacity: 1;
        transform: none;
    }

    .quick-add-sheet__handle {
        display: none;
    }

    .quick-add-toast {
        inset-inline: auto 24px;
        bottom: 24px;
        max-width: 440px;
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .quick-add-sheet__overlay,
    .quick-add-sheet__panel,
    .quick-add-toast,
    .quick-add-chip {
        transition: none;
    }
}
