/* ==========================================================================
   BM Social Analytics — charte graphique Brain Management
   Couleurs : Orange #F79037 · Gris foncé #58595B (remplace le noir) · Gris #9D9FA2 · Platinum #D8D8D8
              Blanc 2 #F4F2EB · Jaune #F2C21C · Rouge #FE3D00
   Typo : Gellix (si installée) → Arial
   ========================================================================== */
:root {
  --orange: #F79037;
  --orange-dark: #E07A20;
  --orange-soft: #FDE6D1;
  --black: #58595B; /* le noir est remplacé par le gris foncé de la marque */
  --ink: #58595B;
  --grey: #9D9FA2;
  --grey-dark: #6B6D70;
  --platinum: #D8D8D8;
  --cream: #F4F2EB;
  --bg: #EFEFEF;
  --white: #FFFFFF;
  --yellow: #F2C21C;
  --red: #FE3D00;
  --green: #2E9E5B;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.05);
  --font: "Gellix", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--orange-dark); }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.muted { color: var(--grey-dark); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--black);
  color: var(--white);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand img { width: 100%; max-width: 200px; display: block; }
.sidebar .brand .tag { font-size: 11px; color: var(--grey); margin-top: 8px; letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  background: transparent; color: #E6E6E6; border: 0; text-align: left;
  padding: 10px 14px; border-radius: var(--radius-pill); cursor: pointer;
  font-weight: 500;
}
.nav button:hover { background: #6B6D70; }
.nav button.active { background: var(--orange); color: var(--black); }
.nav .sep { height: 1px; background: #75767A; margin: 8px 6px; }
.nav .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.sidebar .foot { margin-top: auto; font-size: 11px; color: var(--grey); }
.sidebar .foot b { color: var(--white); }

.main { padding: 26px 32px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.topbar .title .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--grey-dark); }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.demo-banner {
  background: var(--yellow); color: var(--black); border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 18px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}

/* ---------- Controls ---------- */
.btn {
  border: 0; border-radius: var(--radius-pill); padding: 10px 18px; cursor: pointer;
  font-weight: 600; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn-primary { background: var(--orange); color: var(--black); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: #4A4B4D; }
.btn-ghost { background: var(--white); color: var(--ink); border: 1px solid var(--platinum); }
.btn-ghost:hover { border-color: var(--grey); }
.btn-danger { background: var(--white); color: var(--red); border: 1px solid #FFC9B8; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: progress; }
select, input[type=date], input[type=text], input[type=password], input[type=number], textarea {
  border: 1px solid var(--platinum); background: var(--white); border-radius: var(--radius-pill);
  padding: 9px 14px; color: var(--ink); outline: none;
}
textarea { border-radius: var(--radius); width: 100%; min-height: 90px; }
select:focus, input:focus, textarea:focus { border-color: var(--orange); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--grey-dark); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--white); padding: 6px; border-radius: var(--radius-pill); }
.period select, .period input { border: 0; padding: 6px 10px; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.card {
  background: var(--white); border-radius: var(--radius-xl); padding: 22px 24px; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin-bottom: 4px; }
.card .sub { color: var(--grey-dark); font-size: 12px; margin-bottom: 14px; }
.card-orange { background: var(--orange); color: var(--black); }
.card-cream { background: var(--cream); }
.card-black { background: var(--black); color: var(--white); }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.section > h2::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--orange); display: inline-block; }

/* ---------- KPI tiles (pilules façon charte p.24) ---------- */
.kpi {
  background: var(--white); border-radius: var(--radius-xl); padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kpi .label { font-size: 12px; color: var(--grey-dark); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 30px; font-weight: 700; color: var(--orange); letter-spacing: -0.02em; line-height: 1.1; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--grey-dark); }
.kpi.hero { background: var(--orange); }
.kpi.hero .value, .kpi.hero .label { color: var(--black); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--black); background: var(--orange);
  padding: 10px 12px; white-space: nowrap; cursor: pointer; user-select: none;
}
table.data th:first-child { border-top-left-radius: 14px; border-bottom-left-radius: 14px; }
table.data th:last-child { border-top-right-radius: 14px; border-bottom-right-radius: 14px; }
table.data td { padding: 10px 12px; border-bottom: 1px solid #EEE; vertical-align: top; }
table.data tr.clickable:hover td { background: var(--cream); cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
.post-text { max-width: 420px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Correction du format d'une publication */
select.fmt-sel { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-pill); max-width: 150px; }
select.fmt-check { background: #FFF4CC; border-color: var(--yellow); font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-top { background: #DDF3E6; color: #1E7A44; }
.b-mid { background: #EEE; color: #555; }
.b-low { background: #FFE1D6; color: #C23000; }
.b-net { color: var(--white); }
/* Un réseau = une couleur de la charte (identique dans les graphiques) */
.b-linkedin { background: var(--orange); color: var(--black); }
.b-instagram { background: var(--black); }
.b-facebook { background: var(--grey); color: var(--black); }
.b-theme { background: var(--cream); color: var(--ink); }
.b-orange { background: var(--orange); color: var(--black); }
.b-high { background: var(--orange); color: var(--black); }
.b-medium { background: var(--orange-soft); color: var(--ink); }
.b-lowp { background: #EEE; color: #555; }

/* ---------- Recommandations ---------- */
.reco-list { display: flex; flex-direction: column; gap: 10px; }
.reco {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--cream);
}
.reco .n { width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: var(--black); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.reco.good .n { background: var(--green); color: var(--white); }
.reco.bad .n { background: var(--red); color: var(--white); }
.reco .t { font-weight: 600; }
.reco .d { color: #333; font-size: 13px; margin-top: 2px; }
.reco .e { color: var(--grey-dark); font-size: 12px; margin-top: 4px; }

/* ---------- Veille ---------- */
.veille-item { padding: 14px 0; border-bottom: 1px solid #EEE; }
.veille-item:last-child { border-bottom: 0; }
.veille-item .h { font-weight: 600; }
.veille-item .m { font-size: 12px; color: var(--grey-dark); margin: 3px 0 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.event {
  display: grid; grid-template-columns: 74px 1fr; gap: 14px; padding: 14px; border-radius: var(--radius-lg); background: var(--cream); margin-bottom: 10px;
}
.event .date {
  background: var(--orange); border-radius: 18px; text-align: center; padding: 8px 4px; color: var(--black); font-weight: 700; line-height: 1.1;
}
.event .date .d { font-size: 22px; }
.event .date .mo { font-size: 11px; text-transform: uppercase; }
.event .date .y { font-size: 10px; font-weight: 500; }
.idea { border-radius: var(--radius-lg); background: var(--cream); padding: 14px 16px; margin-bottom: 10px; }
.idea .hook { font-style: italic; margin: 6px 0; }

/* ---------- Import ---------- */
.dropzone {
  border: 2px dashed var(--orange); border-radius: var(--radius-xl); padding: 36px; text-align: center; background: var(--white);
  cursor: pointer; transition: background .15s;
}
.dropzone.over, body.dragging .dropzone { background: var(--orange-soft); }
/* Fichiers glissés au-dessus de la page : cadre orange + consigne */
body.dragging .main { outline: 4px dashed var(--orange); outline-offset: -12px; border-radius: var(--radius-xl); }
body.dragging .main::before {
  content: "Déposez vos fichiers d'export : import et statistiques automatiques";
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--orange); color: var(--black); font-weight: 600; padding: 12px 22px; border-radius: var(--radius-pill); box-shadow: var(--shadow);
}
.dropzone .big { font-size: 18px; font-weight: 600; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 38px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--orange);
  font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 12px;
}

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(88,89,91,.55); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--white); border-radius: var(--radius-xl); max-width: 860px; width: 100%; padding: 26px 28px; position: relative; }
.modal .close { position: absolute; top: 16px; right: 16px; }
.mapping-table td { padding: 6px 8px; }
.mapping-table select { width: 100%; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--black); color: var(--white); padding: 12px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow); max-width: 420px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--orange); color: var(--black); }

/* ---------- Décor (modules géométriques de la charte) ---------- */
.deco-arch { width: 120px; height: 60px; border-radius: 120px 120px 0 0; border: 18px solid var(--orange); border-bottom: 0; }
.hero-band {
  background: var(--orange); border-radius: var(--radius-xl); padding: 26px 28px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin-bottom: 18px; overflow: hidden; position: relative;
}
.hero-band h1 { color: var(--black); }
.hero-band p { margin: 6px 0 0; }
.hero-band .shapes { display: flex; gap: 6px; }
.hero-band .shapes span { display: block; background: var(--white); opacity: .85; border-radius: 999px; }

.empty { text-align: center; padding: 40px 20px; color: var(--grey-dark); }
.empty .big { font-size: 18px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(88,89,91,.25); border-top-color: var(--black); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.md p { margin: 0 0 10px; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md h4 { margin: 14px 0 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g-6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .sep { display: none; }
  .sidebar .foot { display: none; }
  .main { padding: 18px 16px 50px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hero-band { grid-template-columns: 1fr; }
  .hero-band .shapes { display: none; }
}
@media (max-width: 560px) {
  .g-6, .g-4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 24px; }
}

/* ---------- Studio contenus ---------- */
.prod-card { display: flex; flex-direction: column; }
.prod-preview { width: 100%; max-height: 520px; object-fit: contain; border-radius: var(--radius-lg); background: var(--cream); display: block; }
.prod-video { position: relative; width: 100%; max-height: 560px; border-radius: var(--radius-lg); overflow: hidden; background: var(--cream); margin: 0 auto; }
.prod-video canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.prod-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); box-shadow: var(--shadow); }
