:root {
  --bg: #f8fafc;
  --bg-gradient: linear-gradient(180deg, #eef2ff 0%, #f8fafc 260px);
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #10b981;
  --primary-dark: #059669;
  --accent: #6366f1;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 6px 18px rgba(15,23,42,0.06);
  --shadow-btn: 0 8px 20px rgba(16,185,129,0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient), var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 96px;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
}
.container.wide { max-width: 620px; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  position: sticky;
  top: 0;
  background: rgba(248,250,252,0.85);
  backdrop-filter: blur(10px);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

header.topbar h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: -0.01em;
}

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

/* --- Cartes d'activité --- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: fadeInUp 0.35s ease both;
}
.card:active { transform: scale(0.98); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.card h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.card p { margin: 3px 0; color: var(--text-muted); font-size: 13.5px; }
.card .meta-row { display: flex; align-items: center; gap: 6px; }

/* Barre de capacité */
.capacity-wrap { margin: 10px 0 4px; }
.capacity-bar {
  height: 7px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}
.capacity-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}
.capacity-fill.full { background: linear-gradient(90deg, var(--danger), #fb7185); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge.free { background: #d1fae5; color: var(--primary-dark); }
.badge.paid { background: #fef3c7; color: #b45309; }
.badge.full { background: #fee2e2; color: #b91c1c; }
.badge.registered { background: #d1fae5; color: var(--primary-dark); }
.badge.declined { background: #fee2e2; color: #b91c1c; }

/* --- Boutons dynamiques --- */
button, .btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #34d399);
  color: #ffffff;
  border: none;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-btn);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
}
button:hover, .btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
button:active, .btn:active { transform: scale(0.96) translateY(0); box-shadow: 0 3px 10px rgba(16,185,129,0.28); }
button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.secondary:active { background: var(--surface-hover); }
button.danger { background: linear-gradient(135deg, var(--danger), #fb7185); box-shadow: 0 8px 20px rgba(239,68,68,0.28); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Bouton d'action rapide sur les cartes (petit format, pill) */
.quick-action {
  padding: 9px 18px;
  font-size: 13px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.quick-action.joined { background: var(--surface); color: var(--primary-dark); border: 1px solid var(--primary); box-shadow: none; }
.quick-action.waitlist { background: var(--surface); color: #b45309; border: 1px solid var(--warning); box-shadow: none; }
.quick-action.declined { background: var(--surface); color: #b91c1c; border: 1px solid var(--danger); box-shadow: none; }

.quick-actions { display: flex; gap: 6px; flex-shrink: 0; }
.quick-action-mini {
  padding: 9px 14px;
  font-size: 12px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}
.quick-action-mini:active { background: #fee2e2; color: var(--danger); }

input, textarea, select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; font-weight: 600; }

.form-group { margin-bottom: 14px; }

.error { color: var(--danger); font-size: 14px; margin: 8px 0; }
.success { color: var(--primary-dark); font-size: 14px; margin: 8px 0; }
.muted { color: var(--text-muted); font-size: 13px; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px;
  font-weight: 600;
  transition: color 0.15s ease;
}
.bottom-nav a.active { color: var(--primary-dark); }

.participant-list { list-style: none; padding: 0; margin: 10px 0; }
.participant-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state .emoji { font-size: 32px; display: block; margin-bottom: 10px; }

/* Sélecteur de vue (Liste / Calendrier) */
.view-switch {
  display: flex;
  background: var(--surface);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.view-switch button {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 11px;
  box-shadow: none;
}
.view-switch button.active {
  background: linear-gradient(135deg, var(--primary), #34d399);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16,185,129,0.35);
}

/* Filtres (chips) */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}
.chip.active {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

/* Légende des types d'activité */
.type-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.legend-item:active { transform: scale(0.95); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Calendrier mensuel */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.calendar-nav button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
  box-shadow: var(--shadow);
}
.calendar-nav h2 {
  font-size: 20px;
  font-weight: 800;
  text-transform: capitalize;
  margin: 0;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 24px;
}
.calendar-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-bottom: 6px;
  text-transform: uppercase;
  font-weight: 700;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  gap: 5px;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.calendar-day:active { transform: scale(0.94); }
.calendar-day.empty { background: transparent; border-color: transparent; cursor: default; }
.calendar-day.today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(16,185,129,0.2); color: var(--primary-dark); }
.calendar-day.selected { background: #eef2ff; border-color: var(--accent); }
.calendar-day .dots { display: flex; gap: 3px; }
.calendar-day .dot { width: 6px; height: 6px; border-radius: 50%; }

@media (min-width: 460px) {
  .calendar-day { font-size: 18px; border-radius: 16px; }
  .calendar-day .dot { width: 7px; height: 7px; }
}

.day-detail-title {
  font-size: 14px;
  color: var(--text-muted);
  margin: 18px 0 10px;
  text-transform: capitalize;
  font-weight: 700;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.3s ease; }

/* --- Sondages --- */
.poll-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.poll-card h4 { margin: 0 0 12px; font-size: 15px; }
.poll-option {
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
}
.poll-option-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #d1fae5, #c7d2fe);
  z-index: 0;
  transition: width 0.4s ease;
}
.poll-option.voted { border-color: var(--primary); }
.poll-option-content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
}
.poll-option-content .votes { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.add-poll-toggle {
  background: none;
  border: 1.5px dashed var(--border);
  color: var(--text-muted);
  width: 100%;
  font-size: 13px;
  padding: 10px;
  box-shadow: none;
}
.poll-option-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.poll-option-input-row input { margin-bottom: 0; }
.poll-option-input-row button { flex-shrink: 0; padding: 10px 12px; }

/* --- Forum / commentaires --- */
.comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.comment .comment-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 600;
}
.comment .comment-author { font-weight: 700; color: var(--text); }
.comment p { margin: 0; font-size: 14.5px; color: var(--text); }

.comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: sticky;
  bottom: 76px;
  background: var(--bg);
  padding-top: 8px;
}
.comment-form textarea {
  margin-bottom: 0;
  resize: none;
  min-height: 44px;
  max-height: 100px;
}
.comment-form button { flex-shrink: 0; }
