/* =========================================================
   Extracteur de pièces jointes — feuille de style (CSP : pas de style inline)
   Charte AXA : bleu nuit #00008F + rouge #FF1721. Contrastes AA.
   ========================================================= */
:root {
    --axa-navy: #00008F;
    --axa-navy-dark: #00005a;
    --axa-red: #FF1721;
    --ink: #0f172a;
    --muted: #4b5563;
    --border: #d9dee7;
    --bg: #f4f6fb;
    --card: #ffffff;
    --ok: #0a7a4f;
    --warn-bg: #fff7e6;
    --warn-border: #ffd98a;
    --warn-ink: #6b4e00;
    --err-bg: #ffe9eb;
    --err-ink: #9f0f17;
    --radius: 10px;
    --focus: 0 0 0 3px rgba(0, 0, 143, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.hidden { display: none !important; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; background: #eef1f7; padding: 1px 5px; border-radius: 4px; }

/* ---------- En-tête ---------- */
header.app {
    background: var(--axa-navy); color: #fff; border-top: 5px solid var(--axa-red);
    padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
header.app .brand { display: flex; align-items: baseline; gap: 12px; }
header.app .brand strong { font-size: 22px; letter-spacing: 1px; }
header.app .brand span { font-size: 14px; opacity: .92; }
.app-nav { display: flex; align-items: center; gap: 18px; }
.app-nav a { color: #fff; text-decoration: none; font-size: 13px; opacity: .92; }
.app-nav a:hover, .app-nav a:focus-visible { text-decoration: underline; opacity: 1; }
header.app .link-btn { color: #fff; }

.link-btn { background: none; border: none; color: var(--axa-navy); text-decoration: underline; font-size: 13px; padding: 4px 2px; }
.link-btn:hover { color: var(--axa-navy-dark); }

/* ---------- Boutons ---------- */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; line-height: 1.2; }
.btn-primary { background: var(--axa-navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--axa-navy-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--axa-navy); border-color: var(--axa-navy); }
.btn-secondary:hover { background: #eef1fb; }
.btn-ghost { background: transparent; color: var(--axa-navy); border-color: var(--border); }
.btn-ghost:hover { background: #eef1fb; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { color: var(--axa-navy); background: #eef1fb; border-color: var(--border); }

/* ---------- État vide : zone de dépôt ---------- */
main { min-height: calc(100vh - 56px); }
.empty { min-height: calc(100vh - 56px); display: flex; align-items: stretch; padding: 24px; }
.dropzone {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    border: 2px dashed #9aa3b8; border-radius: 16px; background: #fff; padding: 40px 24px; color: var(--muted);
    transition: border-color .15s, background .15s;
}
.dropzone.drag, body.drag .dropzone { border-color: var(--axa-navy); background: #eef1fb; }
.dropzone .drop-icon { color: var(--axa-navy); margin-bottom: 14px; }
.dropzone h1 { font-size: 22px; color: var(--ink); margin-bottom: 8px; }
.dropzone p { max-width: 560px; }
.drop-actions { display: flex; align-items: center; gap: 18px; margin: 22px 0 18px; }
.privacy { font-size: 12.5px; color: var(--muted); }
.privacy::before { content: "🔒 "; }

/* ---------- Résultats : bandeau fixe ---------- */
.results { padding: 0 0 60px; }
.toolbar {
    position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--border);
    padding: 12px 22px; box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}
.toolbar-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .field legend { font-size: 12px; font-weight: 600; color: var(--muted); }
.field em { font-style: normal; font-weight: 400; }
.field input[type="text"] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 200px; }
.field input[type="text"]:focus { border-color: var(--axa-navy); }
fieldset.weight { border: none; }
fieldset.weight label { margin-right: 12px; }
fieldset.weight small { color: var(--muted); }
.counter { font-weight: 600; color: var(--axa-navy); padding-bottom: 8px; min-width: 170px; }
.toolbar-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.progress-bar { flex: 1; height: 6px; background: #e3e7ee; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--axa-navy); transition: width .2s; }

.notice { margin-top: 10px; background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-ink); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.notice.error { background: var(--err-bg); border-color: #ffc9cf; color: var(--err-ink); }

/* ---------- Blocs email ---------- */
.emails { max-width: 1400px; margin: 0 auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.email-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.email-block.nested { border-left: 4px solid var(--axa-navy); }
.email-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.email-subject { font-size: 16px; color: var(--axa-navy); }
.email-subject .tag { display: inline-block; font-size: 11px; font-weight: 600; color: #fff; background: var(--axa-navy); border-radius: 4px; padding: 2px 6px; margin-right: 8px; vertical-align: middle; }
.email-from { color: var(--muted); font-size: 13px; }
.email-actions { display: flex; gap: 8px; flex-shrink: 0; }
.warnings { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.warnings li { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-ink); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.warnings li::before { content: "⚠ "; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid:empty { display: none; }
details { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; color: var(--axa-navy); font-size: 13.5px; }
details summary:focus-visible { box-shadow: var(--focus); border-radius: 4px; }
details .grid { margin-top: 10px; }
.file-list { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.file-list .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .f-meta { color: var(--muted); font-size: 12.5px; }

/* ---------- Vignettes ---------- */
.card { position: relative; border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.card:focus-visible { box-shadow: var(--focus); }
.card.selected { border-color: var(--axa-navy); box-shadow: inset 0 0 0 1px var(--axa-navy); }
.card-check { position: absolute; top: 6px; left: 6px; z-index: 2; background: rgba(255,255,255,.92); border-radius: 6px; padding: 4px 5px; display: flex; }
.card-check input { width: 18px; height: 18px; accent-color: var(--axa-navy); cursor: pointer; }
.card-img { aspect-ratio: 4 / 3; background: #eef1f7; display: flex; align-items: center; justify-content: center; cursor: zoom-in; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img .spinner { width: 26px; height: 26px; border: 3px solid #c7cddb; border-top-color: var(--axa-navy); border-radius: 50%; animation: spin .8s linear infinite; }
.card-img .err { color: var(--err-ink); font-size: 12.5px; padding: 10px; text-align: center; }
.card.error .card-img { background: var(--err-bg); cursor: default; }
@keyframes spin { to { transform: rotate(360deg); } }
.card figcaption { padding: 8px 10px 8px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-info { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.badge { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--axa-navy); background: #eef1fb; border-radius: 4px; padding: 1px 6px; }
.badge:empty { display: none; }
.badge.converted { color: #fff; background: var(--axa-navy); }
.card-actions { display: flex; gap: 4px; margin-top: 2px; }
.card-status { font-size: 12px; color: var(--muted); }

.drop-more { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; }

/* ---------- Dialogue d'aide ---------- */
.dialog { border: none; border-radius: 12px; padding: 0; max-width: 620px; width: calc(100% - 32px); box-shadow: 0 30px 60px rgba(6,22,51,.4); }
.dialog::backdrop { background: rgba(6, 22, 51, .55); }
.dialog-card { padding: 24px 26px 20px; }
.dialog-card h2 { font-size: 18px; color: var(--axa-navy); margin-bottom: 10px; }
.dialog-card p { margin-bottom: 10px; }
.dialog-card dl { margin: 12px 0; }
.dialog-card dt { font-weight: 700; margin-top: 10px; }
.dialog-card dd { margin: 2px 0 0; color: #1f2937; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ---------- Aperçu grand format ---------- */
.preview { position: fixed; inset: 0; z-index: 50; background: rgba(6, 22, 51, .92); display: flex; align-items: center; justify-content: center; }
.preview-figure { max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview-img-wrap { max-width: 92vw; max-height: 78vh; display: flex; align-items: center; justify-content: center; }
.preview-img-wrap img { max-width: 92vw; max-height: 78vh; object-fit: contain; background: #fff; border-radius: 4px; }
.preview-caption { color: #fff; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; font-size: 13.5px; }
.preview-caption .preview-hint { opacity: .75; font-size: 12px; }
.preview-check { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 6px; }
.preview-check input { width: 16px; height: 16px; accent-color: #fff; }
.preview-close, .preview-nav { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; width: 44px; height: 44px; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.preview-close { top: 16px; right: 16px; font-size: 18px; }
.preview-nav.prev { left: 16px; }
.preview-nav.next { right: 16px; }
.preview-close:hover, .preview-nav:hover { background: rgba(255,255,255,.25); }
.preview-close:focus-visible, .preview-nav:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.6); }

@media (max-width: 900px) {
    .toolbar-actions { margin-left: 0; }
    .email-head { flex-direction: column; }
}
.card-img { position: relative; }
.card-img .spinner-overlay { position: absolute; right: 8px; bottom: 8px; width: 20px; height: 20px; border-width: 3px; background: rgba(255,255,255,.85); }
