.S4_home {
    padding: 70px 0;
    background-color: var(--body_bgColor);
}

.carousel-container {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.carousel {
    position: relative;
    overflow: visible;
}

.carousel-inner {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 15px;
    padding: 10px 0;
    scroll-snap-type: x mandatory;
    align-items: stretch;
}

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

.carousel-item {
    flex: 0 0 calc(20% - 12px);
    scroll-snap-align: start;
    min-width: 0;
    display: flex;
    align-items: stretch;
}

.product-card {
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(212, 175, 55, 0.15);
    background: #1a1a1a !important;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%; /* User requested height:100% to prevent trapping */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.product-card:hover {
    transform: translateY(-5px);
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.2);
}

body.dark_mode .product-card:hover {
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.3);
}

.product-image {
    position: relative;
    display: block;
    height: clamp(140px, 20vw, 200px);      /* fluid height for image wrapper */
    overflow: hidden !important;
    flex: 0 0 auto;
    padding: 10px !important;
    background: #1a1a1a !important;
}

.product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background-color: #1a1a1a !important;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.sold_out {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 2;
}

/* نفذت الكمية */
.sold_out {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(180, 0, 0, 0.85);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    z-index: 3;
}

/* السعر */
.price-block {
    font-size: 13px;
    font-weight: bold;
    color: #D4AF37;
    margin: 3px 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    direction: ltr;
}

.price-current {
    color: #D4AF37;
    font-weight: 900;
}

.price-old {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-weight: 400;
}

.product-info {
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;      
    min-height: 0;
    overflow: hidden;   
    box-sizing: border-box;
}

.category {
    font-size: 12px;
    color: var(--textColor);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.product-info h3 {
    margin: 0 0 4px 0;
    font-size: 13px;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}

.product-info h3 a {
    color: var(--btnColor);
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-info h3 a:hover {
    color: var(--primary-color);
}

.price {
    font-size: 13px;
    font-weight: bold;
    color: var(--textColor);
    margin: 3px 0;
    flex-shrink: 0;
}

.product-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
    flex-shrink: 0;
}

.link_button {
    flex: 1;
    padding: 7px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 34px;
}

.add-to-cart {
    background-color: var(--btnColor);
    color: white;
}

.add-to-cart:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

.heart {
    background-color: transparent;
    color: var(--btnColor);
    border: 2px solid var(--btnColor);
    width: 50px;
    padding: 10px;
    flex: 0 0 auto;
}

.heart:hover {
    background-color: var(--btnColor);
    color: white;
}

.carousel-control-prev,
.carousel-control-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: var(--btnColor);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.9;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body.dark_mode .carousel-control-prev,
body.dark_mode .carousel-control-next {
    background-color: var(--btnColor);
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    background-color: var(--primary-color);
    transform: translateY(-50%) scale(1.1);
    opacity: 1;
}

.carousel-control-prev.disabled,
.carousel-control-next.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.carousel-control-prev {
    left: -20px;
}

.carousel-control-next {
    right: -20px;
}

@media (max-width: 992px) {
    /* Tablet: 3 كروت */
    .carousel-item {
        flex: 0 0 calc(33.333% - 11px);
    }
    .product-info  { padding: 10px 12px; }
    .product-info h3 { font-size: 12px; margin: 0 0 3px; }
    .price { font-size: 12px; margin: 2px 0; }
    .link_button { font-size: 11px; padding: 6px 8px; min-height: 30px; }
    .heart { width: 30px; flex: 0 0 30px; padding: 4px; min-height: 30px; }
}

@media (max-width: 768px) {
    /* Mobile كبير: 3 كروت */
    .carousel-item { flex: 0 0 calc(33.333% - 9px); }
    .carousel-inner { gap: 9px; }

    .carousel-control-prev,
    .carousel-control-next { width: 28px; height: 28px; font-size: 12px; }
    .carousel-control-prev { left: -12px; }
    .carousel-control-next { right: -12px; }

    .product-info  { padding: 8px 10px; }
    .product-info h3 { font-size: 11px; margin: 0 0 2px; line-height: 1.2; }
    .price { font-size: 11px; margin: 2px 0; }
    .product-actions { gap: 4px; }
    .link_button { font-size: 10px; padding: 5px 5px; min-height: 28px; gap: 2px; }
    .heart { width: 28px; flex: 0 0 28px; padding: 3px; min-height: 28px; }
}

@media (max-width: 400px) {
    /* Mobile صغير: 2 كروت */
    .carousel-item { flex: 0 0 calc(50% - 7px); }
    .carousel-inner { gap: 7px; }
    .carousel-control-prev,
    .carousel-control-next { display: none; }

    .product-image { padding: 8px !important; }
    .product-info  { padding: 7px 9px; }
    .product-info h3 { font-size: 11px; margin: 0 0 2px; }
    .price { font-size: 11px; margin: 2px 0; }
    .product-actions { gap: 4px; }
    .link_button { font-size: 10px; padding: 5px 4px; min-height: 26px; }
    .heart { width: 26px; flex: 0 0 26px; padding: 3px; min-height: 26px; }
}
