/* Deebee Labs — Gravure personnalisée */
@font-face {
    font-family: 'Stencil Militaire';
    src: url("../fonts/SairaStencilOne-Regular-gp190FP.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Plaque Sans';
    src: url("../fonts/NotoSans-Regular-6fnauW9.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Gravure Fallback';
    src: url("../fonts/DejaVuSans-lpQarYT.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Plaque Mono';
    src: url("../fonts/JetBrainsMono-Regular-N4w31-R.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Gunplay';
    src: url("../fonts/Gunplay-Regular-PBthhXk.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Capture It';
    src: url("../fonts/CaptureIt-b2Yeyb0.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Army Rust';
    src: url("../fonts/ArmyRust-F8HF7Pc.ttf") format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Boston Traffic';
    src: url("../fonts/BostonTraffic-ncj1Bxe.ttf") format('truetype');
    font-display: swap;
}

:root {
    --bg: #f2efe7;
    --card: #fbfaf6;
    --border: #d9d4c5;
    --ink: #2b2b25;
    --muted: #6f6f60;
    --accent: #6d7a3a;
    --accent-dark: #57632c;
    --accent-soft: #eef0df;
    --danger: #a03a2c;
    --sidebar: #303a33;
    --sidebar-ink: #e8e6da;
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-display: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
/* L'attribut hidden doit primer sur les display flex/grid du projet. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a { color: var(--accent-dark); }

/* ---------- En-tête public ---------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}
.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--ink);
}
.brand-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 2px solid var(--accent-dark);
    border-radius: 50%;
    color: var(--accent-dark);
    font-size: 1.1rem;
}
.brand-text { font-family: var(--font-display); font-weight: 700; letter-spacing: .04em; line-height: 1.1; }
.brand-text small { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); }
.site-nav { display: flex; gap: 1.2rem; }
.site-nav a {
    text-decoration: none;
    color: var(--ink);
    padding-bottom: .15rem;
    border-bottom: 2px solid transparent;
}
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }

.site-main { max-width: 1180px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.site-footer {
    padding: 1.2rem;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    border-top: 1px solid var(--border);
}

.page-intro h1 { margin: .2rem 0 .2rem; font-size: 1.5rem; font-family: var(--font-display); }
.page-intro p { max-width: 60ch; color: var(--muted); font-size: .92rem; margin: 0 0 .7rem; }

/* ---------- Cartes & champs ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem .9rem;
    margin-bottom: .6rem;
}
fieldset.card { border: 1px solid var(--border); }
fieldset.card legend {
    font-weight: 700;
    padding: 0 .4rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 1.5px solid var(--accent-dark);
    border-radius: 50%;
    color: var(--accent-dark);
    font-size: .85rem;
}

.field { margin-bottom: .45rem; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: .45rem; }
.field-row > .field { margin-bottom: 0; }
.field-row-aligned { align-items: end; }
.field-row-aligned .field.checkbox { padding-bottom: .5rem; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; gap: .45rem; } }
.field > label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .15rem; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea,
.filter-bar input,
.filter-bar select {
    width: 100%;
    padding: .38rem .55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font: inherit;
    color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.field.checkbox { display: flex; gap: .55rem; align-items: flex-start; }
.field.checkbox label { font-weight: 500; margin: 0; }
.field.checkbox input { margin-top: .2rem; }

/* Case ★ accolée à chaque ligne de texte */
.line-input-row { display: flex; align-items: center; gap: .5rem; }
.line-input-row input[type="text"] { flex: 1; }
.star-check {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .3rem .5rem; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; color: #8a7f45; font-size: .95rem; white-space: nowrap;
    cursor: pointer; user-select: none;
}
.star-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

.req { color: var(--danger); }
.hint { font-size: .78rem; color: var(--muted); margin: .2rem 0 0; }
.field-error { color: var(--danger); font-size: .85rem; margin: .3rem 0; }
.field-error ul { margin: .2rem 0; padding-left: 1.1rem; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 7px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.btn-submit { width: 100%; justify-content: center; font-size: 1rem; padding: .6rem; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- Grille formulaire + aperçu ---------- */
.personalize-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
    gap: 1.2rem;
    align-items: start;
}
.preview-panel { position: sticky; top: 1rem; }
.preview-panel h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.plate-figure { margin: 0 0 .5rem; text-align: center; }
.plate-figure canvas {
    width: 100%;
    max-width: 440px;
    height: auto;
    /* Fond plaque métal brossé identique au rendu JS/GD — visible dès le chargement. */
    background:
        repeating-linear-gradient(93deg, rgba(255,255,255,.05) 0 2px, rgba(0,0,0,.04) 2px 4px),
        linear-gradient(160deg, #e8e5d9 0%, #cfccb9 38%, #b9b6a4 62%, #d6d3c4 100%);
    border: 1px solid #b8b4a6;
    border-radius: 10px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,.6), inset 0 -2px 3px rgba(0,0,0,.12);
}
.plate-figure figcaption { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.verso-empty-note { font-style: italic; }
.preview-note, .fonts-status { font-size: .8rem; color: var(--muted); }
.ppi-warning {
    background: #fbf3d8;
    border: 1px solid #e0cf8f;
    border-radius: 6px;
    padding: .5rem .7rem;
    font-size: .85rem;
}

.editor-controls { display: grid; gap: .45rem; margin: .55rem 0; }
.editor-controls label { font-size: .85rem; font-weight: 600; }
.editor-controls input[type="range"] { width: 100%; }
.editor-zoom > label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .2rem; }
.editor-transforms { display: flex; gap: .4rem; flex-wrap: wrap; }
.editor-transforms .btn { padding: .3rem .6rem; font-size: .8rem; }
.btn-ghost[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.zoom-row { display: flex; align-items: center; gap: .5rem; }
.zoom-row input[type="range"] { flex: 1; }
.btn-zoom { padding: .2rem .65rem; font-size: 1.05rem; line-height: 1.2; }
.zoom-value { min-width: 3.2rem; text-align: right; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Vignette photo à côté du champ fichier (maquette écran 01) */
.photo-pick { display: flex; align-items: center; gap: .7rem; margin-top: .4rem; }
.photo-pick img {
    width: 64px; height: 42px; object-fit: cover;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg);
}
.photo-pick .photo-name { font-size: .82rem; color: var(--muted); word-break: break-all; }

/* Mini-plaques dans le récapitulatif (maquette écran 02) */
.plate-mini-pair { display: flex; gap: 1.2rem; margin-bottom: 1rem; }
.plate-mini-pair figure { margin: 0; text-align: center; }
.plate-mini-pair img { max-width: 100%; height: auto; border-radius: 6px; }
.plate-mini-pair figcaption { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.plate-mock {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: .12em;
    width: 170px; height: 104px; position: relative; overflow: hidden;
    border-radius: 10px;
    border: 1px solid #b8b4a6;
    background:
        repeating-linear-gradient(93deg, rgba(255,255,255,.05) 0 2px, rgba(0,0,0,.04) 2px 4px),
        linear-gradient(160deg, #e8e5d9 0%, #cfccb9 38%, #b9b6a4 62%, #d6d3c4 100%);
    box-shadow: inset 0 1px 2px rgba(255,255,255,.6), inset 0 -2px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.15);
}
.plate-mock::before {
    content: ''; position: absolute; left: 7px; top: 50%; translate: 0 -50%;
    width: 15px; height: 15px; border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #fdfbf3, #a9a694 70%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.35), 0 0 0 1.5px rgba(90,88,70,.35);
}
.plate-mock-line {
    font-family: 'Stencil Militaire', 'Gravure Fallback', serif;
    font-size: .82rem; line-height: 1.15; max-width: 82%;
    color: #57544a; text-shadow: 0 1px 0 rgba(255,255,255,.55);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plate-mock-verso { font-size: 1.6rem; color: #6d6a5e; text-shadow: 0 1px 0 rgba(255,255,255,.55); }

/* Vignette verso dans la liste admin */
.admin-thumb {
    width: 96px; height: auto; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg); display: block;
}

/* ---------- Récapitulatif ---------- */
.recap { margin: .4rem 0 .5rem; display: flex; flex-wrap: wrap; gap: .15rem 1.1rem; font-size: .88rem; }
.recap > div { display: flex; gap: .4rem; }
.recap dt { font-weight: 600; color: var(--muted); }
.recap dd { margin: 0; word-break: break-word; }
.recap-card { max-width: 620px; margin: 1rem auto; text-align: left; }

/* ---------- Confirmation ---------- */
.confirmation { text-align: center; padding: 2rem 0; }
.confirmation-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.2rem; height: 4.2rem;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 2.2rem;
    margin: 0;
}
.reference-badge {
    display: inline-block;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: .35rem .9rem;
}
.confirmation-notes { list-style: none; padding: 0; color: var(--muted); }
.confirmation-notes li { margin: .4rem 0; }
.confirmation .btn { margin-top: 1rem; }

.tracking-history { list-style: none; padding: 0; margin: 0; }
.tracking-history li {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem 0;
    border-bottom: 1px dashed var(--border);
}
.tracking-history li:last-child { border-bottom: 0; }
.tracking-history time { color: var(--muted); font-size: .88rem; margin-left: auto; }

/* ---------- Divers ---------- */
.login-card { max-width: 420px; margin: 3rem auto; }
.privacy { max-width: 760px; margin: 1.5rem auto; }
.placeholder-notice {
    background: #fbf3d8;
    border: 1px solid #e0cf8f;
    border-radius: 6px;
    padding: .7rem .9rem;
    font-size: .9rem;
}
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ---------- Administration ---------- */
.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    padding: 1.1rem .9rem;
}
.admin-sidebar .brand { color: var(--sidebar-ink); margin-bottom: 2rem; }
.admin-sidebar .brand-star { color: var(--sidebar-ink); border-color: var(--sidebar-ink); }
.admin-sidebar .brand-text small { color: #b8b8a8; }
.admin-nav { display: grid; gap: .3rem; }
.admin-nav a {
    color: var(--sidebar-ink);
    text-decoration: none;
    padding: .55rem .7rem;
    border-radius: 7px;
}
.admin-nav a[aria-current="page"], .admin-nav a:hover { background: #43504a; }
.admin-sidebar-foot { margin-top: auto; display: grid; gap: .5rem; font-size: .85rem; }
.admin-user { color: #b8b8a8; word-break: break-all; }
.admin-content { flex: 1; padding: 1.4rem 1.6rem; min-width: 0; }
.admin-page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.admin-page-head h1 { margin: 0; font-size: 1.5rem; }
.detail-head { justify-content: space-between; flex-wrap: wrap; }
.back-link { font-size: .9rem; }

.stat-cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.stat-card {
    flex: 1; min-width: 150px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1.1rem;
    display: flex; align-items: center; gap: .7rem;
}
.stat-card strong { font-size: 1.5rem; }
.stat-card span:last-child { color: var(--muted); font-size: .85rem; }
.stat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem;
    border: 1.5px solid var(--accent-dark); border-radius: 8px;
    color: var(--accent-dark);
}

.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr .8fr .8fr .9fr auto;
    gap: .5rem;
    margin-bottom: 1rem;
    align-items: center;
}
.table-card { padding: 0; overflow-x: auto; }
.demands-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.demands-table th, .demands-table td {
    text-align: left;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.demands-table th { background: var(--accent-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.email-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.empty-row { text-align: center; color: var(--muted); padding: 1.5rem; }

.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-lg { font-size: .9rem; padding: .35rem .9rem; }
.badge-nouvelle { background: #e6dcf5; color: #5b3a8a; }
.badge-a_valider { background: #fbe8c8; color: #8a5a12; }
.badge-en_cours { background: #d8e4f5; color: #2f4f80; }
.badge-terminee { background: #dcebd0; color: #3f6225; }
.badge-annulee { background: #f3d5d0; color: var(--danger); }
.badge-pending { background: #fbe8c8; color: #8a5a12; }
.badge-sent { background: #dcebd0; color: #3f6225; }
.badge-failed { background: #f3d5d0; color: var(--danger); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1.2rem; align-items: start; }
.detail-grid h2 { margin-top: 0; font-size: 1.05rem; }
.preview-pair { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.preview-pair figure { margin: 0; text-align: center; }
.preview-pair img {
    max-width: 260px; width: 100%;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg);
}
.preview-pair figcaption { font-size: .8rem; color: var(--muted); }
.history-list, .notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; font-size: .88rem; }
.history-list time { color: var(--muted); }
.download-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.inline-form { display: inline; margin-top: .3rem; }
.danger-card { border-color: #d8b0a8; }
.flash { padding: .7rem 1rem; border-radius: 7px; margin-bottom: .8rem; }
.flash-success { background: #dcebd0; color: #3f6225; }
.flash-error { background: #f3d5d0; color: var(--danger); }

.pagination { display: flex; gap: .35rem; margin-top: 1rem; }
.pagination a {
    padding: .3rem .7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
}
.pagination a.current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .personalize-grid { grid-template-columns: 1fr; }
    .preview-panel { order: -1; position: static; }
    .preview-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
    .preview-panel h2, .preview-panel > p { grid-column: 1 / -1; }
    .plate-figure canvas { max-width: none; }
    .detail-grid { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .preview-panel { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar { width: auto; flex-direction: row; align-items: center; gap: 1rem; }
    .admin-nav { display: flex; }
    .admin-sidebar-foot { margin: 0 0 0 auto; }
    .filter-bar { grid-template-columns: 1fr; }
    .site-header { flex-wrap: wrap; }
}
