/* ================================================================
   WeFiiT Map — Feuille de style principale
   ================================================================ */

/* --- Variables & reset ------------------------------------------ */
:root {
  --bleu:         #1B3C6F;   /* Couleur principale WeFiiT */
  --bleu-clair:   #2563EB;
  --surface:      #FFFFFF;
  --fond:         #F8FAFC;
  --bordure:      #E2E8F0;
  --texte:        #1E293B;
  --texte-muted:  #64748B;
  --shadow:       0 4px 24px rgba(0, 0, 0, 0.10);

  --h-filtres:    56px;
  --w-panel:      360px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--texte);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Barre de filtres ------------------------------------------- */
#filter-bar {
  flex-shrink: 0;
  background: var(--bleu);
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

#filter-bar-row1 {
  height: var(--h-filtres);
  display: flex;
  align-items: center;
  gap: 20px;
}

#filter-bar-row2 {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
#filter-bar-row2::-webkit-scrollbar { display: none; }

.logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filter-label {
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  white-space: nowrap;
}

#filter-roles, #filter-secteurs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
#filter-roles::-webkit-scrollbar,
#filter-secteurs::-webkit-scrollbar { display: none; }

#role-buttons {
  display: flex;
  gap: 6px;
}

.role-btn {
  padding: 4px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.role-btn:hover,
.role-btn.active {
  background: #fff;
  color: var(--bleu);
  border-color: #fff;
}

/* --- Barre de recherche ----------------------------------------- */
#filter-search {
  flex-shrink: 0;
}

#search-input {
  height: 32px;
  padding: 0 12px 0 32px;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  color: #fff;
  font-size: 13px;
  width: 200px;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
#search-input::placeholder { color: rgba(255, 255, 255, 0.5); }
#search-input:focus {
  border-color: rgba(255, 255, 255, 0.7);
  background-color: rgba(255, 255, 255, 0.18);
}
/* Masquer le bouton "X" natif du navigateur sur search */
#search-input::-webkit-search-cancel-button { display: none; }

#filter-stats {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  white-space: nowrap;
}

/* --- Zone principale (carte + panel) ---------------------------- */
#main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* --- Carte Leaflet ---------------------------------------------- */
#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* --- Panel latéral --------------------------------------------- */
#side-panel {
  width: var(--w-panel);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--bordure);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
}
#side-panel.hidden { display: none; }

#panel-close {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px 0 0;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bordure);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--texte-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
#panel-close:hover { background: #CBD5E1; }

#panel-company {
  padding: 16px 20px 16px;
  border-bottom: 1px solid var(--bordure);
  clear: both;
}

#panel-company-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

#panel-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--bordure);
  padding: 4px;
  flex-shrink: 0;
  background: #fff;
}

#panel-company-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

#panel-company-address {
  font-size: 13px;
  color: var(--texte-muted);
}

#panel-consultants {
  padding: 16px 20px;
  flex: 1;
}

#panel-consultants-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--texte-muted);
  margin-bottom: 12px;
}

#panel-consultants-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.consultant-item {
  border-radius: 10px;
  border: 1px solid var(--bordure);
  background: var(--fond);
  overflow: hidden;
  transition: border-color 0.15s;
}

.consultant-item.consultant-expandable { cursor: pointer; }
.consultant-item.consultant-expandable:hover { border-color: var(--bleu-clair); }

.consultant-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.consultant-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.consultant-chevron {
  font-size: 18px;
  color: var(--texte-muted);
  transition: transform 0.2s ease;
}
.consultant-item.expanded .consultant-chevron {
  transform: rotate(90deg);
}

.btn-teams-dm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(91, 94, 166, 0.12);
  color: #5B5EA6;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.btn-teams-dm:hover {
  background: #5B5EA6;
  color: #fff;
  transform: scale(1.1);
}

.consultant-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.consultant-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.consultant-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bleu);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.consultant-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.consultant-nom {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.consultant-role {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  width: fit-content;
}

.consultant-depuis {
  font-size: 11px;
  color: var(--texte-muted);
}

.consultant-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.consultant-detail {
  font-size: 11px;
  color: var(--texte-muted);
}

a.consultant-link {
  color: var(--bleu-clair);
  text-decoration: none;
}
a.consultant-link:hover { text-decoration: underline; }

.consultant-empty {
  color: var(--texte-muted);
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
}

/* --- Détails mission (expand) ----------------------------------- */
.mission-details-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.consultant-item.expanded .mission-details-wrapper {
  grid-template-rows: 1fr;
}
.mission-details-inner {
  overflow: hidden;
}

.mission-details {
  padding: 0 12px 12px;
  border-top: 1px solid var(--bordure);
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mission-titre {
  font-size: 13px;
  font-weight: 600;
  color: var(--texte);
  padding-top: 10px;
  line-height: 1.4;
}

.mission-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mission-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--bleu-clair);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.mission-tag-type {
  background: rgba(27, 60, 111, 0.12);
  color: var(--bleu);
  border-color: rgba(27, 60, 111, 0.2);
  font-weight: 600;
}

.mission-tag-secteur {
  background: rgba(234, 88, 12, 0.1);
  color: #EA580C;
  border-color: rgba(234, 88, 12, 0.2);
}

.mission-tag-produit {
  background: rgba(22, 163, 74, 0.1);
  color: #16A34A;
  border-color: rgba(22, 163, 74, 0.2);
}

.mission-perimetre {
  font-size: 12px;
  color: var(--texte);
  line-height: 1.5;
}

.mission-contexte {
  font-size: 12px;
  color: var(--texte-muted);
  line-height: 1.5;
}

.mission-outils {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mission-outil {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--bordure);
  color: var(--texte-muted);
}

.mission-teams-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #5B5EA6;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  width: fit-content;
  transition: background 0.15s, transform 0.15s;
}
.mission-teams-btn:hover {
  background: #4a4d8f;
  transform: translateY(-1px);
}

/* --- Marqueurs personnalisés MapLibre GL ------------------------ */

/* Neutraliser le wrapper injecté par MapLibre */
.maplibregl-marker { cursor: pointer; }

.custom-marker {
  background: none;
  border: none;
}

.marker-container {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--bleu);
  /* Halo lumineux pour ressortir sur fond sombre */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.marker-container:hover {
  transform: scale(1.15) translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(255,255,255,0.25);
}
.marker-container.marker-empty {
  opacity: 0.4;
  border-color: #94A3B8;
}

.marker-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* L'image se superpose à l'initiale sans bloquer les clics */
.marker-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  background: white;
}

.marker-initials {
  font-size: 17px;
  font-weight: 700;
  color: var(--bleu);
}

.marker-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--bleu-clair);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* --- Légende ---------------------------------------------------- */
#legend {
  position: absolute;
  bottom: 24px;
  left: 12px;
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 500;
  pointer-events: none;
}

.legend-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--texte-muted);
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 2px 0;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Overlay de chargement (uniquement pendant le fetch Notion) - */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 9999;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bordure);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: rotation 0.75s linear infinite;
}

@keyframes rotation {
  to { transform: rotate(360deg); }
}

#loading-overlay p {
  font-size: 14px;
  color: var(--texte-muted);
}

#loading-hint {
  font-size: 13px;
  color: var(--texte-muted);
  text-align: center;
  max-width: 360px;
  line-height: 1.5;
}

/* Panel avec animation d'entrée */
#side-panel:not(.hidden) {
  animation: slideIn 0.2s ease-out;
}

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

/* Légende avec meilleur contraste */
#legend {
  backdrop-filter: blur(4px);
  background: rgba(255, 255, 255, 0.95);
}

/* --- Contrôles carte (recentrer + mode) ------------------------- */
#map-controls {
  position: absolute;
  bottom: 24px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
}

#map-controls button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--texte);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.15s;
  backdrop-filter: blur(4px);
}
#map-controls button:hover {
  background: #fff;
  transform: scale(1.08);
}

