/* WebDépôt — feuille de style unique */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #677084;
    --border: #e2e5eb;
    --accent: #2f5bd3;
    --accent-hover: #2449ad;
    --accent-soft: #eaf0fd;
    --header: #15181f;
    --success: #1f7a4d;
    --success-soft: #e6f4ec;
    --error: #b42318;
    --error-soft: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    color-scheme: light;
}

/* Thème sombre : choisi avec l'interrupteur (data-theme), sinon selon le réglage de l'appareil */
:root[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #181b22;
    --text: #e7e9ee;
    --muted: #9aa2b1;
    --border: #2a2f3a;
    --accent: #7c9cf5;
    --accent-hover: #a3baf8;
    --accent-soft: #1e2640;
    --header: #08090c;
    --success: #5fcf95;
    --success-soft: #13261c;
    --error: #f28b82;
    --error-soft: #2d1614;
    --shadow: none;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1115;
        --surface: #181b22;
        --text: #e7e9ee;
        --muted: #9aa2b1;
        --border: #2a2f3a;
        --accent: #7c9cf5;
        --accent-hover: #a3baf8;
        --accent-soft: #1e2640;
        --header: #08090c;
        --success: #5fcf95;
        --success-soft: #13261c;
        --error: #f28b82;
        --error-soft: #2d1614;
        --shadow: none;
        color-scheme: dark;
    }
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

main { flex: 1; padding-block: 32px 48px; }

.container {
    width: 100%;
    max-width: 1080px;
    margin-inline: auto;
    padding-inline: 16px;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- En-tête ---------- */

.site-header { background: var(--header); color: #fff; }

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    padding-block: 12px;
}

.brand img { display: block; height: 44px; width: auto; }

.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.nav a, .nav button {
    color: #d5d9e2;
    text-decoration: none;
    font: inherit;
    font-size: .95rem;
    padding: 8px 12px;
    border-radius: 8px;
    background: none;
    border: 0;
    cursor: pointer;
}

.nav a:hover, .nav button:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.nav-logout { margin: 0; }

/* ---------- Interrupteur clair / sombre ---------- */

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding: 6px 8px;
    font: inherit;
    font-size: .875rem;
    color: #d5d9e2;
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.theme-switch:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.theme-switch-track {
    position: relative;
    width: 52px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    transition: background .2s;
}

.theme-switch-track::before,
.theme-switch-track::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    line-height: 1;
}

.theme-switch-track::before { content: "☀"; left: 8px; }
.theme-switch-track::after { content: "☾"; right: 9px; }

.theme-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 1;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    transition: transform .2s;
}

.theme-switch[aria-checked="true"] .theme-switch-track { background: var(--accent); }
.theme-switch[aria-checked="true"] .theme-switch-thumb { transform: translateX(24px); }

@media (prefers-reduced-motion: reduce) {
    .theme-switch-track, .theme-switch-thumb { transition: none; }
}

/* ---------- Pied de page ---------- */

.site-footer {
    border-top: 1px solid var(--border);
    padding-block: 20px;
    font-size: .875rem;
    color: var(--muted);
    text-align: center;
}

/* ---------- Blocs ---------- */

.page-head { margin-bottom: 24px; }
.page-head p { color: var(--muted); margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card > :last-child { margin-bottom: 0; }

.narrow { max-width: 440px; margin-inline: auto; }
.medium { max-width: 640px; margin-inline: auto; }

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    margin-bottom: 24px;
}

@media (min-width: 900px) {
    .grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.stat-label { font-size: .875rem; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 650; margin-top: 2px; }

.split { display: grid; gap: 24px; }
@media (min-width: 820px) { .split { grid-template-columns: 1fr 1fr; } }

/* ---------- Formulaires ---------- */

.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; }
@media (min-width: 560px) { .form-row { grid-template-columns: 1fr 1fr; } }

label { display: grid; gap: 6px; font-weight: 550; font-size: .95rem; }
.hint { font-weight: 400; font-size: .85rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="file"], select, textarea {
    width: 100%;
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
}

textarea { min-height: 180px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 18px;
    cursor: pointer;
}

.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); background: var(--bg); border-color: var(--border); }

.btn-red { color: #fff; background: #c8102e; border-color: #c8102e; }
.btn-red:hover { color: #fff; background: #a00d25; border-color: #a00d25; }

.btn-danger { color: var(--error); background: transparent; border-color: var(--border); padding: 6px 12px; font-size: .875rem; }
.btn-danger:hover { color: #fff; background: var(--error); border-color: var(--error); }

.btn-small { padding: 6px 12px; font-size: .875rem; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar h2 { margin: 0; }
.search-inline { display: flex; gap: 8px; flex: 1 1 260px; max-width: 420px; }
.search-inline input { flex: 1; min-width: 0; }

.sort-form { display: flex; align-items: center; gap: 8px; }
.sort-form label { font-weight: 400; font-size: .95rem; color: var(--muted); white-space: nowrap; }
.sort-form select { width: auto; padding-block: 8px; }

.links { display: grid; gap: 6px; margin-top: 20px; font-size: .95rem; }

/* ---------- Messages ---------- */

.alert {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success { color: var(--success); background: var(--success-soft); border-color: currentColor; }
.alert-error { color: var(--error); background: var(--error-soft); border-color: currentColor; }
.alert-info { color: var(--text); background: var(--accent-soft); border-color: var(--border); }

/* ---------- Onglets ---------- */

.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tabs a {
    white-space: nowrap;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-count {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 .4em;
    margin-left: 4px;
    border-radius: 999px;
    font-size: .8rem;
    text-align: center;
    background: var(--bg);
    color: var(--muted);
}

/* ---------- Tableaux ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }

th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: var(--bg); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
tfoot td { font-weight: 650; border-bottom: 0; }

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------- Produits ---------- */

.products {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
}

@media (min-width: 640px) {
    .products { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

.product {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
}

.product:hover { border-color: var(--accent); color: inherit; }

.product-photo {
    aspect-ratio: 1;
    background: var(--bg);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: .85rem;
}

.product-photo img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 12px 14px; display: grid; gap: 4px; }
.product-title { font-weight: 600; font-size: .95rem; }
.product-ref { font-size: .8rem; color: var(--muted); }
.product-price { font-size: 1.05rem; font-weight: 700; color: var(--accent); }

.product-detail { display: grid; gap: 24px; }
@media (min-width: 720px) { .product-detail { grid-template-columns: 320px 1fr; } }
.product-detail .product-photo { border-radius: var(--radius); overflow: hidden; }
.product-detail .product-photo img { object-fit: contain; } /* photo entière sur la fiche */

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; align-items: baseline; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; font-weight: 550; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- Synchronisation des photos ---------- */

.sync-folder { margin: 16px 0; }
.sync-options { border: 0; padding: 0; margin: 20px 0 0; display: grid; gap: 6px; }
.sync-options legend { margin-bottom: 6px; }
[data-sync="resultat"] { margin-top: 20px; }
.sync-summary { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; }
[data-sync="resultat"] details { margin-bottom: 8px; }
[data-sync="resultat"] summary { cursor: pointer; color: var(--accent); }
.sync-apply { margin-top: 16px; }

/* ---------- Impression ---------- */

.print-only { display: none; }

@media print {
    .print-only { display: block; }
    .site-header, .site-footer, .tabs, .pagination, .no-print, .actions { display: none !important; }
    body { background: #fff; color: #000; }
    main { padding: 0; }
    .card { border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Pagination ---------- */

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