/* Best Selling Products Widget Styles */
.mlm-best-selling-products-widget {
    margin: 20px 40px !important;
    padding: 0 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: calc(100% - 80px);
    box-sizing: border-box;
}

/* Widget Container */
.mlm-best-selling-products-widget > * {
    margin-left: 20px !important;
    margin-right: 20px !important;
}

/* Widget Header */
.mlm-best-selling-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.mlm-view-all-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.mlm-view-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 107, 107, 0.4);
    color: white;
    text-decoration: none;
}

.mlm-view-all-btn i {
    font-size: 12px;
}

.mlm-widget-title {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Products Grid */
.mlm-best-selling-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
}

/* Product Card */
.mlm-product-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Horizontal Card Layout */
.mlm-horizontal-card {
    display: flex;
    align-items: center;
}

.mlm-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Product Image - Horizontal Layout */
.mlm-product-image {
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mlm-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mlm-product-card:hover .mlm-product-image img {
    transform: scale(1.05);
}

.mlm-product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Product Info - Horizontal Layout */
.mlm-product-info {
    flex: 1;
    min-width: 0; /* برای truncate کردن متن */
}

.mlm-product-title {
    margin: 0 0 8px 0;
    font-weight: 600;
    line-height: 1.4;
    color: #1e293b;
}

.mlm-product-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.mlm-product-title a:hover {
    color: #3b82f6;
}

.mlm-product-price {
    font-weight: 700;
    color: #059669;
}

.mlm-product-price del {
    color: #94a3b8;
    font-weight: 500;
    margin-left: 8px;
}

/* Ranking Number - Horizontal Layout */
.mlm-rank-number {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    flex-shrink: 0;
    position: relative;
}

.mlm-rank-text {
    font-weight: 700;
}

.mlm-hot-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 10px;
    color: #ff8c00;
    background: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* No Products State */
.mlm-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    margin: 20px 0;
}

.mlm-no-products p {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.mlm-no-products p:last-child {
    margin-bottom: 0;
}

.mlm-no-products small {
    font-size: 14px;
    color: #94a3b8;
}

/* Responsive Design */

/* Desktop - 3 cards horizontal */
@media (min-width: 1025px) {
    .mlm-best-selling-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .mlm-horizontal-card {
        gap: 16px;
        padding: 12px 16px;
        min-height: 80px;
    }
    
    .mlm-rank-number {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .mlm-product-image {
        width: 60px;
        height: 60px;
    }
    
    .mlm-product-title {
        font-size: 16px;
    }
}

/* Tablet - 2 cards horizontal */
@media (max-width: 1024px) and (min-width: 769px) {
    .mlm-best-selling-products-widget {
        margin: 20px 30px !important;
        max-width: calc(100% - 60px);
    }
    
    .mlm-best-selling-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .mlm-best-selling-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .mlm-widget-title {
        font-size: 24px;
    }
    
    .mlm-horizontal-card {
        gap: 14px;
        padding: 10px 14px;
        min-height: 75px;
    }
    
    .mlm-rank-number {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }
    
    .mlm-product-image {
        width: 55px;
        height: 55px;
    }
    
    .mlm-product-title {
        font-size: 15px;
    }
}

/* Mobile - 1 card horizontal */
@media (max-width: 768px) {
    .mlm-best-selling-products-widget {
        margin: 20px 20px !important;
        max-width: calc(100% - 40px);
    }
    
    .mlm-best-selling-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .mlm-best-selling-header {
        margin-bottom: 20px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .mlm-widget-title {
        font-size: 20px;
    }
    
    .mlm-view-all-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .mlm-horizontal-card {
        gap: 12px;
        padding: 10px 12px;
        min-height: 70px;
    }
    
    .mlm-rank-number {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .mlm-rank-text {
        font-size: 14px;
    }
    
    .mlm-product-image {
        width: 50px;
        height: 50px;
    }
    
    .mlm-product-title {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .mlm-product-price {
        font-size: 13px;
    }
    
    .mlm-product-info {
        padding: 0 4px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .mlm-best-selling-products-widget {
        margin: 20px 15px !important;
        max-width: calc(100% - 30px);
    }
    
    .mlm-best-selling-grid {
        gap: 10px;
    }
    
    .mlm-horizontal-card {
        gap: 10px;
        padding: 8px 10px;
        min-height: 60px;
    }
    
    .mlm-rank-number {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .mlm-rank-text {
        font-size: 12px;
    }
    
    .mlm-product-image {
        width: 45px;
        height: 45px;
    }
    
    .mlm-product-title {
        font-size: 13px;
    }
    
    .mlm-product-price {
        font-size: 12px;
    }
}

/* Demo Specific Styles */

/* Default Demo */
body:not(.zhaket-demo) .mlm-best-selling-products-widget {
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
}

body:not(.zhaket-demo) .mlm-product-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Zhaket Demo */
body.zhaket-demo .mlm-best-selling-products-widget {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

body.zhaket-demo .mlm-product-card {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body.zhaket-demo .mlm-product-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* Animation for ranking badges */
@keyframes rankPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.mlm-rank-number[data-rank="1"],
.mlm-rank-number[data-rank="2"],
.mlm-rank-number[data-rank="3"] {
    animation: rankPulse 2s infinite;
}

/* Hover effect for horizontal cards */
.mlm-horizontal-card:hover {
    transform: translateX(4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.mlm-horizontal-card:hover .mlm-product-image img {
    transform: scale(1.1);
}

/* Loading state */
.mlm-best-selling-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.mlm-best-selling-grid.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
