/* Стилі для блоку схожих товарів */
/* Оновлено: 2025-07-24 для очищення кешу користувачів */
.similar-products-section {
    margin: 40px 0;
    padding: 40px 20px;
    background: #f0f0f0;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    /* Reserve space to prevent layout shift (CLS) before products load */
    min-height: 420px; /* Fallback reserved height for desktop */
    content-visibility: auto; /* Skip rendering off-screen until needed */
    contain-intrinsic-size: 460px; /* Approx intrinsic height placeholder */
}

.similar-products-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    text-align: left;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.similar-products-container {
    position: relative;
    overflow: hidden;
    /* Center the carousel area to align with indicators */
    margin: 0 auto;
    max-width: 1160px;
    padding: 0 10px; /* keep the same inner spacing as before */
}

.similar-products-wrapper {
    display: flex;
    transition: transform 0.3s ease;
    gap: 12px;
}

.similar-product-card {
    flex: 0 0 auto;
    width: 250px;
    border: none;
    padding: 15px;
    background-color: white;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    min-height: 300px;
    cursor: pointer;
    overflow: hidden;
}

.similar-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.similar-product-image {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    background: #f0f0f0;
    margin: 0 auto 12px;
    transition: transform 0.3s ease;
}

.similar-product-card:hover .similar-product-image {
    transform: scale(1.02);
}

.similar-product-info {
    flex: 1 1 auto;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0;
    min-height: 0;
}

.similar-product-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 3.5em;
}

.similar-product-price {
    margin-top: 5px;
    color: #007bff;
    font-weight: bold;
    font-size: 1.1rem;
}

.similar-product-availability {
    font-size: 0.85rem;
    padding: 0px 8px;
    border-radius: 12px;
    font-weight: 500;
    display: inline-block;
    margin-top: 1px;
}

.similar-product-availability.available {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.similar-product-availability.unavailable {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.similar-product-availability.limited {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

/* Навігаційні кнопки */
.similar-products-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #007bff;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    z-index: 10;
    border: 2px solid rgba(0, 123, 255, 0.2);
}

.similar-products-nav:hover {
    background: #007bff;
    color: white;
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.4);
    border-color: #007bff;
}

.similar-products-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.7);
    transform: translateY(-50%) scale(0.9);
}

.similar-products-nav.prev {
    left: -12px;
}

.similar-products-nav.next {
    right: -12px;
}

.similar-products-nav svg {
    width: 24px;
    height: 24px;
}

/* Індикатори */
.similar-products-indicators {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 25px;
    /* Match the width and centering of the carousel container */
    max-width: 1160px;
    padding: 0 10px;
    margin-left: auto;
    margin-right: auto;
}

.similar-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.similar-indicator:hover {
    background: rgba(0, 123, 255, 0.6);
    transform: scale(1.2);
}

.similar-indicator.active {
    background: #007bff;
    transform: scale(1.4);
    border-color: rgba(0, 123, 255, 0.3);
}

/* Завантажувач */
.similar-products-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.similar-products-loading .spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    border-top-color: #007bff;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Стан помилки */
.similar-products-error {
    text-align: center;
    padding: 40px 20px;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 8px;
    margin: 20px 0;
}

.similar-products-error button {
    margin-top: 15px;
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

.similar-products-error button:hover {
    background: #c82333;
}

/* Адаптивність */
@media (max-width: 1024px) {
    .similar-products-wrapper {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 25px;
    }
    
    .similar-product-card {
        min-height: 280px;
    }
}

@media (max-width: 1300px) {
    .similar-products-section {
        margin: 20px 0;
        padding: 25px 15px;
    }
    
    .similar-products-title {
        font-size: 1.3rem;
    }
    
    .similar-products-wrapper {
        gap: 20px;
    }
    
    .similar-product-card {
        width: calc(33.333% - 13.33px); /* 3 товари на планшеті */
        min-height: 300px;
        height: auto;
        padding: 12px;
    }
    
    .similar-product-image {
        width: 150px;
        height: 150px;
    }
    
    .similar-product-image {
        width: 100%;
        height: 100%;
        margin: 0 auto 12px;
    }
}

/* Спеціальний медіа-запит для діапазону 601-1300px з 3 товарами */
@media (min-width: 601px) and (max-width: 1300px) {
    .similar-product-card {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        width: calc(33.333% - 13.33px) !important;
    }
    
    .similar-product-image {
        width: 180px !important;
        height: 180px !important;
        margin: 0 auto 12px !important;
        display: block !important;
    }
    
    .similar-product-info {
        width: 100% !important;
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
}

@media (max-width: 600px) {
    .similar-product-card {
        margin: 0;
        padding: 7px;
        width: calc(50% - 7.5px) !important;
        box-sizing: border-box;
        border-radius: 12px;
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
}

@media (max-width: 600px) {
    .similar-products-section {
        margin: 20px 0;
        padding: 15px;
    /* Smaller reserved space on mobile */
    min-height: 340px;
    contain-intrinsic-size: 360px;
    }
    
    .similar-products-title {
        font-size: 1.2rem;
        margin-bottom: 20px;
    }
    
    .similar-products-wrapper {
        gap: 15px;
    }
    
    .similar-product-card {
        width: calc(50% - 7.5px); /* 50% мінус половина gap */
        min-height: 250px;
        padding: 0px 0px 25px 0px;
        margin: 10px 0;
        flex-direction: column;
        text-align: center;
        align-items: center;
        box-sizing: border-box;
        border-radius: 12px;
    }
    
    .similar-product-image {
        width: 120px;
        height: 120px;
    }
    
    .similar-product-image {
        width: 100%;
        height: 100%;
        margin: 0 auto 5px;
    }
    
    .similar-product-title {
        font-size: 0.9rem;
        line-height: 1.2;
        margin-bottom: 5px;
        margin: 1px;
    }
    
    .similar-product-price {
        font-size: 1rem;
    }
    
    .similar-product-availability {
        font-size: 0.8rem;
    }
    
    /* Адаптивні кнопки навігації для мобільних */
    .similar-products-nav {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }
    
    .similar-products-nav.prev {
        left: -12px;
    }
    
    .similar-products-nav.next {
        right: -12px;
    }
    
    .similar-products-nav svg {
        width: 22px;
        height: 22px;
    }
}

/* When content fully initialized (JS can add this class), remove hard min-height but keep intrinsic sizing safety */
.similar-products-section.similar-products-loaded {
    min-height: unset;
}


/* Анімація появи карток */
.similar-product-card {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.similar-product-card:nth-child(1) { animation-delay: 0.1s; }
.similar-product-card:nth-child(2) { animation-delay: 0.2s; }
.similar-product-card:nth-child(3) { animation-delay: 0.3s; }
.similar-product-card:nth-child(4) { animation-delay: 0.4s; }
.similar-product-card:nth-child(5) { animation-delay: 0.5s; }

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

/* SEO and Accessibility Enhancements */
.similar-product-card {
    outline: none;
    border-radius: 12px;
    position: relative;
}

.similar-product-card:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.similar-product-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.similar-product-card[tabindex]:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Improve navigation button accessibility */
.similar-products-nav:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .similar-product-card {
        border: 2px solid #000;
    }
    
    .similar-products-nav {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .similar-products-wrapper {
        transition: none;
    }
    
    .similar-product-card {
        animation: none;
        transition: none;
    }
    
    @keyframes fadeInUp {
        from, to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}
