/* EDG Comité — design system (institutionnel sobre, thème clair).
   Un seul fichier partagé par toutes les pages (staff/admin et candidat). */

:root {
  /* Couleurs */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1f2733;
  --muted: #5b6472;
  --faint: #8a93a3;
  --border: #e4e8ef;
  --border-strong: #d4dae3;

  --primary: #2e5bff;
  --primary-dark: #1e46e0;
  --primary-weak: #eef2ff;
  --primary-border: #cdd8ff;

  --danger: #d23b30;
  --danger-dark: #b52d24;
  --danger-weak: #fdecea;
  --danger-border: #f4c7c2;

  --success: #2e8b45;
  --success-weak: #e9f6ec;
  --warning: #b7791f;

  /* Rayons, ombres, transitions */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --ring: 0 0 0 3px rgba(46, 91, 255, .18);
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.container { max-width: 76rem; margin: 0 auto; padding: 0 1.25rem 4rem; }
.container.narrow { max-width: 34rem; }

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; margin: 1.6rem 0 1rem; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 2.4rem 0 1rem; }
p { margin: .6rem 0; }
.lead { color: var(--muted); max-width: 48rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

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

.link-back {
  display: inline-flex; align-items: center; gap: .35rem;
  color: var(--muted); font-size: .9rem; margin: 0 0 1rem;
}
.link-back:hover { color: var(--primary); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .bar {
  max-width: 76rem; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand .dot {
  width: .7rem; height: .7rem; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak);
}
.site-header nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.site-header nav a {
  color: var(--muted); font-size: .92rem; font-weight: 500;
  padding: .35rem .7rem; border-radius: var(--radius-pill); text-decoration: none;
  transition: background .15s, color .15s;
}
.site-header nav a:hover { background: var(--primary-weak); color: var(--primary-dark); }
.site-header nav a.active { background: var(--primary-weak); color: var(--primary-dark); }
.site-header .me { color: var(--faint); font-size: .85rem; }
.site-header .me a { color: var(--muted); }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  margin: 1rem 0;
}
.card.pad-lg { padding: 1.6rem 1.8rem; }

.panel {
  background: var(--primary-weak);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.panel .sep { color: var(--primary-border); margin: 0 .5rem; }

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem; margin: 1.2rem 0;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem;
}
.stat .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.stat .value small { font-size: 1rem; color: var(--faint); font-weight: 500; }

/* Progress bar */
.progress { background: #e9edf4; border-radius: var(--radius-pill); height: .55rem; overflow: hidden; margin-top: .5rem; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow-x: auto; margin: 1rem 0;
}
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-warn { color: var(--danger); font-weight: 600; }

/* scroll container inside a full-width block, no card chrome */
.scroll-box { max-height: 22rem; overflow-y: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.05rem; font-size: .92rem; font-weight: 600; line-height: 1;
  background: var(--primary); color: #fff; border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }
.btn.sm { padding: .35rem .7rem; font-size: .82rem; }

.actions { margin-top: 1.4rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* Inline delete forms + action cells in tables */
form.inline { display: inline; }
.row-actions { display: inline-flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .6rem 0 1.2rem; }

/* ---------- Forms ---------- */
.form { max-width: 26rem; }
label { display: block; margin: 1rem 0 .3rem; font-weight: 600; font-size: .88rem; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
label.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; margin-top: 1rem; }
label.checkbox input { width: auto; }
.hint { margin: 1.2rem 0 .2rem; font-size: .85rem; color: var(--muted); }

/* ---------- Alerts / badges ---------- */
.errors, .alert {
  border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--danger-border); background: var(--danger-weak); color: #8a2018;
}
.errors ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alert.info { background: var(--primary-weak); border-color: var(--primary-border); color: var(--primary-dark); }
.alert.success { background: var(--success-weak); border-color: #bfe3c6; color: #1d5e2c; }

.badge {
  display: inline-block; padding: .12rem .55rem; border-radius: var(--radius-pill);
  font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.badge.primary { background: var(--primary-weak); color: var(--primary-dark); border-color: var(--primary-border); }
.badge.success { background: var(--success-weak); color: #1d5e2c; border-color: #bfe3c6; }

/* ---------- Public (candidate) shell ---------- */
.public { max-width: 60rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.public-centered { max-width: 34rem; margin: 0 auto; padding: 5rem 1.25rem; text-align: center; }
.public-header { margin-bottom: 1.5rem; }
.public-header .brand { font-size: 1.05rem; }

/* ---------- Committee drag-and-drop ranking (wishes) ---------- */
.rank-list { list-style: none; padding: 0; margin: 1.2rem 0; counter-reset: rank; }
.committee {
  display: flex; align-items: center; gap: .9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: .7rem .9rem; margin-bottom: .6rem;
  transition: box-shadow .15s, border-color .15s, transform .05s;
}
.committee:hover { box-shadow: var(--shadow); }
.committee.dragging { opacity: .55; }
.committee.drop-target { border-color: var(--primary); box-shadow: var(--ring); }
.rank-badge {
  flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
}
.grip { flex: 0 0 auto; cursor: grab; color: var(--faint); font-size: 1.25rem; user-select: none; line-height: 1; }
.grip:active { cursor: grabbing; }
.committee-label { flex: 1 1 auto; min-width: 8rem; font-weight: 500; }
.committee-fields { flex: 0 0 auto; display: flex; gap: .7rem; flex-wrap: wrap; }
.committee-fields label { margin: 0; font-weight: 500; font-size: .75rem; color: var(--muted); }
.committee-fields select { min-width: 9rem; padding: .35rem .5rem; font-size: .88rem; }
.move-buttons { flex: 0 0 auto; display: flex; flex-direction: column; gap: .15rem; }
.move-buttons button {
  width: auto; padding: .05rem .45rem; font-size: .7rem; line-height: 1.3; cursor: pointer;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 5px;
}
.move-buttons button:hover { background: var(--primary-weak); color: var(--primary-dark); border-color: var(--primary-border); }

@media (max-width: 640px) {
  .committee { flex-wrap: wrap; }
  .committee-fields { width: 100%; }
}
