/* ============================================================
   SCI Loisir - feuille de style
   Palette : sauge profond, crème, terre cuite, charbon
   ============================================================ */

:root {
  --cream:        #f6f2ea;
  --cream-2:      #ece6d8;
  --sage:         #6b7f5c;
  --sage-deep:    #3d4a36;
  --sage-light:   #c4cfb6;
  --terracotta:   #c2654a;
  --terracotta-l: #e3a48c;
  --ink:          #2a2823;
  --ink-2:        #5b574d;
  --muted:        #8a8478;
  --line:         #d8d1c1;
  --paper:        #fffdf8;
  --danger:       #b03a2e;
  --ok:           #4f7c4a;
  --shadow:       0 4px 14px rgba(61,74,54,.08);
  --shadow-lg:    0 18px 40px rgba(61,74,54,.16);
  --radius:       12px;
  --radius-sm:    8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  color: var(--sage-deep);
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
}
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .9rem 1.5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-family: 'Fraunces', serif;
  font-weight: 600; font-size: 1.15rem;
  color: var(--sage-deep) !important;
  text-decoration: none !important;
}
.brand-mark {
  display: inline-block;
  color: var(--terracotta);
  font-size: 1.4rem;
  line-height: 1;
  transform: translateY(1px);
}
.nav {
  display: flex;
  gap: .25rem;
  flex: 1;
  flex-wrap: wrap;
}
.nav a {
  padding: .5rem .9rem;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: .95rem;
}
.nav a:hover { background: var(--cream-2); text-decoration: none; }
.nav a.active {
  background: var(--sage-deep);
  color: var(--paper);
}
.user-chip {
  display: flex; align-items: center; gap: .55rem;
  background: var(--cream-2);
  padding: .35rem .35rem .35rem .75rem;
  border-radius: 999px;
  font-size: .9rem;
  color: var(--ink);
}
.user-chip .dot {
  width: .65rem; height: .65rem; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px var(--paper);
}
.user-chip .logout {
  width: 1.8rem; height: 1.8rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper);
  border-radius: 50%;
  color: var(--ink-2) !important;
  text-decoration: none !important;
  font-size: 1rem;
}
.user-chip .logout:hover { background: var(--terracotta); color: white !important; }

.burger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: transparent; border: 0;
  padding: .35rem;
  cursor: pointer;
}
.burger span {
  display: block; width: 22px; height: 2px;
  background: var(--ink); border-radius: 2px;
}

/* ---------- Layout principal ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .95rem;
}
.flash-info     { background: var(--cream-2); color: var(--ink); }
.flash-success  { background: #dde9d6; color: #2f4d2a; }
.flash-error    { background: #f4d8d3; color: #7a2218; }

.footbar {
  text-align: center;
  padding: 1.5rem;
  font-size: .85rem;
  color: var(--muted);
  display: flex; justify-content: center; gap: 1rem;
}
.muted { color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.25rem; }

.card-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}

/* Stats cards */
.stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.75rem;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .35rem;
}
.stat .value {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--sage-deep);
}
.stat .value.positive { color: var(--ok); }
.stat .value.negative { color: var(--danger); }
.stat .sub { font-size: .85rem; color: var(--muted); margin-top: .15rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  text-decoration: none !important;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--sage-deep); color: var(--paper);
}
.btn-primary:hover { background: var(--sage); }
.btn-secondary {
  background: var(--cream-2); color: var(--ink);
}
.btn-secondary:hover { background: var(--sage-light); }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }
.btn-link {
  background: transparent; color: var(--terracotta);
  padding: 0; border: 0;
}
.btn-sm { font-size: .85rem; padding: .35rem .8rem; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--cream-2);
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: rgba(196, 207, 182, 0.25); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.recette { color: var(--ok); font-weight: 600; }
.depense { color: var(--terracotta); font-weight: 600; }

.pill {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
}
.pill-recette { background: #dde9d6; color: var(--ok); }
.pill-depense { background: #f4d8d3; color: var(--terracotta); }
.pill-admin   { background: var(--sage-deep); color: var(--paper); }
.pill-gest    { background: var(--cream-2); color: var(--ink-2); }

/* ---------- Formulaires ---------- */
form.formulaire { display: grid; gap: 1.1rem; max-width: 580px; }
form.formulaire.wide { max-width: 100%; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-row {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 540px) { .field-row { grid-template-columns: 1fr; } }
label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--ink-2);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: .65rem .85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(107,127,92,.15);
}
textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* Toolbar de filtres */
.toolbar {
  display: flex; gap: .75rem; flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.25rem;
}
.toolbar select, .toolbar input {
  padding: .45rem .75rem;
  font-size: .9rem;
}
.toolbar .grow { flex: 1; min-width: 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--cream);
}
.login-side {
  background: var(--sage-deep);
  color: var(--paper);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-side::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at 30% 30%, rgba(196,207,182,.15), transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(194,101,74,.18), transparent 50%);
}
.login-side > * { position: relative; }
.login-side .logo {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 600;
  display: flex; align-items: center; gap: .6rem;
}
.login-side .logo span { color: var(--terracotta-l); font-size: 2.3rem; }
.login-side h1 {
  color: var(--cream);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 500;
  line-height: 1.1;
  margin-top: auto;
}
.login-side p { opacity: .85; max-width: 380px; }
.login-form {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem 1.5rem;
}
.login-form form { width: 100%; max-width: 380px; }
.login-form .btn { width: 100%; justify-content: center; padding: .8rem; }
.login-form .small {
  text-align: center; margin-top: 1rem; font-size: .85rem; color: var(--muted);
}
@media (max-width: 800px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
}

/* ---------- Planning / Calendrier ---------- */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.cal-toolbar .month {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--sage-deep);
  text-transform: capitalize;
}
.cal-toolbar .nav-btns { display: flex; gap: .35rem; }
.cal-toolbar .nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none !important;
  font-size: 1.1rem;
}
.cal-toolbar .nav-btn:hover { background: var(--cream-2); }

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-head {
  background: var(--cream-2);
  padding: .5rem;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .07em;
}
.cal-day {
  background: var(--paper);
  min-height: 110px;
  padding: .35rem .45rem;
  position: relative;
  display: flex; flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background .12s ease;
}
.cal-day:hover { background: var(--cream); }
.cal-day.other { background: #f1ede4; color: var(--muted); }
.cal-day.today .num {
  background: var(--terracotta); color: white;
  border-radius: 50%;
  width: 1.55rem; height: 1.55rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.cal-day.weekend { background: #faf6ec; }
.cal-day .num {
  font-size: .85rem;
  font-weight: 500;
  color: var(--ink-2);
  align-self: flex-start;
}
.cal-event {
  font-size: .75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--sage-light);
  color: var(--sage-deep);
  text-decoration: none !important;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid var(--sage);
  display: block;
}
.cal-event:hover { filter: brightness(.95); }

@media (max-width: 720px) {
  .cal-day { min-height: 70px; padding: .25rem .3rem; }
  .cal-day .num { font-size: .8rem; }
  .cal-event {
    font-size: 0;
    height: 8px;
    padding: 0;
    border-radius: 4px;
    border-left: 0;
  }
}

/* ---------- Mobile nav ---------- */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: .75rem; }
  .burger { display: flex; order: 3; margin-left: auto; }
  .nav {
    order: 99;
    flex-direction: column;
    width: 100%;
    display: none;
  }
  body.nav-open .nav { display: flex; }
  .nav a { padding: .65rem 1rem; border-radius: var(--radius-sm); }
  .user-chip { order: 2; }
}

/* ---------- Empty state ---------- */
.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}
.empty::before {
  content: '✦';
  display: block;
  font-size: 2.5rem;
  color: var(--sage-light);
  margin-bottom: .5rem;
}

/* ---------- Install ---------- */
.install-wrap {
  max-width: 560px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}
.install-wrap .card { padding: 2rem; }

input[type="file"] {
  font-family: inherit;
  font-size: .9rem;
  padding: .5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  width: 100%;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font-family: inherit;
  background: var(--sage-deep);
  color: var(--paper);
  border: 0;
  padding: .45rem .9rem;
  border-radius: 999px;
  margin-right: .75rem;
  cursor: pointer;
}

/* ---------- Utilitaires ---------- */
.text-right { text-align: right; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin: 0 0 1.25rem;
}

/* ---------- V2 : vue jour + agenda entrées/sorties (ajouté) ---------- */
.pill-entree {
  background: var(--sage-light); color: var(--sage-deep);
}
.pill-sortie {
  background: var(--cream-2); color: var(--ink-2);
}
.pill-encours-sejour {
  background: var(--cream-2); color: var(--muted);
}

/* Vue jour (jour.php) */
.jour-liste { display: grid; gap: .75rem; }
.jour-item {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sage);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  box-shadow: var(--shadow);
  text-decoration: none !important;
  color: inherit;
  transition: background .12s ease, transform .08s ease;
}
.jour-item:hover { background: var(--cream); transform: translateY(-1px); }
.jour-item-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .4rem; }
.jour-item-titre { font-weight: 600; font-size: 1.05rem; color: var(--sage-deep); }
.jour-item-sub { font-size: .85rem; margin-top: .15rem; }

/* Agenda du tableau de bord (index.php) */
.agenda-liste { display: grid; gap: .5rem; }
.agenda-item {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  color: inherit;
  transition: background .12s ease;
}
.agenda-item:hover { background: var(--cream); }
.agenda-date {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--sage-deep);
  min-width: 3.2rem;
}
.agenda-titre { flex: 1 1 auto; font-size: .95rem; }

@media (max-width: 540px) {
  .agenda-item { font-size: .9rem; }
  .agenda-titre { flex-basis: 100%; order: 5; }
}
