@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;700;800&display=swap");

:root {
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --color-background: #FFF5F7;
    --color-surface: #FFFFFF;
    --color-text-primary: #4A2733;
    --color-text-secondary: #946070;
    --color-accent: #E56894;
    --color-border: #F8E6EB;
    /* Accent lisible sur les cartes (liens, bouton) et encre posée dessus */
    --color-link: #C2416F;
    --color-on-link: #FFFFFF;
    /* Motif du fond, discret sur les palettes claires */
    --color-texture: #FCEDF1;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body {
  font-family: var(--font-primary);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0; /* Reset padding body pour éviter scrollbar double */
  padding-bottom: 40px;
  /* Texture subtile */
  background-image: linear-gradient(45deg, var(--color-texture) 25%, transparent 25%),
    linear-gradient(-45deg, var(--color-texture) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--color-texture) 75%),
    linear-gradient(-45deg, transparent 75%, var(--color-texture) 75%);
  background-size: 20px 20px;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.2s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: none;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* --- 2. Layout & Containers --- */
.container {
  max-width: 1100px; /* Un peu plus large pour la grille forum */
  margin: 24px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Style Carte Générique (Utilisé par Header, Footer, Profile) */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* --- 3. Header & Footer --- */
.main-header {
  margin: 20px auto 0;
  max-width: 1100px;
  /* Surcharge pour le header qui est hors container dans le DOM */
  width: calc(100% - 40px); 
  box-sizing: border-box;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--color-text-primary);
}

.logo span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.logo-image {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.main-nav a {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.main-nav a:hover {
  color: var(--color-accent);
}

.main-footer {
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin: 0 auto 20px;
  max-width: 1100px;
  width: calc(100% - 40px);
  box-sizing: border-box;
}

/* --- 4. Breadcrumb --- */
.breadcrumb {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: -10px; /* Rapprocher du contenu */
}

.breadcrumb-item {
  color: var(--color-text-secondary);
}

.breadcrumb-item:hover {
  color: var(--color-accent);
}

.breadcrumb-separator {
  margin: 0 8px;
  color: var(--color-border);
}

/* --- 5. Page Accueil (Forum List) --- */

/* Simulation du style Card pour .forum-section qui n'a pas la classe */
.forum-section {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0; /* Padding géré par les items */
  overflow: hidden;
  margin-bottom: 24px;
}

/* Titre de catégorie */
.forum-header {
  margin: 0;
  padding: 20px 24px;
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--color-border);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-text-primary);
  display: block;
}

.forum-header:hover {
  color: var(--color-accent);
}

/* Items du forum (Grille 5 colonnes) */
.forum-item {
  display: grid;
  /* Avatar | Sujet | Auteur | Messages | Dernier msg */
  grid-template-columns: 48px minmax(0, 3fr) minmax(0, 1fr) auto minmax(0, 1.7fr);
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.2s;
}

.forum-item:last-child {
  border-bottom: none;
}

.forum-item:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.forum-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.forum-subject {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.forum-author,
.forum-messages,
.forum-last-message {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.forum-author a {
  color: var(--color-text-secondary);
}

.forum-messages {
  text-align: center;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.forum-last-message {
  text-align: right;
  font-style: italic;
}

/* --- 6. Page User (Profil) --- */

/* Header du Profil */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.profile-details {
  display: flex;
  align-items: center;
  gap: 24px;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid var(--color-background);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.profile-info h1 {
  margin: 0 0 8px 0;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-text-primary);
}

.author-meta {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  display: block;
}

/* Stats (Droite) */
.profile-stats {
  display: flex;
  gap: 24px;
  background: var(--color-background);
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.stat-item strong {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1;
}

.stat-item span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* Flux d'activité */
.activity-feed {
  padding: 0;
  overflow: hidden;
}

.activity-feed .category-title {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 20px 24px;
  margin: 0;
  border-bottom: 1px solid var(--color-border);
  background: rgba(0,0,0,0.1);
}

.thread-list {
  display: flex;
  flex-direction: column;
}

/* Ciblage des div dans la liste (Structure Activity) */
.thread-list > div {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s;
}

.thread-list > div:last-child {
  border-bottom: none;
}

.thread-list > div:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.comment-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.comment-thread-title {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
}

.comment-thread-title a {
  color: var(--color-text-primary);
}

.comment-thread-title a:hover {
  color: var(--color-accent);
}

.comment {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  background: var(--color-background);
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid var(--color-accent);
}

/* --- 7. Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item --- */
.forum-section > a {
  display: block;
}

/* Catégories sans fil masquées sur l'accueil */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
  display: none;
}

.forum-item > * {
  min-width: 0;
}

.forum-subject,
.forum-author {
  overflow-wrap: anywhere;
}

/* Bannière : le moteur insère une balise <img> complète */
.hero-banner img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* --- 8. Page Sujet --- */
.thread-header-card h1 {
  margin: 0 0 12px;
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

.thread-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.thread-meta a,
.author-name,
.post-body a {
  color: var(--color-link);
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
}

.post-author {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding-right: 24px;
  border-right: 1px solid var(--color-border);
  text-align: center;
}

.author-avatar {
  display: block;
  width: 80px;
  height: 80px;
  margin-bottom: 8px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.author-name {
  overflow-wrap: anywhere;
}

.post-meta {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.post-content {
  min-width: 0;
}

/* Contenu des messages : paragraphes, textes longs, images et vidéos intégrées */
.post-body {
  overflow-wrap: anywhere;
}

.post-body p {
  margin: 0;
  white-space: pre-line;
}

.post-body a {
  text-decoration: underline;
}

.post-body img,
.post-body video,
.post-body iframe {
  max-width: 100%;
}

.post-body img,
.post-body video {
  height: auto;
}

.post-body iframe {
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
}

/* Le moteur entoure chaque vidéo de <br> : les retours à la ligne du texte suffisent */
.post-body br:has(+ iframe),
.post-body iframe + br {
  display: none;
}

.post-body pre {
  white-space: pre-wrap;
}

/* Pagination : le moteur ne la remplit que sur les pages catégorie */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.pagination:not(:has(*)) {
  display: none;
}

.pagination .page-link,
.pagination .current-page {
  min-width: 36px;
  padding: 6px 12px;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-align: center;
  color: var(--color-text-primary);
}

.pagination .current-page {
  background-color: var(--color-link);
  border-color: var(--color-link);
  color: var(--color-on-link);
  font-weight: 700;
}

/* Formulaire de réponse */
.reply-form .category-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
  font-weight: 800;
}

.form-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-primary);
  font-size: 1rem;
  resize: vertical;
}

.form-input::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

.button {
  margin-top: 12px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background-color: var(--color-link);
  color: var(--color-on-link);
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  opacity: 0.85;
}

/* --- 9. Page Catégorie --- */
.page-header-card {
  margin-bottom: 24px;
}

.page-header-card h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

/* --- Responsive Mobile --- */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .main-header,
  .main-footer {
    width: calc(100% - 32px);
  }

  .forum-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    text-align: center;
  }

  .forum-avatar {
    margin: 0 auto;
  }

  .forum-messages {
    display: inline-block;
    margin: 5px auto;
  }

  .forum-last-message {
    text-align: center;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
  }

  .profile-details {
    flex-direction: column;
  }

  .header-content {
    flex-direction: column;
    gap: 16px;
  }

  .logo {
    justify-content: center;
    text-align: center;
  }

  .main-nav {
    justify-content: center;
  }

  .post {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .post-author {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 0;
    align-items: center;
    justify-items: start;
    padding: 0 0 12px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
  }

  .post-author > a:first-child {
    grid-row: 1 / span 2;
  }

  .author-avatar {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
  }

  .author-name {
    align-self: end;
  }

  .author-meta {
    align-self: start;
  }
}

@media (max-width: 480px) {
  .container {
    margin: 16px auto;
    gap: 16px;
  }

  .main-header,
  .main-footer,
  .thread-header-card,
  .post,
  .reply-form,
  .page-header-card,
  .profile-header {
    padding: 16px;
  }

  .main-header {
    margin-top: 16px;
  }

  .logo {
    font-size: 1.2rem;
  }

  .forum-header {
    padding: 16px;
    font-size: 1.15rem;
  }

  .forum-item {
    padding: 16px;
  }

  .thread-header-card h1 {
    font-size: 1.4rem;
  }

  .page-header-card h1 {
    font-size: 1.6rem;
  }
}