/* ================================================================= */
/* 🎨 1. CONFIGURATION & VARIABLES                                   */
/* ================================================================= */
:root {
  --menu-width: 220px;
  --filter-width: 280px;
  --header-height: 64px;
  
  --primary: #2563eb;
  --bg-app: #f3f4f6;
  --text-main: #111827;
  --border-color: #e5e7eb;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

/* ================================================================= */
/* 🏗️ 2. LAYOUT DESKTOP (3 Colonnes : Menu | Filtres | Calendrier)   */
/* ================================================================= */
#calendar-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* --- COLONNE 1 : MENU --- */
#main-menu {
  width: var(--menu-width);
  background-color: #1e40af;
  color: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}
.menu-btn {
  display: block; width: 100%; padding: 10px; border-radius: 6px; margin-bottom: 4px; color: #dbeafe; transition: background 0.2s;
}
.menu-btn:hover { background-color: rgba(255,255,255,0.1); color: white; }
.menu-btn.active { background-color: rgba(0,0,0,0.2); color: white; font-weight: 600; border-left: 4px solid #60a5fa; }

/* --- COLONNE 2 : FILTRES --- */
#filters-sidebar {
  width: var(--filter-width);
  background-color: white;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}
/* Styles Filtres */
.sidebar-title { padding: 1.5rem; font-size: 1.25rem; font-weight: 700; border-bottom: 1px solid var(--border-color); margin: 0; }
.filter-group { border-bottom: 1px solid var(--border-color); }
.filter-header { padding: 0.8rem 1.2rem; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; }
.filter-header:hover { background-color: #f9fafb; }
.filter-body { padding: 0.5rem 1rem 1rem; }
.filter-group.collapsed .filter-body { display: none; }
.filter-group.collapsed .toggle-icon { transform: rotate(-90deg); }
.filter-pill { display: inline-flex; align-items: center; padding: 4px 8px; margin: 2px; border: 1px solid var(--border-color); border-radius: 12px; font-size: 0.75rem; cursor: pointer; background: white; }
.filter-pill.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-list-item { width: 100%; padding: 6px; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; }
.filter-list-item:hover { background: #f3f4f6; }
.filter-list-item.active { background: #eff6ff; font-weight: 600; }
.user-color-swatch { width: 12px; height: 12px; border-radius: 50%; }

/* --- COLONNE 3 : CALENDRIER --- */
#calendar-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: white;
  min-width: 0;
  position: relative;
}

#calendar-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background-color: white;
}

#calendar-container {
  flex-grow: 1;
  overflow-y: auto;
  background-color: white;
}

/* ================================================================= */
/* 📱 3. LAYOUT MOBILE (Responsive)                                  */
/* ================================================================= */

/* Header Mobile (Caché sur PC) */
#mobile-header {
  display: none; 
  height: 60px;
  background-color: #2563eb;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  color: white;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#mobile-menu-toggle { font-size: 1.5rem; background: none; border: none; color: white; }

/* Menu Mobile Déroulant */
#mobile-menu-dropdown {
  position: fixed; top: 60px; left: 0; right: 0;
  background-color: #1e40af; color: white; z-index: 49;
  box-shadow: 0 10px 15px rgba(0,0,0,0.3);
  padding-bottom: 1rem;
}
#mobile-menu-dropdown nav a {
  display: block; padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
#mobile-menu-dropdown nav a.active { background-color: rgba(0,0,0,0.2); font-weight: bold; border-left: 4px solid #60a5fa; }

/* --- MEDIA QUERY MOBILE (< 768px) --- */
@media (max-width: 768px) {
  #calendar-wrapper { flex-direction: column; height: auto; }
  
  /* Cacher les sidebars PC */
  #main-menu, #filters-sidebar { display: none !important; }
  
  /* Afficher Header Mobile */
  #mobile-header { display: flex; }
  
  /* Main prend toute la hauteur restante */
  #calendar-main { width: 100%; height: calc(100vh - 60px); }
  
  /* Header du calendrier : On garde la nav date mais on cache le reste */
  #calendar-header { 
    height: auto; 
    padding: 0.5rem; 
    justify-content: center;
    flex-wrap: wrap;
  }
  
  /* Cacher le sélecteur de vues (Mois/Semaine/Jour) sur mobile car on force Planning */
  .view-switcher { display: none !important; }
  
  /* Cacher le bouton planifier Desktop */
  #quick-task-btn { display: none !important; }

  /* Navigation dates centrée */
  .header-nav { width: 100%; justify-content: center; margin-bottom: 0; }
  #current-period-display { font-size: 1rem; }
  
  /* Padding réduit pour le planning */
  .planning-modern { padding: 0.5rem !important; }
  #desktop-add-task-btn { display: none !important; }
  .hidden-on-mobile { display: none !important; }
}

/* ================================================================= */
/* 📅 4. STYLES ÉVÉNEMENTS (Desktop & Mobile)                        */
/* ================================================================= */

/* --- VUE MOIS (Desktop) --- */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid #e5e7eb; }
.day-header { padding: 8px; text-align: center; background: #f9fafb; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; font-weight: 600; }
.day-cell { min-height: 100px; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 2px; }
.day-cell.today { background-color: #eff6ff; }
.day-number { text-align: right; padding-right: 4px; font-size: 0.75rem; color: #6b7280; }

/* --- TUILE ÉVÉNEMENT (LA CORRECTION COULEUR EST ICI) --- */
.event-item {
  /* Récupère la variable JS --user-color */
  border-left: 4px solid var(--user-color, #3b82f6);
  /* Crée un fond pastel automatiquement */
  background-color: color-mix(in srgb, var(--user-color, #3b82f6), white 85%);
  
  color: #1f2937; /* Texte gris foncé pour lisibilité */
  font-weight: 500;
  padding: 2px 4px;
  margin-bottom: 2px;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border-top: 1px solid rgba(0,0,0,0.05);
  border-right: 1px solid rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.event-item:hover { 
  transform: scale(1.02); 
  z-index: 10; 
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  background-color: color-mix(in srgb, var(--user-color, #3b82f6), white 75%);
}

/* --- VUE SEMAINE/JOUR (Desktop) --- */
.time-grid-view { display: flex; flex-direction: column; height: 100%; }
.time-grid-header { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; flex-shrink: 0; }
.time-grid-body { display: flex; flex: 1; overflow-y: auto; position: relative; }
.hour-column { width: 50px; border-right: 1px solid #e5e7eb; flex-shrink: 0; }
.hour-cell { height: 60px; border-bottom: 1px solid #f9fafb; text-align: right; padding-right: 4px; font-size: 0.7rem; color: #9ca3af; }
.day-column { flex: 1; border-right: 1px solid #f9fafb; position: relative; min-width: 100px; }
.day-column-header { flex: 1; text-align: center; padding: 8px; font-weight: 600; border-right: 1px solid #e5e7eb; }

.time-event {
  position: absolute; left: 2px; right: 2px;
  border-left: 4px solid var(--user-color, #3b82f6);
  background-color: color-mix(in srgb, var(--user-color, #3b82f6), white 85%);
  color: #1f2937;
  padding: 2px; font-size: 0.7rem; border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer; z-index: 1; overflow: hidden;
}
.time-event:hover { z-index: 20; height: auto !important; min-height: 50px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }

/* --- VUE PLANNING (Mobile & Desktop) --- */
.planning-modern { padding: 2rem; max-width: 900px; margin: 0 auto; }
.planning-day-title { font-size: 1rem; font-weight: 700; border-bottom: 2px solid #e5e7eb; margin-bottom: 0.8rem; padding-top: 1rem; position: sticky; top: 0; background: white; z-index: 5; text-transform: capitalize; }
.planning-card { background: white; border-radius: 8px; padding: 1rem; margin-bottom: 0.8rem; border-left: 5px solid #ccc; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: pointer; }
.planning-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.planning-time { font-family: monospace; font-weight: 600; color: #6b7280; }
.planning-title { font-weight: 600; color: #111827; font-size: 1rem; }
.planning-status-badge { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; color: white; margin-left: 6px; }

/* Statut En Retard */
.status-en-retard { background-color: #fef2f2 !important; border-left-color: #ef4444 !important; }
.event-item.status-en-retard { border-left-color: #ef4444; background-color: #fef2f2; color: #b91c1c; }

/* ================================================================= */
/* 🛠️ NAVIGATION & FAB                                               */
/* ================================================================= */
.header-nav button { padding: 4px 8px; border: 1px solid #e5e7eb; border-radius: 4px; background: white; cursor: pointer; }
.view-switcher { display: flex; gap: 4px; }
.view-btn { padding: 4px 10px; border: none; background: #f3f4f6; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.view-btn.active { background: var(--primary); color: white; }

.fab-mobile {
  position: fixed; bottom: 20px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  font-size: 28px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4); z-index: 50; cursor: pointer;
}
.fab-mobile:active { transform: scale(0.95); }

/* ================================================================= */
/* 🚑 GESTION OVERLAYS & MODALES                                     */
/* ================================================================= */

/* Z-Index très élevé pour passer au-dessus des sidebars */
#taches-overlay, #event-overlay, .overlay-container { z-index: 9999 !important; }

/* Masquage fort */
.overlay-hidden { display: none !important; opacity: 0; pointer-events: none; }

/* Affichage fort */
#event-overlay:not(.hidden), #taches-overlay:not(.hidden) {
    display: flex !important; opacity: 1; pointer-events: auto;
}
#event-overlay-content {
  max-height: 90vh;
  height: 90vh;
  display: flex;
  flex-direction: column;
}
#event-overlay-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* CRUCIAL en flex */
}

/* Autocomplétion */
#taches-suggestions { z-index: 10000; border: 1px solid #d1d5db; max-height: 150px; overflow-y: auto; background: white; }
#taches-suggestions li { padding: 8px; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
#taches-suggestions li:hover { background: #eff6ff; }

/* Loader */
.loader { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #6b7280; font-weight: 500; }
/* ================================================================= */
/* 📸 STYLE GALERIE (Avant/Après) - Optimisé Desktop & Mobile        */
/* ================================================================= */

.gallery-group {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background-color: #f9fafb;
}

.gallery-group h4 {
  font-weight: 700;
  font-size: 1rem;
  color: #1f2937;
  margin-bottom: 1rem;
  text-align: center; /* Titre centré */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Conteneur des deux photos */
.gallery-pair {
  display: flex;       /* Active Flexbox */
  flex-direction: row; /* Force l'alignement horizontal (gauche/droite) */
  gap: 1.5rem;         /* Espace entre les deux photos */
  align-items: flex-start;
}

/* Bloc individuel (Avant ou Après) */
.gallery-photo {
  flex: 1;             /* Force les deux blocs à avoir la même largeur (50%/50%) */
  min-width: 0;        /* Important pour que l'image ne casse pas le flex */
  background: white;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

/* Label "AVANT" / "APRÈS" */
.gallery-photo p {
  font-size: 0.75rem;
  font-weight: 800;
  color: #6b7280;
  margin-bottom: 0.5rem;
  text-align: center;
  text-transform: uppercase;
}

/* L'image elle-même */
.gallery-photo img {
  width: 100%;
  height: 250px;       /* Hauteur FIXE pour aligner parfaitement gauche/droite */
  object-fit: cover;   /* Recadre l'image sans la déformer (zoom central) */
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gallery-photo img:hover {
  transform: scale(1.02);
}

/* Zone grise si photo manquante */
.photo-missing {
  width: 100%;
  height: 250px;       /* Même hauteur que l'image pour garder l'alignement */
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f3f4f6;
  border: 2px dashed #d1d5db;
  border-radius: 4px;
  color: #9ca3af;
  font-size: 0.85rem;
  font-style: italic;
}

/* --- RESPONSIVE MOBILE --- */
/* Sur petit écran, on empile les photos l'une sous l'autre */
@media (max-width: 640px) {
  .gallery-pair {
    flex-direction: column; /* Empilement vertical */
    gap: 1rem;
  }
  
  .gallery-photo img, 
  .photo-missing {
    height: 200px; /* Un peu moins haut sur mobile */
  }
}



.time-grid-body {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
}

.days-wrapper {
  display: flex;
  flex: 1;
  min-width: 0;
}

.day-column {
  flex: 1;
  min-width: 140px; /* largeur mini par jour */
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.day-grid {
  position: relative;
  height: calc(20 * 60px); /* 4h → 22h */
}

.untimed-section {
  border-top: 1px dashed #e5e7eb;
  padding: 6px;
  background: #fafafa;
  font-size: 0.7rem;
}
.untimed-event {
  position: relative;      /* plus absolute */
  margin-bottom: 6px;
  height: auto !important;
  min-height: 44px;
  cursor: pointer;
}



#connection-status-indicator {
      transition: background-color 0.3s ease-in-out;
    }
    .offline-pulse {
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0%, 100% {
        opacity: 1;
      }
      50% {
        opacity: 0.7;
      }
    }

    /* ========================================================= */
/* 📱 FIX SCROLL MODALE MOBILE                               */
/* ========================================================= */



