/* Thème sombre par défaut ; thème clair seulement si choisi (bouton ☀️ / 🌙) */
:root {
  --bg: #2f333a;
  --surface: #3a3f48;
  --text: #f2f4f7;
  --muted: #bcc3ce;
  --border: #555c68;
  --primary: #4169e1;
  --primary-text: #ffffff;
  --link: #a3b8f8;
  --accent: #5fc39e;
  --danger: #ff7b72;
  --row-done: #2f4a40;
  --shadow: none;
  --radius: 12px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef0f3;
  --surface: #ffffff;
  --text: #1d2027;
  --muted: #5b6270;
  --border: #d5d9e0;
  --primary: #3157d4;
  --primary-text: #ffffff;
  --link: #2a4fc4;
  --accent: #1e6b52;
  --danger: #a61b1b;
  --row-done: #e8f4ee;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
a { color: var(--link); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error { color: var(--danger); min-height: 1.2em; margin: .5em 0 0; }

/* Boutons & champs */
.btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .55em 1em; border-radius: 8px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .3em .7em; font-size: .85rem; }
label { display: flex; flex-direction: column; gap: .3em; font-size: .9rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: .5em; }
label.check { flex-direction: row; align-items: center; gap: .4em; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .55em .7em; width: 100%;
}
input[type="checkbox"] { width: 1.3em; height: 1.3em; accent-color: var(--primary); cursor: pointer; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.btn.primary:hover { filter: brightness(1.12); }
fieldset.access { border: 1px solid var(--border); border-radius: 10px; padding: .6em 1em 1em; margin: 0; display: flex; flex-direction: column; gap: .8em; }
fieldset.access legend { color: var(--link); font-weight: 600; padding: 0 .4em; }
output { font-weight: 700; color: var(--text); padding: .55em 0; }

/* Champs secrets : bouton afficher/masquer à côté du champ (laisse la place à l'icône LastPass) */
.secret { display: flex; gap: .4em; align-items: stretch; }
.secret input { flex: 1; min-width: 0; }
.btn.eye { flex: 0 0 auto; padding: 0 .65em; font-size: 1rem; line-height: 1; }
input.masked { -webkit-text-security: disc; text-security: disc; }
/* Edge ajoute son propre œil : on le masque pour éviter un doublon */
input::-ms-reveal, input::-ms-clear { display: none; }
.rules { list-style: none; margin: .1em 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .2em .8em; font-size: .82rem; color: var(--muted); }
.rules li::before { content: "○ "; }
.rules li.ok { color: var(--accent); }
.rules li.ok::before { content: "✔ "; }
.rules li.ko { color: var(--danger); }
.rules li.ko::before { content: "✗ "; }
.caps { font-size: .82rem; color: var(--danger); font-weight: 600; }
.match.ok { color: var(--accent); }
.match.ko { color: var(--danger); }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .6em; margin-bottom: 1.2em; }
.brand h1 { font-size: 1.4rem; margin: 0; }
.brand.small { margin: 0; font-weight: 700; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 1.2em; }
.tab { flex: 1; font: inherit; border: 0; background: transparent; color: var(--muted); padding: .5em; border-radius: 7px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.login-form { display: flex; flex-direction: column; gap: 1em; }

/* En-tête */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1em; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-btn { font: inherit; border: 0; background: transparent; color: var(--muted); padding: .45em .8em; border-radius: 8px; cursor: pointer; }
.nav-btn.active { background: var(--bg); color: var(--text); font-weight: 600; }
.who { display: flex; align-items: center; gap: .5em; color: var(--muted); }

.content { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1em; flex-wrap: wrap; margin-bottom: .8em; }
.section-head h2 { margin: 0; }
.section-head select { width: auto; min-width: 200px; }
.pill { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: .3em .8em; font-size: .9rem; }
.empty { color: var(--muted); padding: 2em; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Tableau */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.gifts { width: 100%; border-collapse: collapse; }
.gifts th, .gifts td { padding: .65em .8em; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.gifts th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.gifts tbody tr:last-child td { border-bottom: 0; }
.gifts tr.done { background: var(--row-done); }
.gifts .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gifts .center { text-align: center; }
.gifts .loc { max-width: 260px; overflow-wrap: anywhere; }
.pref { display: inline-grid; place-items: center; min-width: 1.8em; height: 1.8em; border-radius: 99px; background: var(--bg); font-weight: 700; }
.row-actions { display: flex; gap: .4em; flex-wrap: wrap; }
.badge { display: inline-block; padding: .15em .6em; border-radius: 99px; font-size: .82rem; font-weight: 600; border: 1px solid var(--border); }
.badge.offert { color: var(--accent); border-color: var(--accent); }
.badge.a_offrir { color: var(--link); border-color: var(--link); }
.badge.locked { color: var(--danger); border-color: var(--danger); }
.status-select { width: auto; padding: .3em .5em; }
.status-select.offert { color: var(--accent); font-weight: 600; }

/* Cartes */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: .8em; box-shadow: var(--shadow); }
.list { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: .4em; }
.row-form { flex-direction: row; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.row-form label { flex: 1 1 160px; }
.row-form label:has(.secret) { flex-basis: 240px; }
.row-form .full { flex-basis: 100%; margin: 0; }
.badge.invited { color: var(--accent); border-color: var(--accent); }
#invite-view .login-card { max-width: 460px; }
#invite-view h2 { font-size: 1.2rem; margin: 0; }
textarea { resize: vertical; min-height: 3.2em; }
.comment { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 320px; font-size: .88rem; color: var(--muted); }
.gifts td.comment-col { min-width: 200px; }
.badge { white-space: nowrap; }
.theme-toggle { padding: .35em .6em; line-height: 1; }
.brand .theme-toggle { margin-left: auto; }
.row-form label.check { flex: 0 0 auto; margin-top: 2.1em; }
.row-form > .btn { margin-top: 1.65em; }

/* Boîtes de dialogue */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: flex; flex-direction: column; gap: .9em; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8em; }
.actions { display: flex; justify-content: flex-end; gap: .6em; margin-top: .4em; }
pre { background: var(--bg); padding: 1em; border-radius: 8px; overflow-x: auto; font-size: 1rem; user-select: all; white-space: pre-wrap; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 150%);
  background: var(--text); color: var(--bg); padding: .7em 1.2em; border-radius: 10px;
  transition: transform .25s, opacity .25s, visibility .25s; max-width: calc(100vw - 32px); z-index: 50;
  opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.error { background: var(--danger); color: #fff; }

/* Mobile : le tableau devient une liste de cartes */
@media (max-width: 760px) {
  .topbar { padding: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav-btn { white-space: nowrap; }
  .who { margin-left: auto; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; }
  table.gifts, .gifts tbody, .gifts tr, .gifts td { display: block; width: 100%; }
  .gifts thead { display: none; }
  .gifts tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; padding: 6px 4px; }
  .gifts td { display: flex; justify-content: space-between; align-items: center; gap: 1em; border: 0; padding: .4em .8em; text-align: right; }
  .gifts td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; }
  .gifts .loc { max-width: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 label:last-child { grid-column: span 2; }
}
