/* Flowboard — interface */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --accent: #6366f1;
  --accent-ink: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 8px 24px rgba(17, 24, 39, .08);
  --shadow-lg: 0 12px 48px rgba(17, 24, 39, .18);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex: none; }
.logo { width: 28px; height: 28px; flex: none; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 650; font-size: 15px; }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px;
  font: 500 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:focus-visible, .tool:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1f2937; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-outline:hover:not(:disabled) { background: #f9fafb; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-sm .ico { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field input, .field textarea {
  font: 14px var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 11px; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
.form-error { margin: -4px 0 14px; color: var(--danger); font-size: 13px; }

/* ---------- Connexion ---------- */
.page-login { display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 1px 1px, #d9dce3 1px, transparent 0) 0 0 / 22px 22px, var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 28px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .muted { margin: 0 0 22px; }

/* ---------- Application ---------- */
.page-app { overflow: hidden; display: flex; flex-direction: column; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 12px 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 5; }
.crumb { color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar form { margin: 0; }
.pill { font-size: 12px; font-weight: 500; color: var(--ink-2); background: #f3f4f6; border-radius: 999px; padding: 3px 10px; }
.save { font-size: 12.5px; color: var(--muted); min-width: 90px; text-align: right; }
.save.err { color: var(--danger); }

#board { flex: 1; position: relative; touch-action: none; background-color: var(--bg);
  background-image: radial-gradient(circle, #cfd3dc 1px, transparent 1.2px); }
#board.tool-line, #board.tool-zone, #board.tool-card { cursor: crosshair; }
#board.panning { cursor: grabbing; }

/* Barre d'outils flottante */
.toolbar { position: fixed; left: 14px; top: 50%; transform: translateY(-50%); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.toolbar hr { width: 24px; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.tool { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-2); cursor: pointer; }
.tool .ico { width: 20px; height: 20px; }
.tool:hover:not(:disabled) { background: #f3f4f6; }
.tool.active { background: var(--accent-soft); color: var(--accent-ink); }
.tool:disabled { opacity: .35; cursor: default; }
.tool.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.tool::after { content: attr(data-tip) "  " attr(data-key); position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%); white-space: pre; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--ink); color: #fff; font-size: 12px; padding: 5px 8px; border-radius: 6px; }
.tool:hover::after { opacity: 1; }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 2px; }
.swatch { width: 15px; height: 15px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.zoombar { position: fixed; right: 14px; bottom: 14px; z-index: 4; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.zoombar .btn { height: 32px; }
.zoombar .btn-icon { width: 32px; }
.zoom-val { min-width: 62px; font-variant-numeric: tabular-nums; padding: 0 6px; font-size: 13px; }
.vsep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

.help-btn { position: fixed; left: 14px; bottom: 14px; z-index: 4; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--muted); font: 500 12.5px var(--font); cursor: pointer; box-shadow: var(--shadow-sm); }
.help-btn:hover { color: var(--ink); }
.help { position: fixed; left: 14px; bottom: 54px; z-index: 6; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; }
.help dl { display: grid; grid-template-columns: auto auto; gap: 6px 18px; margin: 0; font-size: 13px; }
.help dt { font-weight: 600; color: var(--ink-2); }
.help dd { margin: 0; color: var(--muted); }

.empty { position: fixed; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 3; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 32px; box-shadow: var(--shadow); max-width: 380px; }
.empty h2 { font-size: 17px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 0 18px; }

/* ---------- Fiche compte ---------- */
.panel { position: fixed; top: 68px; right: 12px; bottom: 12px; width: 380px; z-index: 6; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: slide-in .16s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden;
  font-weight: 650; color: #fff; background: var(--accent); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.panel-body { overflow-y: auto; flex: 1; }
.block { padding: 16px; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-between h3 { margin-bottom: 0; }
.block .row-between + * { margin-top: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #f3f4f6; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-ink); font-weight: 500; font-size: 13px; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link .ico { width: 15px; height: 15px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint-text { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }

.videos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.video { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 8px; overflow: hidden; background: #e5e7eb; color: #fff; text-decoration: none; }
.video img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video .meta { position: absolute; inset: auto 0 0 0; padding: 18px 6px 5px; font-size: 11.5px; font-weight: 600;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.video:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.notice { font-size: 12.5px; color: var(--muted); background: #f9fafb; border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; margin: 0; }
.notice + .notice, .videos + .notice, .notice + .videos { margin-top: 10px; }
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.more { margin-top: 10px; }

/* ---------- Dialogues ---------- */
.dialog { border: 0; border-radius: 14px; padding: 24px; width: min(400px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); }
.dialog::backdrop { background: rgba(17, 24, 39, .35); }
.dialog h2 { font-size: 17px; margin-bottom: 6px; }
.dialog .muted { margin: 0 0 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px;
  animation: toast-in .18s ease-out; max-width: min(520px, calc(100vw - 32px)); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 720px) {
  .crumb, .pill, .help-btn { display: none; }
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 70vh; bottom: 8px; }
  .toolbar { top: auto; bottom: 64px; transform: none; left: 8px; }
}

/* La fiche ouverte ne doit pas cacher le zoom */
body:has(#panel:not([hidden])) .zoombar { right: 404px; }
@media (max-width: 720px) { body:has(#panel:not([hidden])) .zoombar { display: none; } }

/* ---------- Envoi de vidéo ---------- */
#btn-post { position: relative; }
.dot-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.dialog-wide { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.post-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.post-col h3, .post-history h3 { font-size: 13px; margin: 0 0 8px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 14px; margin-bottom: 14px;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; text-align: center; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-file { border-style: solid; border-color: var(--accent); }
.drop strong { word-break: break-all; }
.drop-ico .ico { width: 28px; height: 28px; color: var(--accent); }
.post-accounts { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.grp + .grp { border-top: 1px solid var(--line); }
.grp-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f9fafb; font-weight: 600; cursor: pointer; position: sticky; top: 0; }
.grp-head small { margin-left: auto; font-weight: 400; }
.grp-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.acc-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 28px; cursor: pointer; }
.acc-row:hover { background: #f9fafb; }
.acc-row.off { cursor: not-allowed; opacity: .6; }
.acc-row small { margin-left: auto; font-size: 12px; }
.mini-av { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; background: var(--accent-soft); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; flex: none; }
.mini-av img { width: 100%; height: 100%; object-fit: cover; }
.acc-h { font-weight: 500; }
.progress { position: relative; height: 26px; margin: 14px 0 4px; background: #f3f4f6; border-radius: 8px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent-soft); border-right: 2px solid var(--accent); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; }
.post-history { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.hist { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.hist strong { word-break: break-all; }
.targets { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.targets li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.chip { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: var(--ink-2); }
.chip.run { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.err-text { color: var(--danger); flex-basis: 100%; }
@media (max-width: 720px) {
  .post-grid { grid-template-columns: 1fr; }
  #btn-post { font-size: 0; gap: 0; }
  #btn-post .ico { margin: 0; }
}
.dialog-wide small.muted, .dialog-wide p.muted.inline { margin: 0; }
.dialog-wide .acc-row small.muted, .dialog-wide .grp-head small.muted { margin-left: auto; }
.dialog-wide .post-accounts > p.muted { margin: 0; padding: 14px; }
