/* Wishlist — feuille de style unique. Aucune règle inline (CSP). */

:root {
    --bg: #f6f4f0;
    --surface: #ffffff;
    --surface-2: #efebe5;
    --text: #1f1d1a;
    --muted: #6b655e;
    --border: #e2ddd5;
    --accent: #2f6f5e;
    --accent-strong: #24574a;
    --accent-contrast: #ffffff;
    --danger: #b3261e;
    --high: #c2410c;
    --high-bg: #fff1e8;
    --low: #52606d;
    --low-bg: #eef1f4;
    --done: #2f6f5e;
    --done-bg: #e7f2ee;
    --success-bg: #e7f2ee;
    --error-bg: #fbeaea;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161514;
        --surface: #201f1d;
        --surface-2: #2a2826;
        --text: #ece8e2;
        --muted: #a39d95;
        --border: #3a3734;
        --accent: #5fb49c;
        --accent-strong: #7cc7b1;
        --accent-contrast: #0f1f1a;
        --danger: #f08b84;
        --high: #fb923c;
        --high-bg: #3a2416;
        --low: #9aa8b5;
        --low-bg: #262b30;
        --done: #7cc7b1;
        --done-bg: #1c2e28;
        --success-bg: #1c2e28;
        --error-bg: #3a1f1d;
        --shadow: none;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
}

a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
img { max-width: 100%; display: block; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 16px 3rem; }

/* ---------- Barre du haut ---------- */
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
    padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.topnav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); }
.topnav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Messages ---------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.flash-success { background: var(--success-bg); }
.flash-error { background: var(--error-bg); color: var(--danger); }
.flash-info { background: var(--surface-2); }
.form-error { background: var(--error-bg); color: var(--danger); padding: .6rem .8rem; border-radius: 8px; margin: 0 0 1rem; }
.field-error { color: var(--danger); font-size: .875rem; margin: .25rem 0 0; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .45rem 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-contrast); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { min-height: 32px; padding: .25rem .6rem; font-size: .875rem; }
.btn-block { width: 100%; }
.link {
    background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--text); }
.link-danger { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .3rem; }
.field > span, .field-label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
input[type="text"], input[type="password"], input[type="url"], input[type="search"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%; min-height: 40px; padding: .5rem .7rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .link:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.check { display: flex; gap: .5rem; align-items: center; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.radio-group { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.stack { display: grid; gap: .75rem; }
.subhead { margin: 1.75rem 0 .75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }

/* ---------- Connexion ---------- */
.login { max-width: 380px; margin: 12vh auto 0; }
.login-title { text-align: center; font-size: 2rem; margin-bottom: 1.25rem; }

/* ---------- En-tête de liste, onglets, filtres ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 10px; }
.tab { padding: .4rem .9rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .3rem; border-radius: 99px; background: var(--border); font-size: .8rem; text-align: center; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.filters input[type="search"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }
.dropdown { position: relative; }
.dropdown > summary {
    list-style: none; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center;
    padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown[open] > summary { border-color: var(--accent); }
.dropdown-panel {
    position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 320px; overflow: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .5rem .75rem; display: grid; gap: .35rem;
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.totals { margin: 0; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); color: var(--muted); padding: .35rem .8rem; font: inherit; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- Badges et tags ---------- */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-high { background: var(--high-bg); color: var(--high); }
.badge-low { background: var(--low-bg); color: var(--low); }
.badge-done { background: var(--done-bg); color: var(--done); }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: 0; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: .8rem; text-decoration: none; }
a.tag:hover { color: var(--text); }

/* ---------- Liste : cartes / tableau ---------- */
.items[data-view="cards"] .items-table { display: none; }
.items[data-view="table"] .cards { display: none; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item-card.prio-high { border-color: var(--high); }
.item-card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.item-card-link:hover { color: inherit; }
.item-card-link:hover h3 { text-decoration: underline; }
.thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { font-size: 2.5rem; opacity: .35; }
.item-card-body { padding: .75rem .9rem .9rem; display: grid; gap: .35rem; }
.item-card-meta { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; font-size: .9rem; }
.price { font-weight: 700; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table-thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }

/* ---------- Fiche produit ---------- */
.back { margin: 0 0 1rem; }
.item-detail-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 800px) {
    .item-detail-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
}
.item-photo { background: var(--surface-2); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 220px; }
.item-photo img { width: 100%; height: auto; }
.item-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.5rem 0 1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.description { margin: 0 0 1rem; }
.meta { font-size: .875rem; }

/* ---------- Dialogue d'achat ---------- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }

/* ---------- Commentaires ---------- */
.comments { margin-top: 2.5rem; max-width: 760px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .75rem; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; }
.comment-head { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: baseline; font-size: .9rem; }
.comment-head time { color: var(--muted); }
.comment-head form { margin-left: auto; }
.comment-body { margin: .3rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: .5rem; }
.comment-form .btn { justify-self: start; }

/* ---------- Formulaire produit ---------- */
.form-grid { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
    .form-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}
.form-main, .form-side { display: grid; gap: 1rem; align-content: start; }
.photo-current, .photo-preview { border-radius: 8px; max-height: 240px; object-fit: contain; background: var(--surface-2); }
.tag-input { position: relative; }
.tag-box {
    display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; min-height: 40px; padding: .3rem .4rem;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: text;
}
.tag-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-pill { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .3rem .1rem .55rem; border-radius: 6px; background: var(--surface-2); font-size: .9rem; }
.tag-pill button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .2rem; }
.tag-pill button:hover { color: var(--danger); }
.tag-box input { border: 0; outline: 0; flex: 1 1 120px; min-width: 120px; min-height: 30px; padding: .2rem; background: transparent; }
.tag-suggestions {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: .25rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.tag-suggestions li { padding: .35rem .6rem; border-radius: 6px; cursor: pointer; }
.tag-suggestions li[aria-selected="true"], .tag-suggestions li:hover { background: var(--surface-2); }

/* ---------- Admin / compte ---------- */
.section { margin-bottom: 2.5rem; }
.admin-inline { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.admin-inline input, .admin-inline select { width: auto; min-width: 140px; }
.narrow { max-width: 480px; }

/* ---------- Erreurs ---------- */
.error-page { text-align: center; padding: 4rem 0; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--muted); margin: 0; }
.debug { text-align: left; white-space: pre-wrap; overflow-x: auto; background: var(--surface-2); padding: 1rem; border-radius: 8px; font-size: .8rem; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    h1 { font-size: 1.35rem; }
    .container { padding-top: 1rem; }
    .page-head .btn-primary { width: 100%; }
    .cards { grid-template-columns: minmax(0, 1fr); }
    .item-card-link { flex-direction: row; }
    .item-card .thumb { width: 96px; flex: 0 0 96px; aspect-ratio: 1; }
    .facts { grid-template-columns: 1fr; gap: 0; }
    .facts dd { margin-bottom: .5rem; }
    .view-toggle { display: none; }
    .items[data-view="table"] .cards { display: grid; }
    .items[data-view="table"] .items-table { display: none; }
}
