/* Mise en page générale --------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  color: #1a2330;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

header {
  background: #2c3e50;
  color: #fff;
  padding: 12px 24px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

header h1 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  font-weight: 600;
}

/* Bandeau de session (titre + identité + déconnexion) -------------------- */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: #bcd;
}

.session-user {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 12px;
}

.session-logout {
  color: #ffd166;
  text-decoration: none;
  font-weight: 600;
}

.session-logout:hover {
  text-decoration: underline;
}

/* Bascule de langue FR / ES ------------------------------------------------ */
.lang-switcher {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #bcd;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.lang-btn.active {
  background: #ffd166;
  color: #1a2330;
}

/* Barre de contrôles ------------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #bcd;
  gap: 4px;
}

.controls select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #4a5d70;
  background: #fff;
  color: #1a2330;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 180px;
}

.status {
  align-self: end;
  font-size: 0.85rem;
  color: #ffd166;
  margin-bottom: 6px;
}

/* Zone principale : carte + panneau --------------------------------------- */
main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#map-container {
  flex: 1;
  position: relative;
  background: #eaf1f7;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pays --------------------------------------------------------------------- */
.country {
  stroke: #ffffff;
  stroke-width: 0.4px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.country.no-data {
  fill: #d0d6de;
}

.country:hover {
  stroke: #1a2330;
  stroke-width: 1.2px;
  opacity: 0.85;
}

.country.selected {
  stroke: #c0392b;
  stroke-width: 2px;
}

/* Infobulle --------------------------------------------------------------- */
#tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(26, 35, 48, 0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

#tooltip .tooltip-name {
  font-weight: 600;
  display: block;
}

#tooltip .tooltip-value {
  color: #ffd166;
}

.hidden {
  display: none !important;
}

/* Légende ----------------------------------------------------------------- */
#legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 0.8rem;
}

#legend .legend-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #2c3e50;
}

#legend .legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

#legend .legend-swatch {
  width: 18px;
  height: 12px;
  border: 1px solid #999;
}

/* Panneau de détail ------------------------------------------------------- */
#detail-panel {
  width: 320px;
  background: #fff;
  border-left: 1px solid #d0d6de;
  padding: 24px 20px;
  position: relative;
  overflow-y: auto;
}

#detail-panel h2 {
  margin: 0 0 16px 0;
  font-size: 1.3rem;
  color: #2c3e50;
}

#detail-panel .panel-row {
  margin: 8px 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

#detail-panel .panel-row .label {
  color: #6c7a89;
  font-weight: 600;
  margin-right: 4px;
}

#detail-panel a {
  display: inline-block;
  margin-top: 16px;
  color: #2980b9;
  text-decoration: none;
  font-weight: 600;
}

#detail-panel a:hover {
  text-decoration: underline;
}

.close-panel {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #6c7a89;
  line-height: 1;
  padding: 4px 10px;
}

.close-panel:hover {
  color: #c0392b;
}

/* Sélecteur de mode (Indicateurs / Projets) ------------------------------- */
.mode-selector {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px 0;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: 8px;
  width: fit-content;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: #bcd;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.mode-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mode-option input[type="radio"] {
  display: none;
}

.mode-option:has(input:checked) {
  background: #ffd166;
  color: #1a2330;
  font-weight: 600;
}

/* Filtres mode projets ---------------------------------------------------- */
.controls-projects label input,
.controls-projects label select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #4a5d70;
  background: #fff;
  color: #1a2330;
  font-size: 0.9rem;
}

.controls-projects label input[type="number"] {
  width: 110px;
}

.btn-apply {
  align-self: flex-end;
  background: #ffd166;
  color: #1a2330;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 1px;
}

.btn-apply:hover {
  background: #ffc233;
}

/* Overlay de chargement (mode projets, pendant le décompte paginé) -------- */
.loading-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.96);
  color: #2c3e50;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 50;
}

.loading-overlay-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d0d6de;
  border-top-color: #2c3e50;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

/* Note "En préparation" --------------------------------------------------- */
.pipeline-note {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.94);
  padding: 8px 12px;
  border-left: 3px solid #ffd166;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #2c3e50;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 8;
}

.pipeline-note code {
  background: #f4f6f8;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.85em;
}

/* Panneau liste projets --------------------------------------------------- */
#projects-list-panel,
#project-detail-panel {
  width: 380px;
  background: #fff;
  border-left: 1px solid #d0d6de;
  padding: 24px 20px;
  position: relative;
  overflow-y: auto;
}

#projects-list-panel h2,
#project-detail-panel h2 {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
  color: #2c3e50;
  padding-right: 32px;
}

.projects-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-item {
  padding: 10px 12px;
  border: 1px solid #e1e5ea;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.project-item:hover {
  background: #f4f6f8;
  border-color: #2980b9;
}

.project-item-title {
  font-weight: 600;
  color: #1a2330;
  font-size: 0.95rem;
  margin-bottom: 6px;
  line-height: 1.3;
}

.project-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: #6c7a89;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ecf0f1;
  color: #34495e;
}

.badge-active   { background: #d4edda; color: #155724; }
.badge-closed   { background: #e2e3e5; color: #383d41; }
.badge-pipeline { background: #fff3cd; color: #856404; }
.badge-dropped  { background: #f8d7da; color: #721c24; }

/* Panneau détail projet --------------------------------------------------- */
.back-link {
  background: none;
  border: none;
  color: #2980b9;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.back-link:hover {
  text-decoration: underline;
}

.project-abstract {
  margin: 12px 0;
  padding: 10px 12px;
  background: #f4f6f8;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #34495e;
  max-height: 240px;
  overflow-y: auto;
}

#project-detail-panel a#project-link {
  display: inline-block;
  margin: 10px 0 16px 0;
  color: #2980b9;
  text-decoration: none;
  font-weight: 600;
}

.documents-title {
  margin: 18px 0 10px 0;
  font-size: 1rem;
  color: #2c3e50;
  border-top: 1px solid #e1e5ea;
  padding-top: 14px;
}

.project-documents {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.document-item {
  padding: 10px 12px;
  border: 1px solid #e1e5ea;
  border-radius: 6px;
  font-size: 0.85rem;
}

.document-item.document-highlight {
  border-color: #ffd166;
  background: #fffbe6;
}

.document-title {
  font-weight: 600;
  color: #1a2330;
  margin-bottom: 4px;
  line-height: 1.3;
}

.document-meta {
  color: #6c7a89;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.document-link {
  color: #2980b9;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.document-link:hover {
  text-decoration: underline;
}

/* Helpers ----------------------------------------------------------------- */
.muted {
  color: #95a5a6;
  font-size: 0.9rem;
  font-style: italic;
}

.error {
  color: #c0392b;
  font-size: 0.85rem;
}

/* Page de login ----------------------------------------------------------- */
/* Le body bascule en flex CENTRÉ (override de body { flex-direction: column }). */
body.login-page {
  background: linear-gradient(135deg, #2c3e50 0%, #3a6073 100%);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* Carte de login : <main class="login-card">.
   Important : on annule explicitement les règles du sélecteur `main`
   (flex:1, display:flex row, overflow:hidden) qui sinon étiraient la carte
   à toute la hauteur et mettaient les enfants côte à côte. */
.login-card {
  flex: 0 0 auto;                /* override `main { flex: 1 }` */
  display: flex;                 /* on garde flex pour empiler proprement */
  flex-direction: column;        /* enfants empilés verticalement */
  align-items: center;           /* enfants centrés horizontalement */
  overflow: visible;             /* override `main { overflow: hidden }` */
  position: relative;

  width: 100%;
  max-width: 400px;
  height: auto;                  /* hauteur dictée par le contenu */
  padding: 40px 36px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-card h1 {
  margin: 0 0 8px 0;
  font-size: 1.5rem;
  color: #2c3e50;
}

.login-subtitle {
  color: #6c7a89;
  font-size: 0.95rem;
  margin: 0 0 28px 0;
  line-height: 1.5;
}

.login-error {
  width: 100%;
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin: 0 0 20px 0;
}

/* Bouton GitHub : inline-flex (icône + texte sur une ligne), hauteur
   dictée par le padding, jamais étiré verticalement. */
.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;                   /* plein largeur de la carte */
  min-height: 44px;
  padding: 0 22px;
  background: #24292f;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;                /* évite que line-height gonfle la hauteur */
  transition: background 0.15s;
  box-sizing: border-box;
}

.login-button:hover {
  background: #000;
}

.login-button-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;                /* l'icône ne se compresse pas */
}

.login-button-secondary {
  background: #2980b9;
}

.login-button-secondary:hover {
  background: #1f6391;
}

.login-footer {
  margin: 28px 0 0 0;
  font-size: 0.8rem;
  color: #95a5a6;
}
