/* ComHub — design system de l'application
   Inspiré de chainedelespoir.org : Montserrat généreuse, bleu nuit, sarcelle,
   corail pour l'action, jaune soleil réservé au trait sous les titres. */

:root {
  --night: #015670;
  --night-2: #01455a;
  --teal: #008895;
  --teal-soft: #d9eff1;
  --coral: #ff5b35;
  --coral-dark: #e4471f;
  --sun: #fab70c;
  --sun-soft: #fff4d6;
  --mist: #edf7f8;
  --line: #d3e5e9;
  --ink: #0f3442;
  --ink-soft: #4d6b76;
  --white: #ffffff;
  --danger: #c62f2f;
  --danger-soft: #fde8e6;
  --success: #00866e;
  --success-soft: #dff3ec;

  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(1, 86, 112, .06), 0 6px 20px rgba(1, 86, 112, .07);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--night); }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { color: var(--night); line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.center { text-align: center; }
.lead { font-size: 1.05rem; color: var(--ink-soft); max-width: 62ch; }
.hidden { display: none !important; }

/* ——— Le trait soleil : signature visuelle, uniquement sous le titre de page */
.page-title { position: relative; display: inline-block; padding-bottom: .35em; margin-bottom: .5em; }
.page-title::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: min(100%, 120px); height: 6px; border-radius: 6px;
  background: var(--sun);
  transform-origin: left; animation: sun-stroke .6s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes sun-stroke { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .page-title::after { animation: none; } }

/* ——— Coquille */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--night) var(--sidebar), transparent 0); }
.sidebar {
  background: var(--night); color: #cfe6ec;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
.brand-mark { font-weight: 800; font-size: 1.5rem; color: var(--night); letter-spacing: -.02em; }
.brand-mark span { color: var(--teal); }
.sidebar .brand-mark { color: var(--white); padding: 0 10px; }
.sidebar .brand-mark span { color: var(--sun); }
.company-switch select {
  width: 100%; background: var(--night-2); color: var(--white); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm); padding: 9px 10px; font: inherit; font-weight: 600;
}
.company-name { color: var(--white); font-weight: 700; padding: 0 10px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: .78rem; color: #8fbac6; padding: 14px 10px 4px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: #d7ebf0; text-decoration: none; padding: 9px 10px; border-radius: var(--radius-sm); font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
.nav a.active { background: var(--white); color: var(--night); font-weight: 700; }
.nav a .count { margin-left: auto; background: var(--coral); color: var(--white); border-radius: 999px; font-size: .72rem; padding: 1px 8px; font-weight: 700; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; font-size: .85rem; padding: 0 10px; }
.sidebar-foot form { display: inline; }
.sidebar-foot button { background: none; border: 0; color: #cfe6ec; font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 32px; background: var(--white); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar .lang { display: flex; gap: 4px; }
.topbar .lang button {
  border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 3px 10px;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.topbar .lang button.on { background: var(--night); color: var(--white); border-color: var(--night); }
.menu-toggle { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--night); }
.content { padding: 28px 32px 60px; max-width: 1240px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ——— Cartes */
.card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-flat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-sun { background: var(--sun-soft); border-radius: var(--radius-lg); padding: 18px 22px; margin-bottom: 18px; }
.card-teal { background: var(--teal-soft); border-radius: var(--radius-lg); padding: 18px 22px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 12px; }
.split > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-size: 2rem; font-weight: 800; color: var(--night); line-height: 1; }
.stat span { color: var(--ink-soft); font-size: .9rem; }

/* ——— Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .92rem; line-height: 1;
  padding: 12px 18px; border-radius: var(--radius-sm); border: 2px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--coral); color: var(--white); box-shadow: 0 3px 0 var(--coral-dark); }
.btn-primary:hover { background: var(--coral-dark); color: var(--white); }
.btn-secondary { background: var(--night); color: var(--white); }
.btn-secondary:hover { background: var(--night-2); color: var(--white); }
.btn-ghost { background: transparent; color: var(--night); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger { background: transparent; color: var(--danger); border-color: #f2c4bf; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 8px 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); cursor: pointer; text-decoration: underline; }

/* ——— Formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--night); }
label .hint, .hint { font-weight: 400; color: var(--ink-soft); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=datetime-local],
input[type=number], input:not([type]), select, textarea {
  font: inherit; font-weight: 500; color: var(--ink); background: var(--white);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type=color] { width: 54px; height: 40px; border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; background: var(--white); }
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.checks { display: flex; gap: 8px 18px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--white); font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink-soft);
}
.chip input:checked + span { background: var(--night); border-color: var(--night); color: var(--white); }
.chip input:focus-visible + span { outline: 3px solid var(--sun); }
.chip { position: relative; display: inline-block; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 700; color: var(--night); margin-bottom: 8px; font-size: .9rem; }

/* ——— Pastilles de statut */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--mist); color: var(--night); white-space: nowrap; }
.pill-draft { background: #eef2f4; color: #4d6b76; }
.pill-review { background: var(--sun-soft); color: #8a5a00; }
.pill-changes_requested { background: var(--danger-soft); color: var(--danger); }
.pill-approved { background: var(--success-soft); color: var(--success); }
.pill-scheduled { background: var(--teal-soft); color: var(--teal); }
.pill-published { background: var(--night); color: var(--white); }
.pill-channel { background: var(--white); border: 1.5px solid var(--line); color: var(--ink-soft); }
.pill-instagram { color: #b0336f; border-color: #f3c6db; background: #fff4f9; }
.pill-x { color: #111; border-color: #ccc; background: #f6f6f6; }
.pill-newsletter { color: var(--teal); border-color: #b6dfe3; background: #f2fbfc; }
.pill-article { color: var(--night); border-color: #bcd6de; background: #f4f9fb; }

/* ——— Tableaux et listes */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 700; color: var(--ink-soft); font-size: .8rem; padding: 10px 12px; border-bottom: 2px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { font-weight: 600; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ——— Messages */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--teal-soft); color: var(--night); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--night); color: var(--white); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 600; max-width: 360px; animation: toast-in .2s ease-out; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.empty { text-align: center; padding: 40px 20px; }
.empty h3 { margin-bottom: .3em; }
.empty p { color: var(--ink-soft); max-width: 46ch; margin: 0 auto 1.2em; }

/* ——— Chargement IA (plein écran discret) */
.loader {
  position: fixed; inset: 0; background: rgba(237, 247, 248, .82); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 90; flex-direction: column; gap: 14px;
}
.loader.on { display: flex; }
.loader .sun {
  width: 54px; height: 54px; border-radius: 50%; background: var(--sun);
  box-shadow: 0 0 0 10px rgba(250, 183, 12, .25), 0 0 0 22px rgba(250, 183, 12, .1);
  animation: pulse 1.4s ease-in-out infinite;
}
.loader p { font-weight: 700; color: var(--night); }
@keyframes pulse { 50% { transform: scale(.86); } }
@media (prefers-reduced-motion: reduce) { .loader .sun { animation: none; } }

/* ——— Conversation (entretien directives / atelier de style) */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.bubble { max-width: 80%; padding: 12px 16px; border-radius: 16px; white-space: pre-wrap; }
.bubble.assistant { background: var(--mist); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.user { background: var(--night); color: var(--white); border-bottom-right-radius: 4px; align-self: flex-end; }

/* ——— Calendrier éditorial */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar .dow { font-size: .78rem; font-weight: 700; color: var(--ink-soft); padding: 4px 6px; }
.calendar .day { background: var(--white); border-radius: 10px; min-height: 108px; padding: 6px; border: 1.5px solid transparent; }
.calendar .day.out { background: transparent; }
.calendar .day.drop { border-color: var(--teal); background: var(--teal-soft); }
.calendar .day .num { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.calendar .day.today .num { color: var(--coral); }
.cal-item {
  display: block; font-size: .76rem; font-weight: 600; padding: 4px 6px; margin-top: 4px; border-radius: 6px;
  background: var(--mist); color: var(--night); text-decoration: none; cursor: grab; border-left: 3px solid var(--teal);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-item.instagram { border-left-color: #b0336f; }
.cal-item.x { border-left-color: #111; }
.cal-item.newsletter { border-left-color: var(--sun); }
.cal-item.article { border-left-color: var(--night); }

/* ——— Éditeurs */
.editor-area { min-height: 320px; font-size: 1rem; }
.rich { border: 1.5px solid var(--line); border-radius: 10px; padding: 14px 16px; min-height: 320px; background: var(--white); line-height: 1.7; }
.rich:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.counter { font-size: .8rem; color: var(--ink-soft); text-align: right; }
.counter.over { color: var(--danger); font-weight: 700; }
.block { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px; background: #fbfdfd; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: .85rem; color: var(--ink-soft); }
.preview-frame { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); min-height: 600px; background: var(--white); }
.markdown h2 { font-size: 1.1rem; margin-top: 1.2em; }
.markdown ul { padding-left: 1.2em; }

/* ——— Réseaux sociaux : aperçu */
.social-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--white); }
.social-card .visual { background: var(--mist); aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.social-card .visual img { width: 100%; height: 100%; object-fit: cover; }
.social-card .body { padding: 14px; white-space: pre-wrap; font-size: .92rem; }
.social-card .tags { color: var(--teal); }

/* ——— Médias */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile { background: var(--white); border-radius: var(--radius); overflow: hidden; border: 2px solid transparent; position: relative; }
.media-tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--mist); }
.media-tile .meta { padding: 6px 8px; font-size: .75rem; color: var(--ink-soft); }
.media-tile.selectable { cursor: pointer; }
.media-tile.selected { border-color: var(--coral); }

/* ——— Visuels (canvas) */
.canvas-wrap { background: repeating-conic-gradient(#e6eff1 0% 25%, #f4f9fa 0% 50%) 50% / 20px 20px; border-radius: var(--radius); padding: 16px; display: flex; justify-content: center; }
.canvas-wrap canvas { max-width: 100%; height: auto; box-shadow: var(--shadow); border-radius: 4px; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); vertical-align: middle; }

/* ——— Pages d'authentification */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(circle at 85% 10%, rgba(250, 183, 12, .18), transparent 40%), var(--mist); }
.auth-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 34px 32px; width: 100%; max-width: 430px; }
.auth-card .brand-mark { margin-bottom: 22px; }
.auth-card h1 { font-size: 1.6rem; }
.checklist { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; }
.checklist .ok { color: var(--success); }
.checklist .ko { color: var(--danger); font-weight: 700; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--night); margin: 0; }

/* ——— Responsive */
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(1, 40, 52, .4); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px 50px; }
  .calendar { grid-template-columns: minmax(0, 1fr); }
  .calendar .dow, .calendar .day.out { display: none; }
  .calendar .day { min-height: 0; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  .topbar .who .name { display: none; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .bubble { max-width: 92%; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn-pulse { animation: btn-pulse 1.6s ease-in-out 3; }
@keyframes btn-pulse { 50% { box-shadow: 0 3px 0 var(--coral-dark), 0 0 0 8px rgba(255, 91, 53, .25); } }
.calendar .day.out .num { opacity: .35; }
