/* Simplified popup styling - no animations, no border radius */
#upsell-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
}

#upsell-popup .popup-content {
    position: relative;
    background-color: #fff;
    width: 100%; 
    max-width: 600px;
    height: auto;
    max-height: 80vh;
    margin: 0;
    overflow-y: auto;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    color: #526336;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #upsell-popup .popup-content {
        max-width: 95vw;
        max-height: 75vh;
        border-radius: 8px !important;
    }

    .product-card {
        padding: 0 !important;
    }

    .product-row {
        padding: 8px !important;
    }

    .section-title {
        padding: 8px;
    }

    .cart-message {
        padding: 8px;
    }

    #upsell-popup .popup-header {
        padding: 8px;
        margin-bottom: 8px;
    }
}

#upsell-popup .popup-header {
    position: sticky;
    top: 0;
    background-color: #f7fafc;
    padding: 12px;
    z-index: 5;
    border-bottom: 1px solid #eee;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: large;
}

.popup-header h4 {
    margin: 0 !important;
}

#upsell-popup h2 {
    margin: 0; /* Adjusted for sticky header */
    font-size: medium;
    text-align: left;
    flex: 1;
}

.go-to-cart-button {
    display: block;
    width: 50%;
    margin: 16px auto;
    margin-top: 0;
    padding: 12px 16px;
    background-color: #caec7d !important;
    color: #526336;
    text-align: center;
    font-size: medium;
    text-decoration: none;
    border: none;
    border-radius: 64px; /* Rounded corners */
    transition: all 0.1s;
    font-weight: 600;
    position: relative;
    padding-right: 32px; /* Space for arrow */
}

.go-to-cart-button:hover {
    background-color: #b1d364 !important;
}

.go-to-cart-button:after {
    content: "→";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: medium;
}

.cart-message {
    margin: 0 0 16px;
    font-size: 16px;
    text-align: left;
    padding: 16px;
}

/* Section styling */
.product-section {
    position: relative;
    padding: 0;
}

.product-section.has-scroll-buttons .product-row {
    padding-left: 16px !important;
    padding-right: 16px !important;
}

.section-title {
    padding: 16px;
    text-align: left;
    font-size: large;
    margin: 0;
    padding-bottom: 0px !important;
}

/* Horizontal scrollable rows */
.product-row-wrapper {
    position: relative;
    overflow: hidden;
}

.product-row {
    display: flex;
    overflow-x: auto;
    padding: 16px; /* Increased padding */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 8px; /* Added gap between items */
}

/* Style scrollbars */
.product-row::-webkit-scrollbar {
    height: 8px; /* Slightly thicker scrollbar */
}

.product-row::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 16px;
}

.product-row::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 16px;
}

.product-row::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Product card styling */
.product-card {
    flex: 0 0 auto;
    width: 150px;
    border: 1px solid #eee;
    border-radius: 8px;
    text-align: center;
    padding: 8px !important;
    background-color: #fff;
    transition: all 0.1s;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.upsell-popup-item,
.product-card {
    border: 1px solid #22242626 !important;
    border-radius: 8px;
    box-shadow: 0 0 18px rgba(44,47,37,.136);
    background: white;
}

.product-card .product-image {
    text-align: center;
    margin-bottom: 10px; /* Increased margin */
    height: 120px; /* Increased height */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card .product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.product-card h4 {
    font-size: 14px; /* Larger */
    margin: 0 0 6px; /* Increased margin */
    line-height: 1.3;
}

.product-card h4 a {
    color: #526336;
    text-decoration: none;
}

.product-card h4 a:hover {
    color: #526336;
}

.product-card .price {
    display: block;
    margin-bottom: 8px; /* Increased margin */
    font-weight: bold;
    color: #526336;
    font-size: 14px;
}

/*.product-card .add-to-cart {*/
/*    padding: 0 10px 10px;*/
/*}*/

.product-card .add-to-cart .button {
    width: 100%;
    text-align: center;
    padding: 8px 0; /* Increased padding */
    font-size: 14px; /* Larger */
    background-color: #526336 !important;
    color: #caec7d;
    border: none; /* No border */
    border-radius: 8px; /* Rounded corners */
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.product-card .add-to-cart .button:hover {
    background-color: #455429 !important;
}

/* Always show the view cart button */
.added_to_cart.wc-forward {
    display: block !important;
    visibility: visible !important;
    width: 100%;
    text-align: center;
    margin-top: 4px; /* Reduced margin */
    padding: 4px 0; /* Reduced padding */
    font-size: 11px; /* Smaller font */
    color: #0073aa;
    text-decoration: none;
    border: 1px solid #0073aa;
    background: #fff;
}

/* Empty state styling */
.product-section.empty {
    opacity: 0.7;
}

.no-products {
    padding: 12px; /* Increased padding */
    background: #f9f9f9;
    border: 1px dashed #ddd;
    font-style: italic;
    margin: 0; /* No margin */
    font-size: 14px; /* Larger */
}

.notice {
    background: #f9f9f9;
    color: #555;
    padding: 12px;
    border-radius: 0;
    border: 1px dashed #ddd;
    font-size: 15px;
}

.product-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-list li {
    margin: 15px 0;
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

.product-list .product-image {
    flex: 0 0 80px;
    margin-right: 15px;
}

.product-list .product-details {
    flex: 1;
    text-align: left;
}

.product-list h3 {
    margin: 0 0 5px;
    font-size: 16px;
}

.product-list .price {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.close-popup {
    position: relative; /* Changed from absolute to allow for larger hitbox */
    font-size: 24px;
    cursor: pointer;
    color: #4a5568;
    font-weight: bold;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px; /* Minimum recommended touch target size */
    min-height: 32px;
    box-sizing: border-box;
    touch-action: manipulation; /* Improve touch behavior */
}

.close-popup:hover {
    color: #000;
}

/* Disable `:hover` effects on mobile to prevent double-tap requirement */
@media (hover: none) {
    .close-popup:hover {
        color: #4a5568;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    #upsell-popup.bottom-drawer.show {
        max-height: 70vh; /* Taller on mobile */
    }
    
    #upsell-popup.bottom-drawer .popup-content {
        padding: 16px 12px 8px;
    }
    
    .product-card {
        width: 150px; /* Still larger than before */
    }
    
    .go-to-cart-button,
    .cart-message {
        font-size: 16px;
    }

    .product-row {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* Add a debugging helper */
.upsell-debug {
    border: 2px solid red;
    padding: 10px;
    margin: 10px 0;
    background: #fff;
    color: #333;
}

/* Hide "View Cart" buttons in the popup */
.upsell-hidden,
#upsell-popup .added_to_cart.wc-forward {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Hide "View Cart" buttons in the popup - more aggressive */
#upsell-popup .added_to_cart.wc-forward,
#upsell-popup .added_to_cart,
#upsell-popup .product-card .added_to_cart,
.upsell-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    border: none !important;
    position: absolute !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    pointer-events: none !important;
}

/* Hide scroll buttons completely */
.scroll-btn,
.product-section .scroll-btn,
button.scroll-btn,
.scroll-left,
.scroll-right {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

/* Remove padding from rows that might have been added for scroll buttons */
.product-section.has-scroll-buttons .product-row {
    padding-left: 16px !important;
    padding-right: 16px !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    #upsell-popup.bottom-drawer.show {
        max-height: 90vh; /* Taller on mobile */
    }
    
    #upsell-popup.bottom-drawer .popup-content {
        padding: 16px 12px 8px;
    }
    
    .product-card {
        width: 150px; /* Still larger than before */
    }
    
    .go-to-cart-button,
    .cart-message {
        font-size: 16px;
    }
}

/* Override the default display property set by JS */
#upsell-popup[style*="display: flex"] {
    display: flex !important;
}
