/* ───────── Charte FoodChain ID ───────── */
:root {
    --brand: #00596b;
    --brand-2: #007681;
    --sky: #38b6cc;
    --light: #d5f5fe;
    --accent: #ffd900;
    --ink: #1a1a1a;
    --muted: #5e6b70;
    --line: #dde3e5;
    --bg: #f3f6f7;
    --card: #ffffff;
    --ok: #13795b;
    --ok-bg: #e3f5ee;
    --warn: #8a5a00;
    --warn-bg: #fff4d1;
    --err: #b42318;
    --err-bg: #fde8e6;
    --li-blue: #0a66c2;
    --radius: 10px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; color: var(--brand); }
h2 { font-size: 1.1rem; margin: 0 0 .7em; }
h3 { font-size: 1rem; margin: 0 0 .5em; }
code { background: var(--light); color: var(--brand); padding: .1em .35em; border-radius: 4px; font-size: .88em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
img { max-width: 100%; }

/* ───────── Formulaires & boutons ───────── */
input, select, textarea {
    font: inherit; color: inherit; width: 100%;
    padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--sky); }
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
label.inline { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; }
label.inline select { width: auto; margin: 0; }
label.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.checkbox input { width: auto; margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--brand);
    background: #fff; color: var(--brand); font: 600 .9rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--light); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { border-color: var(--err); color: var(--err); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn.is-blocked { background: #c9d2d4; border-color: #c9d2d4; color: #fff; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-2); font: inherit; cursor: pointer; text-decoration: underline; }
.linkbtn.danger { color: var(--err); }

.badge {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px; font: 600 .75rem var(--font);
    border: 0; background: var(--light); color: var(--brand); cursor: default;
}
button.badge { cursor: pointer; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: #eceff0; color: var(--muted); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-info { background: var(--light); color: var(--brand); }

/* ───────── Mise en page ───────── */
.topbar {
    display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem;
    background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.brand-mark { background: var(--accent); color: var(--brand); font-weight: 800; border-radius: 4px; padding: 0 .35rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { padding: .35rem .8rem; border-radius: 999px; opacity: .85; }
.mainnav a:hover, .mainnav a.is-active { background: rgba(255,255,255,.15); opacity: 1; }
.usermenu { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.usermenu form { margin: 0; }
.usermenu .linkbtn { color: #fff; }
.subnav { display: flex; gap: .25rem; padding: .5rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subnav a { padding: .3rem .8rem; border-radius: 999px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.subnav a.is-active { background: var(--light); color: var(--brand); font-weight: 600; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 560px; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row form { margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1; min-width: 120px; }
.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: .45rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; align-items: end; }
.grid-form .span-2 { grid-column: span 2; }
.prefix { color: var(--muted); font-weight: 700; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table th, .table td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table form { margin: 0; }
.table input { padding: .35rem .5rem; width: auto; }
.table input.grow { width: 100%; }
tr.is-disabled, .is-disabled { opacity: .5; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); margin: 0; }
.stat strong { font-size: 2rem; color: var(--brand); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

/* ───────── Authentification ───────── */
.page-auth main { display: grid; place-items: center; min-height: calc(100vh - 60px); }
.auth-card { background: #fff; border-radius: 14px; padding: 2.2rem; width: min(440px, 100%); box-shadow: 0 10px 40px rgba(0, 89, 107, .12); border-top: 6px solid var(--accent); }
.lead { font-size: 1.05rem; }

/* ───────── Liste des posts ───────── */
.post-list { display: grid; gap: .8rem; }
.post-item { display: flex; gap: 1rem; align-items: flex-start; margin: 0; }
.post-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.post-main { flex: 1; min-width: 0; }
.post-main h2 { margin: 0; font-size: 1.05rem; }
.post-main h2 a { color: var(--ink); text-decoration: none; }
.excerpt { white-space: pre-line; color: #333; margin: .4rem 0; font-size: .9rem; }
.post-actions { display: flex; flex-direction: column; gap: .4rem; }
.empty { text-align: center; padding: 3rem; }

/* ───────── Admin images ───────── */
.admin-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.admin-image { display: grid; gap: .5rem; margin: 0; }
.admin-image img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: var(--bg); }

/* ───────── Studio (éditeur) ───────── */
.studio {
    display: grid; gap: 1.25rem; padding: 1.25rem; align-items: start;
    grid-template-columns: minmax(400px, 1.1fr) minmax(380px, 1fr) minmax(250px, 300px);
}
.pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; min-width: 0; }
.pane-preview { background: #f4f2ee; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.pane-library { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.pane-head { display: grid; gap: .75rem; margin-bottom: .75rem; }
.title-input { font-size: 1.1rem; font-weight: 600; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; padding: .3rem 0; }
.title-input:focus { outline: 0; border-bottom-color: var(--brand); }

.segmented { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: none; padding: .35rem 1rem; border-radius: 999px; font: 600 .85rem var(--font); color: var(--muted); cursor: pointer; }
.segmented button.is-active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmented.small button { padding: .25rem .7rem; font-size: .78rem; }

.toolbar { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; padding: .35rem; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: #fafbfb; }
.toolbar button { border: 0; background: none; padding: .35rem .6rem; border-radius: 6px; font: .85rem var(--font); cursor: pointer; color: var(--ink); }
.toolbar button:hover { background: var(--light); }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 .25rem; }

.li-compose { border: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 1rem; }
.li-author { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.li-author small { display: block; color: var(--muted); font-size: .75rem; }
.avatar {
    width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand), var(--sky)); color: #fff; font-weight: 700;
}
.ta-wrap { position: relative; }
#body {
    border: 0; padding: 0; resize: none; min-height: 260px; overflow: hidden;
    font: 14px/20px -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: rgba(0,0,0,.9);
}
#body:focus { outline: 0; }

.autocomplete {
    position: absolute; z-index: 30; list-style: none; margin: 0; padding: .3rem 0; width: 280px; max-height: 300px; overflow: auto;
    background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.ac-item { padding: .45rem .8rem; cursor: pointer; }
.ac-item small { display: block; color: var(--muted); font-size: .75rem; }
.ac-item.is-active, .ac-item:hover { background: var(--light); }
.ac-note { padding: .3rem .8rem; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.ac-warn { color: var(--warn); background: var(--warn-bg); text-transform: none; letter-spacing: 0; }

/* Indicateurs de conformité */
.checks { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin: 1rem 0; padding: .8rem; background: #fafbfb; border-radius: 8px; border: 1px solid var(--line); }
.checks.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.meter { display: flex; align-items: center; gap: .5rem; padding: .3rem .7rem; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: .85rem; }
.meter.is-ok { background: var(--ok-bg); color: var(--ok); }
.meter.is-error { background: var(--err-bg); color: var(--err); }
.meter-dots { display: inline-flex; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.dot.on { background: currentColor; }
.dot.over { background: var(--err); border-color: var(--err); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-missing { background: var(--err-bg); color: var(--err); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.charcount { margin-left: auto; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.charcount.is-over { color: var(--err); font-weight: 700; }
.issues { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: .3rem; }
.issue { font-size: .85rem; padding: .3rem .6rem; border-radius: 6px; border-left: 3px solid; }
.issue-ok { color: var(--ok); background: var(--ok-bg); }
.issue-warn { color: var(--warn); background: var(--warn-bg); }
.issue-error { color: var(--err); background: var(--err-bg); }
.issue-info { color: var(--brand); background: var(--light); }
.ac-new { color: var(--brand); background: var(--light); text-transform: none; letter-spacing: 0; }

.media-panel { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.selected-image { display: grid; grid-template-columns: 140px 1fr; gap: 1rem; align-items: start; }
.selected-image > img { width: 140px; border-radius: 6px; }
.selected-image > p { grid-column: 1 / -1; }

.slides { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .6rem; counter-reset: slide; }
.slide { display: grid; grid-template-columns: 72px 1fr auto; gap: .6rem; align-items: start; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; counter-increment: slide; }
.slide-thumb { width: 72px; aspect-ratio: 4/5; border-radius: 6px; overflow: hidden; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: .75rem; position: relative; }
.slide-thumb::before { content: counter(slide); position: absolute; top: 3px; left: 3px; background: var(--accent); color: var(--brand); font-weight: 700; font-size: .7rem; border-radius: 4px; padding: 0 .3rem; }
.slide-thumb img { width: 100%; height: 100%; object-fit: cover; }
.slide-fields { display: grid; gap: .35rem; }
.slide-fields input, .slide-fields textarea, .slide-fields select { padding: .35rem .5rem; font-size: .85rem; }
.slide-opts { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.slide-tools { display: flex; flex-direction: column; gap: .2rem; }
.slide-tools button { border: 1px solid var(--line); background: #fff; border-radius: 4px; width: 28px; height: 26px; cursor: pointer; }
.slide-tools button:disabled { opacity: .3; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.actions #copy { margin-left: auto; }

/* ───────── Aperçu LinkedIn ───────── */
.feed { display: flex; justify-content: center; padding: .5rem 0 1rem; }
.li-post {
    width: 100%; max-width: 555px; background: #fff; border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(140,140,140,.2), 0 2px 3px rgba(0,0,0,.05);
    font: 14px/20px -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: rgba(0,0,0,.9);
    transition: max-width .2s;
}
.li-post.is-mobile { max-width: 360px; }
.li-post-head { display: flex; gap: .5rem; padding: 12px 16px 0; align-items: flex-start; }
.li-post-head strong { font-weight: 600; }
.li-post-head small { display: block; color: rgba(0,0,0,.6); font-size: 12px; line-height: 16px; }
.li-post-head > div { flex: 1; min-width: 0; }
.li-follow { color: var(--li-blue); font-weight: 600; white-space: nowrap; }
.li-text-wrap { padding: 8px 16px 8px; position: relative; }
.li-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.li-text.is-clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.li-more { background: #fff; border: 0; color: rgba(0,0,0,.6); font: inherit; cursor: pointer; padding: 0; float: right; }
.li-more:hover { color: var(--li-blue); text-decoration: underline; }
.li-link, .li-hashtag { color: var(--li-blue); font-weight: 600; text-decoration: none; }
.li-hashtag.is-invalid { color: var(--err); text-decoration: underline wavy var(--err); }
.li-media { clear: both; }
.li-media img { display: block; width: 100%; }
.li-social { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 12px; color: rgba(0,0,0,.6); border-bottom: 1px solid #e8e8e8; }
.li-actions { display: flex; justify-content: space-around; padding: 4px 8px; font-weight: 600; color: rgba(0,0,0,.6); font-size: 13px; }
.li-actions span { padding: 10px 6px; }

.li-doc { background: #1d2226; }
.li-doc-head { color: #fff; font-size: 12px; padding: 6px 12px; background: rgba(0,0,0,.6); }
.li-doc-stage { position: relative; background: #000; }
.li-doc-stage img { width: 100%; height: 100%; object-fit: contain; }
.li-doc-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 22px; cursor: pointer; }
.li-doc-nav:disabled { display: none; }
.li-doc-nav.prev { left: 8px; }
.li-doc-nav.next { right: 8px; }
.li-doc-foot { color: #fff; font-size: 12px; text-align: center; padding: 4px; }

/* ───────── Bibliothèque ───────── */
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; margin-top: .5rem; }
.tile { margin: 0; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: var(--bg); }
.tile.is-selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--accent); }
.tile-pick { display: block; width: 100%; padding: 0; border: 0; cursor: pointer; background: none; }
.tile-pick img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .15s; }
.tile-pick:hover img { transform: scale(1.04); }
.tile figcaption { display: flex; justify-content: space-between; gap: .3rem; padding: .3rem .4rem; font-size: .75rem; }
.tile figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile figcaption a { text-decoration: none; }

/* ───────── Modale lien ───────── */
.dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog::backdrop { background: rgba(0, 40, 50, .45); }
.dialog-inner { padding: 1.25rem; display: grid; gap: .8rem; }
.link-results { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.link-results li { border-bottom: 1px solid var(--line); }
.link-results li.muted { padding: 1rem; }
.link-results button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: .55rem .8rem; cursor: pointer; font: inherit; }
.link-results button:hover { background: var(--light); }
.link-results small { display: block; color: var(--muted); font-size: .78rem; }

/* ───────── Toast ───────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 150%); z-index: 100; max-width: min(560px, calc(100vw - 32px));
    padding: .8rem 1.2rem; border-radius: 8px; background: var(--ink); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.25);
    transition: transform .25s;
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast-success { background: var(--ok); }
.toast-error { background: var(--err); }

/* ───────── Responsive ───────── */
@media (max-width: 1320px) {
    .studio { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
    .pane-library { grid-column: 1 / -1; position: static; max-height: none; }
    .library-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 900px) {
    .studio { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
    .pane-preview { position: static; max-height: none; }
    .topbar { flex-wrap: wrap; gap: .5rem 1rem; }
    .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .grid-form .span-2 { grid-column: auto; }
    .post-item { flex-wrap: wrap; }
    .post-actions { flex-direction: row; }
    .selected-image { grid-template-columns: 1fr; }
    .actions #copy { margin-left: 0; }
}
