/* ═══════════════════════════════════════════════════════════════════════════
   LV Social — Livrable 2 : Groupes + Messagerie
   Ajouter à la fin de assets/style.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Groupes — toolbar ───────────────────────────────────────────────────── */
.lvs-groups-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--lv-border);
}
.lvs-groups-filters { display: flex; }

/* ── Formulaire proposition groupe ──────────────────────────────────────── */
.lvs-group-propose-wrap {
  background: var(--lv-surface);
  border: 1px solid var(--lv-border);
  padding: 24px;
  margin-bottom: 28px;
}
.lvs-info-text { font-size: 13px; color: var(--lv-ink-2); margin: 0 0 16px; }

/* ── Grid groupes ────────────────────────────────────────────────────────── */
.lvs-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--lv-border);
}
.lvs-group-card { background: var(--lv-surface); display: flex; flex-direction: column; }
.lvs-group-card__cover {
  display: block; aspect-ratio: 16/7; overflow: hidden; background: var(--lv-ink);
  text-decoration: none;
}
.lvs-group-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.lvs-group-card:hover .lvs-group-card__cover img { transform: scale(1.04); }
.lvs-group-card__cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff; letter-spacing: .1em;
}
.lvs-group-card__body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.lvs-group-card__name { font-size: 15px; font-weight: 700; color: var(--lv-ink); text-decoration: none; }
.lvs-group-card__name:hover { text-decoration: underline; text-underline-offset: 3px; }
.lvs-group-card__meta { font-size: 12px; color: var(--lv-ink-3); }
.lvs-group-card__desc { font-size: 13px; color: var(--lv-ink-2); margin: 0; line-height: 1.4; flex: 1; }
.lvs-group-card__actions { margin-top: 10px; }
.lvs-disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ── Groupe — page interne ───────────────────────────────────────────────── */
.lvs-group-header {
  display: flex; gap: 20px; align-items: flex-start;
  padding-bottom: 28px; margin-bottom: 24px; border-bottom: 1px solid var(--lv-border);
}
.lvs-group-cover { width: 90px; height: 90px; border-radius: 4px; overflow: hidden; flex-shrink: 0; background: var(--lv-ink); }
.lvs-group-cover-img { width: 100%; height: 100%; object-fit: cover; }
.lvs-group-cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
}
.lvs-group-name { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.lvs-group-meta { font-size: 13px; color: var(--lv-ink-3); display: block; margin-bottom: 6px; }
.lvs-group-desc { font-size: 14px; color: var(--lv-ink-2); margin: 0 0 10px; }
.lvs-group-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.lvs-group-layout { display: grid; grid-template-columns: 1fr 240px; gap: 28px; align-items: start; }
@media (max-width: 640px) { .lvs-group-layout { grid-template-columns: 1fr; } }

/* ── Sidebar membres groupe ──────────────────────────────────────────────── */
.lvs-group-sidebar { background: var(--lv-surface); border: 1px solid var(--lv-border); padding: 16px; }
.lvs-group-members-list { display: flex; flex-direction: column; gap: 8px; }
.lvs-group-member-item {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--lv-ink); font-size: 13px;
  padding: 4px 0; transition: color .12s;
}
.lvs-group-member-item:hover { color: var(--lv-ink-2); }
.lvs-group-member-name { flex: 1; font-size: 13px; }
.lvs-role-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 6px; background: var(--lv-ink); color: #fff;
}
.lvs-role-mod { background: #1a5276; }

/* ── Modal (panel édition groupe) ───────────────────────────────────────── */
.lvs-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lvs-modal-inner {
  background: var(--lv-surface); max-width: 520px; width: 100%;
  padding: 32px; position: relative; max-height: 90vh; overflow-y: auto;
}
.lvs-modal-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  font-size: 20px; cursor: pointer; color: var(--lv-ink-3); line-height: 1;
}
.lvs-modal-close:hover { color: var(--lv-ink); }

/* ── Messagerie — inbox ──────────────────────────────────────────────────── */
.lvs-inbox { max-width: 640px; }
.lvs-new-thread-bar { margin-bottom: 16px; }
.lvs-new-thread-wrap {
  background: var(--lv-surface); border: 1px solid var(--lv-border);
  padding: 20px; margin-bottom: 24px;
}

/* Threads list */
.lvs-threads-list { display: flex; flex-direction: column; gap: 1px; background: var(--lv-border); }
.lvs-thread-item {
  background: var(--lv-surface); display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; text-decoration: none; color: var(--lv-ink); transition: background .12s;
  position: relative;
}
.lvs-thread-item:hover { background: var(--lv-bg); }
.lvs-thread--unread { background: #f0f6ff; }
.lvs-thread--unread:hover { background: #e8f0fc; }

.lvs-thread-avatars { display: flex; flex-direction: row; }
.lvs-thread-avatars .lvs-avatar { margin-right: -8px; border: 2px solid var(--lv-surface); }
.lvs-thread-avatars--sm .lvs-avatar { margin-right: -6px; border: 2px solid var(--lv-surface); }
.lvs-thread-avatars + * { margin-left: 10px; }

.lvs-thread-info { flex: 1; min-width: 0; }
.lvs-thread-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lvs-thread-name { font-size: 14px; font-weight: 700; }
.lvs-thread-preview { font-size: 13px; color: var(--lv-ink-2); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lvs-unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--lv-error);
  flex-shrink: 0; margin-left: 4px;
}

/* ── Messagerie — conversation ───────────────────────────────────────────── */
.lvs-thread-wrap { max-width: 680px; display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 500px; padding-bottom: 0; }

.lvs-thread-header-bar {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 0; border-bottom: 1px solid var(--lv-border);
  position: sticky; top: 0; background: var(--lv-bg); z-index: 10; padding-top: 16px;
}
.lvs-thread-title-group { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.lvs-thread-title-group strong { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lvs-thread-info-panel {
  background: var(--lv-surface); border: 1px solid var(--lv-border);
  padding: 16px; margin-bottom: 0;
}

/* Zone messages */
.lvs-messages-wrap {
  flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}

.lvs-msg-date-sep {
  text-align: center; font-size: 11px; color: var(--lv-ink-3);
  letter-spacing: .08em; text-transform: uppercase;
  padding: 12px 0; position: relative;
}
.lvs-msg-date-sep::before, .lvs-msg-date-sep::after {
  content: ''; position: absolute; top: 50%; width: calc(50% - 60px); height: 1px; background: var(--lv-border);
}
.lvs-msg-date-sep::before { left: 0; }
.lvs-msg-date-sep::after  { right: 0; }

/* Messages */
.lvs-message {
  display: flex; gap: 8px; align-items: flex-end; max-width: 78%; padding: 2px 0;
}
.lvs-message--mine  { margin-left: auto; flex-direction: row-reverse; }
.lvs-message--theirs { margin-right: auto; }

.lvs-message-av { flex-shrink: 0; align-self: flex-end; }

.lvs-message-bubble-wrap { display: flex; flex-direction: column; gap: 3px; }
.lvs-message--mine  .lvs-message-bubble-wrap { align-items: flex-end; }
.lvs-message--theirs .lvs-message-bubble-wrap { align-items: flex-start; }

.lvs-message-author { font-size: 11px; color: var(--lv-ink-3); margin-bottom: 2px; }

.lvs-message-bubble {
  padding: 10px 14px; font-size: 14px; line-height: 1.5; max-width: 100%;
  word-break: break-word;
}
.lvs-message-bubble p { margin: 0; }
.lvs-message--mine   .lvs-message-bubble { background: var(--lv-ink); color: #fff; }
.lvs-message--theirs .lvs-message-bubble { background: var(--lv-surface); border: 1px solid var(--lv-border); color: var(--lv-ink); }

.lvs-msg-media-img img { max-width: 220px; max-height: 220px; object-fit: cover; margin-top: 6px; display: block; }

.lvs-message-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.lvs-message--mine  .lvs-message-meta { flex-direction: row-reverse; }

/* Réactions */
.lvs-msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.lvs-reaction-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; background: var(--lv-surface); border: 1px solid var(--lv-border);
  font-size: 13px; cursor: pointer; transition: border-color .12s;
}
.lvs-reaction-badge:hover, .lvs-reacted { border-color: var(--lv-ink); background: var(--lv-bg); }
.lvs-reaction-badge span { font-size: 12px; color: var(--lv-ink-2); }

.lvs-reaction-wrap { position: relative; }
.lvs-add-reaction {
  background: none; border: none; cursor: pointer; font-size: 14px; color: var(--lv-ink-3);
  padding: 2px 4px; line-height: 1; opacity: 0; transition: opacity .14s;
}
.lvs-message:hover .lvs-add-reaction { opacity: 1; }
.lvs-emoji-picker {
  position: absolute; bottom: 26px; left: 0; background: var(--lv-surface);
  border: 1px solid var(--lv-border); padding: 6px; display: flex; gap: 4px; z-index: 100;
  box-shadow: var(--lv-shadow);
}
.lvs-message--mine .lvs-emoji-picker { left: auto; right: 0; }
.lvs-emoji-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 2px; line-height: 1; }
.lvs-emoji-btn:hover { transform: scale(1.2); }

/* Composer message */
.lvs-msg-composer {
  border-top: 1px solid var(--lv-border); padding: 12px 0 20px;
  background: var(--lv-bg); position: sticky; bottom: 0;
}
.lvs-msg-composer-inner {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--lv-surface); border: 1px solid var(--lv-border); padding: 10px 12px;
}
.lvs-msg-composer-inner textarea {
  flex: 1; border: none; outline: none; font-family: var(--lv-font); font-size: 14px;
  resize: none; background: transparent; color: var(--lv-ink); line-height: 1.5;
  min-height: 22px; max-height: 120px; overflow-y: auto;
}
.lvs-msg-media-preview { display: flex; gap: 8px; align-items: center; }
.lvs-msg-media-preview img { height: 48px; width: 48px; object-fit: cover; border: 1px solid var(--lv-border); }

/* ── Autocomplete user search ────────────────────────────────────────────── */
.lvs-field--search-user { position: relative; }
.lvs-user-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--lv-surface); border: 1px solid var(--lv-border); border-top: none;
  max-height: 220px; overflow-y: auto;
}
.lvs-user-option {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: pointer; font-size: 13px; transition: background .1s;
}
.lvs-user-option:hover { background: var(--lv-bg); }
.lvs-selected-users { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lvs-selected-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--lv-ink); color: #fff; font-size: 12px; padding: 4px 10px;
}
.lvs-selected-tag button { background: none; border: none; color: #fff; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }

/* ── Responsive messagerie ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .lvs-thread-wrap { height: calc(100vh - 80px); }
  .lvs-message { max-width: 90%; }
  .lvs-group-header { flex-direction: column; }
}
