/* --- Polices & Variables --- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap");

:root {
  --font-main: "Inter", sans-serif;
  --color-bg: #0c1427;
  --color-surface: #1a2742;
  --color-text: #e0e7ff;
  --color-text-muted: #9fb3d3;
  --color-accent: #60a5fa;
  --color-border: #314269;
  --radius: 12px;
}

/* --- Styles Généraux --- */
body {
  font-family: var(--font-main);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  font-size: 16px;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}
a {
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity 0.2s;
  font-weight: 500;
}
a:hover {
  opacity: 0.8;
}
h1,
h2,
h3,
h4 {
  font-weight: 700;
  margin: 0;
}

/* --- Header & Footer --- */
.main-header {
  padding: 1.5rem 0;
}
.header-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem 2rem;
}
.logo {
  font-weight: 700;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.logo img {
  height: 28px;
  width: auto;
  flex-shrink: 0;
}
.logo span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
}
.button {
  background: var(--color-accent);
  color: var(--color-bg);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
}

/* --- Grille Bento (Homepage) --- */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(150px, auto);
  gap: 1.5rem;
  margin-top: 2rem;
}
.grid-item {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-sizing: border-box;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 10px;
  margin-bottom: 10px;
}
.grid-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}
.col-span-2 {
  grid-column: span 2;
}
.row-span-2 {
  grid-row: span 2;
}
.col-full {
  grid-column: 1 / -1;
}
.categories-card:hover {
  transform: none;
}
.item-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.item-content h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.item-content p {
  color: var(--color-text-muted);
  margin: 0;
}
.welcome-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.welcome-card h2 {
  font-size: 2.5rem;
  color: white;
}
.welcome-card p {
  color: white;
  opacity: 0.8;
}
.thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.thread-list li {
  padding: 10px;
  border-bottom: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}
.thread-list li:last-child {
  border-bottom: none;
}
.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.stats-list li {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  padding: 0.5rem 0;
}
.stats-list strong {
  font-weight: 700;
  color: var(--color-accent);
}

/* --- Pages Intérieures --- */
.page-header {
  padding: 3rem 0;
  text-align: center;
}
.page-header h1 {
  font-size: 3rem;
  overflow-wrap: anywhere;
}
.page-header .thread-title {
  font-size: 2.5rem;
  margin-top: 1rem;
}
.breadcrumb {
  text-align: center;
  padding-bottom: 2rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.breadcrumb-separator {
  margin-left: 0.3rem;
}
.content-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.card-body {
  padding: 1.5rem;
}
.topic-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.topic-item:last-child {
  border-bottom: none;
}
.topic-info {
  flex-grow: 1;
}
.topic-meta {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.topic-stats {
  text-align: right;
}
.post-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem;
  margin-bottom: 10px;
}
.post-author {
  flex-shrink: 0;
  width: 150px;
  text-align: center;
  overflow-wrap: anywhere;
}
.post-author img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 0.5rem;
}
.post-body {
  flex-grow: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.6;
}
.post-body p {
  margin: 0 0 1em 0;
}
.post-body p:last-child {
  margin-bottom: 0;
}
.post-body img,
.post-body video {
  max-width: 100%;
  height: auto;
}
.post-body iframe {
  display: block;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}
.post-body pre {
  white-space: pre-wrap;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}
.page-link,
.pagination .current-page {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.page-link.active,
.pagination .current-page {
  background-color: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
  font-weight: 500;
}
/* Pagination de catégorie générée par Forum.php : masquée s'il n'y a qu'une page */
.pagination:not(:has(.page-link)) {
  display: none;
}
.form-container {
  max-width: 500px;
  margin: 2rem auto;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
}
.form-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px;
  color: var(--color-text);
}

/* Style pour les liens dans les threads */
.post-body a {
  text-decoration: none;
  font-weight: 500;
  color: var(--color-accent);
  background-image: linear-gradient(var(--color-accent), var(--color-accent));
  background-position: 0% 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.3s;
}
.post-body a:hover {
  background-size: 100% 1px;
}

.main-footer {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  margin-top: 3rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  text-align: left;
}

.footer-column .logo {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.footer-column .logo img {
  height: 32px;
  vertical-align: -4px;
  margin-right: 8px;
}

.footer-column p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-right: 2rem;
}

.footer-column h4 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

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

.footer-column ul li {
  margin-bottom: 0.75rem;
}

.footer-column ul a {
  font-weight: 500;
  color: var(--color-text);
}
.footer-column ul a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.footer-bottom {
  max-width: 1200px;
  margin: 3rem auto 0 auto;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.profile-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.profile-info h1 {
    font-size: 2rem;
    margin: 0;
}

.profile-info .fullname {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    font-weight: 400;
}

.profile-info .meta {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Colonnes du profil : écart régulier entre les cartes */
.profile-details,
.profile-activity {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.profile-details-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.profile-details-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.profile-details-list li:last-child {
    border-bottom: none;
}

.profile-details-list strong {
    color: var(--color-text-muted);
    margin-right: 0.5rem;
}

.activity-list .topic-item {
    padding: 1rem;
}

.activity-list .topic-excerpt {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 2px solid var(--color-border);
    color: var(--color-text-muted);
}

/* Profil : derniers sujets et réponses (balisage généré par Forum.php), titre puis date puis message */
.activity-list > div {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);
}

.activity-list > div:first-child {
    padding-top: 0;
}

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

.activity-list .comment-thread-title {
    order: -1;
    font-size: 1rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.activity-list .comment-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.activity-list .comment {
    margin-top: 0.25rem;
    padding-left: 1rem;
    border-left: 2px solid var(--color-border);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.comment img,
.comment video {
    max-width: 100%;
    height: auto;
}

.comment iframe {
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 0.5rem 0;
    border: 0;
}

.comment pre {
    white-space: pre-wrap;
}

.footer-content>.footer-column:nth-of-type(2), .footer-content>.footer-column:nth-of-type(2)>ul>li{
    display: flex;
    justify-content: flex-start;
    align-items: end;
    flex-direction: column;
}

/* --- Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item --- */
/* Les règles .forum-item livrées en commentaire ne stylaient rien : les fils s'affichaient en
   texte brut. Avatar à gauche, sujet, puis auteur / messages / dernier message en dessous. */
.forum-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.content-card.forum-list {
  padding: 1.5rem;
}
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
  display: none;
}
.forum-section {
  min-width: 0;
}
.forum-section > a {
  display: block;
  color: inherit;
}
.forum-section > a > .forum-header {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-accent);
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.forum-section > a:hover > .forum-header {
  color: var(--color-accent);
}
.forum-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  column-gap: 1rem;
  row-gap: 0.3rem;
  align-items: center;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--color-border);
}
.forum-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.forum-avatar {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.forum-subject {
  grid-column: 2 / -1;
  grid-row: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.forum-subject:hover {
  color: var(--color-accent);
}
.forum-author {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}
.forum-author a {
  font-weight: 600;
}
.forum-messages {
  grid-column: 3;
  grid-row: 2;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  padding: 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
}
.forum-last-message {
  grid-column: 4;
  grid-row: 2;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-align: right;
}

/* --- Mobile --- */
@media (max-width: 900px) {
  /* Cartes empilées : sur deux colonnes, Statistiques s'étirait à la hauteur de Sujets récents */
  .bento-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .col-span-2,
  .col-full {
    grid-column: auto;
  }
  .welcome-card {
    grid-row: auto;
    min-height: 240px;
  }
  .page-header .thread-title {
    font-size: 2rem;
  }
  /* Profil : informations au-dessus de l'activité, les extraits de messages gardent toute la largeur */
  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin-top: 0.5rem;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }
  .main-header {
    padding: 0.5rem 0 1rem;
  }
  .logo {
    font-size: 1.2rem;
  }
  .main-nav {
    gap: 0.5rem 1.25rem;
  }
  .breadcrumb {
    padding-bottom: 1rem;
  }
  .bento-grid {
    gap: 1rem;
    margin-top: 0.5rem;
  }
  .grid-item {
    padding: 1.25rem 1rem;
  }
  .bento-grid > .grid-item {
    margin: 0;
  }
  .profile-header {
    gap: 1rem;
    padding: 0.5rem 0;
  }
  .profile-avatar {
    width: 72px;
    height: 72px;
  }
  .profile-info h1 {
    font-size: 1.5rem;
  }
  .activity-list .comment {
    padding-left: 0.75rem;
  }
  .welcome-card {
    min-height: 200px;
  }
  .welcome-card h2 {
    font-size: 1.75rem;
  }
  .page-header {
    padding: 1.5rem 0;
  }
  .page-header h1,
  .page-header .thread-title {
    font-size: 1.6rem;
    margin-top: 0;
  }
  .content-card.forum-list {
    padding: 1.25rem 1rem;
  }
  .forum-item {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    column-gap: 0.75rem;
  }
  .forum-avatar {
    width: 40px;
    height: 40px;
    grid-row: 1 / span 3;
  }
  .forum-last-message {
    grid-column: 2 / -1;
    grid-row: 3;
    white-space: normal;
    text-align: left;
  }
  .post-item {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }
  .post-author {
    width: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
  }
  .post-author img {
    width: 44px;
    height: 44px;
    margin: 0;
  }
  .main-footer {
    padding: 2rem 1.25rem;
    margin-top: 2rem;
  }
  .footer-content {
    grid-template-columns: minmax(0, 1fr);
  }
  .footer-content > .footer-column:nth-of-type(2),
  .footer-content > .footer-column:nth-of-type(2) > ul > li {
    align-items: flex-start;
  }
  .footer-bottom {
    margin-top: 2rem;
    padding-top: 1.5rem;
  }
}
