/* Stable media frames for storefront dialogs.
   Source images keep their original files and aspect ratios. */

#quick_view .modal-dialog {
    width: min(1120px, calc(100vw - 48px));
    max-width: none !important;
    margin: 24px auto;
}

#quick_view .modal-content {
    width: 100%;
    height: min(760px, calc(100vh - 48px));
    height: min(760px, calc(100dvh - 48px));
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: hidden;
    border: 0;
    border-radius: 18px;
}

#quick_view .modal-content > .wrap {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 0 !important;
    overflow: hidden;
}

#quick_view .tf-product-media-wrap {
    flex: 0 0 52%;
    width: 52% !important;
    max-width: 52%;
    min-width: 0;
    height: 100%;
    padding: 0 !important;
    overflow: hidden;
    background: #f6f8fc;
}

#quick_view .tf-product-media-wrap .swiper,
#quick_view .tf-product-media-wrap .swiper-wrapper,
#quick_view .tf-product-media-wrap .swiper-slide,
#quick_view .tf-product-media-wrap .item {
    width: 100%;
    height: 100% !important;
    min-height: 0;
}

#quick_view #quickViewImage {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: contain !important;
    object-position: center;
    background: #f6f8fc;
}

#quick_view .tf-product-info-wrap {
    flex: 1 1 48%;
    width: 48%;
    min-width: 0;
    height: 100%;
}

#quick_view .tf-product-info-wrap .tf-product-info-list {
    position: static !important;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 48px 36px 32px !important;
    overflow-x: hidden;
    overflow-y: auto !important;
    scrollbar-width: thin;
}

#quick_view .modal-content .icon-close-popup {
    top: 16px !important;
    right: 16px !important;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

#quick_add .modal-content {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
}

#quick_add .modal-content > .wrap {
    max-height: calc(100vh - 92px);
    max-height: calc(100dvh - 92px);
    overflow-y: auto;
}

#quick_add .tf-product-info-item {
    align-items: center;
}

#quick_add .tf-product-info-item .image {
    flex: 0 0 96px;
    width: 96px;
    height: 112px;
    padding: 6px;
    overflow: hidden;
    border: 1px solid #e4ecfa;
    border-radius: 12px;
    background: #f6f8fc;
}

#quick_add .tf-product-info-item .image img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center;
}

/* The AJAX mini-cart inserts a direct img, while the initial template uses an
   anchor around it. Size both structures identically. */
.modal-shopping-cart .tf-mini-cart-item {
    align-items: flex-start;
}

.modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-image {
    flex: 0 0 88px;
    width: 88px;
    height: 112px;
    padding: 5px;
    overflow: hidden;
    border: 1px solid #e8edf5;
    border-radius: 10px;
    background: #f6f8fc;
}

.modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-image > img,
.modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-image > a,
.modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-image > a > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center;
}

.modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-info {
    flex: 1 1 auto;
    min-width: 0;
}

/* Linked-gift chooser */
.ecoway-linked-gift-modal {
    z-index: 1095;
}

.ecoway-linked-gift-modal .modal-dialog {
    width: min(780px, calc(100vw - 32px));
    max-width: none;
    margin: 16px auto;
}

.ecoway-linked-gift-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
    border: 1px solid #e4eaf4;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, .18);
}

.ecoway-linked-gift-modal .modal-header {
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px 15px;
    border: 0;
    border-bottom: 1px solid #eef2f7;
}

.ecoway-linked-gift-modal .modal-title {
    margin: 0;
    color: #0b3ea1;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.25;
}

.ecoway-linked-gift-modal .ecoway-linked-gift-subtitle {
    margin: 5px 0 0;
    color: #64748b;
    font-size: 14px;
    line-height: 1.55;
}

.ecoway-linked-gift-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: #0b3ea1;
    font-size: 27px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.ecoway-linked-gift-close:hover,
.ecoway-linked-gift-close:focus-visible {
    background: #0b3ea1;
    color: #fff;
}

.ecoway-linked-gift-modal .modal-body {
    min-height: 0;
    padding: 18px 22px;
    overflow-y: auto;
    background: #f8fafc;
}

.ecoway-linked-gift-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 16px;
}

.ecoway-linked-gift-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #dde6f3;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(15, 23, 42, .05);
}

.ecoway-linked-gift-card:only-child {
    grid-column: 1 / -1;
    width: calc(50% - 8px);
    justify-self: center;
}

.ecoway-linked-gift-image-frame {
    width: 100%;
    height: 176px;
    padding: 10px;
    overflow: hidden;
    border-radius: 12px;
    background: #f5f7fb;
}

.ecoway-linked-gift-image-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.ecoway-linked-gift-card h6 {
    min-height: 24px;
    margin: 12px 0 4px;
    color: #0b3ea1;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.5;
}

.ecoway-linked-gift-description {
    display: -webkit-box;
    min-height: 0;
    margin: 0 0 9px;
    overflow: hidden;
    color: #64748b;
    font-size: 13px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ecoway-linked-gift-price {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 10px;
    min-height: 26px;
    margin-top: auto;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.ecoway-linked-gift-price del {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    text-decoration-thickness: 1.5px;
}

.ecoway-linked-gift-price strong {
    color: #0b3ea1;
    font-size: 15px;
    font-weight: 800;
}

.ecoway-linked-gift-price strong.is-free {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eaf7ef;
    color: #087443;
    font-size: 13px;
}

.ecoway-linked-gift-card .ecoway-select-linked-gift {
    min-height: 42px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: #0b63d8;
    font-size: 14px;
    font-weight: 800;
}

@media (max-width: 767.98px) {
    #quick_view .modal-dialog {
        width: calc(100vw - 20px);
        margin: 10px auto;
    }

    #quick_view .modal-content {
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }

    #quick_view .modal-content > .wrap {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #quick_view .tf-product-media-wrap {
        flex: 0 0 clamp(230px, 38vh, 320px);
        flex-basis: clamp(230px, 38dvh, 320px);
        width: 100% !important;
        max-width: 100%;
        height: clamp(230px, 38vh, 320px);
        height: clamp(230px, 38dvh, 320px);
    }

    #quick_view .tf-product-info-wrap {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
    }

    #quick_view .tf-product-info-wrap .tf-product-info-list {
        height: auto;
        padding: 24px 18px 28px !important;
        overflow: visible !important;
    }

    #quick_view .modal-content .icon-close-popup {
        top: 10px !important;
        right: 10px !important;
    }

    .modal-shopping-cart .tf-mini-cart-item .tf-mini-cart-image {
        flex-basis: 76px;
        width: 76px;
        height: 96px;
    }

    .ecoway-linked-gift-modal .modal-dialog {
        width: calc(100vw - 12px);
        margin: 6px auto;
    }

    .ecoway-linked-gift-modal .modal-header,
    .ecoway-linked-gift-modal .modal-body {
        padding-left: 10px;
        padding-right: 10px;
    }

    .ecoway-linked-gift-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .ecoway-linked-gift-image-frame {
        height: 132px;
        padding: 7px;
    }

    .ecoway-linked-gift-card {
        padding: 8px;
        border-radius: 12px;
    }

    .ecoway-linked-gift-card h6 {
        min-height: 21px;
        margin-top: 8px;
        font-size: 13px;
    }

    .ecoway-linked-gift-description {
        margin-bottom: 6px;
        font-size: 11px;
    }

    .ecoway-linked-gift-price {
        gap: 3px 7px;
        margin-bottom: 8px;
    }

    .ecoway-linked-gift-price del {
        font-size: 10px;
    }

    .ecoway-linked-gift-price strong,
    .ecoway-linked-gift-price strong.is-free {
        font-size: 11px;
    }

    .ecoway-linked-gift-card .ecoway-select-linked-gift {
        min-height: 38px;
        padding: 7px 6px;
        font-size: 12px;
    }
}
