/* ==========================================
   COMMUNAUTÉ V3 — PAGE DÉDIÉE PLEIN ÉCRAN
   Layout 3 colonnes, full viewport
   ========================================== */

/* ==========================================
   BOUTON HEADER
   ========================================== */
#btn-community {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #FFFFFF;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    background: transparent;
    font-family: inherit;
    font-size: 0.85rem;
    position: relative;
}

#btn-community:hover {
    color: var(--gold);
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(197, 160, 89, 0.3);
}

/* Pastille globale non-lu sur le bouton header */
.community-header-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--danger, #e74c3c);
    border-radius: 50%;
    border: 2px solid var(--header-bg);
}

/* ==========================================
   VUE PLEIN ÉCRAN — Container principal
   ========================================== */
.community-fullpage {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    min-height: calc(100vh - 140px);
}

.community-fullpage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
}

.community-fullpage-title {
    margin: 0;
    color: var(--gold);
    font-family: 'Georgia', serif;
    font-style: italic;
    font-size: 1.4rem;
}

.community-fullpage-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ==========================================
   GRILLE 3 COLONNES
   ========================================== */
/* 1. On passe le conteneur de Grid à Flexbox */
.community-container {
    display: flex; 
    height: calc(100vh - 100px); 
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--panel-bg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* ==========================================
   COLONNE 1 : Sections / Spaces
   ========================================== */
/* 2. Colonne 1 : Sections (Redimensionnable) */
.community-spaces {
    width: 220px;           /* Largeur par défaut */
    min-width: 150px;       /* Limite minimum */
    max-width: 40vw;        /* Limite maximum */
    resize: horizontal;     /* 🪄 LA MAGIE EST ICI */
    overflow-y: auto;
    overflow-x: hidden;     /* Requis pour que le resize fonctionne */
    flex-shrink: 0;         /* Empêche la colonne de s'écraser */
    background: var(--panel-light);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.community-spaces-header {
    padding: 16px 14px 12px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Georgia', serif;
    font-size: 0.92rem;
    font-weight: bold;
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: 0.3px;
}

.community-profile-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.15s;
}

.community-profile-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.community-space-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.community-space-item:hover {
    background: rgba(197, 160, 89, 0.08);
    color: var(--text-main);
}

.community-space-item.active {
    background: rgba(197, 160, 89, 0.12);
    color: var(--gold);
    border-left-color: var(--gold);
    font-weight: 600;
}

.community-space-item.support-space {
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.community-space-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.community-space-count {
    margin-left: auto;
    font-size: 0.72rem;
    background: var(--border-color);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}

/* ---- Bandeau d'explication par section ---- */
.community-space-welcome {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(197, 160, 89, 0.08); /* Fond subtil doré */
    border-bottom: 1px solid var(--border-color);
    line-height: 1.4;
    font-style: italic;
}

/* ==========================================
   COLONNE 2 : Liste des threads
   ========================================== */
.community-threads {
    width: 320px;
    min-width: 200px;
    max-width: 50vw;
    resize: horizontal;     /* 🪄 LA MAGIE EST ICI */
    overflow: hidden;       /* Requis pour que le resize fonctionne */
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
}

.community-threads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    gap: 6px;
}

.community-threads-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.community-threads-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.community-filter-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 9px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-muted);
    transition: all 0.15s;
}

.community-filter-btn:hover,
.community-filter-btn.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(197, 160, 89, 0.06);
}

.btn-new-thread {
    background: var(--gold);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    font-weight: 600;
}

.btn-new-thread:hover {
    background: var(--gold-hover);
}

.community-threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.community-thread-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: background 0.12s;
    position: relative;
}

.community-thread-item:hover {
    background: rgba(197, 160, 89, 0.05);
}

.community-thread-item.active {
    background: rgba(197, 160, 89, 0.1);
    border-left: 3px solid var(--gold);
}

.community-thread-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 16px;
}

.community-thread-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.community-thread-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Pastille non-lu */
.community-unread-dot {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--danger, #e74c3c);
    border-radius: 50%;
    animation: unreadPulse 2s infinite;
}

@keyframes unreadPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==========================================
   COLONNE 3 : Fil de discussion (Chat)
   ========================================== */
/* 4. Colonne 3 : Chat (Prend le reste de la place) */
.community-chat {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.community-chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.community-chat-header h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
    font-family: 'Georgia', serif;
}

.community-chat-header p {
    margin: 2px 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.community-chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.92rem;
    text-align: center;
    padding: 40px;
    font-style: italic;
}

.community-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ==========================================
   MESSAGE
   ========================================== */
.community-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: msgSlideUp 0.2s ease;
    position: relative;
    padding: 7px 10px;
    border-radius: 8px;
    transition: background 0.12s;
}

.community-msg:hover {
    background: rgba(0, 0, 0, 0.02);
}

.community-msg:hover .community-msg-delete {
    opacity: 1;
}

.community-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gold);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    font-family: 'Georgia', serif;
}

.community-msg-body {
    flex: 1;
    min-width: 0;
}

.community-msg-author {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gold);
    margin-right: 5px;
}

.community-msg-time {
    font-size: 0.66rem;
    color: var(--text-muted);
}

.community-msg-text {
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.55;
    margin-top: 2px;
    word-break: break-word;
}

.community-msg-text img {
    max-width: 320px;
    max-height: 240px;
    border-radius: 8px;
    margin-top: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: block;
}

/* Bouton supprimer */
.community-msg-delete {
    position: absolute;
    top: 7px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    padding: 2px 6px;
    border-radius: 4px;
}

.community-msg-delete:hover {
    color: var(--danger, #e74c3c);
    background: rgba(231, 76, 60, 0.08);
}

/* ==========================================
   MESSAGE ADMIN — Design distinctif doré
   ========================================== */
.community-msg.admin-msg {
    background: rgba(197, 160, 89, 0.06);
    border-left: 3px solid var(--gold);
    padding-left: 12px;
}

.community-msg.admin-msg .community-msg-avatar {
    background: linear-gradient(135deg, #C5A059, #e8c97d);
    box-shadow: 0 2px 8px rgba(197, 160, 89, 0.3);
}

.community-admin-tag {
    display: inline-block;
    background: var(--gold);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

/* ==========================================
   BARRE DE SAISIE
   ========================================== */
.community-input-bar {
    padding: 10px 18px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--panel-bg);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.community-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.community-input-bar textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-color);
    min-height: 42px; /* Hauteur de base pour 1 ligne */
    max-height: 150px; /* On lui donne un peu plus de place max */
    line-height: 1.4;
    box-sizing: border-box; /* 🪄 LA MAGIE EST LÀ */
    overflow-y: auto; /* Cache la scrollbar inutile */
    transition: border-color 0.15s;
    field-sizing: content;
}

.community-input-bar textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.community-input-bar textarea::placeholder {
    color: var(--text-muted);
}

.btn-community-attach {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-community-attach:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.btn-community-send {
    background: var(--gold);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s;
    flex-shrink: 0;
}

.btn-community-send:hover { background: var(--gold-hover); }
.btn-community-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Preview pièce jointe */
.community-attach-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.community-attach-preview img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.community-attach-remove {
    cursor: pointer;
    color: var(--danger, #e74c3c);
    font-weight: bold;
    font-size: 0.9rem;
}

/* ==========================================
   MODALE (Thread + Profil)
   ========================================== */
.community-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.community-modal {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 24px;
    width: min(460px, 92vw);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.community-modal h3 {
    margin: 0 0 16px;
    color: var(--gold);
    font-family: 'Georgia', serif;
    font-size: 1.05rem;
}

.community-modal input,
.community-modal select,
.community-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text-main);
    background: var(--bg-color);
    margin-bottom: 10px;
    box-sizing: border-box;
    font-family: inherit;
}

.community-modal input:focus,
.community-modal select:focus,
.community-modal textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.community-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.community-modal-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-modal-cancel {
    background: var(--panel-light);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-modal-confirm {
    background: var(--gold);
    border: none;
    color: #fff;
}

.btn-modal-confirm:hover { background: var(--gold-hover); }
.btn-modal-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==========================================
   RESPONSIVE — Tablette (< 900px)
   ========================================== */
@media (max-width: 900px) {
    .community-fullpage { padding: 12px; }

    .community-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 200px);
    }

    .community-spaces { display: none; }

    .community-mobile-tabs {
        display: flex;
        overflow-x: auto;
        gap: 0;
        border-bottom: 1px solid var(--border-color);
        background: var(--panel-light);
        -webkit-overflow-scrolling: touch;
    }

    .community-mobile-tab {
        padding: 8px 12px;
        font-size: 0.78rem;
        white-space: nowrap;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        color: var(--text-muted);
        transition: all 0.15s;
        position: relative;
    }

    .community-mobile-tab.active {
        color: var(--gold);
        border-bottom-color: var(--gold);
        font-weight: 600;
    }

    .community-threads { border-right: none; }
}

/* ==========================================
   RESPONSIVE — Mobile (< 600px)
   ========================================== */
@media (max-width: 600px) {
    .community-fullpage { padding: 8px; }
    .community-fullpage-header { flex-direction: column; gap: 10px; align-items: flex-start; }

    .community-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 180px);
        border-radius: 8px;
    }

    .community-spaces { display: none; }

    .community-msg-text img { max-width: 100%; }

    /* Mode thread ouvert = masquer la liste */
    .community-container.thread-open .community-threads { display: none; }
    .community-container.thread-open .community-chat { display: flex; }

    /* Mode liste = masquer le chat */
    .community-container:not(.thread-open) .community-chat { display: none; }

    .community-back-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.78rem;
        color: var(--gold);
        cursor: pointer;
        padding: 2px 0;
        margin-bottom: 4px;
    }
}

@media (min-width: 601px) {
    .community-back-btn { display: none; }
}

@media (min-width: 901px) {
    .community-mobile-tabs { display: none; }
}

/* Badge pour les testeurs Alpha (Avant-garde) */
.community-pioneer-badge {
    display: inline-block;
    background: rgba(108, 122, 137, 0.15); /* Gris/Bleu royal très subtil */
    color: #5c6b7a;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 6px;
    font-weight: 600;
    vertical-align: middle;
    border: 1px solid rgba(108, 122, 137, 0.3);
}