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

:root {
    --font-primary: "Roboto", sans-serif;
    --color-background: #F3F6F4;
    --color-surface-main: #FFFFFF;
    --color-surface-column: #F1F5F2;
    --color-text-primary: #1E2A22;
    --color-text-secondary: #5A6D64;
    --color-accent: #2E8B57;
    /* Accent utilisé comme texte (liens, boutons) : lisible sur les surfaces et le fond */
    --color-link: #297C4D;
    --color-border: #EAEFEC;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

body {
  font-family: var(--font-primary);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  margin: 0;
}

a {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
}
a:hover {
  opacity: 0.8;
}

/* --- Structure générale --- */
.page-wrapper {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}
.container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
  box-sizing: border-box;
}

/* --- Header & Footer --- */
.main-header {
  background-color: var(--color-surface-main);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  flex-shrink: 0;
}
.header-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.5rem;
  min-width: 0;
}
.logo span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.logo-image {
  height: 32px;
  width: auto;
  max-width: 120px;
  flex-shrink: 0;
  object-fit: contain;
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.main-nav a {
  color: var(--color-text-secondary);
}
.main-footer {
  padding: 24px 0;
  margin-top: 24px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* --- Composants de la page d'accueil --- */
.breadcrumb {
  padding: 16px 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.breadcrumb .separator,
.breadcrumb-separator {
  margin: 0 8px;
}
.hero-banner {
  border-radius: var(--radius);
  overflow: hidden;
  height: 150px;
  margin-bottom: 16px;
}
.hero-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Le tableau Kanban --- */
.kanban-board-wrapper {
    width: 100%;
    overflow-x: auto;
    flex-grow: 1;
}

.kanban-column {
    flex-shrink: 0;
    width: 340px;
    background-color: var(--color-surface-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}
.column-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--color-border);
}
.thread-list {
    list-style: none;
    padding: 8px;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}
.thread-card {
    background-color: var(--color-surface-main);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
}
.thread-title {
    font-weight: 500;
    color: var(--color-text-primary);
    display: block;
    margin-bottom: 12px;
}
.thread-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}
.author-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.author-avatar-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}


/* --- Footer --- */
.main-footer {
    padding: 24px 0;
    background-color: var(--color-surface-main);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

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

.footer-copyright {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    text-align: left;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.footer-copyright .logo {
    font-size: 1.2rem;
}

.footer-copyright p {
    margin: 0;
}

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

.footer-nav a {
    font-weight: 500;
    color: var(--color-text-secondary);
}
.footer-nav a:hover {
    color: var(--color-accent);
}

.footer-social {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.footer-social a {
    font-weight: 700;
    color: var(--color-text-primary);
}

/* --- Page de Sujet (Thread) --- */

.thread-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 24px;
    margin-top: 32px;
}

.thread-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.thread-header h1 {
    flex: 1 1 320px;
    min-width: 0;
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;
}
.button {
    display: inline-block;
    background-color: var(--color-link);
    color: var(--color-surface-main);
    border: none;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.button:hover {
    opacity: 0.9;
}

.post-card {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.post-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-surface-column);
    border-radius: var(--radius) var(--radius) 0 0;
}
.post-header .author-info {
    min-width: 0;
}
.author-name {
    font-weight: 700;
    color: var(--color-text-primary);
    min-width: 0;
    overflow-wrap: anywhere;
}
.post-meta {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}
.post-body {
    padding: 24px 16px;
    font-size: 1rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}
/* Les messages sont du texte brut : on garde leurs retours à la ligne */
.post-body p {
    margin: 0 0 1em 0;
    white-space: pre-line;
}
.post-body img,
.post-body video {
    max-width: 100%;
    height: auto;
}
/* Le moteur entoure les vidéos de <br> : inutiles avec pre-line */
.post-body br:has(+ iframe),
.post-body iframe + br {
    display: none;
}
.post-body iframe {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
}
.post-body pre {
    white-space: pre-wrap;
}
.post-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
.post-body p:last-child {
    margin-bottom: 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin: 24px 0;
}
.pagination:empty {
    display: none;
}
.pagination-link,
.pagination .page-link,
.pagination .current-page {
    font-weight: 500;
    color: var(--color-text-secondary);
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 14px;
}
.pagination-link:hover,
.pagination .page-link:hover {
    border-color: var(--color-link);
    color: var(--color-link);
    opacity: 1;
}
.pagination-link.active,
.pagination .current-page {
    background-color: var(--color-link);
    color: var(--color-surface-main);
    border-color: var(--color-link);
    pointer-events: none;
}

.reply-form {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
}
.reply-form h3 {
    font-weight: 700;
    margin: 0 0 16px 0;
}
.form-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-primary);
    font-size: 1rem;
    box-sizing: border-box;
    margin-bottom: 16px;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* --- Widgets de la Sidebar --- */
.widget {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    font-size: 0.9rem;
}
.widget-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0 0 16px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}
.widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
    line-height: 2;
    color: var(--color-text-secondary);
}
.widget-list strong {
    color: var(--color-text-primary);
}

/* --- Page Toutes les Catégories --- */
.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 24px;
}
.category-list-container {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.list-header, .category-row, .thread-item-row {
    display: grid;
    align-items: center;
    padding: 12px 24px;
    gap: 16px;
}
.list-header {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--color-border);
}
.category-row, .thread-item-row {
    border-top: 1px solid var(--color-border);
}
/* Spécifique à la liste des catégories */
.category-list-container .list-header, .category-list-container .category-row {
    grid-template-columns: 2.5fr 1fr 1.5fr;
}
.category-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 4px 0;
}
.category-title a {
    color: var(--color-text-primary);
}
.category-desc {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
}
.category-stats {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
}
.last-post-info {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
}
.last-post-info a {
    color: var(--color-text-primary);
    display: block;
}

/* --- Page Catégorie Unique --- */
.thread-list-container {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
/* Spécifique à la liste des threads */
.thread-list-container .list-header, .thread-list-container .thread-item-row {
    grid-template-columns: 3fr 1fr 1fr;
}
.thread-item-row .author-meta {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/* --- Page de Profil Utilisateur --- */

.profile-header {
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.profile-banner {
    height: 150px;
    background-color: var(--color-surface-column);
}

.profile-details {
    padding: 0 24px 24px 24px;
    display: flex;
    align-items: flex-end;
    gap: 24px;
}

.profile-avatar {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--color-surface-main);
    margin-top: -60px; /* Fait remonter l'avatar sur la bannière */
}

.profile-name {
    min-width: 0;
}

.profile-name h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.profile-name span {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.profile-actions {
    margin-left: auto;
}

.post-link-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    display: block;
}

/* Derniers sujets et commentaires du profil : des <li> sans <ul> */
.post-list > li {
    list-style-position: inside;
}

/* --- Pages Login & Register --- */
.form-wrapper {
    padding: 40px 0;
}
.form-container {
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 32px 40px;
    box-shadow: var(--shadow);
}
.form-title {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 32px 0;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
}
.form-container .button {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    margin-top: 8px;
}
.form-switch-link {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.post-body a,
.post-content a,
.activity-snippet a,
.comment a {
    color: var(--color-link); 
    
    text-decoration: none; 
    font-weight: 600;
    
    background-image: linear-gradient(var(--color-link), var(--color-link));
    background-position: 0% 100%;
    background-repeat: no-repeat;
    background-size: 0% 2px;
    transition: background-size 0.3s ease;
}

.post-body a:hover,
.post-content a:hover,
.activity-snippet a:hover,
.comment a:hover {
    background-size: 100% 2px;
}

.thread-main-content{
    background-color: var(--color-surface-main);
    padding: 15px;
    border-radius: 15px;
    min-width: 0;
}

.thread-main-content>.page-title{
font-size: 1.5rem;
}

/* Profil : derniers sujets et commentaires, balisage généré par Forum.php
   (div > h4.comment-thread-title + div.comment-date + div.comment) */
.post-list > div:has(> .comment-thread-title) {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 14px 0;
    border-top: 1px solid var(--color-border);
}
.post-list > .widget-title + div:has(> .comment-thread-title) {
    padding-top: 0;
    border-top: 0;
}
.comment-thread-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.comment-thread-title a {
    font-weight: 600;
}
.comment-date {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}
/* Les messages sont du texte brut : on garde leurs retours à la ligne */
.comment {
    margin-top: 4px;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.comment br:has(+ iframe),
.comment iframe + br {
    display: none;
}
.comment iframe {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
}
.comment img,
.comment video {
    max-width: 100%;
    height: auto;
}
.comment pre {
    white-space: pre-wrap;
}
.comment table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

/* Profil : la colonne latérale est placée avant le contenu */
.thread-layout:has(> .thread-sidebar:first-child) {
    grid-template-columns: 320px minmax(0, 1fr);
}

.kanban-board {
    display: grid;
    gap: 24px;
    padding: 24px 0;
    background-color: var(--color-background);
    grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 768px) {
    .kanban-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ---=== Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item ===--- */
.forum-section {
    background-color: var(--color-surface-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.forum-section:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}
/* Catégorie sans fil : masquée */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
    display: none;
}
.forum-section > a {
    display: block;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
}
.forum-section > a > .forum-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--color-border);
    margin: 0;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
}
.forum-section > a:hover > .forum-header {
    color: var(--color-link);
}
/* Carte de fil : auteur et nombre de messages, sujet, date du dernier message */
.forum-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background-color: var(--color-surface-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 8px 8px 8px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease-in-out;
}
.forum-item:hover {
    box-shadow: 0 6px 12px -3px rgba(0,0,0,0.1);
}
.forum-avatar {
    grid-area: avatar;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.forum-author {
    grid-area: author;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 46px);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
}
.forum-messages {
    grid-area: messages;
    margin-left: auto;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background-color: var(--color-surface-column);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 2px 10px;
}
.forum-subject {
    grid-area: subject;
    order: 1;
    flex: 1 1 100%;
    min-width: 0;
    margin-top: 2px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text-primary);
    line-height: 1.4;
    overflow-wrap: anywhere;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.forum-subject:hover {
    color: var(--color-link);
}
.forum-last-message {
    grid-area: date;
    order: 2;
    flex: 1 1 100%;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/* Page catégorie : une ligne par fil, alignée sur les colonnes de l'en-tête */
.category-list-container {
    overflow: hidden;
}
.category-list-container .list-header,
.category-list-container .forum-item {
    grid-template-columns: 36px minmax(0, 2.5fr) minmax(0, 1fr) minmax(0, 1.5fr);
}
.category-list-container .list-header span:first-child {
    grid-column: 1 / 3;
}
.category-list-container .forum-section,
.category-list-container .forum-section:hover {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    transform: none;
}
.category-list-container .forum-section > a {
    display: none;
}
.category-list-container .forum-item {
    display: grid;
    grid-template-areas:
        "avatar subject messages date"
        "avatar author messages date";
    gap: 2px 16px;
    margin: 0;
    padding: 14px 24px;
    border: 0;
    border-top: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
}
.category-list-container .forum-item:first-of-type {
    border-top: 0;
}
.category-list-container .forum-messages {
    justify-self: start;
    margin-left: 0;
}
.category-list-container .forum-subject {
    margin-top: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

/* --- Tablette --- */
@media (max-width: 1023px) {
    .thread-layout,
    .thread-layout:has(> .thread-sidebar:first-child) {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* --- Mobile --- */
@media (max-width: 767px) {
    .container {
        padding: 0 16px;
    }
    .main-header {
        padding: 12px 0;
    }
    .logo {
        font-size: 1.2rem;
    }
    .kanban-board {
        gap: 16px;
        padding: 16px 0;
    }
    .forum-section {
        padding: 10px;
    }
    .forum-section > a > .forum-header {
        padding: 10px 8px 14px;
    }
    .forum-item {
        margin: 0 0 8px 0;
        padding: 14px;
    }
    .category-list-container .list-header {
        display: none;
    }
    .category-list-container .forum-item {
        display: flex;
        gap: 8px 10px;
        padding: 14px 16px;
    }
    .category-list-container .forum-messages {
        margin-left: auto;
    }
    .page-title {
        font-size: 1.5rem;
        overflow-wrap: anywhere;
    }
    .thread-layout {
        margin-top: 16px;
    }
    .thread-main-content {
        padding: 10px;
    }
    .thread-header h1 {
        flex-basis: 100%;
        font-size: 1.4rem;
    }
    .post-header {
        padding: 10px 12px;
    }
    .post-body {
        padding: 16px 12px;
    }
    .reply-form,
    .widget {
        padding: 16px;
    }
    .profile-banner {
        height: 100px;
    }
    .profile-details {
        flex-wrap: wrap;
        align-items: center;
        gap: 12px 16px;
        padding: 0 16px 16px;
    }
    .profile-avatar {
        width: 96px;
        height: 96px;
        margin-top: -48px;
    }
    .profile-name {
        flex: 1 1 160px;
        min-width: 0;
    }
    .profile-name h1 {
        font-size: 1.3rem;
    }
    .profile-actions {
        margin-left: 0;
    }
    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .footer-copyright {
        align-items: center;
        text-align: center;
    }
    .footer-nav,
    .footer-social {
        justify-content: center;
        gap: 8px 16px;
    }
}
