/* Palette validée (voir skill dataviz) posée en variables CSS, clair + sombre.
   Fond "coquille d'oeuf" et boutons bleu pastel : uniquement le chrome de
   l'UI. --chart-accent reste le bleu saturé validé par le skill dataviz —
   un bleu pastel trop clair perdrait en lisibilité sur les graphiques. */
:root {
  --surface-1: #fffdf7;
  --page-plane: #fbf6ea;
  --text-primary: #0b0b0b;
  --text-secondary: #6b6355;
  --text-muted: #948c78;
  --grid-line: #eae1ce;
  --baseline: #d8cbae;

  --chart-accent: #2a78d6;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-neutral: #898781;

  /* Boutons bleu pastel (surchage des variables Pico.css) */
  --pico-primary: #3d78ab;
  --pico-primary-background: #aecdec;
  --pico-primary-border: #aecdec;
  --pico-primary-underline: rgba(61, 120, 171, 0.5);
  --pico-primary-hover: #2e5f8a;
  --pico-primary-hover-background: #93bce3;
  --pico-primary-hover-border: #93bce3;
  --pico-primary-focus: rgba(142, 188, 227, 0.5);
  --pico-primary-inverse: #16324e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid-line: #2c2c2a;
    --baseline: #383835;
    --chart-accent: #3987e5;
  }
}

:root[data-theme="dark"] {
  --surface-1: #1a1a19;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid-line: #2c2c2a;
  --baseline: #383835;
  --chart-accent: #3987e5;
}

body {
  background: var(--page-plane);
}

.brand {
  font-weight: 700;
  color: var(--text-primary) !important;
  text-decoration: none;
}

/* KPI */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
}

.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--grid-line);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 0;
}

.kpi-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 0 0.35rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Graphiques */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.chart-grid article {
  padding: 1.25rem;
}

.chart-grid canvas {
  max-height: 280px;
}

.chart-grid h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Badges de statut — toujours accompagnés du libellé texte, jamais couleur seule */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-good { background: color-mix(in srgb, var(--status-good) 15%, transparent); color: var(--status-good); }
.badge-warning { background: color-mix(in srgb, var(--status-warning) 22%, transparent); color: #8a5c00; }
.badge-serious { background: color-mix(in srgb, var(--status-serious) 18%, transparent); color: #9c4321; }
.badge-critical { background: color-mix(in srgb, var(--status-critical) 15%, transparent); color: var(--status-critical); }
.badge-neutral { background: color-mix(in srgb, var(--status-neutral) 15%, transparent); color: var(--text-secondary); }

/* Connexion */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.error-text {
  color: var(--status-critical);
}

/* Import Excel */
.import-errors {
  background: color-mix(in srgb, var(--status-critical) 8%, transparent);
  border: 1px solid var(--status-critical);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-block: 1rem;
}

/* Rapport imprimable */
@media print {
  nav, .no-print { display: none !important; }
  body { background: white; }
}

/* Navigation — sur petit écran, la barre doit se replier au lieu d'élargir la
   page. Sans ça, son contenu impose une largeur minimale supérieure à l'écran,
   le navigateur élargit la zone d'affichage pour la faire tenir, et toute la
   page se retrouve dézoomée. */
@media (max-width: 768px) {
  nav.container-fluid {
    position: relative;
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }
  nav.container-fluid > ul {
    flex-wrap: wrap;
  }
  nav.container-fluid .brand {
    font-size: 1rem;
  }

  /* Le panneau déroulant s'étend sur toute la largeur de la barre : ancré au
     bouton, celui de droite sortait de l'écran. */
  nav.container-fluid details.dropdown {
    position: static;
  }
  nav.container-fluid details.dropdown > ul {
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
  }
}

/* Relances commerciales */
.table-scroll {
  overflow-x: auto;
}
.text-muted {
  color: var(--text-muted);
}
.outreach-card header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block-end: 0.75rem;
}
.outreach-card textarea {
  margin-block-end: 0.25rem;
}
/* Pico étire les boutons de formulaire sur toute la largeur : ici ils forment un
   grand cadre vide sous le message. */
.outreach-card form button {
  width: auto;
}
.outreach-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.suggestion-reason {
  margin-block: 0.25rem 0.5rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 3px solid var(--chart-accent);
  color: var(--text-secondary);
}

/* Segments clients — barres de répartition */
.share-row {
  display: grid;
  grid-template-columns: 7rem 1fr 3rem;
  align-items: center;
  gap: 0.5rem;
  margin-block: 0.2rem;
  font-size: 0.85rem;
}
.share-bar {
  display: block;
  height: 0.6rem;
  background: var(--grid-line);
  border-radius: 999px;
  overflow: hidden;
}
.share-bar > span {
  display: block;
  height: 100%;
  background: var(--chart-accent);
}
.share-value {
  text-align: right;
  color: var(--text-secondary);
}

/* Assistant IA */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 40vh;
  max-height: 60vh;
  overflow-y: auto;
  padding: 1rem;
  margin-block-end: 1rem;
  background: var(--surface-1);
  border: 1px solid var(--grid-line);
  border-radius: 0.5rem;
}
.chat-message {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  max-width: 80%;
  white-space: pre-wrap;
}
.chat-message-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--chart-accent) 15%, transparent);
}
.chat-message-assistant {
  align-self: flex-start;
  background: var(--page-plane);
  border: 1px solid var(--grid-line);
}
