/**
 * Shopify Search Modal Styles - Compatible with old4 styling
 * Version: 2.0 - Performance optimized
 */

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* For mobile devices - prevent scroll bounce */
body.modal-open,
body.modal-open * {
    -webkit-overflow-scrolling: auto !important;
}

/* Prevent mega menu interference when search modal is active */
body.shopify-search-active .mega-menu-item-open,
body.shopify-search-active .mega-toggle-on,
body.shopify-search-active .mega-menu-open {
    display: none !important;
}

body.shopify-search-active .mega-menu-item {
    pointer-events: none;
}

body.shopify-search-active .mega-menu-item.mega-header-search,
body.shopify-search-active #mega-menu-item-989031 {
    pointer-events: auto;
}

/* Ensure toasts are always on top of modals */
#toast-container,
.toast,
.toast-container {
    z-index: 20000 !important;
}

/* Make sure cart and other UI elements stay above modals when needed */
#cart-container {
    z-index: 15000 !important;
}

/* Search Icon Styles */
.shopify-search-container {
    display: inline-block;
    position: relative;
}

.shopify-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 50%;
    padding: 6px;
    will-change: transform;
}

.shopify-search-icon:hover {
    background-color: rgba(76, 175, 80, 0.1);
    transform: scale(1.05);
}

.shopify-search-icon svg {
    transition: opacity 0.2s ease;
}

.shopify-search-icon:hover svg {
    opacity: 0.8;
}

/* Search Modal - Same styling as old4 */
.shopify-search-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    will-change: opacity;
}

.shopify-search-modal.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;
    opacity: 1;
    visibility: visible;
}

.shopify-search-modal-content {
    background: white;
    border-radius: 25px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
}

.shopify-search-modal.show .shopify-search-modal-content {
    transform: scale(1);
}

/* Close Button - Match product details modal */
.shopify-search-close {
    position: absolute;
    top: 5px;
    right: 20px;
    cursor: pointer;
    font-size: 40px;
    font-weight: bold;
    color: #aaa;
    line-height: 1;
    transition: color 0.2s ease;
    padding: 4px;
    user-select: none;
    z-index: 10;
}

.shopify-search-close:hover {
    color: #000;
}

/* Search Input Container */
.shopify-search-input-container {
    padding: 50px 25px 20px 25px;
    position: relative;
    background: #fff;
    flex-shrink: 0;
    border-radius: 25px 25px 0 0;
}

.shopify-search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    background: white;
}

.shopify-search-input:focus {
    border-color: #4caf50;
}

/* Loading Spinner - Optimized */
.shopify-search-loader {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #4caf50;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    will-change: transform;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Search Results Container */
.shopify-search-results {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0 25px 25px 25px;
    background: #fff;
    border-radius: 0 0 25px 25px;
    -webkit-overflow-scrolling: touch;
}

.shopify-search-results::-webkit-scrollbar {
    width: 6px;
}

.shopify-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.shopify-search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* Product Count */
.search-results-count {
    padding: 0px 25px 8px 25px;
    background: #fff;
    font-size: 0.9rem;
    color: #666;
    flex-shrink: 0;
}

/* Welcome/Error Messages - Same as old4 */
.shopify-search-welcome,
.shopify-search-no-results,
.shopify-search-error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.shopify-search-welcome p,
.shopify-search-no-results p,
.shopify-search-error p {
    margin: 0;
    font-size: 1rem;
}

.shopify-search-error {
    color: #e53e3e;
}

/* Product Grid in Search Modal */
.shopify-search-modal .product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 0px;
    grid-auto-rows: min-content;
}

.shopify-search-modal .product {
    padding: 16px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 5px;
    transition: box-shadow 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    will-change: box-shadow;
}

.shopify-search-modal .product:hover {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.shopify-search-modal .product .capsule {
    background: rgba(211, 47, 47, 0.75);
    font-size: 12px;
    height: 20px;
    border-radius: 20px;
    padding: 0.5px 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 40;
    color: white;
    box-shadow: 0 0 4px rgba(211, 47, 47, 0.3);
    transition: background 0.2s ease;
}

.shopify-search-modal .product:hover .capsule {
    background: rgba(211, 47, 47, 1);
}

.shopify-search-modal .product .capsule.green {
    background: rgba(181, 117, 51, 0.9);
}

.shopify-search-modal .product:hover .capsule.green {
    background: rgba(181, 117, 51, 1);
}

/* Image Container - Exact copy from old4 */
.shopify-search-modal .shopifyImagesContainer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 180px;
    overflow: hidden;
    width: 100%;
}

.shopify-search-modal .shopifyImagesContainer>div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shopify-search-modal .shopifyImagesContainer .firstImage {
    z-index: 2;
}

.shopify-search-modal .shopifyImagesContainer>.lastImage {
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.shopify-search-modal .shopifyImagesContainer:hover>.lastImage {
    opacity: 1;
}

.shopify-search-modal .shopifyImagesContainer img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Product Text Styles - Match background products */

.shopify-search-modal .product .font-h5 {
    font-size: 16px;
    font-weight: 500;
    color: #555;
}

.shopify-search-modal .product .product-price {
    font-weight: 700;
    font-size: 16px;
    color: #4caf50;
    margin: 6px 0 8px 0;
}

.shopify-search-modal .product .variant-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    margin: 8px 0;
    font-size: 14px;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.shopify-search-modal .product .variant-select:focus {
    outline: none;
    border-color: #4caf50;
}

/* Buttons - Green rounded style to match first screenshot */
.shopify-search-modal .product .details {
    color: #007cba;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: none;
    width: 100%;
    text-align: center;
    display: block;
    background: transparent !important;
    box-shadow: none;
    padding: 0 !important;
}

.shopify-search-modal .product .description {
    display: none;
}

.shopify-search-modal .product-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shopify-search-modal .add-to-cart,
.shopify-search-modal .add-to-cart-modal {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    border-radius: 25px;
    transition: background-color 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    text-transform: none;
}

.shopify-search-modal .add-to-cart:hover,
.shopify-search-modal .add-to-cart-modal:hover {
    background-color: #45a049;
}

.shopify-search-modal .vamtam-button.accent1.hover-accent2.button-solid.details {
    background: #4caf50;
    color: #007cba;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px;
    border-radius: 25px;
    transition: none;
    width: 100%;
    text-align: center;
    display: block;
}

.shopify-search-modal .vamtam-button.accent1.hover-accent2.button-solid.details:hover {
    background: #4caf50;
    color: #007cba;
    text-decoration: underline;
}

.shopify-search-modal .vamtam-button.accent1.hover-accent2.button-solid:hover {
    background-color: #45a049;
}

.shopify-search-modal .vamtam-button.accent1.button-solid.added,
.shopify-search-modal .add-to-cart.added,
.shopify-search-modal .add-to-cart-modal.added {
    background-color: #888;
    cursor: not-allowed;
    opacity: 0.7;
}

.shopify-search-modal .vamtam-button.accent1.button-solid.added:hover,
.shopify-search-modal .add-to-cart.added:hover,
.shopify-search-modal .add-to-cart-modal.added:hover {
    background-color: #888;
    opacity: 0.7;
}

/* Force enabled buttons to appear enabled - override any disabled styles */
.shopify-search-modal .add-to-cart:not(.added):not(:disabled),
.shopify-search-modal .add-to-cart-modal:not(.added):not(:disabled) {
    background-color: #4caf50 !important;
    color: white !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

.shopify-search-modal .add-to-cart:not(.added):not(:disabled):hover,
.shopify-search-modal .add-to-cart-modal:not(.added):not(:disabled):hover {
    background-color: #45a049 !important;
}

/* Product Details Modal - Fast, smooth animations */
#shopify-product-details-modal.modal {
    display: none !important;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0);
    opacity: 0;
    visibility: hidden;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),
        visibility 150ms cubic-bezier(0.4, 0, 0.2, 1),
        background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, visibility;
}

#shopify-product-details-modal.modal.show {
    display: flex !important;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2%;
    opacity: 1;
    visibility: visible;
    background-color: rgba(0, 0, 0, 0.6);
}

#shopify-product-details-modal .modal-content {
    background: #ffffff;
    border-radius: 14px;
    position: relative;
    margin-top: 150px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
    width: 640px;
    max-width: 92%;
    max-height: 500px;
    overflow: scroll;
    transform: scale(0.9) translateY(-20px);
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

@media (max-width: 768px) {
    #shopify-product-details-modal .modal-content {
        max-height: 80vh;
        margin-top: 10vh;
        width: 95%;
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    #shopify-product-details-modal .modal-content {
        max-height: 85vh;
        margin-top: 5vh;
        width: 98%;
        max-width: 98%;
    }
}

#shopify-product-details-modal.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

#shopify-product-details-modal .close {
    font-size: 40px;
    position: absolute;
    right: 20px;
    top: 0px;
    cursor: pointer;
    color: #aaa;
    z-index: 199;
}

#shopify-product-details-modal .close:hover,
#shopify-product-details-modal .close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

#shopify-product-details-modal .modal-description {
    padding: 25px;
    padding-top: 50px;
}

#shopify-product-details-modal .modal-description>div {
    display: flex;
    gap: 25px;
}

#shopify-product-details-modal .modal-description>div>.images {
    width: 40%;
    position: relative;
    min-height: 300px;
}

#shopify-product-details-modal .modal-description .images .bx-wrapper {
    margin: 0 !important;
}

#shopify-product-details-modal .modal-description .details {
    width: 60%;
}

#shopify-product-details-modal .modal-description .details,
#shopify-product-details-modal .modal-description .details>div {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Product Details Modal Variant Select - Match search modal style */
#shopify-product-details-modal .variant-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    margin: 8px 0;
    font-size: 14px;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

#shopify-product-details-modal .variant-select:focus {
    outline: none;
    border-color: #4caf50;
}

/* Product Details Modal Add to Cart Button - Match search modal style */
#shopify-product-details-modal .add-to-cart-modal {
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-transform: none;
    width: 100%;
    margin-top: 0px;
}

#shopify-product-details-modal .add-to-cart-modal:hover {
    background-color: #45a049;
}

#shopify-product-details-modal .add-to-cart-modal:disabled,
#shopify-product-details-modal .add-to-cart-modal.added {
    background-color: #888;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Force enabled modal buttons to appear enabled */
#shopify-product-details-modal .add-to-cart-modal:not(.added):not(:disabled) {
    background-color: #4caf50 !important;
    color: white !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

#shopify-product-details-modal .add-to-cart-modal:not(.added):not(:disabled):hover {
    background-color: #45a049 !important;
}

/* Image Slider Styles */
#shopify-product-details-modal .image-slider {
    position: relative;
    width: 100%;
    min-height: 206px;
    overflow: hidden;
    visibility: hidden;
}

#shopify-product-details-modal .image-slider .slide {
    text-align: center;
    display: none;
}

#shopify-product-details-modal .image-slider .slide.firstImage {
    display: block;
}

#shopify-product-details-modal .image-slider .slide img {
    max-width: 200px;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    border-radius: 10px;
}

#shopify-product-details-modal .images>.image-slider>.slide:not(:first-child) {
    display: none;
}

#shopify-product-details-modal .modal-description .images .bx-wrapper {
    position: relative;
}

#shopify-product-details-modal .bx-viewport,
#shopify-product-details-modal .bx-wrapper .image-slider,
#shopify-product-details-modal .bx-wrapper .slide {
    min-height: 310px !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .shopify-search-modal-content {
        width: 98%;
        max-height: 90vh;
        border-radius: 20px;
    }

    .shopify-search-close {
        font-size: 32px;
        top: 12px;
        right: 15px;
    }

    .shopify-search-input-container {
        padding: 50px 20px 16px 20px;
        border-radius: 20px 20px 0 0;
    }

    .shopify-search-results {
        padding: 0 20px 20px 20px;
        border-radius: 0 0 20px 20px;
    }

    .shopify-search-input {
        padding: 14px 18px;
        font-size: 16px;
        border-radius: 25px;
    }

    .shopify-search-modal .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }

    .shopify-search-modal .shopifyImagesContainer {
        height: 150px;
    }

    .shopify-search-modal .product .font-h5 {
        font-size: 14px;
    }

    .shopify-search-modal .product .product-price {
        font-size: 14px;
        margin: 4px 0 6px 0;
    }

    #shopify-product-details-modal .modal-description>div {
        flex-direction: column;
    }

    #shopify-product-details-modal .modal-description>div>.images {
        width: 100%;
    }

    #shopify-product-details-modal .modal-description .image-slider {
        width: 100%;
        min-height: 250px;
    }

    #shopify-product-details-modal .modal-description .details {
        width: 100%;
    }

    #shopify-product-details-modal .modal-description .images img {
        max-width: 100%;
        max-height: 240px;
        width: auto;
        height: auto;
    }

    #shopify-product-details-modal .image-slider .slide img {
        max-width: 100%;
        max-height: 240px;
        width: auto;
        height: auto;
    }

    #shopify-product-details-modal .modal-description {
        padding: 20px;
        padding-top: 50px;
    }

    #shopify-product-details-modal .modal-description>div {
        gap: 20px;
    }

    #shopify-product-details-modal .modal-description .details,
    #shopify-product-details-modal .modal-description .details>div {
        gap: 15px;
    }

    #shopify-product-details-modal .close {
        font-size: 32px;
        right: 15px;
        top: 5px;
        z-index: 199;
    }
}

@media (max-width: 480px) {
    .shopify-search-modal-content {
        border-radius: 15px;
    }

    .shopify-search-modal .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .shopify-search-input-container {
        padding: 18px 18px 15px 18px;
        border-radius: 15px 15px 0 0;
    }

    .shopify-search-results {
        padding: 0 18px 18px 18px;
        border-radius: 0 0 15px 15px;
    }

    .shopify-search-close {
        font-size: 38px;
        top: -10px;
        right: 2px;
    }

    #shopify-product-details-modal .modal-description {
        padding: 15px;
    }

    #shopify-product-details-modal .close {
        font-size: 48px;
        right: 4px;
        top: -14px;
        z-index: 99;
    }
}