/* ==========================================
   HOME PAGE PRODUCT CAROUSEL - RTL PERSIAN
   Mobile-First Design with Simple RTL Strategy
   
   RTL Strategy (SIMPLE):
   - direction: rtl on carousel
   - flex-direction: row (normal)
   - Products naturally align right to left
   - Scroll works naturally in RTL
   ========================================== */

/* ==========================================
   Category Section Container
   ========================================== */
.category-carousel-section {
    padding: 0 0 28px 0;
    margin-bottom: 8px;
}

.category-carousel-section .section-header {
    padding: 0 16px;
    margin-bottom: 14px;
}

.category-carousel-section .section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
}

.category-carousel-section .section-title i {
    color: var(--secondary-color);
}

/* ==========================================
   ROW 1: Products Carousel
   ========================================== */
.products-carousel-wrapper {
    position: relative;
    margin-bottom: 12px;
    padding-right: 16px;
    padding-left: 0;
}

/* Gradient fade on LEFT (shows more content exists) */
.products-carousel-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: calc(100% - 4px);
    background: linear-gradient(to right, rgba(255,255,255,0.95), rgba(255,255,255,0));
    z-index: 10;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.products-carousel-wrapper.scroll-end::before {
    opacity: 0;
}

.products-carousel {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row; /* Normal direction */
    direction: rtl; /* RTL makes items flow from right */
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
    padding-right: 16px;
    padding-left: 16px;
    
    scroll-snap-type: x mandatory;
    scroll-padding-right: 16px;
}

.products-carousel::-webkit-scrollbar {
    display: none;
}

/* ==========================================
   Product Cards - Show 2.3 cards on mobile
   ========================================== */
.products-carousel .carousel-product-card {
    flex: 0 0 calc((100vw - 56px) / 2.3);
    min-width: calc((100vw - 56px) / 2.3);
    max-width: 160px;
    background: var(--bg-white);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
}

/* Hover effects only for devices with pointer (desktop/laptop) */
@media (hover: hover) and (pointer: fine) {
    /* Only image highlight on hover - no card transform/shadow */
    .carousel-product-card:hover .product-image::before {
        background: rgba(83, 83, 83, 0.25);
    }
}

/* No active transform effect */

.carousel-product-card .product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: var(--bg-light);
    overflow: hidden;
}

.carousel-product-card .product-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.carousel-product-card .product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Product Card Badges for Carousel */
.carousel-product-card .product-card__badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #ef4444;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    animation: none;
}

/* Responsive badge size for mobile */
@media (max-width: 768px) {
    .carousel-product-card .product-card__badge {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.65rem;
    }
}

/* Bottom banners for Carousel */
.carousel-product-card .product-card__badge--sold,
.carousel-product-card .product-card__badge--sale {
    position: absolute;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: none;
    border-radius: 0;
    padding: 0.6rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    box-shadow: none;
    animation: none;
}

/* Out of stock: dark semi-transparent */
.carousel-product-card .product-card__badge--sold {
    background: rgba(0, 0, 0, 0.75);
}

/* Sale: red semi-transparent */
.carousel-product-card .product-card__badge--sale {
    background: rgba(220, 38, 38, 0.82);
}

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

.carousel-product-card .product-card__badge--sold::before {
    content: 'ناموجود';
}

.carousel-product-card .product-card__badge--sale::before {
    content: 'تخفیف خورده';
}

/* Dark overlay on image when out of stock (same as hover) */
.carousel-product-card .product-image.is-out-of-stock::after,
.carousel-product-card .product-image:has(.product-card__badge--sold)::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(83, 83, 83, 0.25);
    z-index: 2;
    pointer-events: none;
}

/* Slightly dim sold products but keep visible */
.carousel-product-card .product-image.is-out-of-stock img,
.carousel-product-card .product-image:has(.product-card__badge--sold) img {
    opacity: 0.7 !important;
    filter: grayscale(15%) !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .carousel-product-card .product-card__badge--sold,
    .carousel-product-card .product-card__badge--sale {
        font-size: 0.7rem;
        padding: 0.5rem 0.4rem;
    }
}

.carousel-product-card .product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.carousel-product-card .product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.carousel-product-card .product-description {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.carousel-product-card .product-price {
    font-size: 14px;
    font-weight: bold;
    color: #d63031;
    margin-top: auto;
    transition: transform 0.2s ease;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.carousel-product-card .product-price--original {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-decoration: line-through;
}

.carousel-product-card .product-price--current {
    font-size: 14px;
    font-weight: 700;
    color: #d63031;
}

.products-carousel .carousel-endcap-card {
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 14px 12px;
    background: linear-gradient(160deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px dashed #fb923c;
    color: #9a3412;
}

.products-carousel .carousel-endcap-card .endcap-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #fdba74;
    background: #ffffff;
    color: #ea580c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

.products-carousel .carousel-endcap-card .endcap-kicker {
    font-size: 11px;
    font-weight: 700;
    color: #c2410c;
}

.products-carousel .carousel-endcap-card .endcap-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.4;
    color: #9a3412;
}

.products-carousel .carousel-endcap-card .endcap-subtitle {
    font-size: 12px;
    line-height: 1.4;
    color: #7c2d12;
}

.products-carousel-wrapper.is-near-end .carousel-endcap-card {
    border-color: #f97316;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.18);
}

/* Scroll hint animation */
@keyframes scroll-hint {
    0% { transform: translateX(0); }
    50% { transform: translateX(-20px); }
    100% { transform: translateX(0); }
}

.products-carousel.animate-hint {
    animation: scroll-hint 0.5s ease-out 0.8s 1;
}

/* ==========================================
   Mobile Indicators
   ========================================== */
.carousel-indicators {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-top: 0;
    padding: 0 16px;
}

.carousel-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    padding: 21px;
    background-clip: content-box;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: content-box;
}

.carousel-indicator.active {
    width: 20px;
    border-radius: 3px;
    background: var(--secondary-color);
    background-clip: content-box;
}

/* ==========================================
   Desktop Navigation
   ========================================== */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: none;
    pointer-events: auto;
}

.carousel-nav-prev {
    right: -20px;
}

.carousel-nav-next {
    left: -20px;
}

.carousel-nav button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.carousel-nav button:hover:not(:disabled) {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.25);
}

.carousel-nav button:active:not(:disabled) {
    transform: scale(0.95);
}

.carousel-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #f5f5f5;
}

.carousel-nav button svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

/* ==========================================
    Legacy Row 2 View-All Link (fallback pages)
    ========================================== */
.view-all-row {
    padding: 0 16px;
}

.carousel-view-all-card {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Right-aligned in RTL */
    padding: 12px 0;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 6px;
    direction: rtl;
}

.carousel-view-all-card .view-all-arrow {
    font-size: 16px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.carousel-view-all-card:hover .view-all-arrow {
    color: var(--secondary-color);
    transform: translateX(-4px);
}

.carousel-view-all-card .view-all-content {
    display: flex;
    align-items: center;
    background: transparent;
    padding: 0;
}

.carousel-view-all-card .view-all-icon {
    display: none;
}

.carousel-view-all-card .view-all-text {
    display: flex;
    align-items: center;
}

.carousel-view-all-card .view-all-title {
    font-size: 14px;
    font-weight: 500;
    color: #555e61;
    transition: color 0.2s ease;
}

.carousel-view-all-card:hover .view-all-title {
    color: var(--secondary-color);
}

.carousel-view-all-card .view-all-subtitle {
    display: none;
}

/* ==========================================
   RESPONSIVE: Tablet (768px+)
   ========================================== */
@media (min-width: 768px) {
    .category-carousel-section {
        padding: 0 0 32px 0;
    }

    .category-carousel-section .section-header {
        padding: 0 20px;
        margin-bottom: 16px;
    }

    .category-carousel-section .section-title {
        font-size: 20px;
    }

    .products-carousel-wrapper {
        padding-right: 20px;
    }

    .products-carousel-wrapper::before {
        width: 40px;
    }

    .products-carousel {
        gap: 14px;
        padding-right: 20px;
        padding-left: 20px;
        scroll-padding-right: 20px;
    }

    .products-carousel .carousel-product-card {
        flex: 0 0 calc((100vw - 74px) / 3.3);
        min-width: calc((100vw - 74px) / 3.3);
        max-width: 200px;
    }

    .carousel-product-card .product-info {
        padding: 12px;
    }

    .carousel-product-card .product-name {
        font-size: 14px;
    }

    .carousel-product-card .product-description {
        font-size: 12px;
    }

    .carousel-product-card .product-price {
        font-size: 15px;
    }

    .carousel-product-card .product-price--current {
        font-size: 15px;
    }

    .carousel-product-card .product-price--original {
        font-size: 13px;
    }

    .products-carousel .carousel-endcap-card .endcap-title {
        font-size: 16px;
    }

    .carousel-indicators {
        margin-top: 0;
        gap: 0;
    }

    .carousel-indicator {
        width: 8px;
        height: 8px;
    }

    .carousel-indicator.active {
        width: 24px;
    }

    .view-all-row {
        padding: 0 20px;
    }

    .carousel-view-all-card {
        padding: 14px 0;
    }

    .carousel-view-all-card .view-all-title {
        font-size: 15px;
    }
}

/* ==========================================
   RESPONSIVE: Desktop (1024px+)
   ========================================== */
@media (min-width: 1024px) {
    .category-carousel-section {
        max-width: 1200px;
        margin: 0 auto 24px auto;
        padding: 0 60px 36px 60px;
    }

    .category-carousel-section .section-header {
        padding: 0;
        margin-bottom: 18px;
    }

    .category-carousel-section .section-title {
        font-size: 22px;
    }

    .products-carousel-wrapper {
        padding: 0;
        margin-bottom: 16px;
    }

    .products-carousel-wrapper::before {
        display: none;
    }

    .products-carousel {
        gap: 18px;
        padding: 0;
        scroll-padding-right: 0;
        scroll-snap-type: none;
    }

    .products-carousel .carousel-product-card {
        flex: 0 0 220px;
        min-width: 220px;
        max-width: 220px;
        scroll-snap-align: none;
    }

    .products-carousel .carousel-endcap-card {
        padding: 16px 14px;
    }

    /* No hover transform/shadow - only image highlight */
    .products-carousel .carousel-product-card:hover {
        box-shadow: none;
        transform: none;
    }

    .carousel-nav {
        display: block;
    }

    .carousel-nav button {
        width: 44px;
        height: 44px;
    }

    .carousel-nav button svg {
        width: 22px;
        height: 22px;
    }

    .carousel-indicators {
        display: none;
    }

    .carousel-product-card .product-info {
        padding: 14px;
    }

    .carousel-product-card .product-name {
        font-size: 15px;
    }

    .carousel-product-card .product-description {
        font-size: 13px;
    }

    .carousel-product-card .product-price {
        font-size: 17px;
    }

    .carousel-product-card .product-price--current {
        font-size: 17px;
    }

    .carousel-product-card .product-price--original {
        font-size: 15px;
    }

    .view-all-row {
        padding: 0;
    }

    .carousel-view-all-card {
        padding: 16px 0;
    }

    .carousel-view-all-card .view-all-title {
        font-size: 16px;
    }

    .carousel-view-all-card .view-all-arrow {
        font-size: 18px;
    }
}

/* ==========================================
   Large Desktop (1280px+)
   ========================================== */
@media (min-width: 1280px) {
    .category-carousel-section {
        max-width: 1320px;
        padding: 0 70px 40px 70px;
    }

    .products-carousel {
        gap: 20px;
    }

    .products-carousel .carousel-product-card {
        flex: 0 0 240px;
        min-width: 240px;
        max-width: 240px;
    }

    .carousel-nav-prev {
        right: -24px;
    }

    .carousel-nav-next {
        left: -24px;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .products-carousel {
        scroll-behavior: auto;
    }
    
    .products-carousel.animate-hint {
        animation: none;
    }
    
    .carousel-product-card,
    .carousel-view-all-card,
    .carousel-nav button,
    .carousel-indicator {
        transition: none;
    }
}

.carousel-product-card:focus-visible,
.carousel-view-all-card:focus-visible,
.carousel-nav button:focus-visible,
.carousel-indicator:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.carousel-product-card .product-image img.lazy:not(.lazy-loaded) {
    opacity: 0.6;
}

.carousel-product-card .product-image img.lazy-loaded {
    opacity: 1;
}

@media (prefers-contrast: high) {
    .carousel-product-card,
    .carousel-nav button {
        border-width: 2px;
    }
}
