/**
 * Cross Widget Styles - Horizontal Carousel with Square Cards
 * Based on production design with scroll support
 * MyChooz Partners v0.2.95+
 */

/* Container */
.mcp-cross-widget {
    margin: 20px 0;
    width: 100%;
    overflow: hidden;
}

/* Title/Header */
.mcp-cross-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

/* Horizontal scroll container */
.mcp-cross-grid {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0 15px 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

/* Hide scrollbar on WebKit browsers but keep functionality */
.mcp-cross-grid::-webkit-scrollbar {
    height: 6px;
}

.mcp-cross-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.mcp-cross-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
    transition: background 0.2s;
}

.mcp-cross-grid::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Individual item - Square card - Production-like size */
.mcp-cross-item {
    flex: 0 0 140px; /* Smaller width like production */
    width: 140px;
    height: 170px; /* Proportionally smaller height */
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    border: 2px solid #f1f3f4;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    scroll-snap-align: start;
    position: relative;
}

.mcp-cross-item:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.15);
    border-color: #ff6b35;
    background: linear-gradient(135deg, #ffffff 0%, #fff8f6 100%);
}

/* Link wrapper */
.mcp-cross-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Image container - Square aspect ratio, premium style */
.mcp-cross-image {
    position: relative;
    width: 100%;
    height: 130px; /* Соответствует критическим стилям */
    background: #f8f9fa;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f3f4;
}

.mcp-cross-image img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    transition: transform 0.3s ease, filter 0.3s ease;
    border-radius: 6px;
    /* Improved image loading */
    background-color: transparent;
    min-height: 50px;
    min-width: 50px;
}

/* Ensure first image loads immediately */
.mcp-cross-item:first-child .mcp-cross-image img {
    content-visibility: visible;
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Remove pattern background when image loads */
.mcp-cross-item:first-child .mcp-cross-image img[src]:not([src=""]) {
    background: transparent;
}

.mcp-cross-item:hover .mcp-cross-image img {
    transform: scale(1.05);
    filter: contrast(1.1) saturate(1.1);
}

/* Product info */
.mcp-cross-info {
    padding: 10px; /* Slightly less padding */
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

/* Title - compact */
.mcp-cross-title-text {
    font-size: 12px;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Store badge - like production */
.mcp-cross-store {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #ff6b35, #e53e3e);
    color: white;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Price section */
.mcp-cross-price {
    margin-bottom: 0px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.mcp-cross-sale-price,
.mcp-cross-current-price {
    font-size: 14px; /* Smaller price font */
    font-weight: 800;
    color: #ff6b35;
    line-height: 1;
}

.mcp-cross-original-price {
    color: #a0aec0;
    text-decoration: line-through;
    font-size: 12px;
    font-weight: 500;
}

.mcp-cross-discount {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    transform: rotate(-1deg);
}

/* Button - compact and stylish */
.mcp-cross-button {
    background: linear-gradient(135deg, #ff5959 0%, #e53e3e 100%);
    color: white !important;
    padding: 6px 12px; /* Smaller button padding */
    border-radius: 6px; /* Smaller border radius */
    font-weight: 700;
    font-size: 14px; /* Standard font size */
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(229, 62, 62, 0.25); /* Smaller shadow */
}

.mcp-cross-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(229, 62, 62, 0.4);
    color: white !important;
    text-decoration: none;
}

/* Responsive: Tablet */
@media (max-width: 768px) {
    .mcp-cross-item {
        flex: 0 0 120px !important; /* Smaller on tablet */
        width: 120px !important;
        height: 168px !important; /* Proportional height (120/150 * 210) */
    }

    .mcp-cross-hint {
        height: 13px !important; /* Proportional hint (16 * 0.8) */
        font-size: 8px !important;
    }

    .mcp-cross-image {
        height: 120px !important; /* Square image on tablet */
        width: 120px !important;
    }

    .mcp-cross-price-wrapper {
        height: 16px !important; /* Proportional price (20 * 0.8) */
    }

    .mcp-cross-button-wrapper {
        height: 19px !important; /* Proportional button (24 * 0.8) */
    }

    .mcp-cross-price {
        font-size: 12px !important;
        line-height: 16px !important;
    }

    .mcp-cross-button {
        padding: 3px 8px !important;
        font-size: 12px !important;
        line-height: 13px !important;
    }
}

/* Responsive: Mobile */
@media (max-width: 480px) {
    .mcp-cross-widget {
        margin: 15px 0;
    }

    .mcp-cross-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .mcp-cross-grid {
        gap: 12px;
        padding: 8px 0 12px 0;
    }

    .mcp-cross-item {
        flex: 0 0 110px !important; /* Even smaller on mobile */
        width: 110px !important;
        height: 165px !important; /* Убрано 10px лишнего пространства */
    }

    .mcp-cross-hint {
        height: 12px !important; /* Proportional hint (16 * 0.73) */
        font-size: 11px !important;
    }

    .mcp-cross-image {
        height: 100px !important; /* Уменьшено для места кнопке */
        width: 110px !important;
    }

    .mcp-cross-price-wrapper {
        height: 18px !important; /* Уменьшено для экономии места */
    }

    .mcp-cross-button-wrapper {
        height: 26px !important; /* Уменьшено но достаточно для видимости */
    }

    .mcp-cross-price {
        font-size: 12px !important;
        line-height: 18px !important;
    }

    .mcp-cross-button {
        padding: 0 !important;
        font-size: 12px !important;
        line-height: 26px !important;
    }

    .mcp-cross-store {
        font-size: 6px !important;
        padding: 1px 2px !important;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .mcp-cross-item {
        flex: 0 0 100px !important;
        width: 100px !important;
        height: 170px !important; /* Увеличенная высота для полного помещения кнопки */
    }

    .mcp-cross-hint {
        height: 10px !important; /* Proportional hint (16 * 0.67) */
        font-size: 6px !important;
    }

    .mcp-cross-image {
        height: 100px !important; /* Square image */
        width: 100px !important;
    }

    .mcp-cross-price-wrapper {
        height: 25px !important; /* Увеличена для видимости */
    }

    .mcp-cross-button-wrapper {
        height: 25px !important; /* Увеличена для видимости */
    }

    .mcp-cross-price {
        font-size: 11px !important;
        line-height: 25px !important;
    }

    .mcp-cross-button {
        padding: 0 !important;
        font-size: 10px !important;
        line-height: 25px !important;
    }
}

/* Loading state */
.mcp-cross-loading {
    text-align: center;
    padding: 40px;
    color: #718096;
    font-weight: 500;
}

.mcp-cross-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f1f3f4;
    border-top: 3px solid #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

/* Error state */
.mcp-cross-error {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #fef2f2, #fed7d7);
    border: 2px solid #fca5a5;
    border-radius: 10px;
    color: #991b1b;
    font-weight: 600;
}

/* Navigation arrows for enhanced UX (optional) */
.mcp-cross-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mcp-cross-nav-btn {
    background: rgba(255, 107, 53, 0.1);
    border: 2px solid rgba(255, 107, 53, 0.2);
    color: #ff6b35;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: bold;
}

.mcp-cross-nav-btn:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: rgba(255, 107, 53, 0.4);
    transform: scale(1.05);
}

.mcp-cross-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* Smooth scrolling enhancement */
.mcp-cross-grid {
    scroll-behavior: smooth;
}

/* Performance optimizations */
.mcp-cross-item {
    will-change: transform;
    contain: layout style paint;
}

.mcp-cross-image img {
    will-change: transform;
}

/* Accessibility improvements */
.mcp-cross-item:focus {
    outline: 3px solid rgba(255, 107, 53, 0.5);
    outline-offset: 2px;
}

.mcp-cross-button:focus {
    box-shadow: 
        0 6px 15px rgba(229, 62, 62, 0.4),
        0 0 0 3px rgba(255, 107, 53, 0.3);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mcp-cross-item,
    .mcp-cross-button,
    .mcp-cross-image img {
        transition: none !important;
    }
    
    .mcp-cross-spinner {
        animation-duration: 2s;
    }
}

