/**
 * Modern Product Loop - Frontend Styles
 * Version: 1.1.1
 */

/* Container */
.mpl-products-wrapper {
    margin: 2rem 0;
    position: relative;
}

/* Grid Layout */
.mpl-products-grid {
    display: grid;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

/* Column classes as fallback */
.mpl-columns-1 { grid-template-columns: repeat(1, 1fr) !important; }
.mpl-columns-2 { grid-template-columns: repeat(2, 1fr) !important; }
.mpl-columns-3 { grid-template-columns: repeat(3, 1fr) !important; }
.mpl-columns-4 { grid-template-columns: repeat(4, 1fr) !important; }
.mpl-columns-5 { grid-template-columns: repeat(5, 1fr) !important; }
.mpl-columns-6 { grid-template-columns: repeat(6, 1fr) !important; }

/* Product Item */
.mpl-product-item {
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mpl-product-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Sale Badge */
.mpl-sale-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: #fff;
    padding: 6px 12px;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 10;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Product Image */
.mpl-product-image {
    display: block;
    position: relative;
    padding-bottom: 100%;
    overflow: hidden;
    background: #f7f7f7;
}

.mpl-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mpl-product-item:hover .mpl-product-image img {
    transform: scale(1.08);
}

/* Product Content */
.mpl-product-content {
    padding: 1rem;
}

.mpl-product-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
}

.mpl-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

.mpl-product-title a:hover {
    color: #000;
}

/* Product Price */
.mpl-product-price {
    margin: 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111;
}

.mpl-product-price del {
    color: #999;
    font-weight: 400;
    margin-right: 0.5rem;
}

.mpl-product-price ins {
    text-decoration: none;
    color: #ff4b2b;
}

/* Product Actions */
.mpl-product-actions {
    margin-top: 1rem;
}

.mpl-add-to-cart {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.mpl-add-to-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: #fff;
}

.mpl-add-to-cart.loading {
    opacity: 0.7;
    pointer-events: none;
}

.mpl-add-to-cart.loading::after {
    content: "...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Loading State */
.mpl-products-wrapper.is-loading .mpl-products-grid {
    opacity: 0.5;
    pointer-events: none;
}

/* No Products Message */
.mpl-no-products,
.mpl-error {
    text-align: center;
    padding: 2rem;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
    grid-column: 1 / -1;
}

.mpl-error {
    background: #fff5f5;
    color: #c00;
}

/* Load More Container */
.mpl-load-more-container {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem;
}

/* Load More Button */
.mpl-load-more-btn {
    display: inline-block;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

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

.mpl-load-more-btn.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.mpl-load-more-btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    margin: auto;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* End Message */
.mpl-end-message {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #666;
    border-radius: 50px;
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .mpl-columns-6,
    .mpl-products-grid[style*="repeat(6"] { 
        grid-template-columns: repeat(4, 1fr) !important; 
    }
    .mpl-columns-5,
    .mpl-products-grid[style*="repeat(5"] { 
        grid-template-columns: repeat(3, 1fr) !important; 
    }
}

@media (max-width: 768px) {
    .mpl-columns-6,
    .mpl-columns-5,
    .mpl-columns-4,
    .mpl-products-grid[style*="repeat(6"],
    .mpl-products-grid[style*="repeat(5"],
    .mpl-products-grid[style*="repeat(4"] { 
        grid-template-columns: repeat(2, 1fr) !important; 
    }
    .mpl-columns-3,
    .mpl-products-grid[style*="repeat(3"] { 
        grid-template-columns: repeat(2, 1fr) !important; 
    }
    
    .mpl-products-grid {
        gap: 1rem;
    }
    
    .mpl-load-more-btn {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .mpl-columns-6,
    .mpl-columns-5,
    .mpl-columns-4,
    .mpl-columns-3,
    .mpl-columns-2,
    .mpl-products-grid[style*="repeat("] { 
        grid-template-columns: 1fr !important; 
    }
    
    .mpl-product-item {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .mpl-sale-badge {
        top: 8px;
        right: 8px;
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* Theme Compatibility - Flatsome */
.theme-flatsome .mpl-products-grid.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
}

.theme-flatsome .mpl-product-item.col {
    padding: 0.75rem;
    flex: 0 0 25%;
    max-width: 25%;
}

.theme-flatsome .mpl-add-to-cart.button.primary {
    background: var(--primary-color, #446084);
}

@media (max-width: 768px) {
    .theme-flatsome .mpl-product-item.col {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Accessibility */
.mpl-product-item:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.mpl-add-to-cart:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .mpl-sale-badge,
    .mpl-product-actions {
        display: none;
    }
}

/* Notification Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}