/* Rapports Igeo — styles de la page (thème clair/sombre par variables). */
*, *::before, *::after { box-sizing: border-box; }
button, input { font: inherit; color: inherit; }
img { display: block; }

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #1f6a86;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn-bg: #fffaeb;
  --warn-text: #93370d;
  /* En-tête du tableau : bleu pétrole du rapport Securysat EC04 */
  --table-head-bg: #1f6a86;
  --table-head-text: #ffffff;
  --row-alt: #f8fafc;
  --row-open: #e8f2f6;
  /* Variables lues par js/ui/dropdown.js */
  --notion-bg: #ffffff;
  --notion-surface: #ffffff;
  --notion-surface-hover: #f1f5f9;
  --notion-border: #e2e8f0;
  --notion-text: #0f172a;
  --notion-text-muted: #64748b;
  --notion-accent: #1f6a86;
  --notion-tag-blue-bg: rgba(31, 106, 134, 0.12);
}
html.dark {
  color-scheme: dark;
  --bg: #111315;
  --surface: #1a1d20;
  --surface-2: #202427;
  --surface-hover: #262a2e;
  --border: #2e3338;
  --text: #e6e6e6;
  --text-muted: #9ba3ab;
  --accent: #4aa3c3;
  --accent-text: #0b1418;
  --danger: #ff8a7a;
  --danger-bg: rgba(255, 115, 105, 0.12);
  --warn-bg: rgba(235, 196, 70, 0.12);
  --warn-text: #f1c742;
  --table-head-bg: #1f6a86;
  --row-alt: #1e2124;
  --row-open: #1d3540;
  --notion-bg: #191919;
  --notion-surface: #202020;
  --notion-surface-hover: #262626;
  --notion-border: #2e3338;
  --notion-text: #e6e6e6;
  --notion-text-muted: #9b9a97;
  --notion-accent: #58a6ff;
  --notion-tag-blue-bg: rgba(82, 156, 202, 0.18);
}
html, body { height: 100%; }
body.eco-page {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
}
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}
@keyframes scaleUp { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

.eco-shell { display: flex; flex-direction: column; height: 100%; }
.eco-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.eco-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.eco-topbar img { height: 28px; }
.eco-topbar .eco-title { font-weight: 700; font-size: 15px; }
.eco-topbar .eco-sub { color: var(--text-muted); font-size: 12px; }
.eco-topbar .eco-spacer { flex: 1; }
.eco-user { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; }

.eco-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.eco-btn:hover { background: var(--surface-hover); }
.eco-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.eco-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.eco-btn.primary:hover { filter: brightness(1.08); }
.eco-btn.ghost { border-color: transparent; background: transparent; }

.notion-modal-dropdown-trigger.eco-trigger {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  background: var(--notion-surface, #fff); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--text); max-width: 100%;
}
.eco-trigger .eco-trigger-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-trigger .ms { font-size: 16px; color: var(--text-muted); }

.eco-input {
  height: 32px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 12px; min-width: 0;
}
.eco-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ── Connexion ── */
.eco-login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.eco-login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
}
.eco-login-card img { height: 40px; align-self: flex-start; }
.eco-login-card h1 { font-size: 20px; font-weight: 700; margin: 0; }
.eco-small { font-size: 12px; }
.eco-login-card p { margin: 0; color: var(--text-muted); line-height: 1.5; }
.eco-login-card .eco-btn.primary { height: 40px; justify-content: center; font-size: 13px; }
.eco-login-card details summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.eco-token-row { display: flex; gap: 8px; margin-top: 8px; }
.eco-token-row .eco-input { flex: 1; }

.eco-alert { border-radius: 8px; padding: 8px 12px; font-size: 12px; line-height: 1.45; }
.eco-alert.error { background: var(--danger-bg); color: var(--danger); }
.eco-alert.warn { background: var(--warn-bg); color: var(--warn-text); }

/* ── Espace de travail ── */
.eco-workspace { flex: 1; display: flex; min-height: 0; }
.eco-units {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px; background: var(--surface); border-right: 1px solid var(--border); min-height: 0;
}
.eco-units-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.eco-units-head span.count { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.eco-units-actions { display: flex; gap: 6px; }
.eco-units-actions .eco-btn { flex: 1; justify-content: center; height: 28px; }
.eco-unit-list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; }
.eco-unit {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
}
.eco-unit:hover { background: var(--surface-hover); }
.eco-unit input { accent-color: var(--accent); width: 15px; height: 15px; flex-shrink: 0; }
.eco-unit .eco-unit-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-unit .eco-unit-plate { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

.eco-report { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.eco-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.eco-toolbar .eco-sep { flex: 1; }
.eco-custom-range { display: inline-flex; align-items: center; gap: 6px; }
.eco-custom-range .eco-input { width: 178px; }
.eco-status { padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
.eco-summary { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-muted); }
.eco-summary b { color: var(--text); font-weight: 700; }
.eco-progress { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.eco-progress > div { height: 100%; background: var(--accent); transition: width 0.2s; }

.eco-report-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 16px 8px;
}
.eco-report-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.eco-report-head .eco-period { color: var(--text-muted); font-size: 13px; }

.eco-table-wrap { flex: 1; min-height: 0; overflow: auto; margin: 0 16px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table.eco-table { border-collapse: separate; border-spacing: 0; font-size: 11px; width: max-content; min-width: 100%; }
.eco-table > thead > tr > th {
  position: sticky; top: 0; z-index: 2; background: var(--table-head-bg); color: var(--table-head-text);
  font-weight: 700; text-align: center; padding: 8px 6px; line-height: 1.25; vertical-align: middle;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}
.eco-table > tbody > tr > td {
  padding: 7px 6px; text-align: center; vertical-align: top; border-bottom: 1px solid var(--border);
  line-height: 1.35;
}
.eco-table > tbody > tr > td.left { text-align: left; }
.eco-table > thead > tr > th:first-child, .eco-table > tbody > tr.trip > td:first-child { position: sticky; left: 0; z-index: 1; }
.eco-table > thead > tr > th:first-child { z-index: 3; }
.eco-table > tbody > tr.trip { cursor: pointer; }
.eco-table > tbody > tr.trip > td { background: var(--surface); }
.eco-table > tbody > tr.trip.alt > td { background: var(--row-alt); }
.eco-table > tbody > tr.trip:hover > td { background: var(--surface-hover); }
.eco-table > tbody > tr.trip.open > td { background: var(--row-open); }
.eco-caret { font-size: 16px; color: var(--text-muted); margin-right: 2px; }
.eco-table > tbody > tr.detail > td { background: var(--surface-2); padding: 0; text-align: left; }
.eco-detail { position: sticky; left: 0; max-width: min(1200px, calc(100vw - 340px)); padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.eco-detail h4 { margin: 8px 0 2px; font-size: 12px; font-weight: 700; }
.eco-detail h4:first-child { margin-top: 0; }
.eco-detail table { border-collapse: collapse; font-size: 11px; width: 100%; }
.eco-detail th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.eco-detail td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.eco-detail a { color: var(--accent); text-decoration: underline; }
.eco-empty { padding: 40px 16px; text-align: center; color: var(--text-muted); }
.eco-more { display: flex; justify-content: center; padding: 10px; }

@media (max-width: 860px) {
  .eco-workspace { flex-direction: column; overflow-y: auto; }
  .eco-units { width: auto; border-right: none; border-bottom: 1px solid var(--border); max-height: 42vh; }
  .eco-report { min-height: 70vh; }
  .eco-detail { max-width: calc(100vw - 48px); }
  .eco-topbar .eco-sub { display: none; }
}

/* ── Langue ── */
.eco-lang { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.eco-lang button { border: 0; background: var(--surface); padding: 5px 9px; font-size: 11px; font-weight: 700; cursor: pointer; color: var(--text-muted); }
.eco-lang button.is-active { background: var(--accent); color: var(--accent-text); }
.eco-topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── Tableau : en-têtes larges pour les colonnes de texte ── */
.eco-table > thead > tr > th.wide { min-width: 160px; }
.eco-empty-small { padding: 16px; }

/* ── Détail d'un trajet ── */
.eco-detail-note { margin: 0; color: var(--text-muted); }
.eco-detail-scroll { overflow-x: auto; }
.eco-chips { min-width: 220px; }
.eco-chip {
  display: inline-block; margin: 1px 3px 1px 0; padding: 1px 6px; border-radius: 10px;
  background: var(--surface-hover); border: 1px solid var(--border); font-size: 10px; white-space: nowrap;
}

/* ── Menus Notion (js/notion_dropdown.js) ── */
.notion-dropdown-menu {
  position: fixed; z-index: 99999; display: flex; flex-direction: column;
  background: var(--notion-surface); color: var(--notion-text);
  border: 1px solid var(--notion-border); border-radius: 12px; padding: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15); font-size: 12px; user-select: none;
  animation: scaleUp 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.notion-dropdown-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.notion-dropdown-title {
  padding: 6px 10px; margin-bottom: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--notion-text-muted); border-bottom: 1px solid var(--notion-border);
}
.notion-dropdown-search { position: relative; display: flex; align-items: center; padding: 4px; margin-bottom: 4px; }
.notion-dropdown-search .ms { position: absolute; left: 12px; font-size: 15px; opacity: 0.5; pointer-events: none; }
.notion-dropdown-search input {
  width: 100%; border-radius: 8px; padding: 6px 10px 6px 30px; font-size: 12px;
  background: var(--notion-bg); border: 1px solid var(--notion-border); color: var(--notion-text); outline: none;
}
.notion-dropdown-search input:focus { border-color: var(--notion-accent); }
.notion-dropdown-list { flex: 1; overflow-y: auto; min-height: 0; }
.notion-dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.notion-dropdown-item:hover { background: var(--notion-surface-hover); }
.notion-dropdown-item.is-selected { background: var(--notion-tag-blue-bg); color: var(--notion-accent); font-weight: 700; }
.notion-dropdown-item.is-disabled { opacity: 0.4; pointer-events: none; }
.notion-dropdown-item .ms { font-size: 16px; opacity: 0.75; }
.notion-dropdown-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notion-dropdown-badge {
  padding: 1px 6px; border-radius: 10px; font-size: 10px; background: var(--notion-surface-hover); color: var(--notion-text-muted);
}
.notion-dropdown-check { margin-left: auto; }
.notion-dropdown-empty { padding: 14px; text-align: center; opacity: 0.6; }
.notion-dropdown-group {
  padding: 8px 10px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--notion-text-muted);
}

/* ── Sélecteur de colonnes (js/column_picker.js) ── */
.column-picker-presets { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px 4px; }
.column-picker-preset {
  border: 1px solid var(--notion-border); background: var(--notion-bg); border-radius: 6px;
  padding: 3px 8px; font-size: 11px; cursor: pointer;
}
.column-picker-preset:hover { border-color: var(--notion-accent); color: var(--notion-accent); }
.column-picker-item { padding: 5px 10px; }
.column-picker-item input, .column-picker-stat input { accent-color: var(--accent); margin: 0; }
.column-picker-hint { padding: 4px 10px 8px; color: var(--notion-text-muted); font-style: italic; }
.column-picker-sensor { display: flex; flex-direction: column; gap: 3px; padding: 5px 10px; border-radius: 8px; }
.column-picker-sensor:hover { background: var(--notion-surface-hover); }
.column-picker-sensor-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-picker-stats { display: flex; flex-wrap: wrap; gap: 4px; }
.column-picker-stat {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--notion-border); font-size: 10px;
}
.column-picker-stat.is-on { border-color: var(--notion-accent); color: var(--notion-accent); background: var(--notion-tag-blue-bg); }
.column-picker-footer { padding: 6px 10px 2px; border-top: 1px solid var(--notion-border); margin-top: 4px; color: var(--notion-text-muted); }
.column-picker-footer.is-warning { color: var(--danger); }
