/* =========================================================
   Base
========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #24292e;
  background-color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main.container {
  flex: 1;
  padding-bottom: 48px;
}

main {
  display: block;
}

/* =========================================================
   Layout
========================================================= */
.container {
  width: 980px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 1000px) {
  .container {
    width: 95%;
  }

  .user-card,
  .santa-card {
    width: 45%;
  }
}

@media (max-width: 600px) {

  .user-card,
  .santa-card {
    width: 100%;
  }
}

/* Flex utilities (utilisées par JS) */
.d-flex {
  display: flex;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-justify-center {
  justify-content: center;
}

.flex-items-center {
  align-items: center;
}

/* =========================================================
   Spacing utilities
========================================================= */
.mt-4 {
  margin-top: 24px;
}

.mb-4 {
  margin-bottom: 24px;
}

.mb-3 {
  margin-bottom: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.m-2 {
  margin: 8px;
}

/* =========================================================
   Typography
========================================================= */
h1 {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 16px;
}

h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 16px 0 8px;
}

.h3 {
  font-size: 20px;
  font-weight: 600;
}

/* =========================================================
   Details / accordéons
========================================================= */
details {
  display: block;
}

details>summary {
  cursor: pointer;
  list-style: revert;
}

details:not([open])> :not(summary) {
  display: none;
}

/* =========================================================
   Markdown body
========================================================= */
.markdown-body {
  margin-top: 8px;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body ol {
  margin: 0;
  padding-left: 20px;
}

.markdown-body li {
  margin-bottom: 6px;
}

/* =========================================================
   Formulaires
========================================================= */
button {
  cursor: pointer;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
}

form {
  margin-top: 8px;
}

input[type="text"] {
  padding: 6px 8px;
  font-size: 14px;
}

input[type="radio"],
input[type="checkbox"] {
  margin-right: 4px;
}

label {
  cursor: pointer;
}

/* =========================================================
   Utilitaires
========================================================= */
.d-none {
  display: none !important;
}

.clickable {
  cursor: pointer;
}

.border {
  border: 1px solid #d0d7de;
}

.box-shadow {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.section-toggle summary {
  font-weight: 600;
}

.draw-section {
  padding-top: 12px;
  /* espace au-dessus */
}

/* =========================================================
   Erreurs
========================================================= */
.error {
  color: #d73a49;
  margin-top: 8px;
}

/* =========================================================
   Users list
========================================================= */
.user strong {
  display: block;
  margin-bottom: 4px;
}

.exclusions-list {
  margin-left: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.exclusions-list label {
  cursor: pointer;
}

/* =========================================================
   Cartes Secret Santa
========================================================= */
.santa-card {
  width: 180px;
  height: 120px;
  perspective: 1000px;
  user-select: none;
}

.santa-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.santa-card.is-flipped .santa-card-inner {
  transform: rotateY(180deg);
}

.santa-card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-weight: 600;
}

.santa-card-front {
  background-color: #ffffff;
}

.santa-card-back {
  background-color: #f6f8fa;
  transform: rotateY(180deg);
}

/* =========================================================
   Cartes Participants
========================================================= */
#users-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  /* centre horizontalement */
  gap: 12px;
  /* espace entre les cartes */
  margin-top: 16px;
  /* un peu de marge par rapport au formulaire */
}

.user-card {
  width: 180px;
  /* largeur fixe pour l'alignement */
  min-height: 120px;
  /* hauteur minimale */
  padding: 12px;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s, background-color 0.2s;
  position: relative;
}

.user-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background-color: #f6f8fa;
  /* léger gris */
}

.user-card:hover {
  background-color: #fefefe;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.delete-user {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #57606a;
  transition: color 0.2s;
}

.delete-user:hover {
  color: #d73a49;
  /* rouge GitHub-like */
}

.exclusions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

/* =========================================================
   Animation : carte bloquée (shake)
========================================================= */
@keyframes shake {
  0% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-4px);
  }

  40% {
    transform: translateX(4px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }

  100% {
    transform: translateX(0);
  }
}

.santa-card.shake {
  animation: shake 0.3s;
}

/* =========================================================
   Positionnement des boutons d'édition
========================================================= */
.edit-user,
.delete-user,
.cancel-edit,
.save-edit {
  position: absolute;
  top: 15px;
  font-size: 14px;
  cursor: pointer;
}

.edit-user {
  right: 28px;
}

.delete-user {
  right: 8px;
}

.cancel-edit {
  right: 8px;
  color: #57606a;
}

.save-edit {
  right: 28px;
  color: #1a7f37;
}

.edit-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 14px;
  margin-bottom: 8px;
}

.edit-user:hover {
  opacity: 0.7;
}

.save-edit:hover {
  color: #2da44e;
}

.cancel-edit:hover {
  color: #d73a49;
}