/**
 * Cadre Intégré Renforcé (CIR) Mali - Animations et Interactions CSS
 * Ce fichier contient les styles pour les animations et interactions modernes
 */

/* ======= Animations générales ======= */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Classe pour l'animation de secousse */
.shake {
  animation: shake 0.5s ease-in-out;
}

/* ======= Preloader ======= */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease-out;
}

.preloader-content {
  text-align: center;
  color: white;
}

.preloader-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.preloader-hidden {
  opacity: 0;
}

/* ======= Header amélioré ======= */
.header-hidden {
  transform: translateY(-100%);
}

#header {
  transition: transform 0.4s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

#header.sticky.header-hidden {
  transform: translateY(-100%);
}

/* ======= Menu mobile avec animations ======= */
.menu-open {
  overflow: hidden;
}

.nav-menu li {
  opacity: 0;
  transform: translateX(-20px);
}

.nav-menu.active li {
  opacity: 1;
  transform: translateX(0);
}

.nav-link.active {
  position: relative;
  color: var(--primary-color);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 2px;
}

/* ======= Back to Top Button avec indicateur de progression ======= */
#back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.2);
  z-index: 99;
}

#back-to-top.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#back-to-top i {
  font-size: 18px;
  transition: transform 0.3s ease;
}

#back-to-top:hover i {
  transform: translateY(-3px);
}

#back-to-top.clicked {
  transform: scale(0.95);
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.3s ease;
}

/* ======= Animations des compteurs ======= */
.number {
  display: inline-block;
  font-weight: 700;
  color: transparent;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  transition: all 0.3s ease;
}

.label {
  opacity: 0.7;
  transform: translateY(5px);
  transition: all 0.5s ease 0.3s;
}

.label.animated {
  opacity: 1;
  transform: translateY(0);
}

.section-visible .chiffre-item {
  animation: fadeInUp 0.8s ease forwards;
}

/* ======= Formulaires améliorés ======= */
.form-group {
  position: relative;
  margin-bottom: 25px;
  transition: all 0.3s ease;
}

/* Style pour les boutons avec spinner */
.btn {
  position: relative;
  overflow: hidden;
}

.btn .btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.btn.loading .btn-text {
  opacity: 0;
  visibility: hidden;
}

.btn.loading .btn-spinner {
  opacity: 1;
  visibility: visible;
}

.form-group.focused label {
  transform: translateY(-20px) scale(0.85);
  color: var(--primary-color);
}

.form-group label {
  position: absolute;
  top: 12px;
  left: 15px;
  color: #666;
  transition: all 0.3s ease;
  pointer-events: none;
  transform-origin: left top;
}

.form-group input,
.form-group textarea {
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  width: 100%;
  font-size: 16px;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.1);
}

.form-group input.has-value + label,
.form-group textarea.has-value + label {
  transform: translateY(-20px) scale(0.85);
}

.form-group input.error,
.form-group textarea.error {
  border-color: #ff3b30;
  background-color: rgba(255, 59, 48, 0.05);
}

.error-message {
  color: #ff3b30;
  font-size: 12px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.error-message.show {
  opacity: 1;
  transform: translateY(0);
}

.error-message i {
  margin-right: 5px;
}

.success-message {
  text-align: center;
  padding: 30px;
  animation: fadeIn 0.5s ease;
}

.success-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.success-icon i {
  font-size: 30px;
  color: white;
}

.newsletter-success {
  margin-top: 10px;
  padding: 10px;
  color: var(--primary-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.newsletter-success.show {
  opacity: 1;
  transform: translateY(0);
}

.newsletter-success i {
  margin-right: 8px;
}

/* Validation visuelle pour le champ email */
input.valid {
  border-color: #34c759 !important;
  background-color: rgba(52, 199, 89, 0.05) !important;
}

input.invalid {
  border-color: #ff3b30 !important;
  background-color: rgba(255, 59, 48, 0.05) !important;
}

/* ======= Carte Mali interactive ======= */
.map-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 10px;
}

.map-background {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.map-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.map-container:hover .map-image {
  transform: scale(1.03);
}

.map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.4));
  pointer-events: none;
}

.map-points {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.map-point {
  position: absolute;
  width: 16px;
  height: 16px;
  background-color: var(--primary-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), 0.3);
  transition: all 0.3s ease;
}

.map-point::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  background-color: rgba(var(--primary-color-rgb), 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
  opacity: 0;
  transition: all 0.3s ease;
}

.map-point:hover,
.map-point.active {
  background-color: var(--secondary-color);
  transform: translate(-50%, -50%) scale(1.2);
}

.map-point:hover::before,
.map-point.active::before {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
}

.pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--primary-color);
  opacity: 0.8;
  z-index: -1;
}

.map-point .pulse {
  animation: pulse 2s infinite;
}

.map-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background-color: white;
  color: #333;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 3;
}

.map-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: white transparent transparent transparent;
}

.map-tooltip strong {
  display: block;
  color: var(--primary-color);
}

.map-point:hover .map-tooltip,
.map-point.active .map-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-5px);
}

.map-info {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 8px;
  max-width: 300px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  z-index: 2;
}

.map-info h3 {
  margin: 0 0 5px;
  color: var(--primary-color);
  font-size: 18px;
}

.map-info p {
  margin: 0 0 10px;
  font-size: 14px;
}

.map-legend {
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: var(--primary-color);
  border-radius: 50%;
  margin-right: 5px;
}

.region-info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.region-info-modal.active {
  opacity: 1;
  visibility: visible;
}

.region-info-modal.closing {
  opacity: 0;
}

.region-info-content {
  background-color: white;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transform: scale(0.9);
  transition: all 0.3s ease;
}

.region-info-modal.active .region-info-content {
  transform: scale(1);
}

.region-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
}

.region-info-header h3 {
  margin: 0;
  color: var(--primary-color);
}

.close-modal {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  transition: all 0.3s ease;
}

.close-modal:hover {
  color: var(--primary-color);
  transform: rotate(90deg);
}

.region-info-body {
  padding: 20px;
}

/* ======= Partenaires Slider ======= */
.partenaires-slider {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.slider-track {
  display: flex;
  transition: transform 0.5s ease-out;
}

.slider-track .partenaire-item {
  flex: 0 0 auto;
  width: calc(100% / 4); /* Default 4 items per view */
  padding: 10px;
  box-sizing: border-box;
}

.slider-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}

.slider-prev,
.slider-next {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.slider-prev:hover,
.slider-next:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.slider-dots {
  display: flex;
  margin: 0 15px;
}

.slider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ddd;
  margin: 0 5px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.slider-dot.active {
  background-color: var(--primary-color);
  transform: scale(1.2);
}

/* ======= Galerie Lightbox ======= */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.9);
  cursor: pointer;
}

.lightbox-container {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  z-index: 1;
}

.lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

.lightbox-image.transitioning {
  opacity: 0.5;
}

.lightbox-caption {
  color: white;
  text-align: center;
  padding: 15px;
  width: 100%;
  font-size: 16px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background-color: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.lightbox-close {
  top: -50px;
  right: 0;
}

.lightbox-prev {
  left: -60px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: -60px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: var(--primary-color);
}

.lightbox-prev.disabled,
.lightbox-next.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

body.lightbox-open {
  overflow: hidden;
}

/* ======= Parallax Effect ======= */
.hero {
  position: relative;
  overflow: hidden;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  will-change: transform;
}

/* ======= Media Queries ======= */
@media (max-width: 992px) {
  .slider-track .partenaire-item {
    width: calc(100% / 3); /* 3 items per view on medium screens */
  }
  
  .lightbox-prev {
    left: 20px;
  }
  
  .lightbox-next {
    right: 20px;
  }
}

@media (max-width: 768px) {
  .slider-track .partenaire-item {
    width: calc(100% / 2); /* 2 items per view on small screens */
  }
  
  .map-info {
    bottom: 10px;
    left: 10px;
    padding: 10px;
    max-width: 250px;
  }
  
  #back-to-top {
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 576px) {
  .slider-track .partenaire-item {
    width: 100%; /* 1 item per view on extra small screens */
  }
  
  .region-info-content {
    width: 95%;
  }
}
