/* ============================================================
   KidsPrivilèges — feuille de style mobile-first
   ============================================================ */

:root {
  --brand:        #6d5efc;
  --brand-dark:   #574bd6;
  --bg:           #f4f5fb;
  --card:         #ffffff;
  --ink:          #1f2330;
  --ink-soft:     #5b6172;
  --line:         #e7e8f2;
  --green:        #1fae63;
  --green-soft:   #e4f7ec;
  --amber:        #e8a319;
  --red:          #e5484d;
  --red-soft:     #fdecec;
  --gold:         #f5b400;
  --radius:       18px;
  --shadow:       0 6px 20px rgba(31, 35, 48, 0.08);
  --shadow-soft:  0 2px 8px rgba(31, 35, 48, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- En-tête ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand);
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  box-shadow: var(--shadow-soft);
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}
.app-header__logo { font-size: 1.5rem; }
.app-header__title { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.app-header { display: flex; align-items: center; justify-content: space-between; }
.app-header__logout-form { margin: 0; }
.app-header__logout {
  appearance: none; border: none; cursor: pointer;
  background: rgba(255,255,255,0.18); color: #fff;
  font-family: inherit; font-weight: 700; font-size: 0.8rem;
  padding: 7px 12px; border-radius: 999px;
}
.app-header__logout:active { transform: scale(0.96); }

/* ---------- Page de connexion ---------- */
.login {
  max-width: 360px; margin: 8vh auto 0; padding: 28px 24px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: center;
}
.login__logo { font-size: 3rem; }
.login__title { font-size: 1.4rem; font-weight: 800; margin: 6px 0 4px; letter-spacing: -0.02em; }
.login__sub { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 22px; }
.login__form { display: flex; flex-direction: column; gap: 12px; }
.login__input {
  width: 100%; padding: 13px 15px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: center;
}
@media (prefers-color-scheme: dark) {
  .login__input { background: #14151c; color: var(--ink); }
}

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 40px);
}

/* ---------- Messages flash ---------- */
.flash {
  max-width: 640px;
  margin: 12px auto 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  animation: slidein 0.25s ease;
}
.flash--notice { background: var(--green-soft); color: #0f7a44; }
.flash--alert  { background: var(--red-soft);   color: #b4262a; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Titres de section ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 16px;
}
.section-head h1 { font-size: 1.35rem; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.section-sub { color: var(--ink-soft); font-size: 0.9rem; margin: -8px 2px 18px; }

/* ---------- Carte enfant ---------- */
.child {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 18px;
}
.child__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.child__avatar {
  width: 52px; height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  background: var(--bg);
  display: grid; place-items: center;
  font-size: 1.7rem;
}
.child__id { flex: 1; min-width: 0; }
.child__name { font-size: 1.2rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.child__points {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff7de; color: #8a6d00;
  font-weight: 700; font-size: 0.85rem;
  padding: 3px 10px; border-radius: 999px; margin-top: 3px;
}
.child__menu { color: var(--ink-soft); text-decoration: none; font-size: 1.4rem; padding: 4px 8px; }

/* ---------- Zone récompense ---------- */
.reward-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
  padding: 10px 0 14px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}
.reward-row .lbl { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; margin-right: 2px; }

/* ---------- Liste des privilèges ---------- */
.priv {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.priv:last-child { border-bottom: none; }
.priv__emoji { font-size: 1.5rem; width: 30px; text-align: center; }
.priv__body { flex: 1; min-width: 0; }
.priv__name { font-weight: 700; font-size: 1.02rem; }
.priv__meta { font-size: 0.82rem; margin-top: 2px; }
.priv__meta--ok  { color: var(--green); }
.priv__meta--out { color: var(--red); }
.priv--removed .priv__emoji,
.priv--removed .priv__name { opacity: 0.45; }

.status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex: 0 0 12px;
}
.status-dot--ok  { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot--out { background: var(--red);   box-shadow: 0 0 0 4px var(--red-soft); }

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Réordonnancement (écran de gestion) ---------- */
.reorder { display: flex; flex-direction: column; gap: 2px; }
.reorder__btn {
  appearance: none; border: none; cursor: pointer;
  background: var(--bg); color: var(--ink-soft);
  width: 30px; height: 22px; border-radius: 7px;
  font-size: 0.7rem; line-height: 1; padding: 0;
}
.reorder__btn:active { transform: scale(0.92); }

/* ---------- Boutons ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 0.9rem;
  padding: 9px 14px; border-radius: 11px;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; line-height: 1;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost   { background: var(--bg); color: var(--ink); }
.btn--green   { background: var(--green); color: #fff; }
.btn--gold    { background: var(--gold); color: #4a3800; }
.btn--danger  { background: var(--red); color: #fff; }
.btn--sm      { padding: 7px 11px; font-size: 0.82rem; border-radius: 9px; }
.btn--pill    { border-radius: 999px; }
.btn--block   { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Disclosure (retirer / prolonger) ---------- */
details.action { margin-top: 2px; }
details.action > summary {
  list-style: none; cursor: pointer;
}
details.action > summary::-webkit-details-marker { display: none; }
.action__panel {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg);
  border-radius: 12px;
}
.action__panel .reason {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-family: inherit; font-size: 0.9rem;
  margin-bottom: 10px; background: #fff;
}
.severity-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.sev-btn {
  appearance: none; cursor: pointer; border: 2px solid transparent;
  font-family: inherit; font-weight: 700; font-size: 0.82rem;
  padding: 10px 4px; border-radius: 11px; text-align: center;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.sev-btn small { font-weight: 600; opacity: 0.75; font-size: 0.72rem; }
.sev-legere  { background: #fff6df; color: #8a6d00; }
.sev-moyenne { background: #ffedd9; color: #9a5600; }
.sev-grave   { background: var(--red-soft); color: #b4262a; }
.sev-btn:active { transform: scale(0.95); }

/* ---------- Formulaires ---------- */
.form-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.92rem; }
.field input[type=text],
.field input[type=number] {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.emoji-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-picker label {
  font-size: 1.5rem; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 12px; background: var(--bg); cursor: pointer; border: 2px solid transparent;
  margin: 0; position: relative;
}
.emoji-picker input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.emoji-picker label:has(input:checked) {
  border-color: var(--brand); background: #efedff;
}
.errors { background: var(--red-soft); color: #b4262a; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 0.9rem; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Cases à cocher (affectation) ---------- */
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  background: var(--bg); border: 2px solid transparent;
  font-weight: 600; font-size: 0.9rem;
}
.check-chip:has(input:checked) { border-color: var(--brand); background: #efedff; }
.check-chip input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Petits badges "qui a ce privilège" dans le catalogue */
.who-chip {
  display: inline-block; margin: 2px 4px 2px 0;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg); font-size: 0.78rem; font-weight: 600;
}

/* ---------- Divers ---------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--ink-soft);
}
.empty__emoji { font-size: 3rem; }
.empty p { margin: 10px 0 20px; }

.link-back { color: var(--brand); font-weight: 700; text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 14px; }

.add-priv {
  display: flex; gap: 8px; margin-top: 14px;
}
.add-priv input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 11px; font-family: inherit; font-size: 0.92rem; background: #fff;
}

/* ---------- Historique ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.timeline .tl-emoji { font-size: 1.3rem; width: 28px; text-align: center; }
.timeline .tl-body { flex: 1; }
.timeline .tl-title { font-weight: 700; font-size: 0.95rem; }
.timeline .tl-time { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; }
.tl-badge { font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; align-self: center; }
.tl-badge--minus { background: var(--red-soft); color: #b4262a; }
.tl-badge--plus  { background: var(--green-soft); color: #0f7a44; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151c; --card: #1e2029; --ink: #eceef5; --ink-soft: #9aa0b3;
    --line: #2c2f3c; --green-soft: #12301f; --red-soft: #331416;
  }
  .child__points { background: #3a3212; color: #f2d788; }
  .field input, .add-priv input, .action__panel .reason { background: #14151c; color: var(--ink); }
}
