/* Adjugé! — front. Messagerie privée (onglet Messages + liste des
   conversations + fil de discussion façon Vinted). Chargé APRÈS app.extras.css
   (cascade) ; ne pas réordonner les <link>. Palette : variables d'app.base.css. */

/* ---------- Icône d'onglet « Messages » (bulle) + badge non-lus ---------- */
.ic-msg { position: relative; width: 18px; height: 16px; display: block; margin-bottom: 1px; }
.ic-msg i {
  position: absolute; top: 0; left: 0; right: 0; height: 13px;
  border: 2.3px solid currentColor; border-radius: 6px; display: block;
}
.ic-msg b {
  position: absolute; left: 4px; bottom: 0; width: 6px; height: 6px;
  background: var(--bg); border-left: 2.3px solid currentColor;
  border-bottom: 2.3px solid currentColor; transform: rotate(-45deg);
  border-bottom-left-radius: 2px; display: block;
}
.tab { position: relative; }
.tab-badge {
  position: absolute; top: -1px; left: calc(50% + 6px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- Écran « Messages » (liste des conversations) ---------- */
#screen-messages {
  padding-top: calc(8px + var(--sat));
  padding-bottom: calc(110px + var(--sab));
}
.msg-head { display: flex; align-items: center; gap: 10px; padding: 8px 0 6px; }
/* Invite de connexion COMMUNE aux deux sous-onglets (Messages ET Notifications) :
   même retrait haut + même espacement du bouton → aucun saut de position quand
   on bascule d'un onglet à l'autre (les deux blocs partagent la structure
   .empty.slim + .empty-sub + .cta). */
#msg-login, #notif-login { margin-top: 24px; text-align: center; }
#msg-login .cta, #notif-login .cta { margin-top: 16px; }
/* Réserve la hauteur de DEUX lignes au sous-titre (font-size 13px, line-height
   1.5 → 2 × 1.5em) : que le texte tienne sur 1 ou 2 lignes, le bouton « Se
   connecter » reste à la même hauteur sur les deux onglets → pas de saut. */
#msg-login .empty-sub, #notif-login .empty-sub { min-height: 3em; }

.conv-row {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 13px 2px; text-align: left; border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}
.conv-row:active { background: var(--chip-bg); }
.conv-thumb {
  width: 52px; height: 52px; border-radius: 999px; flex-shrink: 0;
  background-color: var(--chip-bg); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--chip-ink); font-weight: 900; font-size: 18px;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name {
  font-size: 14.5px; font-weight: 800; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-time { font-size: 11px; color: var(--muted2); flex-shrink: 0; }
.conv-item-title {
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-last {
  font-size: 13px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-row.unread .conv-name { font-weight: 900; }
.conv-row.unread .conv-last { color: var(--ink); font-weight: 700; }
.conv-dot {
  width: 9px; height: 9px; border-radius: 999px; background: var(--orange);
  flex-shrink: 0; align-self: center;
}

/* ---------- Sous-onglets « Messages | Notifications » (façon Vinted) ---------- */
/* Soulignement par box-shadow (et non border + margin négative) : WebKit/iOS
   dédoublait le trait avec l'ancien combo border 1px du conteneur + border 2px
   de l'onglet décalée de -1px. Le box-shadow ne participe pas au layout → trait
   unique, net, sur tous les moteurs. */
.msg-tabs { display: flex; margin: 4px 0 2px; box-shadow: inset 0 -1px 0 var(--line); }
.msg-tab {
  flex: 1; padding: 11px 0 10px; font-size: 14px; font-weight: 700;
  color: var(--muted); text-align: center; background: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color 0.15s;
}
.msg-tab.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--orange); }
.msg-tab:active { opacity: 0.7; }
.msg-tab-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--orange); color: #fff; font-size: 11px; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}

/* ---------- Liste & état vide des notifications ---------- */
.empty-ic { font-size: 42px; line-height: 1; margin-bottom: 12px; opacity: 0.9; }
.notif-row { align-items: flex-start; }
.notif-ico { font-size: 24px; background-color: var(--chip-bg); }
.notif-row .conv-last {
  white-space: normal; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ---------- Balayage « façon iOS » : supprimer une notification ----------
   On glisse la ligne (.notif-fg) vers la GAUCHE pour révéler le bouton rouge
   « Supprimer » placé DERRIÈRE (.notif-del). Marche au tactile ET à la souris
   (Pointer Events côté JS). Le repli après suppression anime max-height → 0. */
.notif-swipe { position: relative; overflow: hidden; }
.notif-swipe.removing { transition: max-height 0.28s ease, opacity 0.28s ease; }
.notif-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 84px; border: 0;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.notif-del:active { filter: brightness(0.92); }
.notif-swipe .notif-fg {
  position: relative; z-index: 1; background: var(--bg);
  touch-action: pan-y;   /* on gère l'horizontal, le vertical reste au scroll */
  will-change: transform;
}

/* ---------- Feuille « Détail d'une notification » ---------- */
#notif-sheet-backdrop {
  position: fixed; inset: 0; z-index: 45; background: rgba(24,17,9,0.45);
  animation: fadeIn 0.25s ease both;
}
#notif-sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 46;
  background: #FFFFFF; border-radius: 26px 26px 0 0;
  padding: 14px 18px calc(20px + var(--sab));
  animation: sheetUp 0.35s cubic-bezier(0.2,0.9,0.3,1) both;
  max-height: 86dvh; overflow: auto;
}
#notif-sheet .onboard-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.notif-sheet-meta { display: flex; align-items: center; gap: 13px; }
.notif-sheet-head { flex: 1; min-width: 0; }
.notif-sheet-title { font-size: 15.5px; font-weight: 800; color: var(--ink); line-height: 1.3; }
.notif-sheet-body {
  margin: 14px 0 4px; font-size: 14px; line-height: 1.55; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-word;
}
.notif-link {
  color: var(--orange); font-weight: 700; text-decoration: underline;
  word-break: break-all;
}
#notif-sheet-cta { margin-top: 16px; }

/* ---------- Écran « Fil de discussion » (plein écran, sans tabbar) ---------- */
#screen-thread { display: flex; flex-direction: column; height: 100dvh; }
.thread-head {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--sat)) 12px 8px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.thread-head .icon-btn {
  width: 38px; height: 38px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--ink); background: transparent;
}
.thread-head .icon-btn:active { background: var(--chip-bg); }
.thread-info-btn { font-size: 19px; }
.thread-head-title {
  flex: 1; text-align: center; font-size: 16px; font-weight: 900;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.thread-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 14px 16px;
}

/* Carte article en tête du fil (titre, photo, prix, statut de remise) */
.thread-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 12px; border-radius: 16px; text-align: left;
  background: #FFFFFF; border: 1px solid var(--card-line);
  box-shadow: 0 2px 10px rgba(34,26,18,0.05);
}
.thread-item:active { transform: scale(0.995); }
.thread-item-thumb {
  width: 50px; height: 50px; border-radius: 11px; flex-shrink: 0;
  background-color: #EFE9E0;
}
.thread-item-info { flex: 1; min-width: 0; }
.thread-item-title {
  font-size: 14px; font-weight: 800; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-item-price {
  font-size: 14.5px; font-weight: 900; color: var(--orange); margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.thread-item-status { font-size: 11.5px; font-weight: 700; color: var(--green-ink); margin-top: 1px; }
.thread-item .chev { color: var(--faint); font-size: 20px; flex-shrink: 0; }

/* Actions de remise (J'ai expédié / J'ai bien reçu / litige / remboursement) */
.thread-actions { display: flex; flex-direction: column; gap: 9px; margin: 12px 0 4px; }
.thread-act {
  width: 100%; height: 46px; border-radius: 14px; font-size: 14.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; transition: transform 0.1s;
}
.thread-act:active { transform: scale(0.98); }
.thread-act.ok { background: var(--orange); color: #fff; }
.thread-act.warn { background: #FFFFFF; color: var(--ink); border: 1.5px solid #E4D9CB; }
.thread-act.ghost { background: var(--chip-bg); color: var(--chip-ink); }
/* Note de litige (motif + précisions) : encadré ambre sous les actions, visible
   aux deux parties pour comprendre le blocage et le résoudre dans le fil. */
.thread-dispute-note {
  margin: 4px 0 8px; padding: 11px 13px; border-radius: 14px;
  background: #FFF6E8; border: 1.5px solid #F2C98A;
  font-size: 13.5px; line-height: 1.4; color: #6B4E1E;
}
.thread-dispute-note .tdn-reason { font-weight: 800; display: block; }
.thread-dispute-note .tdn-comment { margin-top: 3px; color: #7A6240; }
/* Évaluation du vendeur EN BAS du fil (façon Vinted) : carte inline avec
   étoiles cliquables + texte facultatif + Envoyer, sous les messages. */
.thread-review {
  margin: 14px 0 6px; padding: 16px; border-radius: 18px;
  background: #FFFFFF; border: 1.5px solid var(--card-line);
  box-shadow: 0 2px 12px rgba(34,26,18,0.05);
}
.thread-review-title { font-size: 16px; font-weight: 900; text-align: center; }
.thread-review-sub {
  font-size: 12.5px; color: var(--muted); text-align: center;
  margin-top: 3px; line-height: 1.4;
}
.thread-review .star-picker { margin: 12px 0 8px; }
textarea.thread-review-comment { width: 100%; resize: none; line-height: 1.45; margin-top: 4px; }
#thread-review-send { margin-top: 12px; }
/* Avis déjà laissé : état lecture seule dans le fil. */
.thread-review-done {
  margin: 14px 0 6px; min-height: 46px; border-radius: 14px; padding: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--green-ink);
  background: var(--green-bg);
}

.thread-loadmore { display: flex; justify-content: center; }
.thread-loadmore .load-more { margin: 10px 0; }

/* Messages : bulles gauche (other) / droite (mine) */
.thread-messages { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.day-sep {
  align-self: center; margin: 14px 0 8px; padding: 3px 12px; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-ink);
  font-size: 11px; font-weight: 800;
}
.bubble {
  max-width: 78%; padding: 9px 13px 6px; border-radius: 18px; margin-top: 2px;
  font-size: 14.5px; line-height: 1.4; word-break: break-word;
}
.bubble.other { align-self: flex-start; background: #F1ECE4; color: var(--ink); border-bottom-left-radius: 6px; }
.bubble.mine { align-self: flex-end; background: var(--orange); color: #fff; border-bottom-right-radius: 6px; }
.bubble-img {
  display: block; max-width: 220px; width: 100%; border-radius: 12px;
  margin-bottom: 4px; cursor: pointer;
}
.bubble-text { white-space: pre-wrap; }
.bubble-time { font-size: 10px; font-weight: 700; opacity: 0.6; text-align: right; margin-top: 3px; }
.bubble.mine .bubble-time { color: #fff; opacity: 0.8; }
.thread-hint {
  align-self: center; max-width: 80%; text-align: center; margin-top: 18px;
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
/* État de chargement du fil (spinner centré, le temps du fetch) : ouvre l'écran
   sans attendre le réseau, façon Vinted. Réutilise .feed-spinner (app.extras). */
.thread-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 0; min-height: 120px;
}

/* Barre de saisie (photo + texte + envoi) */
.thread-composer {
  flex-shrink: 0; display: flex; align-items: flex-end; gap: 8px;
  padding: 9px 12px calc(9px + var(--sab));
  border-top: 1px solid var(--line); background: var(--bg);
}
.composer-photo, .composer-send {
  width: 42px; height: 42px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: transform 0.1s;
}
.composer-photo { background: var(--chip-bg); color: var(--chip-ink); }
.composer-photo:active, .composer-send:active { transform: scale(0.92); }
.composer-send { background: var(--orange); color: #fff; font-size: 17px; }
.composer-send:disabled { opacity: 0.5; }
.composer-input {
  flex: 1; min-height: 42px; max-height: 120px; border-radius: 21px;
  border: 1.5px solid #E4D9CB; background: #FFFFFF; padding: 10px 16px;
  font-size: 16px; color: var(--ink);
}
.composer-input:focus { outline: none; border-color: var(--orange); }
.ic-cam { position: relative; width: 22px; height: 17px; display: block; }
.ic-cam i {
  position: absolute; inset: 2px 0 0 0; border: 2px solid currentColor;
  border-radius: 5px; display: block;
}
.ic-cam i::before {
  content: ''; position: absolute; top: -4px; left: 5px; width: 7px; height: 4px;
  border: 2px solid currentColor; border-bottom: none; border-radius: 3px 3px 0 0;
}
.ic-cam b {
  position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 999px; display: block;
}
.thread-blocked {
  flex-shrink: 0; padding: 14px 18px calc(14px + var(--sab));
  border-top: 1px solid var(--line); background: var(--bg);
  font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.5;
}

/* ---------- Feuille « Détails » de la conversation ---------- */
#thread-details-backdrop {
  position: fixed; inset: 0; z-index: 45; background: rgba(24,17,9,0.45);
  animation: fadeIn 0.25s ease both;
}
#thread-details-sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 46;
  background: #FFFFFF; border-radius: 26px 26px 0 0;
  padding: 14px 18px calc(20px + var(--sab));
  animation: sheetUp 0.35s cubic-bezier(0.2,0.9,0.3,1) both;
  max-height: 86dvh; overflow: auto;
}
#thread-details-sheet .onboard-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.td-row {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 15px 2px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 700; color: var(--ink);
}
.td-row:active:not(.td-static) { background: var(--chip-bg); }
.td-static { cursor: default; }
.td-row:last-child { border-bottom: none; }
.td-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-row .chev { color: var(--faint); font-size: 20px; }
.td-thumb { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; background-color: #EFE9E0; }
.td-avatar {
  width: 40px; height: 40px; border-radius: 999px; flex-shrink: 0;
  background: var(--chip-bg); color: var(--chip-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px;
}
.td-ic {
  width: 28px; text-align: center; font-size: 18px; flex-shrink: 0;
}
.td-ic-help {
  width: 26px; height: 26px; border-radius: 999px; border: 2px solid currentColor;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: var(--ink-soft);
}
.td-row.danger { color: var(--red); }
.td-row.danger .td-ic { color: var(--red); }

/* ====================================================================
   Fil de NÉGOCIATION (« Faire une offre », façon Vinted) — écran
   #screen-offer-thread. Réutilise .thread-head / .thread-scroll /
   .thread-messages / .bubble ; n'ajoute que la barre d'action + les bulles
   d'offre (montant) et les lignes « système » (accepté/refusé/expiré).
   ==================================================================== */
#screen-offer-thread { display: flex; flex-direction: column; height: 100dvh; }
.oth-head-spacer { width: 38px; flex-shrink: 0; }
.oth-actions {
  flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px calc(10px + var(--sab));
  border-top: 1px solid var(--line); background: var(--bg);
}
.oth-btn {
  flex: 1; min-width: 96px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; background: #FFFFFF;
  border: 1.5px solid #E4D9CB; color: var(--ink); cursor: pointer;
  transition: transform 0.1s;
}
.oth-btn:active { transform: scale(0.98); }
.oth-accept { background: var(--orange); color: #fff; border-color: var(--orange); }
.oth-decline { color: var(--red); }
.oth-waiting {
  flex: 1; min-width: 100%; text-align: center; font-size: 13px;
  color: var(--muted); font-weight: 600; padding: 4px 0;
}
.oth-concluded {
  flex: 1; min-width: 100%; text-align: center; font-size: 14px;
  font-weight: 700; color: var(--ink); padding: 2px 0 8px;
}
/* Bulle d'offre : le montant en gros + une légende (Votre proposition / …). */
.bubble .oth-amount { font-size: 18px; font-weight: 900; line-height: 1.1; margin-bottom: 1px; }
/* Lignes « système » centrées (offre acceptée / refusée / expirée). */
.oth-sys {
  align-self: center; max-width: 86%; text-align: center; margin: 10px auto;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  background: var(--chip-bg); border-radius: 999px; padding: 6px 14px;
}
.oth-sys-ok { color: #1E7A3C; background: #E6F4EA; }
