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

/* --- 1. VARIABLES & RESET --- */
:root {
  /* Tes variables dynamiques */
  --color-bg: #0f172a;
  --color-bg-light: #1e293b;
  --color-text: #f1f5f9;
  --color-accent: #6366f1;
  --color-card: #1e293b;
  --color-border: #334155;
  --color-text-muted: #94a3b8;
  --color-text-soft: #8392a6;
  --color-highlight: #ffd23f;
  --color-header-bg: rgba(15, 23, 42, 0.9);
  --color-link-muted: #94a3b8;
  --color-link-soft: #64748b;
  --gradient-hero: linear-gradient(135deg, #6366f1, #3b82f6);
  --gradient-logo: linear-gradient(90deg, #6366f1, #3b82f6);
  /* Accent employé comme couleur de texte (liens, pseudos) : lisible sur les cartes */
  --color-accent-text: #8486f4;
  /* Texte posé sur un fond accent (bouton) et sur le dégradé du hero */
  --color-on-accent: #ffffff;
  --color-on-hero: #ffffff;
  --hero-text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);

  --radius: 12px;
  --header-height: 70px;
}

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

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: var(--color-accent-text);
  transition: all 0.2s ease;
}
a:hover {
  color: var(--color-highlight);
}

.container {
  max-width: 1240px;
  margin: auto;
  padding: 0 24px;
}

img {
  max-width: 100%;
  display: block;
}

/* --- 2. HEADER & NAV --- */
.main-header {
  background: var(--color-header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: var(--header-height);
  padding: 8px 0;
  display: flex;
  align-items: center;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--color-text);
  letter-spacing: -0.5px;
}
.logo img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
  margin-right: 12px;
}
.logo span {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--gradient-logo);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-nav {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 32px;
}
.main-nav a {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  position: relative;
}
.main-nav a:hover {
  color: var(--color-text);
}
.main-nav a:not(.btn)::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--color-accent);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-nav a:not(.btn):hover::after {
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: var(--radius);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-cta {
  background: var(--color-accent);
  color: var(--color-on-accent) !important;
  padding: 10px 24px;
  box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1);
}
.btn-cta:hover {
  box-shadow: 0 6px 20px rgba(var(--color-accent), 0.4); /* Suppose RGB variable hack or fallback */
  filter: brightness(1.1);
}

/* --- 3. HERO SECTION --- */
/* Hero Banner (Image vide dans le DOM, gestion du fallback) */
.hero-banner {
  width: 100%;
  height: auto;
  min-height: 20px; /* Si vide */
}
.hero-banner img {
  height: auto;
  margin: 0 auto;
}

/* Hero Content */
.hero {
  background: var(--gradient-hero);
  position: relative;
  overflow: hidden;
  padding: 100px 0;
  text-align: center;
  color: var(--color-on-hero);
  margin-bottom: 40px;
}

.hero-content h1 {
  font-size: 3rem;
  font-weight: 800;
  margin: 0 0 16px 0;
  letter-spacing: -1px;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-shadow: var(--hero-text-shadow);
}
.hero-content p {
  font-size: 1.25rem;
  opacity: 0.9;
  margin: 0 auto 32px auto;
  max-width: 600px;
  text-shadow: var(--hero-text-shadow);
}
.btn-hero {
  background: white;
  color: var(--color-bg) !important; /* Contraste fort */
  padding: 14px 32px;
  font-size: 1.1rem;
}

/* --- 4. BREADCRUMB --- */
.breadcrumb {
  padding: 16px 24px;
  margin-bottom: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.breadcrumb-item {
  color: var(--color-text-muted);
  font-weight: 500;
}
.breadcrumb-separator {
  margin: 0 8px;
  opacity: 0.5;
}
.breadcrumb-item:hover {
  color: var(--color-accent-text);
}

/* --- 5. HOME: CATEGORIES & FORUM ITEMS --- */
.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  letter-spacing: -0.5px;
  overflow-wrap: anywhere;
}

/* La grille principale */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr)); /* Adaptatif */
  gap: 24px;
  margin-bottom: 60px;
}

/* Le conteneur d'une catégorie (ex: Banque, Assurance) */
.forum-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%; /* Égalise la hauteur */
}

/* Catégorie sans aucun fil : masquée (ne touche pas les .forum-section des pages profil) */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
  display: none;
}

/* Le titre de la catégorie */
.forum-section > a {
  display: block;
  background: var(--color-bg-light);
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.forum-section > a:hover .forum-header {
  color: var(--color-accent-text);
}
.forum-header {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

/* Les items (Threads) dans la liste : avatar à gauche, puis sujet,
   auteur • messages sur une ligne, et la date du dernier message */
.forum-item {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 12px;
  row-gap: 4px;
  min-height: 82px;
  padding: 16px 20px 16px 84px; /* 20px + avatar 48px + 16px */
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s;
}
.forum-item:last-child {
  border-bottom: none;
}
.forum-item:hover {
  background: var(--color-bg-light);
}

.forum-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%; /* Cercle complet */
  object-fit: cover;
  border: 1px solid var(--color-border);
}
.forum-item .forum-avatar {
  position: absolute;
  top: 16px;
  left: 20px;
}

.forum-subject {
  flex: 0 0 100%;
  min-width: 0;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-text);
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}
.forum-subject:hover {
  color: var(--color-accent-text);
  text-decoration: none;
}

/* Metadonnées (Auteur, messages, date) */
.forum-author,
.forum-messages,
.forum-last-message {
  min-width: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.forum-author {
  overflow-wrap: anywhere;
}
.forum-author a {
  font-weight: 600;
  color: var(--color-text-soft);
}
.forum-author a:hover {
  color: var(--color-accent-text);
}

.forum-messages {
  white-space: nowrap;
}
.forum-messages::before {
  content: "•";
  margin-right: 8px;
  opacity: 0.5;
}

.forum-last-message {
  flex: 0 0 100%;
  font-size: 0.8rem;
  font-style: italic;
}

/* --- 6. PAGE THREAD --- */
.thread-meta {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 32px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 20px;
  overflow-wrap: anywhere;
}

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

.thread-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  min-width: 0;
  overflow-wrap: anywhere;
}

.thread-card p {
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  color: var(--color-text);
  white-space: pre-line;
}
.thread-card p:first-child {
  margin-top: 0;
}

/* Contenu des messages : vidéos, images et blocs de code tiennent dans la carte */
.thread-card img,
.thread-card video,
.thread-card iframe {
  max-width: 100%;
}
.thread-card img,
.thread-card video {
  height: auto;
}
.thread-card iframe {
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}
.thread-card pre {
  white-space: pre-wrap;
}

.post-author {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-bottom: 0 !important; /* Override p margin */
  text-align: right;
}
.post-author a {
  font-weight: 700;
  color: var(--color-accent-text);
}

/* Aucun formulaire de réponse n'est généré : le bloc vide est masqué */
.reply-box:not(:has(form)) {
  display: none;
}
.reply-box {
  margin-top: 40px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
}
.reply-box h3 {
  margin-top: 0;
}

/* Pagination des pages catégorie */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}
.category-grid + .pagination {
  margin-top: -28px;
}
.pagination:empty {
  display: none;
}
.pagination .page-link,
.pagination .current-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text);
  font-weight: 600;
}
.pagination .page-link:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-text);
}
.pagination .current-page {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

/* --- 7. PAGE USER --- */
.profile {
  margin-top: 20px;
}

.profile-header {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-accent);
}

.profile-header > div {
  min-width: 0;
}
.profile-header h1 {
  margin: 0 0 8px 0;
  font-size: 2rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.profile-header p {
  margin: 0;
  color: var(--color-text-muted);
}

.profile-bio {
  background: var(--color-bg-light);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: 40px;
  font-style: italic;
  color: var(--color-text-soft);
  overflow-wrap: anywhere;
}
.profile-bio p {
  margin: 0;
}
.profile-bio p + p {
  margin-top: 6px;
}
.profile-bio strong {
  font-style: normal;
  font-weight: 600;
  color: var(--color-text);
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* Style générique pour les items dans thread-list (comme les posts ou threads) */
.thread-list > div,
.thread-list > article,
.thread-list > li {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  padding: 16px;
  border-radius: var(--radius);
  min-width: 0;
  overflow-wrap: anywhere;
}
.thread-list > li > a {
  font-weight: 600;
  color: var(--color-text);
}
.thread-list > li > a:hover {
  color: var(--color-accent-text);
}
.thread-list + .section-title {
  margin-top: 48px;
}

/* Balisage généré par Forum.php : derniers messages et sujets du membre
   (titre du fil, date, puis le message) */
.thread-list > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.thread-list .comment-thread-title {
  order: -1;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}
.thread-list .comment-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.thread-list .comment {
  margin-top: 6px;
  white-space: pre-line;
}
.thread-list .comment img,
.thread-list .comment video,
.thread-list .comment iframe {
  max-width: 100%;
}
.thread-list .comment img,
.thread-list .comment video {
  height: auto;
}
.thread-list .comment iframe {
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}
.thread-list .comment pre {
  white-space: pre-wrap;
}

/* --- 8. FOOTER --- */
.footer {
  margin-top: auto;
}
.main-footer {
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  padding: 60px 0 20px;
  margin-top: 80px;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.footer-content {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-logo {
  height: 36px;
  width: auto;
  margin-bottom: 16px;
  opacity: 0.8;
}

.footer-col h4 {
  color: var(--color-text);
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.footer-col a {
  display: block;
  margin-bottom: 12px;
  color: var(--color-text-muted);
}
.footer-col a:hover {
  color: var(--color-accent-text);
  padding-left: 4px; /* Petit effet de glissement */
}

.footer-bottom {
  text-align: center;
  border-top: 1px solid var(--color-border);
  padding: 24px 24px 0;
  font-size: 0.9rem;
}

/* --- 9. RESPONSIVE --- */
@media (max-width: 768px) {
  .logo { font-size: 1.25rem; }

  .hero { padding: 72px 0; }
  .hero-content h1 { font-size: 2rem; }

  .category-grid { grid-template-columns: 1fr; }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }
  .footer-logo { margin: 0 auto 16px; }
  .footer-col h4 { margin: 0 0 12px; }
  .footer-col a { margin-bottom: 8px; }

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

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

  /* Header sur deux lignes : nom du site, puis la navigation */
  .main-header { position: relative; padding: 12px 0; }
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .logo { font-size: 1.2rem; }
  .main-nav {
    flex-wrap: wrap;
    gap: 8px 20px;
  }
  .main-nav .btn-cta {
    margin-left: auto;
    padding: 8px 18px;
  }

  .breadcrumb { padding: 12px 16px; }

  .hero { padding: 48px 0; margin-bottom: 32px; }
  .hero-content h1 { font-size: 1.75rem; }
  .hero-content p { font-size: 1.05rem; margin-bottom: 24px; }
  .btn-hero { padding: 12px 24px; font-size: 1rem; }

  .section-title { font-size: 1.4rem; }
  .category-grid { gap: 16px; margin-bottom: 40px; }
  .category-grid + .pagination { margin-top: -16px; }

  .forum-section > a { padding: 14px 16px; }
  .forum-item {
    min-height: 72px;
    padding: 14px 16px 14px 68px; /* 16px + avatar 40px + 12px */
  }
  .forum-item .forum-avatar {
    top: 14px;
    left: 16px;
    width: 40px;
    height: 40px;
  }

  .thread-meta { margin-bottom: 24px; }
  .post-list { gap: 16px; }
  .thread-card { padding: 16px; }
  .thread-card p { font-size: 1rem; }

  .profile-header { padding: 24px 16px; gap: 16px; }
  .profile-avatar { width: 80px; height: 80px; }
  .profile-header h1 { font-size: 1.6rem; }
  .profile-bio { padding: 16px; margin-bottom: 32px; }
  .thread-list + .section-title { margin-top: 40px; }

  .main-footer { padding: 40px 0 16px; margin-top: 56px; }
  .footer-bottom { padding: 16px 16px 0; }
}
