/* Notifications (cloche) et messagerie privée (bulle) dans la barre du haut */
.inbox-wrap { position: relative; }
.icon-btn .badge { display: none; }
.icon-btn .badge.show {
  display: flex; align-items: center; justify-content: center;
  top: 2px; right: 0; width: auto; height: 16px; min-width: 16px; padding: 0 4px;
  border-radius: var(--radius-full); border: 2px solid var(--background);
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 1; box-sizing: content-box;
}

.inbox-panel {
  position: absolute; top: calc(100% + 10px); right: -8px; z-index: 300;
  width: 380px; max-width: calc(100vw - 24px); max-height: min(560px, 78vh);
  display: none; flex-direction: column; overflow: hidden;
  background: var(--background); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}
.inbox-panel.open { display: flex; animation: inboxIn 0.2s var(--ease-out); }
@keyframes inboxIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.inbox-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.inbox-head h3 { margin: 0; font-family: var(--font-title); font-size: 16px; font-weight: 600; color: var(--text-title); flex: 1; }
.inbox-link { border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.inbox-link:hover { background: var(--background-soft); color: var(--accent); }
.inbox-back { border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--primary); padding: 2px 8px; border-radius: 8px; }
.inbox-back:hover { background: var(--background-soft); }

.inbox-list { overflow-y: auto; flex: 1; }
.inbox-empty { padding: 36px 24px; text-align: center; color: var(--text-muted); font-size: 14px; }

.inbox-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 12px 18px; border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit;
  transition: background 0.2s;
}
.inbox-item:hover { background: var(--background-soft); }
.inbox-item.unread { background: #F7F5FC; }
.inbox-item.unread:hover { background: #F0ECF9; }
.inbox-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: var(--grad); color: #fff;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center;
}
.inbox-avatar.sm { width: 32px; height: 32px; font-size: 11px; }
.inbox-body { min-width: 0; flex: 1; }
.inbox-text { font-size: 13.5px; color: var(--text-body); line-height: 1.45; }
.inbox-text strong { color: var(--text-title); font-weight: 600; }
.inbox-excerpt { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-time { margin-top: 3px; font-size: 11px; color: var(--text-faint); }
.inbox-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 6px; }
.inbox-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; align-self: center; }
.inbox-name { font-weight: 600; font-size: 14px; color: var(--text-title); }
.inbox-item.unread .inbox-excerpt { color: var(--text-title); font-weight: 600; }

/* Fil de messages */
.thread { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 240px; }
.bubble { max-width: 78%; padding: 9px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.bubble.theirs { align-self: flex-start; background: var(--background-soft); color: var(--text-body); border-bottom-left-radius: 6px; }
.bubble.mine { align-self: flex-end; background: var(--grad-diagonal); color: #fff; border-bottom-right-radius: 6px; }
.bubble-time { font-size: 10.5px; opacity: 0.7; margin-top: 2px; }
.thread-empty { margin: auto; text-align: center; color: var(--text-muted); font-size: 13px; }
.thread-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-soft); }
.thread-form input {
  flex: 1; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius-full);
  font-size: 14px; font-family: var(--font-body); outline: none;
}
.thread-form input:focus { border-color: var(--primary); }
.thread-form button { padding: 9px 18px; border-radius: var(--radius-full); border: 0; background: var(--primary); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.thread-form button:hover { background: var(--secondary); }
.thread-form button:disabled { opacity: 0.5; cursor: default; }

/* Bouton « Message » sur les cartes de membres */
.member-dm-btn {
  margin-left: auto; align-self: flex-start; padding: 7px 16px; border-radius: var(--radius-full);
  border: 1.5px solid var(--primary); background: transparent; color: var(--primary);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.25s; white-space: nowrap;
}
.member-dm-btn:hover { background: var(--primary); color: #fff; }

/* Post ciblé depuis une notification */
.post-card.flash { animation: postFlash 2.4s ease-out; }
@keyframes postFlash { 0%, 40% { box-shadow: 0 0 0 3px var(--light-accent); } 100% { box-shadow: var(--shadow-soft); } }

@media (max-width: 640px) {
  .inbox-panel { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; max-width: none; }
}

.member-card:has(.member-dm-btn) { grid-template-columns: auto 1fr auto; }
