/* Comprehensive RTL carousel fixes */

/* Base RTL carousel styles */
.rtl-carousel,
html[dir="rtl"] .carousel {
    direction: ltr !important; /* Keep carousel sliding direction as LTR */
}

/* Ensure carousel items are visible */
html[dir="rtl"] .carousel-item,
html[dir="rtl"] .carousel-item.active,
.rtl-carousel .carousel-item,
.rtl-carousel .carousel-item.active {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
}

/* Ensure images are visible and properly positioned */
html[dir="rtl"] .carousel-item img,
html[dir="rtl"] .carousel-image,
.rtl-carousel .carousel-item img,
.rtl-carousel .carousel-image {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 5 !important;
    width: 100% !important;
    height: 70vh !important;
    object-fit: cover !important;
}

/* Fix carousel caption for RTL */
html[dir="rtl"] .carousel-caption,
.rtl-carousel .carousel-caption {
    direction: rtl !important;
    text-align: center !important;
    background: rgba(0, 0, 0, 0.7) !important;
    border-radius: 10px !important;
    padding: 20px !important;
    max-width: 600px !important;
    margin: 0 auto !important;
    bottom: 30px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    position: absolute !important;
    z-index: 15 !important;
}

/* Ensure black background for all Arabic carousel captions */
#sliderCarousel.rtl-carousel .carousel-caption,
.carousel.rtl-carousel .carousel-caption,
.rtl-carousel .carousel-item .carousel-caption,
html[dir="rtl"] #sliderCarousel .carousel-caption,
html[dir="rtl"] .carousel .carousel-caption {
    background: rgba(0, 0, 0, 0.7) !important;
    border-radius: 10px !important;
    padding: 20px !important;
}

/* Fix Arabic text styling */
html[dir="rtl"] .carousel-caption h5,
.rtl-carousel .carousel-caption h5 {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    margin-bottom: 1rem !important;
    color: #fff !important;
    text-align: center !important;
}

html[dir="rtl"] .carousel-caption p,
.rtl-carousel .carousel-caption p {
    font-size: 1.2rem !important;
    margin-bottom: 1.5rem !important;
    color: #FFC43F !important;
    text-align: center !important;
}

/* Fix control button positioning for RTL */
html[dir="rtl"] .carousel-control-prev,
.rtl-carousel .carousel-control-prev {
    right: 0 !important;
    left: auto !important;
    z-index: 100 !important;
}

html[dir="rtl"] .carousel-control-next,
.rtl-carousel .carousel-control-next {
    left: 0 !important;
    right: auto !important;
    z-index: 100 !important;
}

/* Fix for control icons direction */
html[dir="rtl"] .carousel-control-prev-icon,
html[dir="rtl"] .carousel-control-next-icon,
.rtl-carousel .carousel-control-prev-icon,
.rtl-carousel .carousel-control-next-icon {
    transform: rotate(180deg) !important;
}

/* Fix button alignment in carousel caption */
html[dir="rtl"] .carousel-caption .d-flex,
.rtl-carousel .carousel-caption .d-flex {
    justify-content: center !important;
    direction: ltr !important;
}

html[dir="rtl"] .carousel-caption .btn,
.rtl-carousel .carousel-caption .btn {
    margin: 0 5px !important;
}

/* Emergency fix for carousel display issues */
.carousel-emergency-fix {
    position: relative !important;
    overflow: visible !important;
}

.carousel-emergency-fix .carousel-item {
    position: relative !important;
    display: none !important;
}

.carousel-emergency-fix .carousel-item.active {
    display: block !important;
}

.carousel-emergency-fix .carousel-item img {
    width: 100% !important;
    height: 70vh !important;
    object-fit: cover !important;
    display: block !important;
}

.carousel-emergency-fix .carousel-img-container {
    position: relative !important;
    width: 100% !important;
    height: 70vh !important;
    overflow: hidden !important;
}

/* Keep flex directions correct for RTL */
html[dir="rtl"] .d-flex {
    flex-direction: row-reverse;
}

/* Fix for sports category carousel in RTL mode */
html[dir="rtl"] .swiper-wrapper {
    direction: rtl;
}

html[dir="rtl"] .swiper-buttons {
    direction: ltr; /* Keep the swiper buttons in LTR direction */
}

/* Static fallback styling */
.static-carousel-fallback {
    position: relative;
    width: 100%;
    height: 70vh;
    overflow: hidden;
}

.static-carousel-fallback img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.static-carousel-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    width: 80%;
}

.static-carousel-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.static-carousel-content p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

/* IMPORTANT: Force black background for Arabic carousel captions */
/* This rule has highest specificity to ensure it overrides everything */
body .carousel.rtl-carousel .carousel-caption,
body .rtl-carousel .carousel-caption,
body #sliderCarousel.rtl-carousel .carousel-caption,
body html[dir="rtl"] .carousel-caption,
body html[dir="rtl"] #sliderCarousel .carousel-caption {
    background: rgba(0, 0, 0, 0.7) !important;
    border-radius: 10px !important;
    padding: 20px !important;
}

/* Ensure text styling matches English version exactly */
body .rtl-carousel .carousel-caption h5,
body html[dir="rtl"] .carousel-caption h5 {
    color: #fff !important;
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    margin-bottom: 1rem !important;
}

body .rtl-carousel .carousel-caption p,
body html[dir="rtl"] .carousel-caption p {
    color: #FFC43F !important;
    font-size: 1.2rem !important;
    margin-bottom: 1.5rem !important;
}
