@font-face {
    font-family: "Familjen Grotesk";
    src: url("../fonts/familjen-grotesk.woff2") format("woff2");
    font-weight: 400 700;
    font-display: swap;
}

@font-face {
    font-family: "DSEG7";
    src: url("../fonts/dseg7.woff2") format("woff2");
    font-display: block;
}

:root {
    --paper: #e9edf1;
    --surface: #f7f9fb;
    --ink: #17283a;
    --muted: #526375;
    --line: #c6d0da;
    --action: #2346d5;
    --on-action: #fff;
    --link: var(--action);
    --action-soft: #dfe5fb;
    --panel: #14222f;
    --on-panel: #dbe4ec;
    --amber: #ffb238;
    --whatsapp: #0b7a5b;
    --form: #6a3fb5;
    --danger: #b3261e;
    --danger-soft: #fbe4e2;
    --ok-soft: #dcefe8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 1.0625rem/1.5 "Familjen Grotesk", system-ui, sans-serif;
}

h1, h2, p { margin: 0; }
h1 { font-size: 2.25rem; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; font-weight: 600; margin-block: 2rem .75rem; }
h1 a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .15em; }

a { color: var(--link); }

:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.muted { color: var(--muted); font-size: .95rem; }

/* Back-office : le rail porte l'afficheur, seul élément expressif de l'interface. */
.admin { display: grid; grid-template-columns: 13rem minmax(0, 1fr); min-height: 100vh; }

.rail {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1.25rem 1rem;
    background: var(--panel);
    color: var(--on-panel);
}

.display {
    display: block;
    padding: 1rem;
    border-radius: 6px;
    background: #0b141c;
    box-shadow: inset 0 0 0 1px #2c3e4e;
    color: var(--amber);
    text-decoration: none;
}

.display__digits {
    position: relative;
    display: block;
    font: 700 4.25rem/1 "DSEG7", monospace;
    text-align: right;
    text-shadow: 0 0 14px rgb(255 178 56 / .45);
}

/* Les segments éteints restent visibles, comme sur un vrai afficheur. */
.display__digits::before {
    content: attr(data-ghost);
    position: absolute;
    inset: 0;
    color: rgb(255 178 56 / .08);
    text-shadow: none;
}

.display__label { display: block; margin-top: .5rem; text-align: right; font-size: .9rem; }

.rail__org { padding-inline: .6rem; font-weight: 600; }
.orgs { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.orgs form { margin: 0; }
.orgs__item { display: flex; justify-content: space-between; align-items: center; gap: .5rem; width: 100%; padding: .45rem .6rem; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
button.orgs__item:hover { background: rgb(128 128 128 / .25); }
.orgs__item[aria-current] { background: rgb(128 128 128 / .3); box-shadow: inset 0 0 0 1px currentcolor; cursor: default; }
.orgs__count { min-width: 1.6rem; padding-inline: .3rem; border-radius: 3px; text-align: center; font-variant-numeric: tabular-nums; }
.orgs__count--waiting { background: var(--amber); color: #14222f; font-weight: 700; }
.public__org { margin-bottom: .75rem; color: var(--muted); font-weight: 600; font-size: 1.1rem; }
.rail__nav { display: grid; gap: .25rem; }

.rail a:not(.display) {
    padding: .45rem .6rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
}

.rail__nav a:hover { background: rgb(128 128 128 / .25); }
.rail__nav a[aria-current] { background: rgb(128 128 128 / .3); font-weight: 600; }
.rail__logout { margin-top: auto; font-size: .9rem; }
.rail :focus-visible { outline-color: var(--on-panel); }

.main { padding: 2rem clamp(1rem, 4vw, 3.5rem); max-width: 62rem; }
.main h1 { font-size: 1.5rem; }

/* L'organisation prime sur le titre de la page : c'est elle qu'on ne doit pas confondre. */
.banner { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 4px solid var(--action); }
.banner__logo { max-height: 3.5rem; max-width: 12rem; object-fit: contain; }
.banner__name { font-size: clamp(2.25rem, 5vw, 3.25rem); line-height: 1.1; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.logo-preview { display: block; max-height: 5rem; max-width: 100%; margin-bottom: 1rem; object-fit: contain; }
select { width: 100%; padding: .55rem .7rem; border: 1px solid #8a9aaa; border-radius: 4px; background: #fff; color: inherit; font: inherit; }
input[type="color"] { width: 4rem; height: 2.5rem; padding: .15rem; cursor: pointer; }

.filters { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-block: 1rem 1.5rem; border-bottom: 1px solid var(--line); }
.filters a { padding-bottom: .5rem; color: var(--muted); text-decoration: none; }
.filters a[aria-current] { color: var(--ink); font-weight: 600; box-shadow: 0 2px 0 var(--ink); }

/* Listes : des lignes, pas des cartes. La couleur de la tranche indique le canal. */
.rows { border-top: 1px solid var(--line); }

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .15rem 1rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid transparent;
    color: inherit;
    text-decoration: none;
}

.row:hover { background: var(--surface); }
.row--whatsapp { border-left-color: var(--whatsapp); }
.row--form { border-left-color: var(--form); }
.row__who { font-weight: 600; }
.row__when { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.row__what { color: var(--muted); overflow-wrap: anywhere; }
.row__what strong { color: var(--ink); font-weight: 600; }
.row__actions { display: flex; gap: .5rem; align-items: center; }
.row__actions form { margin: 0; }
.row__tags { display: flex; gap: .4rem; align-items: end; justify-content: end; }

.tag {
    padding: .05rem .5rem;
    border-radius: 3px;
    background: var(--line);
    font-size: .8rem;
    white-space: nowrap;
}

.tag--whatsapp { background: var(--ok-soft); color: #075a43; }
.tag--form { background: #e9e1f7; color: #4d2c88; }

.empty { padding: 1.5rem 1rem; color: var(--muted); }

.head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }

.thread { display: flex; flex-direction: column; gap: .75rem; margin-block: 1.75rem; }

.bubble {
    max-width: min(36rem, 88%);
    padding: .6rem .9rem;
    border-radius: 10px;
    background: var(--surface);
    overflow-wrap: anywhere;
}

.bubble--in { align-self: start; border-bottom-left-radius: 2px; }
.bubble--out { align-self: end; border-bottom-right-radius: 2px; background: var(--action-soft); }
.bubble--bot { align-self: end; border: 1px dashed var(--muted); background: transparent; }
.bubble__meta, .bubble__status { color: var(--muted); font-size: .85rem; }
.bubble__status { margin-top: .25rem; text-align: right; }
.bubble__status--failed { color: var(--danger); font-weight: 600; }

.notice { margin-block: 1rem; padding: .7rem 1rem; border-left: 4px solid var(--amber); background: #fdf1da; }

.flash { margin-bottom: 1rem; padding: .7rem 1rem; border-radius: 4px; }
.flash--success { background: var(--ok-soft); }
.flash--error { background: var(--danger-soft); color: #7c1a14; }

/* Formulaires */
form > div, form > div > div { margin-bottom: 1rem; }
label { display: block; margin-bottom: .25rem; font-weight: 600; font-size: .95rem; }

input:not([type="checkbox"]), textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid #8a9aaa;
    border-radius: 4px;
    background: #fff;
    color: inherit;
    font: inherit;
}

input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin-right: .4rem; vertical-align: -.15rem; }
input[type="checkbox"] + label { display: inline; }
.help-text, form .form-help { color: var(--muted); font-size: .9rem; }
form ul { margin: .25rem 0 0; padding: 0; list-style: none; color: var(--danger); font-size: .9rem; }

.trap { position: absolute; left: -9999px; }

.btn {
    display: inline-block;
    padding: .6rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--action);
    color: var(--on-action);
    font: 600 1rem/1.3 "Familjen Grotesk", system-ui, sans-serif;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { filter: brightness(.9); }
.btn:disabled { opacity: .7; cursor: progress; }
.btn--quiet { background: transparent; border-color: #8a9aaa; color: var(--ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--whatsapp { display: inline-flex; align-items: center; gap: .6rem; background: var(--whatsapp); color: #fff; padding: .85rem 1.5rem; font-size: 1.15rem; }

.composer { margin-bottom: 1rem; }
#messagerie { scroll-margin-top: 1rem; }
[data-pending] + .flash { margin-top: 1rem; }
.search { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-block: 1rem 1.5rem; }
.search label { width: 100%; margin: 0; }
.search input { flex: 1 1 16rem; width: auto; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2.5rem; }
.narrow { max-width: 36rem; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.danger-zone .btn { margin-top: .5rem; }

/* Pages publiques */
.public { border-top: 8px solid var(--panel); }
.public__logo { display: block; max-height: 5rem; max-width: 16rem; margin-bottom: 1.25rem; object-fit: contain; }
.public__main { max-width: 38rem; margin-inline: auto; padding: clamp(2rem, 7vw, 4.5rem) 1rem; }
.public__main--narrow { max-width: 24rem; }
.public__main--narrow h1 { margin-bottom: 1.5rem; }
.public__title { font-size: clamp(2.25rem, 7vw, 3.25rem); margin-bottom: 1.25rem; }
.lead { font-size: 1.15rem; margin-bottom: 1.25rem; max-width: 34rem; }
.public h2 { margin-top: 3rem; font-size: 1.5rem; }
.public h2 + .lead { margin-top: 0; }

/* Page de présentation : l'afficheur reste le seul élément expressif. */
.home__top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; max-width: 72rem; margin-inline: auto; padding: 1.25rem 1rem; }
.home__brand { font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(2rem, 6vw, 5rem); align-items: center; max-width: 72rem; margin-inline: auto; padding: clamp(2rem, 6vw, 5rem) 1rem; }
.hero h1 { font-size: clamp(2.5rem, 6vw, 4.25rem); line-height: 1.04; letter-spacing: -.025em; }
.hero__lead { max-width: 34rem; margin-block: 1.5rem 2rem; font-size: 1.25rem; line-height: 1.45; color: var(--muted); }
.btn--large { padding: .85rem 1.5rem; font-size: 1.15rem; }

.device { padding: 1rem; border-radius: 14px; background: var(--panel); color: #dbe4ec; box-shadow: 0 24px 48px -24px rgb(20 34 47 / .55); }
.device__display { padding: 1rem 1.25rem; border-radius: 6px; background: #0b141c; box-shadow: inset 0 0 0 1px #2c3e4e; color: var(--amber); }
.device__display .display__digits { font-size: clamp(4.5rem, 10vw, 6.5rem); }
.device__list { margin: .75rem 0 0; padding: 0; list-style: none; }
.device__list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .75rem; padding: .7rem .5rem; border-top: 1px solid #2c3e4e; }
.device__list li:first-child { border-top: 0; }
.device__list p { grid-column: 1 / -1; color: #a9bac9; font-size: .95rem; }

.steps, .sides, .closing { max-width: 72rem; margin-inline: auto; padding: clamp(2rem, 5vw, 4rem) 1rem; }
.home h2 { margin-top: 0; font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.015em; }
.steps ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(1.5rem, 4vw, 3rem); margin: 1.5rem 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; padding-top: 1rem; border-top: 3px solid var(--ink); }
.steps li::before { content: counter(step); display: block; margin-bottom: .5rem; color: var(--action); font: 700 2rem/1 "DSEG7", monospace; }
.steps h3 { margin: 0 0 .4rem; font-size: 1.2rem; }
.steps p { color: var(--muted); }
.sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(2rem, 6vw, 5rem); }
.sides ul { margin: 1rem 0 0; padding: 0; list-style: none; }
.sides li { padding-block: .65rem; border-top: 1px solid var(--line); }
.closing { padding-bottom: clamp(3rem, 8vw, 6rem); }
.closing p { margin-block: .5rem 1.5rem; font-size: 1.2rem; color: var(--muted); }

@media (max-width: 760px) {
    .hero, .sides { grid-template-columns: minmax(0, 1fr); }
    .steps ol { grid-template-columns: minmax(0, 1fr); }
    .admin { grid-template-columns: minmax(0, 1fr); }
    .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 1rem; padding: .75rem 1rem; }
    .display { padding: .4rem .6rem; }
    .display__digits { font-size: 2rem; }
    .display__label { margin-top: .15rem; font-size: .75rem; }
    .rail__nav { display: flex; flex: 1 1 auto; }
    .rail__logout { margin-top: 0; }
    .split { grid-template-columns: minmax(0, 1fr); }
    h1 { font-size: 1.85rem; }
    .main h1 { font-size: 1.35rem; }
}
