/* PlannerAV : feuille de style commune, mobile d'abord. */

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #1f2333;
    --muted: #6b7089;
    --border: #e3e5ee;
    --primary: #4f46e5;
    --primary-text: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 14px;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12131a;
        --surface: #1c1e28;
        --text: #eceef6;
        --muted: #9a9fb8;
        --border: #2c2f3d;
        --primary: #818cf8;
        --primary-text: #12131a;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Barre du haut ------------------------------------------------------ */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.mainnav { display: flex; gap: 4px; margin-left: auto; }
.mainnav a { padding: 6px 10px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; }
.mainnav a[aria-current] { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.topbar-user { text-decoration: none; border-radius: 50%; }
.topbar-user[aria-current] .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }

/* --- Profil ------------------------------------------------------------- */
.profile-card { display: flex; align-items: center; gap: 16px; }
.profile-card p { margin: 0; }
.profile-name { font-weight: 700; font-size: 1.15rem; }
.avatar-large { width: 64px; height: 64px; font-size: 1.6rem; }
.logout-form { text-align: center; margin-top: 24px; }

.avatar {
    display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: var(--member, var(--primary)); color: #fff; font-weight: 700; font-size: .9rem; flex: none;
}
.avatar-small { width: 22px; height: 22px; font-size: .7rem; }

/* --- Mise en page ------------------------------------------------------- */
.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.stack { display: grid; gap: 16px; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; display: grid; gap: 12px; justify-items: center; }

.flash { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); margin: 0 0 12px; }
.flash-error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.flash-success { background: color-mix(in srgb, var(--success) 14%, var(--surface)); }

/* --- Boutons et champs -------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-small { min-height: 32px; padding: 0 10px; font-size: .875rem; }
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    border: 0; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; list-style: none;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.icon-btn[aria-pressed="false"] { filter: grayscale(1); opacity: .45; }
.icon-btn-quiet { opacity: .5; }
.icon-btn-quiet:hover { opacity: 1; color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], select {
    width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); flex: none; }

.field, form > div { display: grid; gap: 6px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, legend, form > div > label { font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.help, .help-text, .form-help, small { color: var(--muted); font-size: .85rem; }
ul:has(> li) { padding-left: 0; }
.form-error-message, form ul li { color: var(--danger); }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input[type="text"], .inline-form input[type="email"] { flex: 1; }
.inline-form select { width: auto; }

.auth { max-width: 420px; margin: 8vh auto 0; display: grid; gap: 16px; }
.auth h1 { font-size: 1.8rem; }

/* Choix segmentés (type, visibilité) */
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented input, .swatches input, .icons input, .tag-picker input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 500; background: var(--surface);
}
.segmented input:checked + label { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.segmented input:focus-visible + label, .swatches input:focus-visible + label, .icons input:focus-visible + label, .tag-picker input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches label { width: 34px; height: 34px; border-radius: 50%; background: var(--swatch); cursor: pointer; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatches input:checked + label { box-shadow: 0 0 0 3px var(--swatch); }

.icons { display: flex; flex-wrap: wrap; gap: 6px; }
.icons label { min-width: 44px; height: 44px; display: grid; place-items: center; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; font-size: 1.3rem; background: var(--surface); }
.icons label:first-of-type { font-size: .85rem; color: var(--muted); }
.icons input:checked + label { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-picker label { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--tag); color: var(--tag); cursor: pointer; font-weight: 600; font-size: .9rem; }
.tag-picker input:checked + label { background: var(--tag); color: #fff; }

/* --- Tags et badges ----------------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; text-decoration: none;
    color: var(--tag); background: color-mix(in srgb, var(--tag) 14%, transparent);
}
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); }
.badge-private { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 4px; scrollbar-width: none; }
.chip {
    flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); text-decoration: none; font-weight: 500; font-size: .9rem;
}
.chip[style] { border-color: color-mix(in srgb, var(--tag) 40%, var(--border)); }
.chip[aria-current] { background: var(--tag, var(--primary)); border-color: var(--tag, var(--primary)); color: #fff; }
.chip-manage { color: var(--muted); border-style: dashed; }

/* --- Cartes de listes --------------------------------------------------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
    position: relative; display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border);
    border-left: 6px solid var(--list); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-link { flex: 1; display: flex; gap: 12px; align-items: flex-start; padding: 14px; color: inherit; text-decoration: none; min-width: 0; }
.card-icon { font-size: 1.6rem; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--list) 14%, transparent); }
.card-body { display: grid; gap: 4px; min-width: 0; }
.card-title { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-meta { color: var(--muted); font-size: .85rem; }
.card-actions { display: flex; flex-direction: column; justify-content: center; padding: 4px; }
.card-actions form { display: contents; }
.card-archived { opacity: .75; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(to right, var(--list) var(--done), transparent var(--done)); }

/* --- Page d'une liste --------------------------------------------------- */
.list-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.back { font-size: 1.4rem; text-decoration: none; color: var(--muted); padding: 4px 8px 4px 0; }
.list-icon { font-size: 1.6rem; width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--list) 18%, transparent); border: 2px solid var(--list); }
.list-title { flex: 1; min-width: 0; display: grid; gap: 4px; }
.list-title h1 { overflow-wrap: anywhere; }

.menu { position: relative; }
.menu summary::-webkit-details-marker { display: none; }
.menu-items {
    position: absolute; right: 0; top: 40px; z-index: 5; min-width: 230px; display: grid; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / 15%);
}
.menu-items a, .menu-items button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }

.add-item { display: flex; gap: 8px; position: sticky; top: 58px; z-index: 4; padding: 8px 0; background: var(--bg); }
.add-item input[name="label"] { flex: 1; }
.add-item .qty { width: 80px; flex: none; }
.add-item .btn { width: 44px; min-height: 44px; padding: 0; font-size: 1.4rem; }

.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.items:empty { display: none; }
.item { display: flex; align-items: center; gap: 4px; padding-right: 6px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item-toggle { flex: 1; min-width: 0; }
.check {
    width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px;
    border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.box { width: 24px; height: 24px; flex: none; border-radius: 7px; border: 2px solid var(--border); display: grid; place-items: center; transition: background .15s; }
.check:hover .box { border-color: var(--primary); }
.is-checked .box { background: var(--success); border-color: var(--success); }
.is-checked .box::after { content: "✓"; color: #fff; font-weight: 700; font-size: .9rem; }
.item-label { flex: 1; overflow-wrap: anywhere; }
.is-checked .item-label { text-decoration: line-through; color: var(--muted); }
.qty-badge { font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); }
.done-head { display: flex; align-items: center; justify-content: space-between; }
.items-done { opacity: .85; }

/* --- Foyer et tags ------------------------------------------------------ */
.members, .invitations, .tag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.members li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.members li form { margin-left: auto; }
.invitations li { display: grid; gap: 4px; }
.tag-list li { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.tag-list li .inline-form { flex: 1; }

@media (max-width: 480px) {
    .brand span { display: none; }
    .mainnav a { padding: 6px 8px; }
    .inline-form { flex-wrap: wrap; }
    .tag-list li { flex-wrap: wrap; }
}

/* --- Assignation et échéances ------------------------------------------ */
.item-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: .8rem; color: var(--muted); }
.assignee { display: inline-flex; align-items: center; gap: 4px; }
.assignee .avatar-small { width: 18px; height: 18px; font-size: .6rem; }
.due { font-weight: 600; }
.due-overdue { color: var(--danger); }
.due-today { color: #d97706; }
.list-ref { font-weight: 500; }
.icon-btn-edit { font-size: .85rem; text-decoration: none; }
.add-item { flex-wrap: wrap; }
.add-item-options { flex-basis: 100%; display: flex; gap: 8px; }
.add-item-options select, .add-item-options input[type="date"] { flex: 1; min-height: 38px; padding: 4px 10px; font-size: .9rem; }
input[type="date"], textarea {
    width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit;
}
.my-items {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 600;
}
