/* ==========================================================================
   POSTRONOME — feuille de styles
   Idée de mise en page : une barre latérale de navigation + une zone de travail.
   La file d'attente est traitée comme une grille horaire (heures en grand,
   surligneur jaune sur le prochain départ) : c'est le seul élément « fort »,
   tout le reste reste sobre.
   ========================================================================== */

/* ---------- Jetons de design : thème clair (valeurs par défaut) ---------- */
:root {
  --paper:   #F2F4F1;  /* fond de page, gris légèrement vert */
  --surface: #FFFFFF;  /* panneaux et champs */
  --sunken:  #E7EBE7;  /* zones en creux : onglets, créneaux libres */
  --ink:     #17212B;  /* texte principal et boutons primaires */
  --muted:   #5A6672;  /* texte secondaire */
  --line:    #D3DAD5;  /* filets et bordures */
  --marker:  #FFD23F;  /* surligneur : prochain créneau, élément actif */
  --marker-ink: #2A2100; /* texte posé sur le surligneur */
  --btn-bg:  #17212B;
  --btn-fg:  #FFFFFF;
  /* Couleurs sémantiques, distinctes du surligneur */
  --ok:   #1B7F4F;
  --warn: #B45F06;
  --crit: #C0352B;
  /* Typographie : une police de caractère pour les titres et les heures, une pour le texte */
  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-s: 6px;
  --r-m: 10px;
  color-scheme: light;
}

/* ---------- Thème sombre : préférence système (sauf si l'hôte force le clair) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10151A; --surface: #19212A; --sunken: #212B35; --ink: #E8ECEF;
    --muted: #9AA6B1; --line: #2D3944; --marker: #FFD23F; --marker-ink: #2A2100;
    --btn-bg: #E8ECEF; --btn-fg: #10151A;
    --ok: #4CC38A; --warn: #F0A04B; --crit: #FF7A6E;
    color-scheme: dark;
  }
}
/* ---------- Thème sombre : forcé par l'hôte ---------- */
:root[data-theme="dark"] {
  --paper: #10151A; --surface: #19212A; --sunken: #212B35; --ink: #E8ECEF;
  --muted: #9AA6B1; --line: #2D3944; --marker: #FFD23F; --marker-ink: #2A2100;
  --btn-bg: #E8ECEF; --btn-fg: #10151A;
  --ok: #4CC38A; --warn: #F0A04B; --crit: #FF7A6E;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Structure générale ---------- */
.app { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; align-self: start;
  display: flex; flex-direction: column; gap: 20px;
  padding: 22px 14px; min-height: 100vh;
  border-right: 1px solid var(--line);
}
.brand { font: 800 24px/1 var(--font-display); letter-spacing: -0.02em; padding: 0 8px; }
.brand span { background: var(--marker); color: var(--marker-ink); padding: 0 6px; border-radius: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-s);
  text-decoration: none; font-weight: 500; color: var(--muted);
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--marker); }
.badge {
  min-width: 20px; padding: 0 6px; border-radius: 10px; text-align: center;
  background: var(--sunken); color: var(--ink); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.badge.due { background: var(--crit); color: #fff; }
.side-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--muted); }
.main { padding: 26px 28px 80px; min-width: 0; }
.view { max-width: 1120px; display: flex; flex-direction: column; gap: 24px; }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.head p { color: var(--muted); max-width: 62ch; margin-top: 6px; }
.tt-day::first-letter, .week .day b::first-letter { text-transform: uppercase; }
.panel .tt-row:last-child { border-bottom: 0; padding-bottom: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel > .head h2 { font-size: 17px; }
.empty { padding: 22px; border: 1px dashed var(--line); border-radius: var(--r-m); color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.note { padding: 10px 12px; border-radius: var(--r-s); background: var(--sunken); font-size: 13px; }
.note.warn { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-s); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btn.mark { background: var(--marker); color: var(--marker-ink); border-color: var(--marker); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.quiet:hover { color: var(--ink); background: var(--sunken); }
.btn.danger:hover { color: var(--crit); border-color: var(--crit); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input[type="text"], input[type="password"], input[type="time"], input[type="number"], input[type="datetime-local"], input[type="search"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }
textarea { resize: vertical; line-height: 1.5; }
label.field, .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }

/* ---------- Pastilles de réseau (monogramme coloré, jamais la couleur seule) ---------- */
.net {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 5px; border-radius: 5px;
  background: var(--c, #555); color: #fff; font: 700 11px/1 var(--font-body);
  border: 1px solid rgba(255,255,255,.18);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="false"] { opacity: .55; background: transparent; }
.chip[aria-pressed="true"] { border-color: var(--ink); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--sunken); font-size: 12px; font-weight: 500; }
.state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.ok::before { background: var(--ok); }
.state.due::before { background: var(--crit); }
.state.sched::before { background: var(--marker); box-shadow: 0 0 0 1px var(--marker-ink); }

/* ---------- Accueil ---------- */
.next { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.next .count { font: 800 clamp(30px, 5vw, 46px)/1.05 var(--font-display); letter-spacing: -0.02em; }
.next .count mark { background: var(--marker); color: var(--marker-ink); padding: 0 8px; border-radius: 6px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week .day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px; min-height: 78px; display: flex; flex-direction: column; gap: 6px; }
.week .day.today { border-color: var(--ink); }
.week .day b { font-size: 12px; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); }
.dot.full { background: var(--ink); border-color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; }
.kpi b { display: block; font: 700 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }

/* ---------- Grille horaire (file d'attente) ---------- */
.timetable { display: flex; flex-direction: column; }
.tt-day { font: 700 14px/1 var(--font-display); padding: 16px 0 8px; color: var(--muted); border-bottom: 1px solid var(--line); }
.tt-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tt-time { font: 700 22px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tt-row.is-next .tt-time span { background: var(--marker); color: var(--marker-ink); padding: 2px 6px; border-radius: 5px; }
.tt-row.free .tt-time { color: var(--muted); font-weight: 500; }
.tt-body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.tt-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.tt-free { color: var(--muted); font-size: 14px; }
.tt-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.pub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- Calendrier ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--line); gap: 1px; }
.cal-h { background: var(--paper); padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-c { background: var(--surface); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-c.out { background: var(--paper); }
.cal-c.over { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-c .d { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; }
.cal-c.today .d b { background: var(--marker); color: var(--marker-ink); padding: 0 6px; border-radius: 9px; }
.cal-add { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; border-radius: 4px; }
.cal-add:hover { background: var(--sunken); color: var(--ink); }
.cal-p { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 5px; padding: 3px 5px; font-size: 12px; cursor: grab; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-p.done { opacity: .6; cursor: pointer; }
.cal-p b { font-variant-numeric: tabular-nums; }
.cal-slot { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Rédaction ---------- */
.composer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; background: var(--sunken); border-radius: var(--r-s); padding: 3px; }
.tab { border: 0; background: transparent; padding: 5px 10px; border-radius: 4px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); }
.tab i { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.toolbar select { width: auto; padding: 4px 8px; font-size: 13px; }
#c-text { min-height: 260px; font-size: 15px; }
.counters { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.counter { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.counter.over { color: var(--crit); font-weight: 700; }
.ai { border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ai-out { white-space: pre-wrap; background: var(--sunken); border-radius: var(--r-s); padding: 10px; font-size: 14px; overflow-wrap: anywhere; }
.ai-hooks { display: flex; flex-direction: column; gap: 6px; }
.ai-hooks button { text-align: left; white-space: normal; font-weight: 500; }
details.more { border-top: 1px solid var(--line); padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details.more .inner { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.sched { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sched input { width: auto; }
.thumb { max-width: 140px; border-radius: var(--r-s); border: 1px solid var(--line); display: block; }

/* ---------- Aperçu d'une publication ---------- */
.pv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.pv-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px 0; }
.pv-av { width: 44px; height: 44px; border-radius: 50%; background: var(--sunken); display: grid; place-items: center; font: 700 15px var(--font-display); flex: none; }
.pv-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.pv-sub { font-size: 12px; color: var(--muted); line-height: 1.3; }
.pv-body { padding: 10px 14px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.pv-body .lk { color: #0A66C2; font-weight: 600; }
.pv-body .ov { background: color-mix(in srgb, var(--crit) 22%, transparent); }
.pv-more { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 600; cursor: pointer; }
.pv-img { display: block; width: 100%; max-height: 320px; object-fit: cover; border-top: 1px solid var(--line); }
.pv-ph { display: grid; place-items: center; height: 150px; background: var(--sunken); color: var(--muted); font-size: 13px; }
.pv-foot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; color: var(--muted); display: flex; gap: 18px; }

/* ---------- Idées ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { background: var(--sunken); border-radius: var(--r-m); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.col.over { box-shadow: inset 0 0 0 2px var(--ink); }
.col h3 { display: flex; justify-content: space-between; padding: 2px 4px; }
.idea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: grab; }
.idea p { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.idea strong { overflow-wrap: anywhere; }
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.model { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s); padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.model p { font-size: 13px; color: var(--muted); }

/* ---------- Statistiques ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td input[type="number"] { width: 84px; padding: 4px 6px; text-align: right; }
td .tt-text { max-width: 320px; -webkit-line-clamp: 1; }
.chart text { font: 500 11px var(--font-body); fill: var(--muted); }
.chart .v { fill: var(--ink); font-weight: 600; }
.chart rect { fill: var(--ink); }
.chart rect.last { fill: var(--marker); stroke: var(--marker-ink); stroke-width: 1; }
.chart line { stroke: var(--line); }

/* ---------- Réglages ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.slots-day { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.slots-day:last-child { border-bottom: 0; }
.slot-pill { display: inline-flex; align-items: center; gap: 2px; background: var(--sunken); border-radius: 14px; padding: 1px 2px 1px 9px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot-pill button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 10px; }
.slot-pill button:hover { color: var(--crit); }
.slots-day input[type="time"] { width: 104px; padding: 3px 6px; }
.netrow { display: grid; grid-template-columns: auto 34px minmax(0, 1fr); gap: 8px; align-items: center; padding: 5px 0; }

/* ---------- Fenêtre modale et notification ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 15, 20, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal > div { background: var(--surface); border-radius: var(--r-m); border: 1px solid var(--line); padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--btn-bg); color: var(--btn-fg); padding: 10px 14px; border-radius: var(--r-s); display: flex; gap: 12px; align-items: center; z-index: 30; max-width: calc(100% - 32px); font-size: 14px; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ---------- Petits écrans ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 10; min-height: 0; flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; background: var(--paper); border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .nav { flex-direction: row; }
  .nav a { white-space: nowrap; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--marker); }
  .side-foot { display: none; }
  .brand { font-size: 19px; padding: 0; }
  .main { padding: 18px 16px 80px; }
  .cols, .composer, .board { grid-template-columns: minmax(0, 1fr); }
  .tt-row { grid-template-columns: 62px minmax(0, 1fr); }
  .tt-actions { grid-column: 2; justify-content: flex-start; }
  .tt-time { font-size: 19px; }
  .cal-c { min-height: 70px; padding: 4px; }
  .cal-p { font-size: 11px; padding: 2px 3px; }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 8px); opacity: .4; } }
}

/* ---------- Page de connexion ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 28px; }
.login-box .brand { padding: 0; }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
#login-error { color: var(--crit); min-height: 1.5em; }
code { font-size: 12.5px; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
.note a { font-weight: 600; }

