/*
 * ============================================================
 *  FARMAI ADMIN : STYLE
 * ============================================================
 *  Reprend l'identité de farmai.ag (couleurs, polices, boutons
 *  en pilule, cartes arrondies). Les couleurs sont toutes
 *  définies dans ":root" ci-dessous.
 * ============================================================
 */

/* ---------- Polices FarmAI (hébergées avec l'admin) ---------- */
@font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url(../fonts/plusjakartasans-normal-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url(../fonts/plusjakartasans-normal-latin-ext.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/instrumentsans-normal-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/instrumentsans-normal-latin-ext.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Couleurs et mesures (identiques à farmai.ag) ---------- */
:root {
    --ink: #15241f;
    --forest: #1d3a30;
    --forest-2: #274a3d;
    --forest-3: #345b4b;
    --moss: #5d7a4a;
    --moss-text: #46622f;
    --vert-vif: #6cbf3a;
    --sage: #c9d3bd;
    --sage-soft: #e3e8d9;
    --ivory: #f6f1e6;
    --paper: #fcfaf5;
    --sand: #ece3cf;
    --straw: #e7b75f;
    --straw-soft: #f4dfb1;
    --clay: #954020;
    --muted: #4d5a53;
    --danger: #a3261d;
    --danger-soft: #f7e1dc;
    --line: rgba(21, 36, 31, .13);

    --font-display: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --radius: 18px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(21,36,31,.06), 0 12px 32px -12px rgba(21,36,31,.18);
    --ease: cubic-bezier(.2, .7, .2, 1);
    --hauteur-entete: 72px;
}

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

body {
    margin: 0;
    background: var(--ivory);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0 0 .5em;
}
h1 { font-size: clamp(1.75rem, 1.45rem + 1.2vw, 2.4rem); }
h1 em { font-style: normal; color: var(--moss); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--forest); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--straw); outline-offset: 3px; border-radius: 4px; }
code { font-size: .92em; background: var(--sage-soft); padding: .1em .35em; border-radius: 6px; }

.visuellement-cache {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.lien-evitement {
    position: absolute; left: 12px; top: -60px; z-index: 200;
    background: var(--forest); color: var(--ivory); padding: 10px 16px; border-radius: 8px;
}
.lien-evitement:focus { top: 12px; }

.petit { font-size: .9rem; }
.discret { color: var(--muted); }
.intro { font-size: 1.15rem; color: var(--muted); max-width: 720px; }

/* Petite étiquette en capitales, ocre, précédée d'un trait vert */
.surtitre {
    display: inline-flex; align-items: center; gap: .6em;
    font-size: .82rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--clay); margin-bottom: .8em;
}
.surtitre::before { content: ""; width: 22px; height: 2px; background: var(--moss); border-radius: 2px; }

/* ---------- En-tête ---------- */
.entete {
    position: sticky; top: 0; z-index: 100;
    background: var(--forest);
    color: var(--ivory);
    box-shadow: 0 2px 10px rgba(21,36,31,.25);
}
.entete__interieur {
    display: flex; align-items: center; gap: 18px;
    max-width: 1280px; margin: 0 auto; padding: 0 20px;
    min-height: var(--hauteur-entete);
}
.entete__marque { display: flex; align-items: center; gap: 14px; color: var(--ivory); text-decoration: none; }
.entete__marque img { width: 104px; height: auto; }
.entete__titres { display: flex; flex-direction: column; line-height: 1.2; border-left: 1px solid rgba(246,241,230,.25); padding-left: 14px; }
.entete__surtitre { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--straw); font-weight: 600; }
.entete__projet { font-family: var(--font-display); font-weight: 650; font-size: 1.05rem; }

/* Badge d'environnement (TEST / PRODUCTION) sur les cartes et les actions */
.badge-env {
    display: inline-block;
    padding: .3em .8em;
    border-radius: 999px;
    font-size: .75rem; font-weight: 700; letter-spacing: .08em;
    white-space: nowrap;
}
.badge-env--test  { background: var(--straw); color: var(--ink); }
.badge-env--prod  { background: var(--vert-vif); color: var(--ink); }
.badge-env--local { background: var(--sage); color: var(--ink); }
main .badge-env--prod { background: var(--forest); color: var(--ivory); }

/* ---------- Menu ---------- */
.menu { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.menu__liste { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.menu__compte { display: flex; align-items: center; gap: 4px; padding-left: 12px; border-left: 1px solid rgba(246,241,230,.25); }
.menu__compte form { margin: 0; }
.menu__lien {
    display: inline-flex; align-items: center; gap: .4em;
    min-height: 40px; padding: 0 12px;
    border-radius: 999px;
    color: var(--ivory); text-decoration: none; font-weight: 500; font-size: .93rem;
    white-space: nowrap;
}
.menu__lien:hover { background: rgba(246,241,230,.1); }
.menu__lien[aria-current="page"] { background: var(--ivory); color: var(--forest); }
.menu__bouton { background: none; border: 0; font: inherit; cursor: pointer; }
.pastille {
    font-size: .7rem; font-weight: 700; padding: .1em .55em; border-radius: 999px;
    background: var(--straw); color: var(--ink);
}

.entete__burger {
    display: none; margin-left: auto;
    width: 44px; height: 44px; border-radius: 999px;
    background: transparent; border: 1.5px solid rgba(246,241,230,.45); color: var(--ivory);
    cursor: pointer;
}
.entete__burger span, .entete__burger span::before, .entete__burger span::after {
    display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; margin: 0 auto; position: relative;
}
.entete__burger span::before, .entete__burger span::after { content: ""; position: absolute; left: 0; }
.entete__burger span::before { top: -6px; }
.entete__burger span::after { top: 6px; }

/* ---------- Contenu ---------- */
.contenu { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 36px 20px 56px; }
.contenu--etroit { max-width: 560px; padding-top: 56px; }
.titre-section { margin-top: 2.2rem; }
.fil { margin-bottom: .5rem; }
.entete-page { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 1.5rem; }
.entete-page h1 { margin: 0; }

.pied { text-align: center; padding: 20px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
.pied p { margin: 0; }

/* ---------- Grilles et cartes ---------- */
.grille { display: grid; gap: 20px; }
@media (min-width: 760px) {
    .grille--2 { grid-template-columns: repeat(2, 1fr); }
    .grille--3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1040px) {
    .grille--3 { grid-template-columns: repeat(3, 1fr); }
}

.carte {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.carte > :last-child { margin-bottom: 0; }
.carte--info { background: var(--sage-soft); box-shadow: none; }
.carte--connexion { padding: 32px; }
.carte__entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: .6rem; }
.carte__entete h3 { margin: 0; }
.carte--lien {
    position: relative; display: block; color: inherit; text-decoration: none;
    transition: transform .2s var(--ease), box-shadow .2s;
}
.carte--lien:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(21,36,31,.06), 0 20px 40px -16px rgba(21,36,31,.3); }
.carte--lien p { color: var(--muted); margin-bottom: 1.6rem; }
.carte__fleche { position: absolute; right: 24px; bottom: 18px; font-size: 1.3rem; color: var(--moss); transition: transform .2s var(--ease); }
.carte--lien:hover .carte__fleche { transform: translateX(4px); }

/* ---------- Boutons (pilules, comme sur farmai.ag) ---------- */
.bouton {
    --fond: var(--forest); --texte: var(--ivory);
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    min-height: 46px; padding: .7em 1.3em;
    background: var(--fond); color: var(--texte);
    border: 1.5px solid var(--fond); border-radius: 999px;
    font: 600 1rem/1.1 var(--font-body);
    text-decoration: none; cursor: pointer;
    transition: transform .2s var(--ease), background-color .2s, border-color .2s, box-shadow .2s;
}
.bouton:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -10px rgba(21,36,31,.55); }
.bouton--principal:hover { --fond: var(--forest-2); }
.bouton--secondaire { background: transparent; color: var(--ink); border-color: rgba(21,36,31,.35); }
.bouton--secondaire:hover { border-color: var(--ink); }
.bouton--danger { --fond: var(--danger); --texte: #fff; }
.bouton--petit { min-height: 36px; padding: .45em 1em; font-size: .9rem; }
.bouton--large { width: 100%; }
.bouton--lien {
    background: none; border: 0; padding: 0; min-height: 0; color: var(--forest);
    text-decoration: underline; font-weight: 500; margin-top: 1rem;
}
.bouton--lien:hover { transform: none; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---------- Messages ---------- */
.alerte { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 1.2rem; font-weight: 500; }
.alerte--succes { background: var(--sage-soft); color: var(--forest); border-left: 4px solid var(--vert-vif); }
.alerte--erreur { background: var(--danger-soft); color: var(--danger); border-left: 4px solid var(--danger); }
.alerte--info   { background: var(--straw-soft); color: var(--ink); border-left: 4px solid var(--straw); }

/* Petits états : Activée, En attente, Échec... */
.etat {
    display: inline-block; padding: .15em .7em; border-radius: 999px;
    font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.etat--ok      { background: var(--sage-soft); color: var(--moss-text); }
.etat--attente { background: var(--straw-soft); color: #6b4a12; }
.etat--erreur  { background: var(--danger-soft); color: var(--danger); }
.etat--info    { background: var(--sand); color: var(--muted); }

/* ---------- Formulaires ---------- */
.formulaire { margin-bottom: 1rem; }
.champ { margin-bottom: 1.1rem; }
.champ label { display: block; font-weight: 600; margin-bottom: .35rem; }
.champ input[type="text"],
.champ input[type="email"],
.champ input[type="password"],
.champ select,
.champ textarea {
    width: 100%; min-height: 46px; padding: .6em .9em;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    background: var(--paper); color: var(--ink); font: inherit;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--straw-soft);
}
.champ--erreur input, .champ--erreur select { border-color: var(--danger); }
.champ__erreur { color: var(--danger); font-size: .9rem; margin: .35rem 0 0; }
.champ .petit { margin: .35rem 0 0; }
.champ--case { display: flex; align-items: center; gap: .6em; }
.champ--case label { margin: 0; font-weight: 500; }
.champ--case input { width: 20px; height: 20px; accent-color: var(--forest); }
.champ-code { max-width: 240px; font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Double authentification ---------- */
.etapes { padding-left: 1.3em; }
.etapes li { margin-bottom: .8em; }
.qr { margin: .8rem 0; display: block; width: fit-content; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qr img, .qr svg { width: 200px; height: 200px; }
.cle-secrete { display: inline-block; letter-spacing: .1em; word-break: break-all; }

/* ---------- Installation ---------- */
.verifications { list-style: none; padding: 0; }
.verifications li { padding: .45em 0; border-bottom: 1px solid var(--line); }
.verifications .etat { min-width: 84px; text-align: center; margin-right: .5em; }

/* ---------- Tableaux ---------- */
.tableau-conteneur { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; }
.tableau th, .tableau td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tableau th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--paper); }
.tableau tbody tr:last-child td { border-bottom: 0; }
.tableau tbody tr:hover { background: var(--paper); }
.tableau--compact th, .tableau--compact td { padding: 10px 14px; font-size: .92rem; }
.tableau__actions { text-align: right; white-space: nowrap; }
.ligne--inactive td { color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 1.5rem; }

/* Écran moyen : on resserre l'en-tête pour que tout tienne */
@media (max-width: 1360px) {
    .entete__surtitre { display: none; }
    .entete__interieur { gap: 12px; }
    .menu { gap: 6px; }
    .menu__liste { gap: 0; }
    .menu__compte { padding-left: 6px; }
}

/* ============================================================
 *  TÉLÉPHONE ET TABLETTE
 * ============================================================ */
@media (max-width: 1240px) {
    .entete__burger { display: block; }
    .menu {
        display: none;
        position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--forest); padding: 8px 12px 16px;
        box-shadow: 0 12px 24px rgba(21,36,31,.3);
    }
    .menu.est-ouvert { display: flex; }
    .menu__liste { flex-direction: column; }
    .menu__compte { flex-direction: column; align-items: stretch; border-left: 0; border-top: 1px solid rgba(246,241,230,.25); padding: 8px 0 0; margin-top: 8px; }
    .menu__lien { width: 100%; min-height: 48px; }
}

@media (max-width: 640px) {
    .entete__interieur { gap: 10px; padding: 0 14px; }
    .entete__marque img { width: 84px; }
    .entete__surtitre { display: none; }
    .entete__titres { padding-left: 10px; }
    .contenu { padding: 24px 16px 40px; }
    .carte, .carte--connexion { padding: 20px; }

    /* Les tableaux deviennent des fiches */
    .tableau-conteneur { background: transparent; box-shadow: none; }
    .tableau, .tableau tbody, .tableau tr, .tableau td { display: block; width: 100%; }
    .tableau thead { display: none; }
    .tableau tr { background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow); margin-bottom: 12px; padding: 8px 0; }
    .tableau td { border: 0; padding: 6px 16px; }
    .tableau td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
    .tableau__actions { text-align: left; }
}

/* ============================================================
 *  PAGE VERSIONS
 * ============================================================ */
.version-en-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: .3rem; font-size: 1.05rem; }
.version-titre { font-weight: 600; margin-bottom: .3rem; }
.etiquette {
    display: inline-block; padding: .1em .6em; border-radius: 999px;
    background: var(--sand); color: var(--clay); font-size: .78rem; font-weight: 700;
}
.badge-env--mini { font-size: .68rem; padding: .2em .65em; margin-left: 4px; vertical-align: middle; }
.lien-discret { color: var(--muted); font-size: .92rem; }
.comparaison {
    margin-top: 20px; padding: 14px 20px; border-radius: var(--radius-sm);
    background: var(--sage-soft); color: var(--forest); font-weight: 500;
}
.comparaison--ecart { background: var(--straw-soft); color: var(--ink); }
.erreur-detail { color: var(--danger); margin: .3rem 0; max-width: 320px; }

/* Confirmation */
.recap { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0 0 1.4rem; }
.recap dt { font-weight: 600; color: var(--muted); }
.recap dd { margin: 0; }
.liste-versions { list-style: none; padding: 0; margin-bottom: 1.4rem; }
.liste-versions li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.choix-versions { border: 0; padding: 0; margin: 0 0 1.2rem; }
.choix-version {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--paper);
}
.choix-version:has(input:checked) { border-color: var(--forest); background: var(--sage-soft); }
.choix-version input { margin-top: .35em; accent-color: var(--forest); width: 18px; height: 18px; }
.champ-confirmation { max-width: 280px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
h1 .badge-env { vertical-align: middle; font-size: .8rem; margin-left: 8px; }
.carte h2 { font-size: 1.15rem; }

@media (max-width: 640px) {
    .recap { grid-template-columns: 1fr; gap: 2px; }
    .recap dd { margin-bottom: 10px; }
}

/* ============================================================
 *  PAGE BASE DE DONNÉES
 * ============================================================ */
.bloc-actions { margin-bottom: 1.2rem; }
.bloc-actions form { margin: 0; }
.titre-script { font-size: clamp(1.2rem, 1rem + 1vw, 1.7rem); word-break: break-all; }
.code-sql {
    background: var(--ink); color: #e9efe4; border-radius: var(--radius);
    padding: 20px 22px; overflow-x: auto; font-size: .9rem; line-height: 1.55;
    box-shadow: var(--shadow);
}
.code-sql code { background: none; padding: 0; color: inherit; font-size: inherit; }
.sql-mot { color: var(--straw); font-weight: 600; }
.sql-texte { color: #a9d68b; }
.sql-nom { color: #9fd0e6; }
.sql-nombre { color: #f0a988; }
.sql-commentaire { color: #8fa197; font-style: italic; }
.liste-versions li .etat { margin-left: 6px; }
.liste-versions ul { margin: .3rem 0 0; }

/* ============================================================
 *  PAGE SUPPORT
 * ============================================================ */
.pastille-compteur {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
    border-radius: 999px; background: var(--clay); color: #fff;
    font-size: .72rem; font-weight: 700; line-height: 1;
}
.menu__lien .pastille-compteur { background: var(--straw); color: var(--ink); }
.ligne--non-lue td { background: var(--straw-soft); }
.ligne--non-lue a { font-weight: 700; }
.filtres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1rem; }
.filtre {
    padding: .4em 1em; border-radius: 999px; border: 1.5px solid var(--line);
    text-decoration: none; color: var(--ink); font-size: .92rem; background: #fff;
}
.filtre[aria-current="page"] { background: var(--forest); border-color: var(--forest); color: var(--ivory); }
.formulaire--large { max-width: 900px; }
.grille--serree { gap: 0 16px; }
.champ--bas { align-self: end; padding-bottom: 12px; }
.champ textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.champ input[type="file"] { display: block; width: 100%; padding: 10px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.titre-ticket { margin-bottom: .3rem; }
.meta-ticket { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 1.5rem; }

.ticket { display: grid; gap: 20px; align-items: start; }
@media (min-width: 1000px) {
    .ticket { grid-template-columns: minmax(0, 1fr) 320px; }
}
.fil-messages { display: flex; flex-direction: column; gap: 14px; }
.message { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; border-left: 4px solid var(--sage); }
.message--farmai { border-left-color: var(--forest); background: var(--paper); }
.message--interne { border-left-color: var(--straw); background: var(--straw-soft); box-shadow: none; }
.message__entete { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: .6rem; }
.message__entete .pastille { background: var(--forest); color: var(--ivory); }
.message__texte { overflow-wrap: anywhere; }
.pieces { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-direction: column; gap: 4px; }
.pieces a { font-weight: 600; }
.contexte dl { margin: 0 0 1rem; font-size: .9rem; }
.contexte dt { font-weight: 600; color: var(--muted); margin-top: .6rem; }
.contexte dd { margin: 0; overflow-wrap: anywhere; }
