/* L'Aparté - Layout & Sidebar (commun à toutes les pages) */
.layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
}
.layout.no-sidebar {
    justify-content: center;
}
.layout.no-sidebar .col-main {
    max-width: 1000px;
}
.col-main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
}
.sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}
.sidebar-block {
    background: var(--carte);
    border: 1px solid var(--bord);
    border-radius: 12px;
    padding: 1.1rem 0.9rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.sidebar-block h3 {
    margin: 0 0 0.8rem 0;
    padding: 0 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--bord);
    padding-bottom: 0.5rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.6rem;
    margin-bottom: 0.2rem;
    border-radius: 8px;
    color: var(--texte);
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link .ico {
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-link:hover {
    background: var(--fond);
    color: var(--accent2);
}
.sidebar-link.active {
    background: rgba(3,105,161,0.08);
    color: var(--accent2);
    font-weight: 600;
}
#sidebarGroups .sidebar-link {
    color: var(--texte);
    font-weight: 400;
}
#sidebarGroups .sidebar-link::before {
    content: "👥";
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}
.theme-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--bord);
    border-radius: 8px;
    background: var(--fond);
    color: var(--texte);
    font-size: 0.93rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-btn:hover {
    border-color: var(--accent2);
    color: var(--accent2);
}
.theme-btn .ico { width: 1.4rem; text-align: center; }

/* Badge admin (messages non lus) */
.admin-badge {
    background: var(--err);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    margin-left: auto;
}

/* Réglages du fil (ordre + source) */
.feed-settings { display: flex; flex-direction: column; gap: 0.5rem; }
.feed-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.feed-options { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.feed-opt {
    flex: 1;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--bord);
    border-radius: 6px;
    background: var(--fond);
    color: var(--texte);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.feed-opt:hover { border-color: var(--accent); }
.feed-opt.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}

/* --- Bouton hamburger (mobile uniquement) --- */
.hamburger-btn {
    display: none;
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: #ffffff;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, transform 0.15s;
}
.hamburger-btn:hover { border-color: var(--accent); transform: scale(1.05); }

/* --- Overlay sombre derrière la sidebar (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* --- Bouton de fermeture ✕ (mobile) --- */
.sidebar-close {
    display: none;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--texte);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; position: static; }
}

/* Mobile (≤768px) : sidebar en overlay, ouverte via hamburger */
@media (max-width: 768px) {
    .hamburger-btn { display: inline-flex; }
    .sidebar-close { display: block; }
    .layout { display: block; }
    .col-main { max-width: 100%; }
    #sidebarMount { display: block; }
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        margin: 0;
        padding: 1.5rem 1rem;
        background: var(--carte);
        box-shadow: -4px 0 16px rgba(0,0,0,0.35);
        overflow-y: auto;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    /* Menu partage : ne jamais dépasser l'écran sur mobile */
    .share-menu {
        min-width: 0;
        width: max-content;
        max-width: calc(100vw - 16px);
    }
}

/* Tablette (769-1024px) : sidebar toujours à droite (layout horizontal), portrait ET paysage */
@media (min-width: 769px) and (max-width: 1024px) {
    .layout { flex-direction: row; }
    .sidebar { width: 220px; position: sticky; }
    .col-main { max-width: 100%; }
}

/* Desktop (>1024px) : sidebar à droite (inchangé) */
@media (min-width: 1025px) {
    .sidebar { width: 280px; }
}

/* ===== MODE APP (coquille WebView) =====
   Déclenché par html[data-app="mobile"] (détecté dans theme.js via le UA
   WebView ou ?app=1). Force le comportement téléphone QUELLE QUE SOIT la
   largeur de rendu : la sidebar devient un tiroir ouvert par le hamburger.
   Indépendant des media queries de largeur, donc robuste même si la WebView
   se croit en desktop. */
html[data-app="mobile"] .layout { display: block !important; }
html[data-app="mobile"] .layout .col-main,
html[data-app="mobile"] .layout.no-sidebar .col-main { max-width: 680px; margin: 0 auto; }
html[data-app="mobile"] .hamburger-btn { display: inline-flex; }
html[data-app="mobile"] .sidebar-close { display: block; }
html[data-app="mobile"] .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100dvh;
    margin: 0;
    padding: 1.5rem 1rem;
    background: var(--carte);
    box-shadow: -4px 0 16px rgba(0,0,0,0.35);
    overflow-y: auto;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
html[data-app="mobile"] .sidebar.open { transform: translateX(0); }
html[data-app="mobile"] .share-menu {
    min-width: 0;
    width: max-content;
    max-width: calc(100vw - 16px);
}
/* Le contenu des cartes/du fil ne doit jamais dépasser l'écran */
html[data-app="mobile"] .post,
html[data-app="mobile"] .card {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* --- Menu de partage (openShareMenu) + modal DM --- */
/* Déplacé ici depuis index.css pour être disponible sur TOUTES les pages (groups.html, mur.html, etc.) */
.share-menu {
    position: fixed;
    z-index: 1000;
    min-width: 240px;
    background: var(--carte);
    border: 1px solid var(--bord);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.share-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: none;
    border: none;
    border-radius: 7px;
    color: var(--texte);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}
.share-menu-item:hover { background: var(--fond); }
.share-menu-ico { font-size: 1.05rem; line-height: 1; }

/* Modal de partage en DM */
.dm-share-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.dm-share-modal {
    background: var(--carte);
    border: 1px solid var(--bord);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 380px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dm-share-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--bord);
}
.dm-share-head h3 { margin: 0; font-size: 1rem; color: var(--texte); }
.dm-share-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.dm-share-close:hover { color: var(--texte); }
.dm-share-search {
    margin: 0.7rem 1rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--bord);
    border-radius: 8px;
    background: var(--fond);
    color: var(--texte);
    font-size: 0.9rem;
}
.dm-share-search:focus { outline: none; border-color: var(--accent2); }
.dm-share-list {
    overflow-y: auto;
    padding: 0 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dm-share-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--texte);
    text-align: left;
    cursor: pointer;
}
.dm-share-user:hover { background: var(--fond); }
.dm-share-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.dm-share-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dm-share-name { font-size: 0.9rem; }
.dm-share-name small { color: var(--muted); }

/* Invitations de groupe dans la sidebar */
.sidebar-invite {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--bord, rgba(100,116,139,0.1));
}
.sidebar-invite:last-child { border-bottom: none; }
.sidebar-invite-text {
    font-size: 0.8rem;
    line-height: 1.3;
    margin-bottom: 0.3rem;
}
.sidebar-invite-actions {
    display: flex;
    gap: 0.3rem;
}
.sidebar-invite-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
}
