/* ========================================
   COMMUNITY SIDEBAR — Clairval
   Barre verticale Liquid Glass à gauche
   Icônes seules, dépliage au survol 1 seconde
   Utilise #community-sidebar pour éviter conflits avec .community-submenu des pages
   ======================================== */

/* Barre communautaire — mêmes valeurs que panneaux latéraux taverne (blur, contours, couleurs) */
/* #guest-sidebar = même rendu pour la page d'accueil déconnectée */
#community-sidebar,
.community-submenu#community-sidebar,
#guest-sidebar,
.community-submenu#guest-sidebar {
    position: fixed !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    left: 20px !important;
    right: auto !important;
    z-index: 100000;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px;
    padding: 10px 10px 28px 10px;
    border-radius: 16px;
    min-width: 60px !important;
    width: 60px !important;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    transition: width 0.2s ease-out, min-width 0.2s ease-out;
    /* Liquid glass = panneaux taverne */
    background: linear-gradient(
        135deg,
        rgba(30, 29, 35, 0.35) 0%,
        rgba(30, 29, 35, 0.55) 50%,
        rgba(30, 29, 35, 0.72) 100%
    );
    border: 1px solid rgba(196, 117, 90, 0.18);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 4px 32px rgba(0, 0, 0, 0.35);
}

@supports (backdrop-filter: url(#liquid-glass-refract)) {
    #community-sidebar,
    .community-submenu#community-sidebar,
    #guest-sidebar,
    .community-submenu#guest-sidebar {
        backdrop-filter: url(#liquid-glass-refract) blur(40px) saturate(180%);
        -webkit-backdrop-filter: url(#liquid-glass-refract) blur(40px) saturate(180%);
    }
}

/* Bordure spéculaire — même dégradé que panneaux taverne */
#community-sidebar::before,
.community-submenu#community-sidebar::before,
#guest-sidebar::before,
.community-submenu#guest-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.28) 0%,
        rgba(255, 255, 255, 0.1) 25%,
        rgba(196, 117, 90, 0.18) 50%,
        transparent 70%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Déplié : afficher le label */
#community-sidebar.expanded,
#guest-sidebar.expanded {
    width: auto !important;
    min-width: 180px !important;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Boutons : GRID = colonne 1 = icône (24px), colonne 2 = texte — le texte ne peut jamais prendre la place de l'icône */
#community-sidebar .community-sidebar-btn,
#guest-sidebar .community-sidebar-btn {
    display: grid;
    grid-template-columns: 24px;
    grid-template-rows: auto;
    align-items: center;
    justify-items: center;
    gap: 0;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text-primary, #f2ebe3);
    text-decoration: none;
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
    position: relative;
    min-width: 40px;
    width: 40px;
    box-sizing: border-box;
}
#guest-sidebar button.community-sidebar-btn {
    border: none;
    background: none;
    cursor: pointer;
}

/* Déplié : 2 colonnes — colonne 1 = 24px fixe (icône), colonne 2 = reste (texte) */
#community-sidebar.expanded .community-sidebar-btn,
#guest-sidebar.expanded .community-sidebar-btn {
    grid-template-columns: minmax(24px, 24px) minmax(0, 1fr);
    gap: 0 12px;
    width: 100%;
    min-width: 0;
    justify-items: start;
}

/* Icône : TOUJOURS en colonne 1, 24px — inline-block pour que Font Awesome (::before) s'affiche */
#community-sidebar .community-sidebar-btn i,
#guest-sidebar .community-sidebar-btn i {
    grid-column: 1 !important;
    grid-row: 1 !important;
    font-size: 1.2em;
    width: 24px;
    min-width: 24px;
    text-align: center;
    display: inline-block !important; /* FA a besoin d'inline-block sur le <i> */
}

/* Quand déplié : forcer l'icône visible (aucune règle ne doit la cacher) */
#community-sidebar.expanded .community-sidebar-btn i,
#guest-sidebar.expanded .community-sidebar-btn i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 24px !important;
    min-width: 24px !important;
}

/* Label : masqué par défaut */
#community-sidebar .community-sidebar-btn .community-sidebar-label,
#guest-sidebar .community-sidebar-btn .community-sidebar-label {
    grid-column: 1;
    grid-row: 1;
    display: none !important;
}

/* Label visible quand expanded : colonne 2, à côté de l'icône (colonne 1) */
#community-sidebar.expanded .community-sidebar-btn .community-sidebar-label,
#guest-sidebar.expanded .community-sidebar-btn .community-sidebar-label {
    grid-column: 2;
    grid-row: 1;
    display: block !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#community-sidebar .community-sidebar-btn:hover,
#guest-sidebar .community-sidebar-btn:hover {
    background: rgba(196, 117, 90, 0.15);
    color: var(--primary-color, #f4a261);
}

#community-sidebar .community-sidebar-btn.active,
#guest-sidebar .community-sidebar-btn.active {
    background: rgba(196, 117, 90, 0.2);
    color: var(--primary-color, #f4a261);
}

/* Boutique désactivée (PC/Mobile) */
#community-sidebar .community-sidebar-btn.shop-disabled,
.community-sidebar-btn.shop-disabled {
    cursor: default;
    pointer-events: none;
    opacity: 0.5;
    color: var(--text-secondary, #888);
}

/* Lore — bientôt disponible : grisé, barré, (Soon) */
#community-sidebar .community-sidebar-btn-soon {
    cursor: default;
    pointer-events: none;
    opacity: 0.55;
    color: var(--text-secondary, #888);
}
#community-sidebar .community-sidebar-btn-soon i {
    color: inherit;
}
#community-sidebar .community-sidebar-btn-soon .label-strikethrough {
    text-decoration: line-through;
}
#community-sidebar .community-sidebar-btn-soon .label-soon {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Badge notifications sur les boutons */
#community-sidebar .community-sidebar-btn.has-badge {
    position: relative;
}

/* Scrollbar fine pour ne pas réduire la zone visible */
#community-sidebar::-webkit-scrollbar,
#guest-sidebar::-webkit-scrollbar {
    width: 6px;
}
#community-sidebar::-webkit-scrollbar-thumb,
#guest-sidebar::-webkit-scrollbar-thumb {
    background: rgba(196, 117, 90, 0.3);
    border-radius: 3px;
}
#community-sidebar::-webkit-scrollbar-thumb:hover,
#guest-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(196, 117, 90, 0.5);
}
#community-sidebar::-webkit-scrollbar-track,
#guest-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#community-sidebar .header-notification-badge,
#guest-sidebar .header-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error-color, #e76f51);
    color: white;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65em;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    padding: 0 4px;
}

/* Scroll-area avec barre communautaire : réserve d'espace à gauche */
/* 20px marge + 60px barre + 8px = 88px */
.scroll-area.has-community-submenu,
main.has-community-submenu,
#main-content.has-community-submenu,
body.has-guest-layout #main-content {
    padding-left: 88px !important;
    overflow-x: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    #community-sidebar,
    #guest-sidebar {
        top: 50%;
        transform: translateY(-50%);
        left: 12px;
        min-width: 56px;
        width: 56px;
    }
    
    #community-sidebar .community-sidebar-btn,
    #guest-sidebar .community-sidebar-btn {
        min-width: 40px;
        width: 40px;
        padding: 8px 10px;
    }
    
    .scroll-area.has-community-submenu,
    main.has-community-submenu,
    #main-content.has-community-submenu,
    body.has-guest-layout #main-content {
        padding-left: 76px !important;
    }
}
