/* Styles communs : page publique et page d'administration. */

:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f3ede2;
  --text: #1d2a24;
  --muted: #5f6b64;
  --line: #e6decf;
  --header: #1f5c45;
  --green: #1f6b4f;
  --on-green: #ffffff;
  --red: #b3263a;
  --on-red: #ffffff;
  --gold: #9a7414;
  --gold-bg: #f7eed3;
  --ok-bg: #e4f2ea;
  --ok: #1d6a47;
  --shadow: 0 1px 2px rgba(30, 40, 35, .05), 0 6px 18px rgba(30, 40, 35, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1713;
    --surface: #17221c;
    --surface-2: #1d2a23;
    --text: #ecf2ee;
    --muted: #9fb0a6;
    --line: #2a3a31;
    --header: #143a2c;
    --green: #4aa37d;
    --on-green: #0b120e;
    --red: #e0566a;
    --on-red: #1a0a0d;
    --gold: #e0bd5a;
    --gold-bg: #2d2714;
    --ok-bg: #173126;
    --ok: #7fd1a8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
body.busy { cursor: progress; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1080px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 700; letter-spacing: -.01em; }
[hidden] { display: none !important; }

/* ---------- En-tête ---------- */
.top {
  background-color: var(--header);
  background-image:
    radial-gradient(rgba(255,255,255,.16) 1.2px, transparent 1.8px),
    radial-gradient(rgba(255,255,255,.10) 1px, transparent 1.6px);
  background-size: 34px 34px, 23px 23px;
  background-position: 0 0, 11px 17px;
  color: #fff;
}
.top .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand svg { flex: none; }
.brand h1 { margin: 0; font-size: clamp(26px, 5vw, 34px); line-height: 1.1; }
.countdown { margin: 2px 0 0; font-size: 14px; color: rgba(255,255,255,.8); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: rgba(255,255,255,.85); }
.who select, .top-btn {
  font: inherit; font-size: 15px; font-weight: 600; color: #fff; text-decoration: none;
  background-color: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.top-btn:hover { background-color: rgba(255,255,255,.2); }
.who select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='white' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.who select option { color: #1d2a24; background: #fff; }

/* ---------- Bandeau « Qui êtes-vous ? » ---------- */
.hello {
  margin-top: 20px; padding: 16px 18px; border-radius: 14px;
  background: var(--gold-bg); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
}
.hello p { margin: 0 0 10px; }
.hello p.small { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.hello-names { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Personnes (pastilles) ---------- */
.people { display: flex; flex-wrap: wrap; gap: 8px; padding: 20px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 500; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--green); }
.chip.active { background: var(--green); border-color: var(--green); color: var(--on-green); }
.chip .count {
  font-size: 12px; font-weight: 600; min-width: 20px; text-align: center;
  padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.chip.active .count { background: rgba(255,255,255,.2); color: inherit; }
.chip .me-tag { font-size: 12px; opacity: .75; }

/* ---------- Liste de cadeaux ---------- */
.list-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 20px 0 14px;
}
.list-head h2 { margin: 0; font-size: clamp(24px, 4.5vw, 30px); line-height: 1.15; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.own-note {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-size: 14px;
}
.items { list-style: none; margin: 0 0 48px; padding: 0; display: grid; gap: 12px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 6px;
}
.item.taken { background: var(--surface-2); box-shadow: none; }
.item.taken .title { color: var(--muted); }
.item.byme { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.price {
  flex: none; font-size: 13px; font-weight: 600; color: var(--gold);
  background: var(--gold-bg); padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
.note { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.link { font-size: 14px; color: var(--green); font-weight: 500; text-decoration: none; width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }
.item-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; margin-top: 6px;
}
.status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.taken { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Boutons ---------- */
.btn {
  font: inherit; font-size: 15px; font-weight: 600; border-radius: 999px;
  padding: 8px 16px; border: 1px solid transparent; cursor: pointer; line-height: 1.3;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn.primary { background: var(--green); color: var(--on-green); }
.btn.gift { background: var(--red); color: var(--on-red); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 10px; }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { color: var(--red); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn.secondary.danger { color: var(--red); }

/* ---------- États vides / erreurs ---------- */
.empty { text-align: center; color: var(--muted); padding: 34px 16px; border: 1px dashed var(--line); border-radius: 16px; }
.empty p { margin: 0 0 6px; }
.empty .empty-title { font-family: Fraunces, Georgia, serif; font-size: 22px; font-weight: 600; color: var(--text); }
.empty .btn { margin-top: 12px; }
.error-box { margin-top: 24px; padding: 16px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--red); }
.error-box p { margin: 0 0 8px; }
.error-box strong { color: var(--red); }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 5px; font-size: 14px; font-weight: 500; min-width: 0; }
.field .opt { color: var(--muted); font-weight: 400; }
input[type=text], input[type=password], textarea, select.input {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ---------- Fenêtres ---------- */
dialog {
  border: none; border-radius: 18px; padding: 0;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10, 20, 15, .5); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 22px; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
.hint.err { color: var(--red); }
@media (max-width: 480px) { dialog .row { grid-template-columns: 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); color: #fff; }

/* ---------- Administration ---------- */
.login {
  max-width: 400px; margin: 48px auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: grid; gap: 14px;
}
.login h2 { margin: 0; font-size: 24px; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 16px; margin-top: 20px;
}
.toolbar .group { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; margin: 16px 0 48px; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.panel > h2 { margin: 0 0 12px; font-size: 20px; }
.plist { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 2px; }
.prow { display: flex; align-items: center; gap: 2px; }
.prow .pick {
  flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; text-align: left; color: var(--text);
  background: transparent; border: none; border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.prow .pick:hover { background: var(--surface-2); }
.prow.active .pick { background: var(--green); color: var(--on-green); }
.prow .pick .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pick .count { font-size: 12px; font-weight: 600; opacity: .7; }
.icon-btn {
  flex: none; width: 30px; height: 30px; display: inline-grid; place-items: center;
  font: inherit; font-size: 14px; color: var(--muted);
  background: transparent; border: none; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .25; cursor: default; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 24px; }
.panel-head .group { display: flex; gap: 4px; flex-wrap: wrap; }
.add-item {
  display: grid; grid-template-columns: 2fr 1.4fr 0.8fr; gap: 10px;
  padding: 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 16px;
}
.add-item .wide { grid-column: 1 / -1; }
.add-item .foot { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
@media (max-width: 560px) { .add-item { grid-template-columns: minmax(0, 1fr); } }
.alist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.arow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.arow .order { display: grid; gap: 0; }
.arow .order .icon-btn { width: 26px; height: 22px; font-size: 12px; }
.arow .body { display: grid; gap: 2px; min-width: 0; }
.arow .line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.arow .title { font-size: 16px; }
.arow .acts { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .arow { grid-template-columns: auto minmax(0, 1fr); }
  .arow .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------- Zones ---------- */
.prow .pick .who-zone { display: grid; min-width: 0; line-height: 1.25; }
.prow .pick .zones { font-size: 12px; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pick .zones.none { color: var(--red); opacity: 1; }
.prow.active .pick .zones.none { color: inherit; }
.zone-boxes { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.add-person { display: grid; gap: 8px; }
.zone-edit {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  margin: -6px 0 14px; font-size: 14px; color: var(--muted);
}
.warn {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: var(--gold-bg); color: var(--text);
}

/* ---------- Pied de page public ---------- */
.page-foot { text-align: center; padding-bottom: 32px; }
.link-btn {
  font: inherit; font-size: 13px; color: var(--muted); background: none; border: none;
  padding: 6px 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }
