/* Charte METRIX — tokens & classes WeWeb METRIX-CR */
@import url("../fonts/Hermes/font.css");

:root {
  --mx-black: #1d1d1b;
  --mx-text-secondary: #52525b;
  --mx-text-muted: #8a8a8a;
  --mx-white: #ffffff;
  --mx-bg: #f5f5f5;
  --mx-border: #e3e3e3;
  --mx-border-input: #d4d4d8;
  --mx-border-card: #e4e4e7;
  --mx-green: #118d64;
  --mx-green-soft: #dff7e3;
  --mx-red: #e83030;
  --mx-red-soft: #f4e6e6;
  --mx-yellow: #facf54;
  --mx-blue: #024397;
  --mx-blue-soft: #eff6ff;
  --mx-shadow-card: 0px 0px 3px 1px #e3e3e3;
  --mx-shadow-login: 0px 1px 1px 0px #10182805;
  --mx-shadow-elevated: 0 12px 24px -4px #919eab4d;
  --mx-radius-sm: 4px;
  --mx-radius: 8px;
  --mx-radius-lg: 12px;
  --mx-nav-width: 240px;
  --mx-font: "Hermes", "Plus Jakarta Sans", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--mx-font);
  font-size: 14px;
  line-height: 18px;
  font-weight: 400;
  color: var(--mx-black);
  background: var(--mx-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--mx-black);
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
}

/* ——— Shell app ——— */
.mx-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--mx-bg);
}

.mx-topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 24px;
  background: var(--mx-white);
  border-bottom: 1px solid var(--mx-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.mx-topbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.mx-topbar-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

/* Plus spécifique que .mx-btn pour rester masqué en desktop. */
.mx-btn.mx-topbar-toggle {
  display: none;
  height: 36px;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}

.mx-topbar-chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -4px;
  transition: transform 0.15s ease;
}

.mx-topbar:not(.is-collapsed) .mx-topbar-chevron {
  transform: rotate(-135deg);
  margin-top: 2px;
}

.mx-topbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: 0;
}

.mx-field--inline {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.mx-field--inline label {
  display: block;
  height: 15px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 15px;
  white-space: nowrap;
}

.mx-field--inline label.mx-label-spacer {
  visibility: hidden;
  user-select: none;
}

.mx-topbar-filters .mx-field--date {
  width: 190px;
}

.mx-topbar-filters .mx-field--agence {
  width: 180px;
}

.mx-topbar-filters .mx-field--action {
  width: auto;
}

.mx-topbar-filters .mx-field input,
.mx-topbar-filters .mx-field select,
.mx-topbar-filters .mx-field .mx-btn {
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  margin: 0;
  padding: 0 10px;
  font-size: 13px;
  line-height: 34px;
}

.mx-topbar-filters .mx-field .mx-btn {
  width: auto;
  min-width: 110px;
  padding: 0 14px;
  line-height: 1;
}

.mx-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mx-brand img {
  height: 28px;
  width: auto;
  display: block;
}

.mx-brand-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mx-text-muted);
  padding: 4px 8px;
  background: var(--mx-bg);
  border-radius: var(--mx-radius-sm);
}

.mx-topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--mx-text-secondary);
}

.mx-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--mx-radius-sm);
  background: var(--mx-bg);
  border: 1px solid var(--mx-border);
  color: var(--mx-text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.mx-badge-ds {
  background: var(--mx-black);
  border-color: var(--mx-black);
  color: var(--mx-white);
}

/* ——— Boutons (btn-secondary-black / btn-primary-white) ——— */
.mx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--mx-radius-sm);
  border: 0 solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0;
  box-shadow: 0px 1px 1px 0px #27272a05;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mx-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mx-btn-primary {
  background: var(--mx-black);
  color: var(--mx-white);
}

.mx-btn-primary:hover:not(:disabled) {
  background: #000000;
}

.mx-btn-secondary {
  background: transparent;
  color: var(--mx-text-secondary);
  border: 1px solid var(--mx-text-secondary);
}

.mx-btn-secondary:hover:not(:disabled) {
  background: var(--mx-bg);
  color: var(--mx-black);
  border-color: var(--mx-black);
}

.mx-btn-ghost {
  background: transparent;
  color: var(--mx-text-secondary);
  border: 1px solid var(--mx-border);
  box-shadow: none;
}

.mx-btn-ghost:hover:not(:disabled) {
  color: var(--mx-black);
  border-color: var(--mx-text-secondary);
}

/* ——— Layout ——— */
.mx-layout {
  display: grid;
  grid-template-columns: var(--mx-nav-width) 1fr;
  flex: 1;
  min-height: 0;
}

.mx-nav {
  background: var(--mx-white);
  border-right: 1px solid var(--mx-border);
  padding: 24px 12px;
  min-height: calc(100vh - 53px);
}

.mx-nav-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mx-text-muted);
  margin: 0 12px 12px;
}

.mx-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--mx-radius-sm);
  color: var(--mx-text-secondary);
  font-size: 14px;
  line-height: 22px;
  margin-bottom: 2px;
  transition: background-color 0.15s ease, color 0.15s ease, font-weight 0.15s ease;
}

.mx-nav a:hover {
  background: var(--mx-bg);
  color: var(--mx-black);
}

.mx-nav a.active {
  background: var(--mx-bg);
  color: var(--mx-black);
  font-weight: 700;
}

.mx-nav a.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.mx-main {
  padding: 24px 32px 40px;
  max-width: 1280px;
}

.mx-page-header {
  margin-bottom: 20px;
}

.mx-page-header h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--mx-black);
  line-height: 1.3;
}

.mx-page-header p {
  margin: 0;
  font-size: 14px;
  color: var(--mx-text-muted);
}

/* ——— Filtres ——— */
.mx-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  background: var(--mx-white);
  border-radius: var(--mx-radius);
  box-shadow: var(--mx-shadow-card);
  padding: 16px;
  margin-bottom: 20px;
}

.mx-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.mx-field label {
  font-size: 12px;
  font-weight: 700;
  line-height: 15px;
  color: var(--mx-black);
  margin: 0 0 4px;
}

.mx-field input,
.mx-field select {
  width: 100%;
  height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--mx-border-input);
  border-radius: var(--mx-radius-sm);
  background: var(--mx-white);
  color: var(--mx-text-secondary);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.15s ease;
}

.mx-field input:focus,
.mx-field select:focus {
  border-color: var(--mx-black);
  color: var(--mx-black);
}

/* ——— KPI cards ——— */
.mx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mx-grid--kpi {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
}

.mx-contrib-row {
  margin-bottom: 20px;
  align-items: stretch;
}

.mx-contrib-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 360px;
}

.mx-contrib-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.mx-table-scroll {
  flex: 1;
  min-height: 0;
  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
}

.mx-table-scroll .mx-table thead th {
  position: sticky;
  top: 0;
  background: var(--mx-white);
  z-index: 1;
}

.mx-card {
  background: var(--mx-white);
  border-radius: var(--mx-radius);
  box-shadow: var(--mx-shadow-card);
  padding: 16px;
}

.mx-kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 88px;
}

.mx-card-label {
  color: var(--mx-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mx-card-value {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--mx-black);
  font-variant-numeric: tabular-nums;
}

/* ——— Charts & sections ——— */
.mx-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--mx-black);
  width: 100%;
  padding: 8px 12px;
  margin: 0 0 12px;
  background: var(--mx-bg);
  border-radius: var(--mx-radius-sm);
}

.mx-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.mx-charts--timelines-dual {
  grid-template-columns: 1fr 1fr;
}

.mx-chart-hint {
  margin: -4px 0 10px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--mx-text-muted);
}

.mx-section-hint {
  margin: -4px 0 16px;
  padding: 0 4px;
}

.mx-chart-box {
  background: var(--mx-white);
  border-radius: var(--mx-radius);
  box-shadow: var(--mx-shadow-card);
  padding: 16px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.mx-chart-box--wide {
  grid-column: 1 / -1;
  min-height: 300px;
}

.mx-chart-box h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--mx-black);
}

.mx-chart-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.mx-chart-body--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.mx-chart-canvas-wrap {
  position: relative;
  flex: 1 1 55%;
  min-width: 160px;
  min-height: 220px;
  height: 220px;
}

.mx-chart-body--stacked .mx-chart-canvas-wrap {
  flex: 0 0 auto;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  height: 200px;
  min-height: 200px;
}

.mx-chart-canvas-wrap--line {
  flex: 1;
  width: 100%;
  min-height: 260px;
  height: 260px;
}

.mx-chart-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.mx-chart-canvas-wrap.is-empty canvas {
  visibility: hidden;
}

.mx-chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--mx-text-muted);
  font-size: 13px;
  background: var(--mx-white);
  z-index: 1;
}

.mx-chart-canvas-wrap.is-empty .mx-chart-empty {
  display: flex;
}

.mx-chart-empty[hidden] {
  display: none !important;
}

.mx-chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 45%;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.mx-chart-body--stacked .mx-chart-legend {
  flex: 0 0 auto;
  width: 100%;
  max-height: 180px;
  min-width: 0;
}

.mx-chart-legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--mx-radius-sm);
  cursor: pointer;
  outline: none;
}

.mx-chart-legend-item:hover,
.mx-chart-legend-item:focus-visible {
  background: var(--mx-bg);
}

.mx-chart-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 3px;
}

.mx-chart-legend-label {
  font-size: 13px;
  line-height: 1.35;
  color: var(--mx-black);
  overflow: visible;
  white-space: normal;
  word-break: break-word;
}

.mx-chart-legend-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--mx-black);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.mx-chart-legend-pct {
  font-weight: 400;
  font-size: 11px;
  color: var(--mx-text-muted);
}

@media (max-width: 960px) {
  .mx-grid--kpi {
    grid-template-columns: repeat(2, 1fr);
  }

  .mx-charts--timelines-dual {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .mx-chart-body {
    flex-direction: column;
  }

  .mx-chart-canvas-wrap {
    width: 100%;
    height: 200px;
  }

  .mx-chart-legend {
    max-height: 180px;
    width: 100%;
  }

  .mx-chart-box--wide {
    grid-column: auto;
  }

  .mx-grid--kpi {
    grid-template-columns: 1fr;
  }
}

.mx-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.mx-two-col .mx-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.mx-table {
  width: 100%;
  border-collapse: collapse;
}

.mx-table th,
.mx-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--mx-border);
  font-size: 14px;
}

.mx-table th {
  color: var(--mx-text-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mx-table td {
  color: var(--mx-black);
}

.mx-error {
  background: var(--mx-red-soft);
  color: var(--mx-red);
  border: 1px solid #f0c0c0;
  border-radius: var(--mx-radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14px;
}

.mx-loading {
  color: var(--mx-text-muted);
  padding: 16px 0;
  font-size: 14px;
}

/* Loader page (style WeWeb) — contenu masqué pendant le fetch */
.mx-page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: min(420px, 60vh);
  width: 100%;
  padding: 48px 16px;
}

.mx-page-loader[hidden] {
  display: none !important;
}

.mx-page-loader p {
  margin: 0;
  font-size: 14px;
  color: var(--mx-text-muted);
}

.mx-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--mx-border);
  border-top-color: var(--mx-green);
  animation: mx-spin 0.7s linear infinite;
}

.mx-page-content[hidden] {
  display: none !important;
}

.mx-main.is-loading .mx-page-header {
  opacity: 0.55;
}

.mx-topbar-filters.is-busy .mx-btn-primary,
.mx-topbar-filters.is-busy input,
.mx-topbar-filters.is-busy select {
  pointer-events: none;
  opacity: 0.65;
}

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

/* ——— Login (page authentification Metrix) ——— */
.mx-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mx-bg);
  padding: 32px;
}

.mx-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--mx-white);
  border: 1px solid var(--mx-border-card);
  border-radius: var(--mx-radius-lg);
  padding: 32px 24px;
  box-shadow: var(--mx-shadow-login);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mx-login-card .mx-login-logo {
  height: 80px;
  width: auto;
  margin-bottom: 24px;
  display: block;
}

.mx-login-card h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--mx-black);
  text-align: center;
  width: 100%;
}

.mx-login-card > p {
  margin: 0 0 24px;
  color: var(--mx-text-muted);
  font-size: 14px;
  text-align: center;
  width: 100%;
}

.mx-login-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mx-login-card .mx-btn {
  width: 100%;
  margin-top: 8px;
}

.mx-login-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--mx-text-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .mx-topbar {
    padding: 10px 12px;
    gap: 0;
  }

  .mx-btn.mx-topbar-toggle {
    display: inline-flex;
  }

  .mx-topbar-panel {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-top: 12px;
  }

  .mx-topbar:not(.is-collapsed) .mx-topbar-panel {
    display: flex;
  }

  .mx-topbar-filters {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .mx-topbar-filters .mx-field--date,
  .mx-topbar-filters .mx-field--agence,
  .mx-topbar-filters .mx-field--action {
    width: 100%;
  }

  .mx-topbar-filters .mx-field .mx-btn {
    width: 100%;
  }

  .mx-topbar-meta {
    width: 100%;
    padding-top: 4px;
    border-top: 1px solid var(--mx-border);
  }

  .mx-layout {
    grid-template-columns: 1fr;
  }

  .mx-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--mx-border);
    min-height: auto;
    padding: 12px;
  }

  .mx-nav-title {
    display: none;
  }

  .mx-nav a {
    white-space: nowrap;
  }

  .mx-two-col {
    grid-template-columns: 1fr;
  }

  .mx-main {
    padding: 16px;
  }

  .mx-login-page {
    padding: 16px;
  }
}

@media (min-width: 901px) {
  .mx-topbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .mx-topbar-bar {
    width: auto;
    flex: 0 0 auto;
  }

  .mx-topbar-panel {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .mx-topbar.is-collapsed .mx-topbar-panel {
    display: flex;
  }

  .mx-btn.mx-topbar-toggle {
    display: none;
  }
}
