@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&display=swap");

:root {
  /* Variables de couleur dynamiques */
  --bg-primary: #f5fcf9;
  --bg-secondary: #ffffff;
  --border-color: #d8e5e1;
  --accent-primary: #10b981;
  --text-primary: #1f2937;
  --text-secondary: #525f71;
  --heading-text: #111827;

  /* Variables statiques */
  --white: #ffffff;
  --transparent: transparent;
  --item-hover-bg: rgba(255, 255, 255, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: "Manrope", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  animation: fadeIn 0.5s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-image: radial-gradient(var(--border-color) 1px, transparent 0);
  background-size: 30px 30px;
  opacity: 0.3;
  pointer-events: none;
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-primary);
}

h1, h2, h3, h4 {
  font-weight: 800;
  color: var(--heading-text);
}

/* --- STRUCTURE --- */
body > header,
body > main,
body > footer {
  width: 100%;
  max-width: 1200px;
  padding: 0 20px;
}

main {
  flex: 1;
  margin-top: 30px;
  width: 100%;
}

/* --- HEADER --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.logo-container a {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  height: 40px;
  object-fit: contain;
}

header nav ul {
  display: flex;
  gap: 30px;
  list-style: none;
}

header nav a {
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  padding: 5px 0;
  font-size: 15px;
}

header nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--accent-primary);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}

header nav a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

header nav a:hover {
  color: var(--text-primary);
}

.auth-buttons {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 8px 20px;
  border: 1px solid;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--white);
}

.btn-primary:hover {
  background-color: transparent;
  color: var(--accent-primary);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
  background-color: var(--item-hover-bg);
}

/* --- BREADCRUMB --- */
.breadcrumb {
  margin-bottom: 25px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

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

.breadcrumb-item:last-child {
  color: var(--text-primary);
  font-weight: 600;
  pointer-events: none;
}

.breadcrumb-separator {
  margin: 0 8px;
  font-size: 10px;
  opacity: 0.5;
}

/* --- HOME & CATEGORIES (CORRIGÉ) --- */
.masonry-grid {
  column-count: 2;
  column-gap: 30px;
}

.forum-section {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 30px;
  break-inside: avoid;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.forum-header-link {
  display: block;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255,255,255,0.02);
}

.forum-header {
  padding: 18px 25px;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--heading-text);
  letter-spacing: 0.5px;
}

/* Layout Items corrigé pour éviter l'écrasement */
.forum-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid var(--border-color);
  background-color: transparent;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

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

.forum-item:hover {
  background-color: var(--item-hover-bg);
  border-left-color: var(--accent-primary);
  transform: translateX(5px);
}

.forum-avatar {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  margin-right: 15px;
  border: 1px solid var(--border-color);
}

/* Titre sur une ligne complète à droite de l'avatar */
.forum-subject {
  width: calc(100% - 70px);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* Métadonnées forcées sous le titre */
.forum-author {
  margin-left: 65px; /* Avatar + Marge */
}

.forum-author,
.forum-messages,
.forum-last-message {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 15px;
  display: inline-block;
}

.forum-messages::before,
.forum-last-message::before {
  content: "•";
  margin-right: 8px;
  opacity: 0.5;
}

.forum-author a {
  color: var(--accent-primary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

/* --- THREAD VIEW --- */
.thread-header {
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.thread-header h1 {
  font-size: 26px;
  line-height: 1.3;
}

.post {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 20px;
  overflow: hidden;
}

.post-user-info {
  flex-shrink: 0;
  width: 180px;
  background: rgba(0,0,0,0.1);
  padding: 20px;
  text-align: center;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.post-user-info .forum-avatar {
  width: 80px;
  height: 80px;
  margin-right: 0; /* Reset margin from Home items */
  margin-bottom: 15px;
  border: 2px solid var(--border-color);
}

.post-user-info .username {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent-primary);
  word-break: break-word;
}

.post-content {
  flex-grow: 1;
  padding: 20px 25px;
  display: flex;
  flex-direction: column;
}

.post-meta {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border-color);
}

.post-body {
  font-size: 15px;
  line-height: 1.7;
}

.post-body p {
  margin-bottom: 1em;
}

.post-body iframe {
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  margin: 10px 0;
  display: block;
}

/* --- USER PROFILE --- */
.profile-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 30px;
  display: flex;
  align-items: center;
  gap: 30px;
  position: relative;
  overflow: hidden;
}

.profile-header::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--item-hover-bg));
  pointer-events: none;
}

.profile-header .forum-avatar {
  width: 120px;
  height: 120px;
  border: 4px solid var(--bg-primary);
  box-shadow: 0 0 0 2px var(--accent-primary);
  margin: 0;
}

.profile-info h1 {
  font-size: 32px;
  margin-bottom: 5px;
}

.profile-info .usertitle {
  font-size: 14px;
  text-transform: uppercase;
  background: var(--accent-primary);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 10px;
  font-weight: 700;
}

.profile-info .joindate {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

.profile-body {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-top: 20px;
}

.profile-details,
.profile-activity {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 25px;
}

.profile-body h3 {
  font-size: 16px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.details-list {
  list-style: none;
}

.details-list li {
  margin-bottom: 15px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 5px;
}

.details-list li strong {
  display: block;
  color: var(--accent-primary);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.activity-list > div {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.activity-list .comment-thread-title {
  margin-bottom: 5px;
}

.activity-list .comment-thread-title a {
  font-weight: 700;
  font-size: 15px;
}

.activity-list .comment-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.activity-list .comment {
  font-size: 14px;
  background: var(--bg-primary);
  padding: 12px;
  border-radius: 4px;
  border-left: 3px solid var(--accent-primary);
  font-style: italic;
  color: var(--text-secondary);
}

/* --- FOOTER --- */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  padding: 40px 20px;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

footer nav {
  display: flex;
  gap: 25px;
}

footer nav a {
  color: var(--text-secondary);
}

footer nav a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 992px) {
  .masonry-grid {
    column-count: 1;
  }
  
  .profile-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }
  
  header nav ul {
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .forum-author {
    margin-left: 0;
    display: block;
    width: 100%;
    margin-top: 5px;
  }

  .post {
    flex-direction: column;
  }

  .post-user-info {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
    padding: 10px 15px;
    text-align: left;
    justify-content: flex-start;
    gap: 15px;
  }

  .post-user-info .forum-avatar {
    width: 50px;
    height: 50px;
    margin-bottom: 0;
    margin-right: 0;
  }

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