:root {
  /* -- Thème Clair (défaut) -- */
  --color-bg: #F2F6FE;
  --color-surface: #FFFFFF;
  --color-border: #E0E7F4;
  --color-text-primary: #1C274C;
  --color-text-secondary: #576289;
  --color-accent: #0F52BA;
  --color-accent-hover: #0E48A2;
  /* Texte des boutons pleins (fond accent) */
  --color-text-on-accent: #FFFFFF;
  /* Texte en couleur accent (survols) sur le fond de page ou les cartes */
  --color-accent-text: #0F52BA;

  /* -- Couleurs fixes -- */
  --color-banner-overlay: rgba(20, 30, 40, 0.5);
  --color-banner-text-primary: #FFFFFF;
  --color-banner-text-secondary: #E5E7EB;

  /* -- Polices & Espacements -- */
  --font-family: 'Inter', sans-serif;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.07);
}

body.dark-mode {
  /* -- Thème Sombre -- */
  --color-bg: #0A1931;
  --color-surface: #182C4A;
  --color-border: #2A4065;
  --color-text-primary: #E9ECF4;
  --color-text-secondary: #9DA6B9;
  --color-accent: #5A92ED;
  --color-accent-hover: #7DAAF0;
  --color-text-on-accent: #0A1931;
  --color-accent-text: #5A92ED;
}

/* ===== CONFIGURATION GLOBALE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-family);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Lien global par défaut (reset) */
a {
    color: inherit;
    text-decoration: none;
}

.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  transition: border-color 0.3s ease;
}
.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 80px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text-primary);
  text-decoration: none;
}
.logo img {
  height: 40px;
  width: auto;
  max-width: 120px;
  flex-shrink: 0;
  object-fit: contain;
}
.logo span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.main-nav {
  display: flex;
  gap: 2rem;
  flex-shrink: 0;
}
.main-nav a {
  text-decoration: none;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
}
.main-nav a.active,
.main-nav a:hover {
  color: var(--color-accent-text);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
#theme-toggle:hover {
  background-color: var(--color-surface);
  color: var(--color-accent-text);
}
.login-button {
  background-color: var(--color-accent);
  color: var(--color-text-on-accent);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
.login-button:hover {
  background-color: var(--color-accent-hover);
}

/* ===== FIL D'ARIANE (BREADCRUMB) ===== */
/* Liens générés par Forum.php, regroupés dans nav.breadcrumb (header.html) */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
    min-width: 0;
}
a.breadcrumb-item {
    display: inline-block;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}
a.breadcrumb-item:hover {
    color: var(--color-accent-text);
    text-decoration: underline;
}
.breadcrumb-separator {
    display: inline-block;
    margin: 0 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/* ===== BANNIÈRE (ACCUEIL) ===== */
.banner {
  text-align: center;
  border-radius: var(--radius);
  margin-top: 2rem;
  position: relative;
  overflow: hidden;
  padding: 0;
  min-height: 250px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background-color: var(--color-surface); /* Fallback */
}
/* Le moteur insère la bannière en <img> sans classe : image de fond */
.banner > img,
.banner-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.banner-content {
    position: relative;
    z-index: 2;
    padding: 2rem;
    width: 100%;
    min-width: 0;
    /* Overlay pour lisibilité */
    background: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.7));
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.banner h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  color: #FFFFFF;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}
.banner p {
  font-size: 1.1rem;
  color: #E5E7EB;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  overflow-wrap: anywhere;
}

/* ===== CONTENU PRINCIPAL ===== */
.main-content {
  padding: 2rem 0;
  flex: 1;
}

/* ===== LISTE DES FORUMS (HOME) ===== */
.forum-section {
    margin-bottom: 2.5rem;
}

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

/* Titre de section (Catégorie) */
.forum-section > a {
    text-decoration: none;
    display: block;
    margin-bottom: 1rem;
}

.forum-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    border-left: 4px solid var(--color-accent);
    padding-left: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
    /* Reset du style breadcrumb-item s'il est appliqué par erreur via la classe */
    margin-top: 0;
}

/* Carte/Ligne d'un sujet */
.forum-item {
    display: grid;
    /* Avatar | Sujet (extensible) | Auteur | Messages | Date
       (messages et date à largeur fixe : colonnes alignées d'une ligne à l'autre) */
    grid-template-columns: 48px minmax(0, 3fr) minmax(0, 1.2fr) minmax(6rem, auto) minmax(15rem, auto);
    gap: 1.25rem;
    align-items: center;
    padding: 1.25rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    margin-bottom: -1px; /* Fusion des bordures */
    transition: background-color 0.2s ease, z-index 0.2s;
    position: relative;
}

.forum-item:first-of-type {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}
.forum-item:last-of-type {
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    margin-bottom: 0;
}
.forum-item:hover {
    background-color: rgba(0,0,0,0.02); /* Très léger changement au survol */
    z-index: 1; /* Met la bordure au dessus */
}

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

/* Sujet du thread */
.forum-subject {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 1.05rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.forum-subject:hover {
    color: var(--color-accent-text);
}

/* Colonnes méta (Auteur, Messages, Date) */
.forum-author,
.forum-messages,
.forum-last-message {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.forum-author a {
    font-weight: 600;
    color: var(--color-text-primary);
}
.forum-author a:hover {
    text-decoration: underline;
}

.forum-messages {
    text-align: center;
    white-space: nowrap;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.forum-last-message {
    font-size: 0.85rem;
    text-align: right;
    white-space: nowrap;
}

/* ===== PAGE PROFIL (GRID) ===== */
.profile-grid {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 2rem;
    align-items: flex-start;
}
.profile-sidebar,
.profile-main-content {
    min-width: 0;
}

/* Sidebar Profil */
.profile-sidebar {
    position: sticky;
    top: 2rem;
}

.profile-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--color-bg);
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    object-fit: cover;
}

.profile-username {
    margin: 0.5rem 0;
    font-size: 1.8rem;
    line-height: 1.25;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
}

.profile-job {
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    overflow-wrap: anywhere;
}

.profile-meta {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.profile-card-title {
    font-size: 1.1rem;
    text-align: left;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 0.5rem;
    display: inline-block;
}
.profile-card p {
    text-align: left;
    color: var(--color-text-secondary);
    line-height: 1.5;
    overflow-wrap: anywhere;
}
/* Métier centré sous le pseudo */
.profile-card .profile-job {
    text-align: center;
}

/* Contenu Principal Profil (Activité) */
.profile-section {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.category-title::before {
    content: '';
    display: block;
    width: 6px;
    height: 24px;
    background-color: var(--color-accent);
    border-radius: 2px;
}

/* Liste d'activités (basée sur des divs simples comme dans le DOM) */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-list > div {
    min-width: 0;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.activity-list > div > :last-child {
    margin-bottom: 0;
}

.activity-list > div:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--color-accent);
}

/* Détails des commentaires/threads */
.comment-date {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.comment-thread-title {
    font-size: 1.1rem;
    margin: 0 0 1rem 0;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.comment-thread-title a {
    color: var(--color-text-primary);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}
.comment-thread-title a:hover {
    color: var(--color-accent-text);
}

.comment {
    font-size: 1rem;
    color: var(--color-text-secondary);
    background-color: var(--color-bg); /* Léger contraste interne */
    padding: 1rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--color-border);
    font-style: italic;
    overflow-wrap: anywhere;
}
/* Vidéos, images et code des messages : limités à la largeur */
.comment img,
.comment video,
.comment iframe {
    max-width: 100%;
}
.comment img,
.comment video {
    height: auto;
}
.comment iframe {
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    vertical-align: middle;
}
.comment pre {
    white-space: pre-wrap;
}

/* ===== TITRE DE PAGE, BOUTONS, PAGINATION ===== */
.page-title {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 2rem;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
}
.button {
    display: inline-block;
    background-color: var(--color-accent);
    color: var(--color-text-on-accent);
    padding: 0.7rem 1.3rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.button:hover {
    background-color: var(--color-accent-hover);
}
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}
.pagination:empty {
    display: none;
}
/* Une seule page : pas de bouton « 1 » isolé */
.pagination:not(:has(.page-link)) {
    display: none;
}
.pagination .current-page,
.pagination .page-link {
    min-width: 2.5rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-weight: 500;
    text-align: center;
}
.pagination .page-link {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
}
.pagination .page-link:hover {
    border-color: var(--color-accent);
    color: var(--color-accent-text);
}
.pagination .current-page {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-on-accent);
}

/* ===== PAGE SUJET (THREAD) ===== */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.post-card {
    min-width: 0;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.post-author {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.post-author > a {
    display: block;
    flex-shrink: 0;
    line-height: 0;
}
.post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}
.post-author-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.4;
}
.author-name {
    font-weight: 700;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
}
.author-name:hover {
    color: var(--color-accent-text);
}
.post-date {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}
.post-content {
    padding: 1.5rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}
/* Liens des messages : couleur du texte, soulignés en accent */
.post-content a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 2px;
}
.post-content a:hover {
    color: var(--color-accent-text);
}
.post-content img,
.post-content video,
.post-content iframe {
    max-width: 100%;
}
.post-content img,
.post-content video {
    height: auto;
}
.post-content iframe {
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    vertical-align: middle;
}
.post-content pre {
    white-space: pre-wrap;
}
.reply-form {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
}
.reply-form h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.reply-form textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

/* ===== FOOTER ===== */
.footer {
    margin-top: auto; /* Push footer to bottom */
}
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
  padding: 2rem 0;
  background-color: var(--color-surface);
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.footer-nav {
  display: flex;
  gap: 1.5rem;
}
.footer-nav a {
  font-weight: 500;
  color: var(--color-text-secondary);
}
.footer-nav a:hover {
  color: var(--color-accent-text);
}

/* ===== ANIMATION À L'AFFICHAGE ===== */
/* Fondu joué au chargement : le contenu reste visible sans JavaScript */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
[data-animate="fade-in"] {
  animation: fade-in-up 0.6s ease-out both;
}
@media (prefers-reduced-motion: reduce) {
  [data-animate="fade-in"] {
    animation: none;
  }
}

/* ===== RESPONSIVE ===== */
/* Liste des fils sous 1100 px : sujet sur toute la largeur, auteur / messages / date dessous.
   Un pseudo long passe à la ligne ; le nombre de messages et la date gardent leur place. */
@media (max-width: 1099px) {
    .forum-item {
        grid-template-columns: 48px auto auto minmax(9rem, 1fr);
        gap: 0.35rem 1rem;
        padding: 1rem 1.25rem;
    }
    .forum-avatar {
        grid-column: 1;
        grid-row: 1 / span 2;
    }
    .forum-subject {
        grid-column: 2 / -1;
        grid-row: 1;
    }
    .forum-author,
    .forum-messages,
    .forum-last-message {
        grid-row: 2;
        display: block;
        font-size: 0.85rem;
    }
    .forum-author { grid-column: 2; }
    .forum-messages {
        grid-column: 3;
        min-width: auto;
        text-align: left;
    }
    .forum-last-message {
        grid-column: 4;
        text-align: right;
        white-space: normal;
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        padding: 0 1.5rem;
    }
    .header-content {
        min-height: 0;
        padding: 1rem 0;
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
    }
    .logo {
        flex: 1 1 auto;
        font-size: 1.3rem;
    }
    .main-nav {
        order: 3;
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1.5rem;
    }

    .banner {
        min-height: 200px;
        margin-top: 1.5rem;
    }
    .banner-content {
        padding: 1.5rem;
    }
    .banner h1 {
        font-size: 1.9rem;
    }
    .banner p {
        font-size: 1rem;
    }

    /* Profil Mobile */
    .profile-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .profile-sidebar {
        position: static;
    }
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0 1rem;
        text-align: center;
    }
    .footer-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1.25rem;
    }
    .footer-nav a {
        white-space: nowrap;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .page-wrapper {
        padding: 0 1rem;
    }
    /* Logo sur toute la largeur, menu et boutons sur la ligne suivante */
    .logo {
        flex-basis: 100%;
        font-size: 1.2rem;
    }
    .main-nav {
        order: 2;
        width: auto;
        justify-content: flex-start;
        gap: 0.5rem 1rem;
        font-size: 0.95rem;
    }
    .header-actions {
        order: 3;
        margin-left: auto;
        gap: 0.5rem;
    }
    .login-button {
        padding: 0.5rem 0.9rem;
    }

    .banner {
        min-height: 180px;
        margin-top: 1.25rem;
    }
    .banner-content {
        padding: 1.25rem 1rem;
    }
    .banner h1 {
        font-size: 1.5rem;
    }
    .banner p {
        font-size: 0.95rem;
    }

    .forum-header,
    .page-title {
        font-size: 1.35rem;
    }
    .page-title {
        margin-bottom: 1.25rem;
    }

    .forum-item {
        grid-template-columns: 40px auto 1fr;
        gap: 0.3rem 0.75rem;
        padding: 0.9rem 1rem;
    }
    .forum-avatar {
        grid-row: 1 / span 3;
        align-self: start;
        width: 40px;
        height: 40px;
    }
    /* Titre complet, sur plusieurs lignes */
    .forum-subject {
        display: block;
        overflow: visible;
        -webkit-line-clamp: unset;
        font-size: 1rem;
    }
    .forum-messages::before {
        content: "·";
        margin-right: 0.75rem;
    }
    .forum-last-message {
        grid-column: 2 / -1;
        grid-row: 3;
        text-align: left;
    }

    .post-author {
        padding: 0.85rem 1rem;
    }
    .post-content {
        padding: 1rem;
    }
    .reply-form {
        padding: 1rem;
    }

    /* Profil */
    .profile-card {
        padding: 1.5rem 1.25rem;
    }
    .profile-avatar {
        width: 96px;
        height: 96px;
    }
    .profile-username {
        font-size: 1.5rem;
    }
    .category-title {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    .activity-list > div {
        padding: 1rem;
    }
    .comment-thread-title {
        font-size: 1rem;
    }
    .comment {
        padding: 0.75rem;
    }
}

/* Petits mobiles (360 px) : menu et boutons gardent la même ligne */
@media (max-width: 400px) {
    .header-content {
        column-gap: 0.75rem;
    }
    .main-nav {
        column-gap: 0.75rem;
    }
    #theme-toggle {
        padding: 0.4rem;
    }
    .login-button {
        padding: 0.5rem 0.75rem;
    }
}
