/* =============================================================================
   LaCordeilleSnap - styles du back-office (mobile d'abord)
   ============================================================================= */

:root {
    --c-bg: #f4f6fa;
    --c-surface: #ffffff;
    --c-text: #1d2433;
    --c-muted: #5b6475;
    --c-border: #dde3ee;
    --c-primary: #2f54d6;
    --c-primary-dark: #1f3a8a;
    --c-success: #1f8a4c;
    --c-success-bg: #e5f5ec;
    --c-warning: #a35b00;
    --c-warning-bg: #fff3e0;
    --c-danger: #c23030;
    --c-danger-bg: #fdecec;
    --c-info-bg: #e8eefc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--c-text); background: var(--c-bg); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
a { color: var(--c-primary); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; word-break: break-all; }
img { max-width: 100%; }

/* --- Barre supérieure ------------------------------------------------------ */
.topbar { background: var(--c-primary-dark); color: #fff; display: flex; flex-wrap: wrap; align-items: center; padding: .6rem 1rem; gap: .5rem; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.nav-toggle { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: .35rem .7rem; font: inherit; cursor: pointer; }
.main-nav { display: none; width: 100%; flex-direction: column; gap: .2rem; padding-top: .5rem; }
.main-nav.open { display: flex; }
.main-nav a, .main-nav .link-button { color: #dfe6ff; text-decoration: none; padding: .45rem .6rem; border-radius: 6px; text-align: left; }
.main-nav a:hover, .main-nav a[aria-current] { background: rgba(255,255,255,.14); color: #fff; }
.main-nav .link-button { color: #dfe6ff; }
.nav-sep { height: 1px; background: rgba(255,255,255,.2); margin: .3rem 0; }

@media (min-width: 900px) {
    .nav-toggle { display: none; }
    .main-nav { display: flex; width: auto; flex-direction: row; align-items: center; padding: 0; }
    .nav-sep { width: 1px; height: 1.4rem; margin: 0 .4rem; }
}

/* --- Mise en page ------------------------------------------------------- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.breadcrumb { margin: 0 0 .2rem; font-size: .9rem; }
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin: 0 0 1rem; }
.card-danger { border-color: #f1c4c4; }
.card-danger h2 { color: var(--c-danger); }
.grid-2 { display: grid; gap: 1rem; }
.grid-2 > .card { margin: 0; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2 + * { margin-top: 1rem; }
.narrow { max-width: 560px; }
.muted { color: var(--c-muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hint { color: var(--c-muted); font-size: .88rem; margin: -.3rem 0 .6rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline { display: inline; }

/* --- Indicateurs ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--c-muted); font-size: .88rem; }
.stat-warning { border-color: #f3c98b; background: var(--c-warning-bg); }

/* --- Formulaires ------------------------------------------------------- */
form.stack, .stack { display: flex; flex-direction: column; gap: .75rem; }
.form-grid { display: flex; flex-direction: column; gap: 0; }
fieldset { border: 1px solid var(--c-border); }
fieldset.card { padding-top: .6rem; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0 .3rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; margin-bottom: .7rem; }
.stack label { margin-bottom: 0; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
    font: inherit; font-weight: 400; color: inherit; background: #fff; border: 1px solid #c3cbdb; border-radius: 8px; padding: .6rem .7rem; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(47, 84, 214, .35); outline-offset: 1px; border-color: var(--c-primary); }
input[aria-invalid=true] { border-color: var(--c-danger); }
label.check { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; }
label.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; flex: none; }
.row { display: flex; flex-direction: column; gap: 0 1rem; }
.row-end { align-items: stretch; }
@media (min-width: 640px) {
    .row { flex-direction: row; }
    .row > label { flex: 1; }
    .row-end { align-items: flex-end; }
    .row-end > label { margin-bottom: 0; }
    .row-wrap { flex-wrap: wrap; }
    .row-wrap > label { flex: 1 1 45%; }
}
.field-error { color: var(--c-danger); font-size: .88rem; margin: -.4rem 0 .6rem; font-weight: 600; }
.stack .field-error { margin: -.4rem 0 0; }
.form-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--c-bg) 30%); padding: 1rem 0 .5rem; }
details.card summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: .8rem; }
.code-input { font-size: 1.4rem; letter-spacing: .25em; text-align: center; }

/* --- Boutons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    background: #fff; color: var(--c-text); border: 1px solid #c3cbdb; border-radius: 8px; padding: .55rem 1rem; min-height: 2.6rem; }
.btn:hover { background: #f0f3f9; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-warning { background: var(--c-warning-bg); border-color: #f3c98b; color: var(--c-warning); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #9e2222; }
.btn-small { padding: .3rem .6rem; min-height: 2rem; font-size: .88rem; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--c-primary); cursor: pointer; text-decoration: underline; }
.link-button.danger { color: var(--c-danger); font-size: .9rem; margin-top: .6rem; }

/* --- Alertes et badges ------------------------------------------------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; border: 1px solid transparent; }
.alert p { margin: 0 0 .3rem; }
.alert-success { background: var(--c-success-bg); border-color: #b7e2c8; color: #145c33; }
.alert-error { background: var(--c-danger-bg); border-color: #f1c4c4; color: #8f1f1f; }
.alert-info { background: var(--c-info-bg); border-color: #c6d4f7; color: #1f3a8a; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: #e9edf4; color: var(--c-muted); vertical-align: middle; }
.badge-success { background: var(--c-success-bg); color: var(--c-success); }
.badge-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-public { background: #f3e8ff; color: #6b21a8; }
.status { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 6px; }
.status-draft { background: #e9edf4; color: var(--c-muted); }
.status-open { background: var(--c-success-bg); color: var(--c-success); }
.status-closed { background: var(--c-info-bg); color: var(--c-primary-dark); }
.status-purged { background: #eee; color: #777; }

/* --- Tableaux ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--c-border); vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--c-muted); }
td.num, th.num { text-align: right; }
tr.inactive td { opacity: .55; }
td.actions { gap: .3rem; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.filters a { text-decoration: none; padding: .3rem .8rem; border-radius: 999px; background: #fff; border: 1px solid var(--c-border); color: var(--c-text); font-size: .9rem; }
.filters a[aria-current] { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* --- Éléments spécifiques ---------------------------------------------- */
.qr-preview { display: block; margin: .6rem auto; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; }
.url-box { background: #f4f6fa; border-radius: 6px; padding: .4rem .6rem; font-size: .85rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.details dt { color: var(--c-muted); }
.details dd { margin: 0; }
.member-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.member-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .5rem; }
.secret { letter-spacing: .08em; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Calibrage qualité et statistiques --------------------------------- */
.lab { display: grid; gap: 1rem; align-items: start; }
.lab > .card { margin: 0; }
@media (min-width: 980px) { .lab { grid-template-columns: 320px 1fr; } .lab-thresholds { position: sticky; top: 1rem; } }
.lab-input { display: flex; gap: .6rem; align-items: center; }
.lab-input input[type=range] { flex: 1; min-width: 0; accent-color: var(--c-primary); }
.lab-input input[type=number] { width: 6.5rem; flex: none; }
.lab-thresholds label { font-size: .88rem; }
.lab-summary { font-weight: 600; }
.lab-thumb { display: block; width: 96px; height: 72px; object-fit: cover; border-radius: 6px; background: #e9edf4; }
td.ko { color: var(--c-danger); font-weight: 700; }
.bar-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.bar-list li { display: grid; grid-template-columns: 11rem 1fr 3rem; gap: .6rem; align-items: center; font-size: .92rem; }
.bar-track { height: .7rem; background: #edf0f6; border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--c-primary); border-radius: 99px; }

h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
[hidden] { display: none !important; }
.choice-inline { border: 1px solid var(--c-border); border-radius: 8px; padding: .5rem .8rem; margin: 0; display: flex; flex-direction: column; gap: .2rem; }
.choice-inline legend { font-weight: 600; font-size: .95rem; padding: 0 .3rem; }
.choice-inline label.check { margin: 0; }
.export-progress { margin-top: .8rem; display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.export-progress .bar-fill { width: 0; transition: width .3s; }
.export-list { padding-left: 1.2rem; margin: .8rem 0; }
.export-list li { margin-bottom: .3rem; }

/* --- Galerie et modération ----------------------------------------------- */
.toolbar-filters { gap: 0 1rem; }
.toolbar-filters label { margin-bottom: 0; }
.toolbar-filters input[type=range] { accent-color: var(--c-primary); }
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; background: var(--c-surface);
    border: 1px solid var(--c-border); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: .8rem; box-shadow: var(--shadow); }
.bulk-bar label.check { margin: 0; font-weight: 600; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.tile { position: relative; background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.tile.selected { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(47, 84, 214, .25); }
.tile-priority { border-color: #f3c98b; }
.tile-open { display: block; width: 100%; padding: 0; border: 0; background: #e9edf4; cursor: zoom-in; aspect-ratio: 4 / 3; }
.tile-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-select { position: absolute; top: .4rem; left: .4rem; z-index: 2; margin: 0; background: rgba(255,255,255,.9); border-radius: 6px; padding: .25rem; }
.tile-select input { width: 1.2rem; height: 1.2rem; margin: 0; display: block; }
.score { position: absolute; top: .4rem; right: .4rem; font-size: .78rem; font-weight: 800; padding: .1rem .45rem; border-radius: 6px; color: #fff; }
.score-good { background: var(--c-success); } .score-mid { background: #b7791f; } .score-low { background: var(--c-danger); }
.tile-meta { display: flex; flex-direction: column; gap: .2rem; padding: .45rem .55rem; }
.status-refused .tile-open img { opacity: .55; }
.photo-detail { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1000px) { .photo-detail { grid-template-columns: 1.4fr 1fr; } }
.photo-detail .card { margin: 0 0 1rem; }
.photo-figure { position: relative; margin: 0; }
.photo-figure img { display: block; width: 100%; height: auto; border-radius: 8px; }
/* Cadre numéroté d'un visage : jaune = flouté, vert = déflouté avec consentement */
.face-box { position: absolute; border: 2px solid #ffd43b; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.5);
    color: #000; background: transparent; font-size: .75rem; font-weight: 800; line-height: 1; pointer-events: none;
    padding: .1rem .2rem; text-shadow: 0 0 2px #ffd43b, 0 0 2px #ffd43b; }
.face-box.unblurred { border-color: #2fb36b; text-shadow: 0 0 2px #2fb36b, 0 0 2px #2fb36b; }
.face-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.face-list li { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; padding-bottom: .6rem; border-bottom: 1px solid var(--c-border); }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; }
.inline-form select { width: auto; max-width: 16rem; padding: .3rem .5rem; }
.tile-link { display: inline-block; font-size: .8rem; font-weight: 600; }
.qualif { font-weight: 700; }
.qualif-unknown { color: var(--c-warning); } .qualif-yes_consent { color: var(--c-primary-dark); } .qualif-no { color: var(--c-success); }
.card-warning { border-color: #f3c98b; }
.removal-text { background: #f7f8fb; border-radius: 8px; padding: .7rem .9rem; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgba(10, 14, 26, .92); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
.lb-btn { position: fixed; background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 2rem; width: 3rem; height: 3rem; border-radius: 50%; cursor: pointer; }
.lb-btn:hover { background: rgba(255,255,255,.3); }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); } .lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-close { top: 1rem; right: 1rem; font-size: 1.3rem; }

/* --- Écrans de connexion / installation -------------------------------- */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, #e8eefc, #f4f6fa 60%); }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 14px; box-shadow: 0 8px 30px rgba(20, 30, 60, .12); padding: 1.6rem 1.4rem; }
.auth-card.wide { max-width: 620px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; color: var(--c-primary-dark); margin-bottom: 1.2rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.checklist li { display: flex; gap: .6rem; padding: .3rem 0; border-bottom: 1px dashed var(--c-border); }
.checklist .ok span:first-child { color: var(--c-success); }
.checklist .ko span:first-child { color: var(--c-danger); font-weight: 700; }
.checklist .warn span:first-child { color: var(--c-warning); font-weight: 700; }
