/* MitraMobile Woo Product Grid Widget Styles */

.mitramobile-woo-product-grid {
    display: grid;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Grid Column Classes */
.mitramobile-woo-product-grid.columns-1 { grid-template-columns: 1fr; }
.mitramobile-woo-product-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.mitramobile-woo-product-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.mitramobile-woo-product-grid.columns-4 { grid-template-columns: repeat(4, 1fr); }
.mitramobile-woo-product-grid.columns-5 { grid-template-columns: repeat(5, 1fr); }
.mitramobile-woo-product-grid.columns-6 { grid-template-columns: repeat(6, 1fr); }
.mitramobile-woo-product-grid.columns-7 { grid-template-columns: repeat(7, 1fr); }

/* Product Item */
.mitramobile-product-item {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: visible;
    transition: all 0.3s ease;
    padding: 2px;
    margin-bottom: 0px;
    border: 1px solid #f0f0f0;
    position: relative;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.mitramobile-product-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Product Image */
.mitramobile-product-image {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    margin-bottom: 2px;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.mitramobile-product-image img {
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

.mitramobile-product-image:hover img {
    transform: scale(1.05);
}

/* Sale Badge */
.mitramobile-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff4444;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

/* Free Shipping Badge Overlay */
.mitramobile-shipping-badge-overlay {
    position: absolute;
    bottom: 0;
    left: 8px;
    z-index: 10;
    pointer-events: none;
    opacity: 1;
    transform: translateY(0);
}

.shipping-badge-image {
    background: url('https://mitramobile.com/wp-content/uploads/2025/11/download.png') no-repeat center center;
    background-size: cover;
    width: 72px;
    height: 22px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 0;
    text-indent: -9999px;
    overflow: hidden;
    transform: translateY(1px);
}

.shipping-badge-image::before {
    display: none;
}

/* Style for custom uploaded image badge */
.shipping-badge-image img {
    max-width: 80px;
    max-height: 40px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

/* Custom Image Styles */
.mitramobile-custom-image {
    width: 100%;
    margin: 20px 0;
    text-align: center;
}

.mitramobile-custom-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mitramobile-custom-image-top {
    margin-bottom: 30px;
    grid-column: 1 / -1;
}

.mitramobile-custom-image-bottom {
    margin-top: 30px;
    grid-column: 1 / -1;
}

/* Out of Stock Badge */
.mitramobile-out-of-stock {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #666;
    z-index: 3;
}

/* Product Content */
.mitramobile-product-content {
    padding: 8px 8px 8px 8px;
}

/* Product Title */
.mitramobile-product-title {
    margin: 0;
    padding: 0 0 0 0;
    min-height: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    flex: 0 0 auto;
    position: relative;
    z-index: 2; /* keep above overlays/buttons */
    background: #fff;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    overflow: hidden;
    white-space: normal;
    line-height: 1.2;
    min-height: 2.4em;
    max-height: 2.4em;
}

/* Carousel Mode - Enhanced spacing for better visibility */
.mitramobile-woo-product-grid.carousel-mode .mitramobile-product-content {
    padding: 12px 10px 12px 10px;
}

.mitramobile-woo-product-grid.carousel-mode .mitramobile-product-title {
    padding: 0 0 0 0;
    min-height: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
    max-height: 2.4em;
}

.mitramobile-product-title a {
    color: #333;
    text-decoration: none;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    height: auto !important;
    max-height: 2.4em !important;
    line-height: 1.2 !important;
    min-height: 2.4em !important;
    transition: color 0.3s ease;
    position: relative !important;
    z-index: 2 !important;
}

/* Ensure WooCommerce default title markup also clamps to 2 lines within grid */
.mitramobile-woo-product-grid .woocommerce-loop-product__title,
.mitramobile-woo-product-grid .woocommerce-loop-product__title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    min-height: 2.4em;
    max-height: 2.4em;
}

.mitramobile-product-title a:hover {
    color: #007cba;
}

/* Product Price - Made smaller */
.mitramobile-product-price {
    margin: 0;
    font-size: 12px;
}

.mitramobile-product-title + .mitramobile-product-price {
    margin-top: 6px !important;
}

.mitramobile-product-price .price-row {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: nowrap;
}

.mitramobile-product-price .current-price,
.mitramobile-product-price .price-sale {
    font-size: 12px;
    font-weight: bold;
    color: #e74c3c;
}

.mitramobile-product-price .original-price,
.mitramobile-product-price .price-original {
    font-size: 9px;
    color: #999;
    text-decoration: line-through;
    white-space: nowrap;
}

.mitramobile-product-price .discount-badge,
.mitramobile-product-price .sale-badge {
    background: #e74c3c;
    color: white;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 2px;
    border-radius: 2px;
    white-space: nowrap;
}

/* Product Meta (Rating and Sold Count) */
.mitramobile-product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0px 0 0px 0;
    font-size: 10px;
    color: #666;
}

.mitramobile-product-rating {
    display: flex;
    align-items: center;
}

.mitramobile-product-rating .rating-stars {
    font-size: 10px;
}

.mitramobile-product-sold {
    font-size: 10px;
    color: #666;
}

/* Shipping Info */
.mitramobile-shipping-info {
    margin: 0px 0 0 0 !important;
    display: flex;
    align-items: center;
    gap: 3px;
}

.mitramobile-shipping-info .shipping-badge {
    background: #e8f5e8;
    color: #27ae60;
    font-size: 8px;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 500;
}

/* Product Actions Container */
.mitramobile-product-actions {
    position: relative;
    margin-top: 8px;
}

/* Plus Button for Add to Cart - Positioned on Product Image */
.mitramobile-plus-cart {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 124, 186, 0.5);
    transition: all 0.3s ease;
    z-index: 15;
    opacity: 0.9;
}

.mitramobile-plus-cart:hover {
    background: #005a87;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.4);
}

.mitramobile-plus-cart:active {
    transform: scale(0.95);
}

.mitramobile-plus-cart .plus-icon {
    display: block;
    line-height: 1;
}

/* Hide plus button when setting is disabled */
.mitramobile-product-item:not([data-show-plus-cart="yes"]) .mitramobile-plus-cart {
    display: none !important;
}

/* Hide default add to cart button when plus button is shown */
.mitramobile-product-add-to-cart {
    display: none;
}

/* Price Wrapper - Horizontal layout like in reference image */
.mitramobile-price-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Horizontal Container for prices */
.mitramobile-price-wrapper .price-horizontal-container {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

/* Price Row - all prices in one line */
.mitramobile-price-wrapper .price-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

/* Original Price (crossed out) - smaller, inline */
.mitramobile-price-wrapper .price-original {
    text-decoration: line-through;
    color: #9e9e9e;
    font-size: 10px;
    font-weight: 400;
    line-height: 1;
}

/* Sale Price - prominent but not too large, inline */
.mitramobile-price-wrapper .price-sale {
    color: #333;
    font-weight: 600;
    font-size: 12px;
    line-height: 1;
}

/* Regular Price - when no sale */
.mitramobile-price-wrapper .price-regular {
    color: #333;
    font-weight: 600;
    font-size: 12px;
    line-height: 1;
}

/* Small Discount Badge - compact and positioned at the end */
.mitramobile-price-wrapper .discount-badge-small {
    background: #ff4444;
    color: white;
    font-size: 8px;
    font-weight: 600;
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
    white-space: nowrap;
    margin-left: auto;
}

/* Hide WooCommerce price elements to prevent duplicates - but be more specific */
.mitramobile-product-price > del,
.mitramobile-product-price > ins,
.mitramobile-product-price > .woocommerce-Price-amount,
.mitramobile-product-price > .price:not(.mitramobile-price-wrapper),
.mitramobile-product-price .woocommerce-Price-currencySymbol:not(.mitramobile-price-wrapper .woocommerce-Price-currencySymbol) {
    display: none !important;
}

/* Hide default WooCommerce spans but preserve our custom elements */
.mitramobile-product-price span:not(.mitramobile-price-wrapper):not(.mitramobile-price-wrapper *) {
    display: none !important;
}

/* Only show our custom price structure - with stronger specificity */
.mitramobile-price-wrapper,
.mitramobile-price-wrapper .price-horizontal-container,
.mitramobile-price-wrapper .price-row,
.mitramobile-price-wrapper .price-original,
.mitramobile-price-wrapper .price-sale,
.mitramobile-price-wrapper .price-regular,
.mitramobile-price-wrapper .discount-badge-small {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.mitramobile-price-wrapper .price-original,
.mitramobile-price-wrapper .price-sale,
.mitramobile-price-wrapper .price-regular,
.mitramobile-price-wrapper .discount-badge-small {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure price wrapper is always visible */
.mitramobile-product .mitramobile-price-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Sold Count - Made smaller and consistent */
.mitramobile-product-sold,
.mitramobile-sold-count {
    font-size: 9px !important;
    color: #666;
    margin: 0px 0;
    padding: 1px 2px;
    background: #f8f8f8;
    border-radius: 2px;
    font-style: italic;
    border-left: 2px solid #007cba;
}

/* Rating */
.mitramobile-product-rating {
    margin: 6px 0;
    padding: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mitramobile-product-rating .star-rating {
    color: #ffa500;
    font-size: 14px;
}

.mitramobile-product-rating .rating-count {
    font-size: 12px;
    color: #666;
}

/* Product Actions Container */
.mitramobile-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 0;
}

/* Plus Button for Quick Add to Cart */
.mitramobile-plus-cart {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #007cba;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 124, 186, 0.3);
    flex-shrink: 0;
}

.mitramobile-plus-cart:hover {
    background: #005a87;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.4);
}

.mitramobile-plus-cart:active {
    transform: scale(0.95);
}

.mitramobile-plus-cart .plus-icon {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

.mitramobile-plus-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Add to Cart Button */
.mitramobile-product-add-to-cart {
    flex: 1;
}

.mitramobile-add-to-cart {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
}

.mitramobile-add-to-cart:hover {
    background: #005a87;
    transform: translateY(-2px);
}

.mitramobile-add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Loading Animation */
.mitramobile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.mitramobile-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: mitramobile-spin 1s linear infinite;
}

@keyframes mitramobile-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No Products Message */
.mitramobile-no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    grid-column: 1 / -1;
}

/* Load More Button Styles */
.mitramobile-load-more-container {
    text-align: center;
    margin-top: 30px;
    padding: 20px 0;
}

.mitramobile-load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.mitramobile-load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.mitramobile-load-more-btn:active {
    transform: translateY(0);
}

.mitramobile-load-more-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.mitramobile-load-more-btn .load-more-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Loading Animation for New Products */
.mitramobile-product-item.loading-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for multiple items */
.mitramobile-product-item.loading-item:nth-child(1) { animation-delay: 0.1s; }
.mitramobile-product-item.loading-item:nth-child(2) { animation-delay: 0.2s; }
.mitramobile-product-item.loading-item:nth-child(3) { animation-delay: 0.3s; }
.mitramobile-product-item.loading-item:nth-child(4) { animation-delay: 0.4s; }
.mitramobile-product-item.loading-item:nth-child(5) { animation-delay: 0.5s; }
.mitramobile-product-item.loading-item:nth-child(6) { animation-delay: 0.6s; }

/* Enhanced Currency Styling */
.mitramobile-product-price .currency {
    font-size: 0.7em;
    vertical-align: top;
    opacity: 0.8;
    margin-right: 2px;
}

.mitramobile-product-price .amount {
    font-weight: 600;
}

/* Sale Price Styling */
.mitramobile-product-price del {
    opacity: 0.6;
    margin-right: 8px;
}

.mitramobile-product-price ins {
    text-decoration: none;
    font-weight: 700;
}

/* Animation Classes */
.mitramobile-fade-in {
    animation: mitramobile-fadeIn 0.5s ease-in;
}

@keyframes mitramobile-fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hover Effects */
.mitramobile-product-item .mitramobile-add-to-cart {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.mitramobile-product-item:hover .mitramobile-add-to-cart {
    opacity: 1;
    transform: translateY(0);
}

/* Custom Scrollbar for Grid Container */
.mitramobile-woo-product-grid::-webkit-scrollbar {
    width: 8px;
}

.mitramobile-woo-product-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.mitramobile-woo-product-grid::-webkit-scrollbar-thumb {
    background: #007cba;
    border-radius: 4px;
}

.mitramobile-woo-product-grid::-webkit-scrollbar-thumb:hover {
    background: #005a87;
}

/* Shipping Badge Overlay Styles */
.mitramobile-shipping-badge-overlay {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 10;
    pointer-events: none;
    opacity: 1;
    transform: translateY(0);
}

.shipping-badge-image {
    background: url('https://mitramobile.com/wp-content/uploads/2025/10/Untitled.png') no-repeat center center;
    background-size: cover;
    width: 60px;
    height: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 0;
    text-indent: -9999px;
    overflow: hidden;
}

.shipping-badge-image::before {
    display: none;
}

.shipping-badge-image img {
    max-width: 80px;
    max-height: 40px;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}
@media (max-width: 767px) {
    .mitramobile-woo-product-grid.carousel-mode .mitramobile-product-title,
    .mitramobile-woo-product-grid.carousel-mode .mitramobile-product-title a {
        -webkit-line-clamp: 2;
    }
}

/* Universal two-line clamp for product titles in grid (all modes) */
.mitramobile-woo-product-grid .mitramobile-product-title,
.mitramobile-woo-product-grid .mitramobile-product-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    min-height: 2.4em;
    max-height: 2.4em;
}

/* Highest-specificity clamp to win over any theme/plugin styles */
html body .mitramobile-woo-product-grid .mitramobile-product-content .mitramobile-product-title,
html body .mitramobile-woo-product-grid .mitramobile-product-content .mitramobile-product-title a {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
    min-height: 2.4em !important;
    max-height: 2.4em !important;
}

/* Clamp common WooCommerce/Elementor title markup within grid scope */
.mitramobile-woo-product-grid .woocommerce-loop-product__title,
.mitramobile-woo-product-grid .woocommerce-loop-product__title a,
.mitramobile-woo-product-grid .elementor-loop-item .elementor-heading-title,
.mitramobile-woo-product-grid .elementor-loop-item .elementor-heading-title a,
.mitramobile-woo-product-grid .mitramobile-product-content h1,
.mitramobile-woo-product-grid .mitramobile-product-content h1 a,
.mitramobile-woo-product-grid .mitramobile-product-content h2,
.mitramobile-woo-product-grid .mitramobile-product-content h2 a,
.mitramobile-woo-product-grid .mitramobile-product-content h3,
.mitramobile-woo-product-grid .mitramobile-product-content h3 a {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
    min-height: 2.4em !important;
    max-height: 2.4em !important;
}

/* Clamp common WooCommerce/Elementor title markup within grid scope */
.mitramobile-woo-product-grid .woocommerce-loop-product__title,
.mitramobile-woo-product-grid .woocommerce-loop-product__title a,
.mitramobile-woo-product-grid .elementor-loop-item .elementor-heading-title,
.mitramobile-woo-product-grid .elementor-loop-item .elementor-heading-title a,
.mitramobile-woo-product-grid .mitramobile-product-content h1,
.mitramobile-woo-product-grid .mitramobile-product-content h1 a,
.mitramobile-woo-product-grid .mitramobile-product-content h2,
.mitramobile-woo-product-grid .mitramobile-product-content h2 a,
.mitramobile-woo-product-grid .mitramobile-product-content h3,
.mitramobile-woo-product-grid .mitramobile-product-content h3 a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    min-height: 2.4em;
    max-height: 2.4em;
}
