/* ============================================================================
   0.  GLOBAL VARIABLES
============================================================================ */
:root {
  --color-bg: #f8fff4;
  --color-accent: #d6f0cf;
  --color-primary: #042a2b;
  --radius: 8px;
}

/* ============================================================================
   1.  RESET & BASE
============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%; /* nécessaire pour le footer collant */
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-primary);
  line-height: 1.4;
}

body {
  display: flex; /* empile : header – contenu – footer */
  flex-direction: column;
}

#login,
#register {
  flex: 1; /* pousse le footer en bas */
  display: flex; /* pour centrer son contenu verticalement */
}

a {
  text-decoration: none;
  color: inherit;
}

/* ============================================================================
   2.  HEADER
============================================================================ */
.header {
  width: 100%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header__button {
  font-size: 20px;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
}

.header__nav {
  display: flex;
  gap: 24px;
  font-size: 20px;
  color: var(--color-primary);
  text-decoration: none;
}

.header__logo {
  height: 64px;
}

.header__button:hover {
  background: #031919;
}

/* ============================================================================
   3.  HERO
============================================================================ */
.hero {
  background: var(--color-accent);
  display: flex;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}
.hero__inner {
  max-width: 800px;
}
.hero__title {
  font-size: 48px;
  margin-bottom: 24px;
}
.hero__subtitle {
  font-size: 20px;
  margin-bottom: 32px;
}
.hero__cta {
  display: inline-block;
  font-size: 20px;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 12px 24px;
}
.hero__cta:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ============================================================================
   4.  HOW TO USE  (mobile‑first)
============================================================================ */
.how {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px;
  gap: 24px;
  text-align: left;
}
.how__text {
  width: 100%;
}
.how__title {
  font-size: 32px;
  margin-bottom: 16px;
}
.how__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.how__list li {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.how__step {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  margin-right: 12px;
}
.how__desc {
  flex: 1;
  font-size: 20px;
}
.how__image {
  text-align: center;
}
.how__image img {
  width: min(80vw, 220px);
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ============================================================================
   5.  CALL TO ACTION
============================================================================ */
.cta {
  background: var(--color-accent);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
}
.cta__btn {
  display: inline-block;
  width: min(80vw, 300px);
  font-size: 24px;
  padding: 16px 32px;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  text-align: center;
}
.cta__btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ============================================================================
   6. AUTH (login & register)
============================================================================ */
/* la section auth occupe tout l’espace entre header & footer */
.auth-page {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #bde0fe; /* fond bleu demandé */
  padding: 40px 16px;
}

.auth-panel {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.auth-title {
  font-size: 32px;
  margin-bottom: 24px;
  color: var(--color-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-form label {
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 16px;
}

.auth-form input {
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  font-size: 16px;
}

.auth-btn {
  margin-top: 24px;
  padding: 12px 24px;
  background: #cdb4db; /* bouton violet demandé */
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.auth-btn:hover {
  opacity: 0.85;
}

.auth-foot {
  margin-top: 16px;
  font-size: 14px;
  text-align: center;
}
.auth-foot a {
  color: #cdb4db;
}
.auth-foot a:hover {
  text-decoration: underline;
}

/* ============================================================================
   7.  FLASH‑CARDS PAGE
============================================================================ */
/* --- conteneur vertical qui s’étend jusqu’au footer -------------------- */
#cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* centre la section cartes */
  background: var(--color-accent);
}

/* --- wrapper interne --------------------------------------------------- */
.cards-page {
  flex: 1;
  padding: 48px 16px 64px; /* padding bas réduit */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cards-title {
  font-size: 56px;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 48px;
  text-align: center;
}

/* --- zone (❌ carte ✔) -------------------------------------------------- */
.card-panel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 900px;
}

/* ==== wrapper des cartes : prend tout l'espace entre les boutons ==== */
.card-wrapper,
#card-container {
  flex: 1; /* remplit l'espace horizontal restant */
  display: flex; /* flex interne pour centrer la carte */
  justify-content: center; /* centre horizontalement */
  align-items: center; /* centre verticalement */
}

/* --- boutons carrés ---------------------------------------------------- */
.card-btn {
  width: 88px;
  height: 88px;
  aspect-ratio: 1/1;
  background: #fff;
  border: none;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}
.card-btn img {
  width: 40px;
  height: 40px;
  pointer-events: none;
}
.card-btn--fail:hover {
  background: #ffe8e8;
}
.card-btn--success:hover {
  background: #e8ffe8;
}

/* --- carte recto ‑ verso ---------------------------------------------- */
.flashcard {
  flex: 1 1 auto;
  width: 100%;
  max-width: 900px;
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 60px 48px; /* espace interne */
  min-height: 280px; /* ↙  hauteur minimale ajoutée */
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px; /* profondeur 3D pour le flip */
}

.flashcard__inner {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s;
}
.flashcard.is-flipped .flashcard__inner {
  transform: rotateY(180deg);
}

/* faces --------------------------------------------------------------- */
.flashcard__face {
  display: flex;
  flex-direction: column; /* empile chaque nœud (textes, <br>, etc.) verticalement */
  justify-content: center;
  align-items: center;
}

/* pour que le verso (réponse) colle à gauche du conteneur */
.flashcard__back {
  align-items: flex-start;
}

.flashcard__face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0 32px; /* padding horizontal seulement */
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 24px;
  backface-visibility: hidden;
}
.flashcard__back {
  transform: rotateY(180deg);
}

.flashcard__text {
  font-size: 32px;
  line-height: 1.3;
  margin: 0 auto;
  color: var(--color-primary);
}

.flashcard__front {
  text-align: center;
}
.flashcard__back {
  text-align: left;
}

.cards-progress-btn {
  display: inline-block;
  margin-bottom: 24px;
  font-size: 18px;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 8px 16px;
  transition: background 0.2s, color 0.2s;
}
.cards-progress-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ============================================================================
   8. PAGE PROGRESSION
============================================================================ */
#progress {
  flex: 1; /* pousse footer en bas */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--color-accent);
  padding: 48px 16px 64px;
}

.progress-page {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.progress-title {
  font-size: 48px;
  margin: 0;
  color: var(--color-primary);
  text-align: center;
}

/* 1. Résumé global */
.progress-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-summary p {
  margin: 0;
  font-size: 18px;
}
.progress-bar {
  background: #eee;
  border-radius: var(--radius);
  overflow: hidden;
  height: 16px;
}
.progress-fill {
  background: var(--color-primary);
  height: 100%;
  width: 0; /* ajusté en ligne en mockup */
  transition: width 0.3s ease;
}

/* 2. Tableau « À revoir » */
.progress-panel {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
.progress-panel h2 {
  margin-top: 0;
  font-size: 24px;
}
.progress-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.progress-table th,
.progress-table td {
  padding: 12px 8px;
  text-align: left;
  font-size: 16px;
}
.progress-table thead th {
  border-bottom: 2px solid #ddd;
}
.progress-table tbody tr + tr td {
  border-top: 1px solid #eee;
}

/* 3. Bouton redirigeant vers cards*/
.btn-entrainer {
  padding: 8px 16px;
  font-size: 14px;
  text-decoration: none;
  border: none;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 20px;
  display: inline-block;
}
.btn-entrainer:hover {
  opacity: 0.8;
}

/* ============================================================================
   9.  ADMIN PANEL
============================================================================ */

/* 1) Le conteneur racine #admin doit pousser le footer en bas
   et centrer horizontalement la “carte” blanche */
#admin {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--color-bg);
  padding: 32px 16px;
}

/* 2) Carte blanche principale */
.admin-page {
  width: 100%;
  max-width: 1000px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Titre */
.admin-title {
  font-size: 2.5rem;
  color: var(--color-primary);
  text-align: center;
  margin: 0;
}

/* Onglets */
.admin-tabs {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.admin-tab {
  padding: 8px 16px;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  background: #fff;
  color: var(--color-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.admin-tab.is-active {
  background: var(--color-primary);
  color: #fff;
}

/* Panels utilisateurs / cartes */
.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-panel.is-hidden {
  display: none !important;
}

/* Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}
.admin-table th,
.admin-table td {
  padding: 12px 8px;
  border-bottom: 1px solid #eee;
  font-size: 1rem;
  text-align: left;
}
.admin-table thead th {
  border-bottom: 2px solid #ddd;
  font-weight: 600;
}

/* Boutons dans l’admin */
.btn-small {
  padding: 6px 12px;
  font-size: 0.875rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s;
  background: var(--color-primary);
  color: #fff;
}
.btn-small:hover {
  opacity: 0.85;
}
.btn-danger {
  background: #ffb3b3;
  margin-left: 8px;
}
.btn-danger:hover {
  opacity: 0.85;
}

/* ============================================================================
   Modal générique
============================================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal.active {
  display: flex;
}
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
.modal-content h3 {
  margin-top: 0;
  color: var(--color-primary);
  font-size: 1.5rem;
}
.modal-content label {
  display: block;
  margin-top: 12px;
  font-weight: 500;
}
.modal-content input,
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  font-size: 1rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.btn-cancel {
  background: #eee;
  color: var(--color-primary);
}
.btn-cancel:hover {
  opacity: 0.8;
}

/* ============================================================================
   10.  FOOTER
============================================================================ */
.footer {
  background: #fff;
  text-align: center;
  padding: 24px;
  margin-top: auto; /* colle en bas de page */
}
.footer__logo {
  height: 64px;
  margin-bottom: 16px;
}
.footer__text {
  font-size: 14px;
  margin: 0;
}

/* ============================================================================
   11.  MEDIA QUERIES
============================================================================ */

/* ≥769px : Desktop ------------------------------------------------------ */
@media (min-width: 769px) {
  .how {
    flex-direction: row;
    align-items: center;
    padding: 60px 24px;
    gap: 40px;
  }
  .how__text {
    flex: 1;
  }
  .how__title {
    font-size: 40px;
    line-height: 1.2;
    margin-bottom: 20px;
  }
  .how__list li {
    margin-bottom: 16px;
  }
  .how__step {
    width: 44px;
    height: 44px;
    font-size: 22px;
    margin-right: 14px;
  }
  .how__image img {
    width: clamp(180px, 20vw, 240px);
  }
}

/* ≤768px : Mobile ------------------------------------------------------- */
@media (max-width: 768px) {
  .hero__title {
    font-size: 36px;
  }

  /* Cartes */
  .cards-title {
    font-size: 40px;
    margin-bottom: 32px;
  }
  .card-panel {
    flex-direction: column;
    gap: 24px;
  }
  .flashcard {
    padding: 48px 24px;
    min-height: 220px; /* ↘  hauteur mini adaptée au mobile */
  }
  .flashcard__face {
    padding: 0 24px;
  }
  .flashcard__text {
    font-size: 24px;
  }
  .card-btn {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 768px) {
  /* on garde déjà votre flex-direction:column et le gap */
  .card-panel {
    width: 100%; /* bien prendre toute la largeur du container */
    padding: 0 16px; /* on ajoute un petit padding pour souffler */
    align-items: center; /* centrer boutons ET carte */
  }
  .card-wrapper {
    width: 100%; /* full-width pour le wrapper */
  }
  .flashcard {
    width: 100%; /* full-width pour la carte */
    max-width: none; /* on supprime la limite à 900px */
    min-height: 220px; /* conserve votre hauteur mini */
  }
}

/* ==== Animations swipe =============================================== */
.flashcard {
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.swipe-right {
  transform: translateX(120%);
  opacity: 0;
}
.swipe-left {
  transform: translateX(-120%);
  opacity: 0;
}

/* préfère : moins d’animations */
@media (prefers-reduced-motion: reduce) {
  .flashcard {
    transition: none;
  }
}
