/* Reset CSS */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Variables */
:root {
  --carousel-gap: 1rem;
  --carousel-button-size: 48px;
  --carousel-indicator-size: 12px;
  --carousel-transition: 300ms ease-in-out;
  --carousel-primary-color: #333;
  --carousel-secondary-color: #fff;
  --carousel-focus-color: #4a90e2;
  --slide-width: 450px;
  --slide-height: 330px;
  --spacing-lg: 1.5rem;
  --spacing-md: 1rem;
  --spacing-xl: 2rem;
  --border-radius: 8px;
  --color-white: #ffffff;
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-heavy: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Instance-specific variables support */
.carousel {
  --slide-width-dynamic: var(--slide-width);
  --total-slide-width: calc(var(--slide-width-dynamic) + var(--spacing-lg));
}

/* Carousel component */
.carousel {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
  overflow: hidden;
}

/* Carousel wrapper */
.carousel__wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: calc(var(--slide-height) + 3rem);
  margin: 0 auto;
}

.carousel__container {
  display: flex;
  gap: var(--spacing-lg);
  align-items: center;
  justify-content: flex-start;
  list-style: none;
  margin: 0;
  padding: var(--spacing-xl) 0;
  overflow: visible;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* Width calculée dynamiquement par JavaScript */
  width: auto;
}

/* Reset any default list item styling that might create backgrounds */
.carousel__container li {
  list-style: none !important;
  background: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.carousel__slide {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  min-height: calc(var(--slide-height) + 60px);
  position: relative;
  z-index: 5;
  opacity: 0.6;
  transform: translateY(10px) scale(0.8);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  width: var(--slide-width);
  max-width: calc(33.333% - var(--spacing-lg));
}

/* Ensure images display cleanly without any container interference */
.carousel__slide img {
  display: block;
  width: 100%;
  max-width: var(--slide-width);
  height: auto;
  max-height: var(--slide-height);
  object-fit: cover;
  border-radius: var(--border-radius);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(1);
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

/* Active slide styling - center image prominent */
.carousel__slide.active {
  z-index: 10;
  opacity: 1;
  transform: translateY(-20px) scale(1.1);
  box-shadow: none;
  background: transparent;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel__slide.active img {
  transform: scale(1);
  filter: brightness(1.05);
  box-shadow: none;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px;
}

/* Left visible slide styling */
.carousel__slide.active-left {
  z-index: 8;
  opacity: 0.8;
  transform: translateY(-20px) scale(1.1);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  left: 7%;
}

.carousel__slide.active-left img {
  transform: scale(0.9);
  opacity: 0.8;
  filter: brightness(0.95);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px;
}

/* Right visible slide styling */
.carousel__slide.active-right {
  z-index: 8;
  opacity: 0.8;
  transform: translateY(-20px) scale(1.1);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  right: 7%;
}

.carousel__slide.active-right img {
  transform: scale(0.9);
  opacity: 0.8;
  filter: brightness(0.95);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px;
}

/* Non-active slides styling - completely hidden slides */
.carousel__slide:not(.active):not(.active-left):not(.active-right) {
  z-index: 5;
  transform: translateY(10px) scale(0.7);
  opacity: 0.3;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel__slide:not(.active):not(.active-left):not(.active-right) img {
  transform: scale(0.7);
  opacity: 0.4;
  box-shadow: none;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Navigation buttons */
.carousel__button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 0px 26px 26px 0px;
  background: white;
  border: 2px solid #005f7d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 95, 125, 0.2);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 20;
  color: #005f7d;
}

.carousel__button .material-symbols-outlined {
  font-size: 24px;
  font-weight: 400;
  transition: all 0.3s ease;
  line-height: 1;
}

/* Fallback pour les chevrons si Material Symbols ne charge pas */
.carousel__button .material-symbols-outlined::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transition: all 0.3s ease;
}

.carousel__button--prev .material-symbols-outlined::before {
  transform: rotate(-135deg);
  margin-left: 2px;
}

.carousel__button--next .material-symbols-outlined::before {
  transform: rotate(45deg);
  margin-right: 2px;
}

/* Si Material Symbols charge correctement, masquer le fallback */
.carousel__button .material-symbols-outlined:not(:empty)::before {
  display: none;
}

.carousel__button:hover {
  background: #005f7d;
  color: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 8px 25px rgba(0, 95, 125, 0.4);
}

.carousel__button:hover .material-symbols-outlined {
  transform: scale(1.2);
}

.carousel__button:hover .material-symbols-outlined::before {
  transform: scale(1.2) rotate(-135deg);
}

.carousel__button--next:hover .material-symbols-outlined::before {
  transform: scale(1.2) rotate(45deg);
}

.carousel__button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 95, 125, 0.3);
}

.carousel__button:active {
  transform: translateY(-50%) scale(0.95);
}

.carousel__button:disabled {
  background: #f5f5f5;
  color: #bdbdbd;
  border-color: #e0e0e0;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.carousel__button:disabled .material-symbols-outlined {
  transform: scale(1);
}

.carousel__button:disabled .material-symbols-outlined::before {
  border-color: #bdbdbd;
  transform: rotate(-135deg);
}

.carousel__button--next:disabled .material-symbols-outlined::before {
  transform: rotate(45deg);
}

.carousel__button--prev {
  left: 20px;
  border-radius: 0px 26px 26px 0px;
}

.carousel__button--next {
  right: 20px;
  border-radius: 0px 26px 26px 0px !important;
}

/* Animation pour les boutons */
@keyframes buttonPulse {
  0% {
    box-shadow: 0 4px 15px rgba(0, 95, 125, 0.2);
  }
  50% {
    box-shadow: 0 8px 25px rgba(0, 95, 125, 0.4);
  }
  100% {
    box-shadow: 0 4px 15px rgba(0, 95, 125, 0.2);
  }
}

.carousel__button:not(:disabled):hover {
  animation: buttonPulse 2s ease-in-out infinite;
}

/* Indicators */
.carousel__indicators {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 20;
}

.carousel__indicator {
  width: var(--carousel-indicator-size);
  height: var(--carousel-indicator-size);
  border-radius: 50%;
  border: 2px solid var(--carousel-primary-color);
  background-color: transparent;
  cursor: pointer;
  transition: all var(--carousel-transition);
}

.carousel__indicator[aria-selected='true'] {
  background-color: var(--carousel-primary-color);
  transform: scale(1.2);
}

.carousel__indicator:hover,
.carousel__indicator:focus {
  background-color: var(--carousel-primary-color);
  outline: 3px solid var(--carousel-focus-color);
  outline-offset: 2px;
}

/* ===== MOBILE CAROUSEL - COMPLETE OVERRIDE ===== */
/* This section completely overrides desktop carousel behavior on mobile */

@media (max-width: 768px) {
  /* Reset carousel to normal slider behavior */
  .carousel {
    padding: 2rem 1rem !important;
    overflow: hidden !important;
    position: relative !important;
  }

  .carousel__wrapper {
    height: auto !important;
    overflow: hidden !important;
    width: 100% !important;
    position: relative !important;
  }

  .carousel__container {
    display: flex !important;
    gap: 20px !important;
    padding: 1rem 0 !important;
    transition: transform 0.3s ease !important;
    justify-content: flex-start !important;
    align-items: center !important;
    margin: 0 !important;
    width: auto !important;
    list-style: none !important;
  }

  /* MOBILE SLIDES - Complete reset */
  .carousel__slide {
    width: 100% !important;
    max-width: 320px !important;
    min-width: 280px !important;
    flex-shrink: 0 !important;
    opacity: 1 !important;
    transform: none !important;
    z-index: 1 !important;
    position: relative !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    transition: none !important;
    min-height: auto !important;
  }

  /* MOBILE IMAGES - Complete reset */
  .carousel__slide img {
    width: 100% !important;
    height: auto !important;
    max-height: 250px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
    transition: none !important;
  }

  /* Override ALL desktop states */
  .carousel__slide.active,
  .carousel__slide.mobile-active,
  .carousel__slide.active-left,
  .carousel__slide.active-right,
  .carousel__slide:not(.active):not(.mobile-active) {
    opacity: 1 !important;
    transform: none !important;
    z-index: 1 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    left: auto !important;
    right: auto !important;
    position: relative !important;
  }

  /* Override ALL desktop image states */
  .carousel__slide.active img,
  .carousel__slide.mobile-active img,
  .carousel__slide.active-left img,
  .carousel__slide.active-right img,
  .carousel__slide:not(.active):not(.mobile-active) img {
    width: 100% !important;
    height: auto !important;
    max-height: 250px !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    transition: none !important;
  }

  /* Mobile buttons */
  .carousel__button {
    width: 50px !important;
    height: 50px !important;
  }

  .carousel__button .material-symbols-outlined {
    font-size: 24px !important;
  }

  .carousel__button--prev {
    left: 10px !important;
  }

  .carousel__button--next {
    right: 10px !important;
  }

  /* Mobile indicators */
  .carousel__indicator {
    width: 16px !important;
    height: 16px !important;
    margin: 0 4px !important;
  }

  /* Force clean mobile layout */
  .carousel__slide *,
  .carousel__slide::before,
  .carousel__slide::after {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
    transform: none !important;
    filter: none !important;
  }
}

@media (max-width: 480px) {
  .carousel {
    padding: 1.5rem 0.5rem 0.5rem !important;
  }

  .carousel__slide {
    max-width: 280px !important;
    min-width: 260px !important;
  }

  .carousel__button {
    width: 45px !important;
    height: 45px !important;
  }

  .carousel__button .material-symbols-outlined {
    font-size: 20px !important;
  }

  .carousel__button--prev {
    left: 5px !important;
  }

  .carousel__button--next {
    right: 5px !important;
  }

  .carousel__indicators {
    bottom: -10px !important;
  }
}

/* Touch-friendly mobile enhancements */
@media (max-width: 768px) and (pointer: coarse) {
  .carousel__button {
    width: 54px !important;
    height: 54px !important;
  }

  .carousel__button .material-symbols-outlined {
    font-size: 24px !important;
  }

  .carousel__indicator {
    width: 18px !important;
    height: 18px !important;
    margin: 0 6px !important;
  }
}

/* Force single-slide layout on very small screens */
@media (max-width: 360px) {
  .carousel__slide {
    max-width: 260px !important;
    min-width: 240px !important;
  }

  .carousel__button--prev {
    left: 2px !important;
  }

  .carousel__button--next {
    right: 2px !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .carousel__container,
  .carousel__slide,
  .carousel__slide img,
  .carousel__button,
  .carousel__indicator {
    transition: none;
  }
}

/* Ensure no background or border effects anywhere */
.carousel__slide,
.carousel__slide *,
.carousel__slide::before,
.carousel__slide::after {
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}

/* Elementor integration - force full width adaptation */
.elementor-widget-container .carousel,
.carousel--responsive {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 2rem 1rem !important;
}

.elementor-widget-container .carousel__wrapper,
.carousel--responsive .carousel__wrapper {
  width: 100% !important;
  max-width: none !important;
}

.elementor-widget-container .carousel__slide,
.carousel--responsive .carousel__slide {
  width: auto !important;
  min-width: 200px !important;
  flex: 1 0 auto !important;
}

.elementor-widget-container .carousel__slide img,
.carousel--responsive .carousel__slide img {
  width: 100% !important;
  height: auto !important;
  max-height: 300px !important;
  object-fit: cover !important;
}

/* Force container to take full width in Elementor */
.elementor-widget-container {
  width: 100% !important;
  overflow: hidden !important;
}

@media (max-width: 768px) {
  .elementor-widget-container .carousel__slide,
  .carousel--responsive .carousel__slide {
    max-width: calc(50% - 0.5rem) !important;
  }
}

@media (max-width: 480px) {
  .elementor-widget-container .carousel__slide,
  .carousel--responsive .carousel__slide {
    max-width: calc(50% - 0.5rem) !important;
    left: 20%;
  }
}

/* Elementor customization overrides */
.elementor-widget-container .carousel__button {
  background-color: var(--button-bg-color, #ffffff);
  border-color: var(--button-border-color, #005f7d);
  color: var(--button-icon-color, #005f7d);
}

.elementor-widget-container .carousel__button:hover {
  background-color: var(--button-hover-bg-color, #005f7d);
  color: var(--button-hover-icon-color, #ffffff);
}

.elementor-widget-container .carousel__button .material-symbols-outlined {
  color: inherit;
}

.elementor-widget-container .carousel__button .material-symbols-outlined::before {
  border-color: currentColor;
}

/* Ensure Elementor custom styles take precedence */
.elementor-widget-container .carousel__button[style*='background-color'] {
  background-color: var(--e-global-color-primary, #ffffff) !important;
}

.elementor-widget-container .carousel__button[style*='border-color'] {
  border-color: var(--e-global-color-secondary, #005f7d) !important;
}

.elementor-widget-container .carousel__button[style*='color'] {
  color: var(--e-global-color-text, #005f7d) !important;
}
