:root {
  --primary: #85AB76;
  --primary-dark: #749565;
  --secondary: #AF6F47;
  --secondary-dark: #9A6240;
  --danger: #A50C0C;
  --danger-dark: #8B0A0A;
  --info: #4693cc;
  --info-dark: #3a7bad;
  --background: #f8fafc;
  --text: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

/* ------ STYLES GÉNÉRAUX ------ */

.planning-container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.planning-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

#planning-search {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

#planning-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(133,171,118,0.2);
}

.planning-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.planning-nav input[type="date"] {
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 6px;
}

.nav-button,
.elementor-button {
  border: none;
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-button {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
}

.elementor-button.elementor-button-success {
  background-color: var(--primary);
  color: #fff;
}

.elementor-button.elementor-button-danger {
  background-color: var(--danger);
  color: #fff;
}

.elementor-button.elementor-button-secondary {
  background-color: var(--secondary);
  color: #fff;
}

.elementor-button.elementor-button-info {
  background-color: var(--info);
  color: #fff;
}

/* ---------- AFFICHAGE JOURNALIER (MATIN / APRÈS-MIDI) ---------- */

.day-activities-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.day-column {
  flex: 1;
  min-width: 300px;
}

.planning-section-title {
  margin: 1.5rem 0 1rem;
  font-size: 1.2rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.activite-item {
  display: flex;
  background: #fff;
  margin-bottom: 10px;
  align-items: center;
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
  /* Sur PC, on reste en ligne tant que > 992px */
  flex-wrap: nowrap;
}

.activite-color {
  flex: 0 0 4%;
  height: 100%;
}

.activite-info {
  flex: 0 0 25%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.5rem;
  text-align: left;
}

.activite-info .activite-time,
.activite-info .activite-title,
.activite-info .activite-guide {
  margin: 2px 0;
  font-size: 0.9rem;
}

.activite-participants-count {
  flex: 0 0 15%;
  text-align: center;
  font-size: 1.2em;
}

.activite-participants-blocks-wrapper {
  flex: 0 0 43%;
  padding: 0.5rem;
}

.activite-participants-blocks {
  display: flex;
  gap: 2px;
}

.activite-participants-blocks .participant-block {
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  padding: 0.3rem;
  text-align: center;
  border-radius: 4px;
}

/* 
   Conteneur des 3 boutons (dupliquer, supprimer, éditer).
   Sur PC, on laisse le style inline par défaut (en ligne).
*/

/* ---------- AFFICHAGE SEMAINE ---------- */
.week-title {
  margin-bottom: 2rem !important;
  font-size: 1.5rem;
  text-align: center;
  color: var(--text);
  font-weight: 600;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.week-day {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.week-day-header {
  background: var(--primary);
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

.no-activity {
  color: var(--text-light);
  font-size: 0.85rem;
}

/* ----------------------------------------
   MEDIA QUERY POUR TABLETTE / MOBILE
   (≤ 992px)
---------------------------------------- */
@media (max-width: 992px) {

  /* Empile matin/après-midi */
  #planning-list > div[style*="display:flex"] {
    flex-direction: column !important;
    gap: 0 !important;
  }
  #planning-list > div[style*="display:flex"] > div {
    width: 100% !important;
  }

  /* Autorise le wrap dans la .activite-item pour éviter chevauchement */
  .activite-item {
    flex-wrap: wrap !important;
    flex-direction: row !important;
    align-items: flex-start !important;
  }

  .activite-color {
    width: 100% !important;
    height: 4px !important;
    order: 1 !important;
  }
  .activite-info {
    width: 100% !important;
    order: 2 !important;
  }
  .activite-participants-count {
    width: auto !important;
    order: 3 !important;
  }
  .activite-participants-blocks-wrapper {
    width: 100% !important;
    order: 4 !important;
  }

  /* 
    Forcer le DIV de 20% (celui qui a display:flex, 
    justify-content:flex-end, etc.) à passer en colonne, aligné à droite 
    => C’est votre conteneur de 3 boutons.
    
    On sait, via votre code PHP, que c'est 
    <div style="width:20%; display:flex; align-items:center; justify-content:flex-end; gap:5px; ...">
  */
  div[style*="width:20%"][style*="display:flex"][style*="justify-content:flex-end"] {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important; /* aligne les boutons à droite */
    justify-content: flex-start !important;
    gap: 8px !important;
    margin-top: 0.5rem !important;
    order: 5 !important; /* On le place après les autres blocs */
  }

  /* Grille semaine => 1 colonne */
  .week-grid {
    grid-template-columns: 1fr !important;
  }
}

/* --------------------------------
   RECHERCHE & MODALES etc.
-------------------------------- */
#planning-search-results,
#lieu-search-results {
  position: absolute;
  background: #fff;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 999;
  top: calc(100% + 5px);
  left: 0;
  max-height: 200px;
  overflow-y: auto;
}

.planning-search-modal {
  position: absolute;
  background: #fff;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  border-radius: 6px;
  z-index: 999;
}

.activite-form-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 80%;
  max-width: 1200px;
  height: 100vh;
  background: #fff;
  z-index: 9999;
  transition: right 0.3s ease;
  overflow-y: auto;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
}

.activite-form-panel.open {
  right: 0;
}

.activite-form-content {
  margin: 2rem;
  position: relative;
}

#activite-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-row-double {
  display: flex;
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.creation-mode-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 5px;
}

#duplicate-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 999999;
  align-items: center;
  justify-content: center;
}

#duplicate-modal .modal-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  min-width: 300px;
  max-width: 450px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#duplicate-modal-cancel {
  position: absolute;
  right: 1rem;
  top: 1rem;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: #333;
}

#duplicate-modal-cancel:hover {
  opacity: 0.7;
}

#duplicate-modal .modal-content h3 {
  margin-top: 0;
}

#duplicate-modal .modal-content label {
  margin-bottom: 0.25rem;
  color: #444;
}

#duplicate-modal .modal-content input[type="date"],
#duplicate-modal .modal-content input[type="time"] {
  padding: 0.4rem;
  border: 2px solid #ccc;
  border-radius: 4px;
}

#duplicate-modal-confirm {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background-color: #85AB76;
  color: #fff;
  transition: background-co;
}

#close-panel {
  position: absolute;
  top: 20px;
  right: 20px;
}

.multiple-dates-field label {
  display: block;
  margin-bottom: 0.5rem;
}

.multiple-dates-field > div {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.loading-spinner {
  text-align: center;
  font-size: 1rem;
  color: var(--text-light);
  padding: 1rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.switch input:checked + .slider.round {
  background-color: var(--primary);
}

.switch input:checked + .slider.round:before {
  transform: translateX(26px);
}
