@charset "UTF-8";

/* ─── VARIABLES ─── */
:root {
  --dist-navy: #003087;
  --dist-orange: #F7941D;
  --dist-green: #28a745;
  --dist-blue: #0d6efd;
  --dist-red: #dc3545;
  --dist-purple: #6f42c1;
  --dist-orange-warn: #fd7e14;
  --dist-bg: #f4f6f9;
}

/* ─── KPI GRID ─── */
.dist-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.dist-kpi-section {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0,48,135,0.08);
  border-top: 4px solid var(--dist-navy);
}

.dist-kpi-section.agex { border-top-color: var(--dist-green); }
.dist-kpi-section.beneficiaire { border-top-color: var(--dist-blue); }

.dist-kpi-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-kpi-section-title i { font-size: 1rem; }

.dist-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.dist-kpi-item {
  text-align: center;
}

.dist-kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}

.dist-kpi-value.sync {
  font-size: 1.4rem;
  color: var(--dist-orange);
}



.dist-kpi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ─── GRAPHIQUES ─── */
.dist-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dist-chart-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0,48,135,0.06);
}

.dist-chart-card.full-width {
  grid-column: 1 / -1;
}

.dist-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.dist-chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

.dist-chart-canvas {
  position: relative;
  height: 280px;
}

/* ─── CARTE LEAFLET ─── */
.dist-map-container {
  height: 450px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.dist-map-popup img {
  max-width: 120px;
  max-height: 80px;
  border-radius: 6px;
  margin-top: 8px;
}

.dist-map-popup .popup-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dist-map-popup .popup-type.agex { background: #d4edda; color: #155724; }
.dist-map-popup .popup-type.beneficiaire { background: #cce5ff; color: #004085; }

/* ─── TOOLBAR ─── */
.dist-toolbar {
  background: var(--card);
  border-radius: 16px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 16px rgba(0,48,135,0.06);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.dist-search {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.dist-search input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  font-family: inherit;
}

.dist-search input:focus {
  outline: none;
  border-color: var(--dist-navy);
  box-shadow: 0 0 0 4px rgba(0,48,135,0.08);
}

.dist-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.dist-filters {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.dist-filters select {
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.dist-filters select:focus {
  outline: none;
  border-color: var(--dist-navy);
}

.dist-btn-dev {
  padding: 0.75rem 1.2rem;
  border: 2px solid var(--dist-navy);
  background: white;
  color: var(--dist-navy);
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dist-btn-dev:hover, .dist-btn-dev.active {
  background: var(--dist-navy);
  color: white;
}

.dist-btn-dev i { font-size: 0.8rem; }

/* ─── ONGLETS ─── */
.dist-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--card);
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,48,135,0.04);
}
.dist-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.dist-tab:hover { background: rgba(0,48,135,0.06); color: var(--navy); }
.dist-tab.active {
    background: var(--dist-navy);
    color: white;
    box-shadow: 0 2px 8px rgba(0,48,135,0.2);
}
.dist-tab i { font-size: 0.9rem; }


/* ─── TABLEAU ─── */
.dist-table-container {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0,48,135,0.06);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.dist-table-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dist-table-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

.dist-table-wrapper {
  overflow-x: auto;
}

.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.dist-table th {
  background: #f8f9fa;
  padding: 0.9rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #eee;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.dist-table th:hover {
  background: #e9ecef;
}

.dist-table th i.fa-sort { margin-left: 4px; opacity: 0.4; font-size: 0.65rem; }
.dist-table th.sorted i.fa-sort { opacity: 1; color: var(--dist-navy); }

.dist-table td {
  padding: 0.8rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.dist-table tr:hover {
  background: #f8f9fa;
}

.dist-table tr:last-child td {
  border-bottom: none;
}

/* ─── COLONNES SPÉCIFIQUES ─── */
.col-id { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem; }

.dist-badge-type {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dist-badge-type.agex { background: #d4edda; color: #155724; }
.dist-badge-type.beneficiaire { background: #cce5ff; color: #004085; }

.dist-badge-type::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.dist-badge-type.agex::before { background: var(--dist-green); }
.dist-badge-type.beneficiaire::before { background: var(--dist-blue); }
/* ─── COLONNE JOURS DE RETARD ─── */
.col-retard {
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}
.col-retard .badge-retard {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
}
.col-retard .badge-retard.negatif { background: #d4edda; color: #155724; }
.col-retard .badge-retard.zero { background: #fff3cd; color: #856404; }
.col-retard .badge-retard.positif { background: #f8d7da; color: #721c24; animation: pulse-retard 2s infinite; }
@keyframes pulse-retard {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
/* ─── CONTENEUR PRINCIPAL ─── */
.dist-main-container {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,48,135,0.06);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

/* ── DESIGN DES ONGLETS ─── */
.dist-tabs-nav {
    display: flex;
    background: #f8f9fa; /* Fond gris clair pour le bandeau */
    padding: 0.8rem 0.8rem 0;
    border-bottom: 2px solid #e9ecef; /* Ligne de séparation */
}

.dist-tab-btn {
    padding: 1rem 1.5rem;
    border: 1px solid transparent;
    background: transparent;
    border-bottom: none; /* Pas de bordure en bas */
    font-size: 0.95rem;
    font-weight: 600;
    color: #6c757d; /* Texte gris par défaut */
    cursor: pointer;
    border-radius: 10px 10px 0 0; /* Coins arrondis en haut */
    transition: all 0.2s;
    margin-bottom: -2px; /* Chevauche la ligne du bas pour fusionner */
    display: flex;
    align-items: center;
    gap: 8px;
}

.dist-tab-btn i { font-size: 1rem; }

.dist-tab-btn:hover {
    background: rgba(13, 110, 253, 0.05);
    color: var(--dist-blue);
}

/* Onglet actif : Bleu, Texte Blanc */
.dist-tab-btn.active {
    background: var(--dist-blue);
    color: white;
    box-shadow: 0 -4px 10px rgba(13, 110, 253, 0.15); /* Léger effet d'ombre vers le haut */
}

/* ─── COLONNE JOURS DE RETARD ─── */
.col-retard { 
    font-weight: 600; 
    text-align: center; 
    white-space: nowrap; 
}
.col-retard .badge-retard {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
}
.col-retard .badge-retard.negatif { background: #d4edda; color: #155724; }
.col-retard .badge-retard.zero { background: #fff3cd; color: #856404; }
.col-retard .badge-retard.positif { background: #f8d7da; color: #721c24; animation: pulse-retard 2s infinite; }

@keyframes pulse-retard {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}


/* Barre de progression */
.dist-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.dist-progress-bar {
  flex: 1;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}

.dist-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.dist-progress-fill.ok { background: var(--dist-green); }
.dist-progress-fill.attente { background: var(--dist-orange-warn); }
.dist-progress-fill.ecart { background: var(--dist-red); }
.dist-progress-fill.depassement { background: var(--dist-purple); }

.dist-progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}

/* Dates */
.dist-dates {
  line-height: 1.4;
}

.dist-dates .date-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dist-dates .date-value {
  font-size: 0.85rem;
}

.dist-dates .date-ecart {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 2px;
}

.dist-dates .date-ecart.retard { color: var(--dist-red); }
.dist-dates .date-ecart.avance { color: var(--dist-green); }

/* Statut */
.dist-badge-statut {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dist-badge-statut.complete { background: #d4edda; color: #155724; }
.dist-badge-statut.attente { background: #fff3cd; color: #856404; }
.dist-badge-statut.ecart { background: #f8d7da; color: #721c24; }

/* GPS */
.dist-gps-link {
  color: var(--dist-navy);
  font-size: 1.2rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.dist-gps-link:hover {
  background: rgba(0,48,135,0.08);
  transform: scale(1.1);
}

/* Photo */
.dist-photo-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.dist-photo-thumb:hover {
  border-color: var(--dist-navy);
  transform: scale(1.1);
}

.dist-photo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Description tooltip */
.dist-desc {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Colonnes dev */
.col-dev {
  display: none;
}

.dist-table.show-dev .col-dev {
  display: table-cell;
}

/* Activité tooltip */
.dist-activite {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

/* ─── MODALE PHOTO ─── */
.dist-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.dist-modal-overlay.active {
  display: flex;
}

.dist-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.dist-modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.dist-modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dist-modal-info {
  position: absolute;
  bottom: -40px;
  left: 0;
  color: white;
  font-size: 0.9rem;
}

/* ─── PAGINATION ─── */
.dist-pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
  gap: 1rem;
}

.dist-pagination {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.dist-pagination button {
  min-width: 36px;
  height: 36px;
  border: 1px solid #e9ecef;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.2s;
  padding: 0 0.6rem;
}

.dist-pagination button:hover:not(:disabled) {
  border-color: var(--dist-navy);
  color: var(--dist-navy);
}

.dist-pagination button.active {
  background: var(--dist-navy);
  border-color: var(--dist-navy);
  color: white;
  font-weight: 600;
}

.dist-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dist-limit-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dist-limit-selector select {
  padding: 0.4rem 1.8rem 0.4rem 0.6rem;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.85rem;
  background: white;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  cursor: pointer;
}

.dist-pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── SKELETON ─── */
.dist-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 6px;
  height: 16px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── EMPTY STATE ─── */
.dist-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.dist-empty i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
  .dist-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .dist-charts-grid { grid-template-columns: 1fr; }
  .dist-chart-card.full-width { grid-column: auto; }
  .dist-map-container { height: 350px; }
}

@media (max-width: 768px) {
  .dist-kpi-grid { grid-template-columns: 1fr; }
  .dist-kpi-row { grid-template-columns: 1fr; }
  .dist-toolbar { flex-direction: column; align-items: stretch; }
  .dist-search { min-width: auto; }
  .dist-table th, .dist-table td { padding: 0.6rem 0.5rem; font-size: 0.78rem; }
  .dist-progress { min-width: 100px; }
  .dist-photo-thumb, .dist-photo-placeholder { width: 32px; height: 32px; }
  .dist-pagination-bar { flex-direction: column; align-items: center; }
}

@media (max-width: 480px) {
  .dist-kpi-value { font-size: 1.3rem; }
  .dist-chart-canvas { height: 220px !important; }
  .dist-map-container { height: 300px; }
}

/* ─── DÉTAIL KPI (Tôles / Accessoires) ─── */
.dist-kpi-detail {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.3;
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-top: 4px;
    display: block;
}