/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #1F4E79;
  --blue-mid:    #2E75B6;
  --blue-light:  #D6E4F0;
  --blue-pale:   #EEF4FA;
  --accent:      #00B0F0;
  --green:       #375623;
  --bg:          #F4F6F9;
  --card:        #FFFFFF;
  --cardfond:    #D6E4F0;
  --border:      #DDE3EC;
  --text:        #1A1A2E;
  --text-muted:  #6B7280;
  --sidebar-w:   300px;
  --header-h:    56px;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(31,78,121,.10);
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--blue);
  color: #fff;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-inner {
  display: flex; align-items: center; gap: 16px;
  height: 100%; padding: 0 24px;
}
.header-title { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.header-count {
  margin-left: auto;
  font-size: 13px; opacity: .85;
  background: rgba(255,255,255,.15);
  padding: 4px 12px; border-radius: 20px;
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: calc(100dvh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  flex-shrink: 0;
}
.sidebar-inner { padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 4px; padding-bottom: 120px;}

.filter-section { margin-bottom: 16px; }
.filter-section h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--blue); margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 2px solid var(--blue-light);
}
.filter-section label {
  display: block; font-size: 12px; color: var(--text-muted);
  margin-bottom: 4px; margin-top: 8px;
}
.filter-section input[type="text"],
.filter-section input[type="number"],
.filter-section select {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--bg);
  transition: border-color .2s;
}
.filter-section input:focus,
.filter-section select:focus {
  outline: none; border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}
/* Multi-select pour ville */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

#villeSuggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 99999;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 220px;
  overflow-y: auto;
}
/* Multi-select list */
.multi-wrapper {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); max-height: 160px; overflow-y: auto;
}
.multi-list { padding: 4px 0; }
.multi-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; cursor: pointer;
  transition: background .15s;
  font-size: 13px;
}
.multi-item:hover { background: var(--blue-pale); }
.multi-item input[type="checkbox"] { accent-color: var(--blue-mid); }

.btn-row { display: flex; gap: 6px; margin-top: 6px; }
.btn-sm {
  flex: 1; padding: 5px 8px;
  font-size: 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--card);
  cursor: pointer; transition: background .15s;
}
.btn-sm:hover { background: var(--blue-pale); border-color: var(--blue-mid); }

.btn-apply {
  width: 50%; padding: 9px;
  background: var(--blue-mid); color: #fff;
  border: none; border-radius: 8px;
  font-size: 11px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
  transition: background .2s, transform .1s;
}
.btn-apply:hover  { background: var(--blue); }
.btn-apply:active { transform: scale(.98); }

.btn-deconnect {
  width: 50%; padding: 9px;
  background: var(--blue-mid); color: #fff;
  border: none; border-radius: 8px;
  font-size: 11px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
  transition: background .2s, transform .1s;
}
.btn-deconnect:hover  { background: var(--blue); }
.btn-deconnect:active { transform: scale(.98); }



.btn-secondary {
  width: 50%; padding: 9px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 11px; cursor: pointer; margin-top: 6px;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-tableau {
  padding: 10px 14px;
  background: var(--blue-mid);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
  flex: 1;
  min-width: 180px;
}
.btn-tableau:hover  { background: var(--blue); }
.btn-tableau:active { transform: scale(.98); }

/* ── MAIN CONTENT ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1; padding: 20px 24px 40px;
  display: flex; flex-direction: column; gap: 20px;
  overflow-x: hidden;
}

/* Stats bar */
.stats-bar { display: flex; gap: 1px; }
.stat-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 7px;

  display: flex;
  align-items: center;
  gap: 8px;

  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.conteneurs {
  background: var(--cardfond);
  border: 5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 10px;
}
/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: var(--blue-pale);
  border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--blue);
}

/* Map */
.map-container {
  width: 100%;
  overflow: hidden;
}

.map-container iframe {
  width: 100%;
  height: 65vh;
  min-height: 320px;
  border: none;
  display: block;
}


.loading-badge {
  margin-left: auto; font-size: 12px; font-weight: 400;
  background: var(--blue-mid); color: #fff;
  padding: 3px 10px; border-radius: 20px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* Table */
.table-search {
  margin-left: auto; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; width: 220px;
}
.table-wrapper { overflow-x: auto; max-height: 420px; overflow-y: auto; }
table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 10px;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}
th {
  background: var(--blue); color: #fff;
  padding: 10px 14px; text-align: left;
  font-weight: 600; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background .15s;
}
th:hover { background: var(--blue-mid); }
td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:nth-child(even) td { background: var(--blue-pale); }
tr:hover td { background: var(--blue-light); }

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
td[contenteditable="true"] {

  background: #fffef5;
  transition: background 0.2s;

}

td[contenteditable="true"]:focus {

  outline: 2px solid #4a90e2;
  background: white;

}

.save-status {

  width: 30px;
  text-align: center;
  font-size: 14px;

}
/* Email link in table */
td a { color: var(--blue-mid); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-mid); }


/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */

/* Bouton menu mobile */
.menu-toggle {
  display: none;
  border: none;
  background: transparent;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

/* Desktop large */
@media (max-width: 1200px) {

  .btn-tableau {
    width: auto;
    padding: 8px 12px;
  }

  .table-search {
    width: 180px;
  }

}

@media (max-width: 992px) {

  body {
    font-size: 13px;
  }

  .menu-toggle {
    display: block;
  }

  .header-inner {
    padding: 0 12px;
    gap: 10px;
  }

  .header-title {
    font-size: 15px;
  }

  .header-count {
    display: none;
  }

  .layout {
    display: block;
  }

  /* SIDEBAR MOBILE */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: -100%;
    width: 85%;
    max-width: 320px;
    min-width: unset;
    height: calc(100dvh - var(--header-h));
    background: var(--card);
    z-index: 999;
    transition: left .3s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,.2);
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-inner {
    padding-bottom: 120px;
  }

  .main-content {
    width: 100%;
    padding: 12px;
    gap: 14px;
  }

  .card-header {
    padding: 12px;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .stat-card {
    width: 100%;
    min-width: unset;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-apply,
  .btn-secondary,
  .btn-tableau,
  .btn-sm {
    width: 100%;
    min-height: 42px;
    touch-action: manipulation;
  }

  .table-search {
    width: 100%;
    margin-left: 0;
    margin-top: 10px;
  }

  .table-wrapper {
    overflow-x: auto;
  }

  table {
    min-width: 900px;
  }

  th,
  td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .map-container iframe {
    height: 45vh;
    min-height: 280px;
    border-radius: 0 0 var(--radius) var(--radius);
  }

}
/* Très petits mobiles */
@media (max-width: 480px) {

  .header-title {
    font-size: 14px;
  }

  .filter-section h3 {
    font-size: 11px;
  }

  .multi-item {
    font-size: 12px;
  }

  .stat-value {
    font-size: 14px;
  }

  .stat-label {
    font-size: 11px;
  }

  .card {
    border-radius: 8px;
  }

}
.card,
.stat-card,
.sidebar,
.conteneurs {
  will-change: transform;
}
button {
  -webkit-tap-highlight-color: transparent;
}

input,
select,
button,
textarea {
  font: inherit;
}

html {
  -webkit-text-size-adjust: 100%;
}