/* ==========================================================================
   BSF UNIFIED TOPBAR STYLES (v7 - Light Mode Fix)
   ========================================================================== */

:root {
  --bsf-topbar-h: 80px;
  --bsf-glass: rgba(255, 255, 255, 0.95);
  --bsf-stroke: rgba(12, 48, 76, 0.1);
  --bsf-text: #213743;
  --bsf-muted: #5A7A90;
  --bsf-accent: #1E70B8;
  --bsf-brand: #0C304C;
  --bsf-bg2: #FFFFFF;
  --bsf-shadow: 0 20px 60px rgba(12, 48, 76, 0.1);
  --bsf-shadow-sm: 0 8px 24px rgba(12, 48, 76, 0.08);
  --bsf-r-xl: 999px;
}

[data-theme="dark"] {
  --bsf-glass: rgba(25, 51, 78, 0.95);
  --bsf-stroke: rgba(77, 158, 208, 0.20);
  --bsf-text: #E8F1F8;
  --bsf-muted: #7FA8C4;
  --bsf-bg2: #19334E;
  --bsf-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

body {
  padding-top: var(--bsf-topbar-h);
}

.bsf-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  padding: 10px 0;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
}

.bsf-topbar-inner {
  width: calc(100% - 48px);
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bsf-glass);
  border: 1px solid var(--bsf-stroke);
  border-radius: var(--bsf-r-xl);
  padding: 8px 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--bsf-shadow-sm);
  box-sizing: border-box;
  min-height: 60px;
}

.bsf-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none !important;
  color: var(--bsf-text) !important;
  min-width: 0;
}

.bsf-logo-ring {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #ffffff;
  box-shadow: 0 0 0 2px var(--bsf-accent), 0 4px 14px rgba(12,48,76,0.2);
}

.bsf-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.bsf-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bsf-brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.5px;
  line-height: 1.1;
  white-space: nowrap;
  color: var(--bsf-text) !important;
}

.bsf-brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--bsf-muted) !important;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.bsf-spacer { flex: 1; }

.bsf-stats-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--bsf-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--bsf-accent) 20%, transparent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bsf-accent) !important;
  white-space: nowrap;
  margin-right: 8px;
}

.bsf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none !important;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--bsf-stroke);
  background: var(--bsf-bg2);
  color: var(--bsf-text) !important;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(10,40,30,0.06);
}

.bsf-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--bsf-shadow-sm);
  border-color: var(--bsf-accent);
  color: var(--bsf-accent) !important;
}

.bsf-btn-primary {
  background: var(--bsf-accent) !important;
  border-color: var(--bsf-accent) !important;
  color: #fff !important;
}

.bsf-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--bsf-stroke);
  background: var(--bsf-bg2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .18s ease;
  color: var(--bsf-text) !important;
  padding: 0;
}
.bsf-icon-btn:hover { color: var(--bsf-accent) !important; border-color: var(--bsf-accent) !important; }

/* Dropdowns & Menus */
.bsf-dropdown { position: relative; }
.bsf-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 260px;
  background: var(--bsf-bg2) !important;
  border: 1px solid var(--bsf-stroke) !important;
  border-radius: 18px;
  box-shadow: var(--bsf-shadow);
  padding: 8px;
  display: none;
  z-index: 1001;
}
.bsf-dropdown[aria-expanded="true"] .bsf-menu { display: block; }

.bsf-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none !important;
  color: var(--bsf-text) !important;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s ease;
  background: transparent !important;
}
.bsf-menu-item:hover {
  background: color-mix(in srgb, var(--bsf-accent) 10%, transparent) !important;
  color: var(--bsf-accent) !important;
}

.bsf-icon-sun { display: none; }
html[data-theme="dark"] .bsf-icon-moon { display: none; }
html[data-theme="dark"] .bsf-icon-sun { display: block; }

@media (max-width: 768px) {
  .bsf-topbar { padding: 8px 0; }
  .bsf-topbar-inner { width: calc(100% - 16px); padding: 6px 12px; min-height: 52px; gap: 8px; }
  .bsf-logo-ring { width: 38px; height: 38px; }
  .bsf-brand-name { font-size: 15px; }
  .bsf-hide-mobile { display: none !important; }
  .bsf-btn { height: 36px; padding: 0 12px; font-size: 12px; }
  .bsf-icon-btn { width: 36px; height: 36px; }
}

/* ==========================================================================
   NOTIFICATION BELL STYLES
   ========================================================================== */

/* Red badge count on the bell */
.bsf-notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 16px;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--bsf-bg2, #fff);
}

/* Notification dropdown panel */
.bsf-notif-menu {
  width: 300px !important;
  max-height: 380px;
  display: none;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}
.bsf-dropdown[aria-expanded="true"] .bsf-notif-menu {
  display: flex !important;
}

/* Header row inside notification panel */
.bsf-notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bsf-text, #213743);
  border-bottom: 1px solid var(--bsf-stroke, rgba(12,48,76,0.1));
  flex-shrink: 0;
}

.bsf-notif-clear-btn {
  background: none;
  border: none;
  color: var(--bsf-accent, #1E70B8);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.bsf-notif-clear-btn:hover { text-decoration: underline; }

/* Scrollable notification list */
.bsf-notif-list {
  overflow-y: auto;
  max-height: 320px;
  padding: 6px;
}

/* Individual notification item */
.bsf-notif-item {
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--bsf-text, #213743) !important;
  text-decoration: none !important;
  transition: background 0.15s;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}
.bsf-notif-item:hover {
  background: color-mix(in srgb, var(--bsf-accent, #1E70B8) 8%, transparent);
}
.bsf-notif-item.unread {
  font-weight: 700;
  background: color-mix(in srgb, var(--bsf-accent, #1E70B8) 5%, transparent);
}
.bsf-notif-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--bsf-muted, #5A7A90);
  font-size: 12px;
}

/* ==========================================================================
   CHAT WIDGET STYLES  (v2 — centralisé, toutes classes incluses)
   ========================================================================== */

/* ── Bouton flottant — MASQUÉ (déclencheur uniquement via topbar) ──────────── */
.chat-widget {
  position: fixed; bottom: 24px; right: 24px; z-index: 1100;
  pointer-events: none; /* container fantôme, ne capte aucun clic */
}
.chat-toggle { display: none; } /* bouton flottant supprimé — déclencheur uniquement via topbar */
.chat-toggle-icon, .chat-toggle-text { display: none; }

/* Badge de non-lus (conservé invisible — la logique JS tourne toujours) */
.chat-unread-badge { display: none; }

/* ── Panel popup — repositionné en fixed (indépendant du container) ───────── */
.chat-panel {
  position: fixed; bottom: 88px; right: 24px;
  width: 360px; height: 520px; max-height: calc(100dvh - 110px);
  background: var(--bsf-bg2, #fff); border: 1px solid var(--bsf-stroke);
  border-radius: 22px; box-shadow: var(--bsf-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity .25s ease, transform .28s cubic-bezier(.19,1,.22,1);
}
.chat-widget[data-open="true"] .chat-panel {
  opacity: 1; pointer-events: all; transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.chat-header {
  padding: 16px 20px;
  background: var(--bsf-brand, #0C304C); color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.chat-header strong { font-size: 15px; font-weight: 800; }
.chat-sub { font-size: 11px; opacity: .75; margin-top: 2px; }
.chat-close {
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-close:hover { background: rgba(255,255,255,.28); }

/* ── Corps messages ──────────────────────────────────────────────────────── */
.chat-body {
  flex: 1; overflow-y: auto; padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
}
.chat-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 13px; line-height: 1.55; max-width: 86%;
  word-break: break-word; white-space: pre-wrap;
}
.chat-bubble.bot, .chat-bubble.admin {
  background: color-mix(in srgb, var(--bsf-accent,#1E70B8) 8%, var(--bsf-bg2,#fff));
  border: 1px solid var(--bsf-stroke);
  align-self: flex-start; border-bottom-left-radius: 4px;
  color: var(--bsf-text, #213743);
}
.chat-bubble.user {
  background: var(--bsf-accent, #1E70B8); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.chat-bubble-meta {
  font-size: 10px; opacity: .55; margin-top: 3px;
  align-self: flex-end;
}

/* ── Formulaire ──────────────────────────────────────────────────────────── */
.chat-form {
  padding: 12px 14px; border-top: 1px solid var(--bsf-stroke);
  display: flex; gap: 8px; flex-shrink: 0;
  background: var(--bsf-bg2);
}
.chat-input {
  flex: 1; border: 1px solid var(--bsf-stroke); border-radius: 12px;
  padding: 9px 13px; font-family: inherit; font-size: 13px;
  resize: none; background: var(--bsf-bg2); color: var(--bsf-text);
  outline: none; max-height: 100px; line-height: 1.4;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--bsf-accent, #1E70B8); }
.chat-send-btn {
  height: 40px; padding: 0 16px; background: var(--bsf-accent, #1E70B8);
  color: #fff; border: none; border-radius: 12px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap;
  transition: opacity .15s;
}
.chat-send-btn:hover { opacity: .88; }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Actions (non connecté) ──────────────────────────────────────────────── */
.chat-actions {
  padding: 14px 16px; border-top: 1px solid var(--bsf-stroke);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.chat-action-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 11px 18px; border-radius: 12px; font-size: 13px; font-weight: 700;
  text-decoration: none; transition: all .15s; cursor: pointer;
  border: none; font-family: inherit; gap: 6px;
}
.chat-action-btn.primary { background: var(--bsf-accent, #1E70B8); color: #fff; }
.chat-action-btn.primary:hover { opacity: .88; }
.chat-action-btn.ghost {
  background: transparent; color: var(--bsf-text, #213743);
  border: 1.5px solid var(--bsf-stroke);
}
.chat-action-btn.ghost:hover { border-color: var(--bsf-accent, #1E70B8); color: var(--bsf-accent, #1E70B8); }

/* ── Liens sociaux ───────────────────────────────────────────────────────── */
.chat-links {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--bsf-stroke); flex-shrink: 0;
}
.chat-link {
  font-size: 12px; font-weight: 600; color: var(--bsf-accent, #1E70B8);
  text-decoration: none; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--bsf-accent, #1E70B8);
  transition: all .15s;
}
.chat-link:hover { background: var(--bsf-accent, #1E70B8); color: #fff; }

/* ── Modal auth ──────────────────────────────────────────────────────────── */
.chat-auth-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.chat-auth-modal.is-open { display: flex; }
.chat-auth-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.chat-auth-card {
  position: relative; background: var(--bsf-bg2, #fff);
  border-radius: 24px; padding: 36px 28px; width: 100%; max-width: 380px;
  text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.chat-auth-card h3 {
  font-size: 18px; font-weight: 800; margin-bottom: 10px;
  color: var(--bsf-text, #213743);
}
.chat-auth-card p {
  font-size: 13px; color: var(--bsf-muted, #5A7A90);
  margin-bottom: 20px; line-height: 1.5;
}
.chat-auth-actions { display: flex; flex-direction: column; gap: 10px; }
.chat-auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: var(--bsf-stroke, rgba(0,0,0,.08)); cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  color: var(--bsf-muted, #5A7A90); transition: background .15s;
}
.chat-auth-close:hover { background: var(--bsf-stroke); color: var(--bsf-text); }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 72px;
    max-height: calc(100dvh - 90px);
  }
}


/* ==========================================================================
   PEER CHAT MEMBRES  (v2 — Premium Design)
   ========================================================================== */

/* ── Widget shell ────────────────────────────────────────────────────────── */
.pc-widget {
  position: fixed; inset: 0; z-index: 1200; pointer-events: none;
}
.pc-widget[data-open="true"] { pointer-events: auto; }

/* ── Overlay ─────────────────────────────────────────────────────────────── */
.pc-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(6, 20, 36, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1;
}

/* ── Main panel ──────────────────────────────────────────────────────────── */
.pc-panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -47%) scale(.96);
  width: min(920px, calc(100vw - 20px));
  height: min(660px, calc(100dvh - 76px));
  background: var(--bsf-bg2, #fff);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(12,48,76,.07),
    0 24px 60px rgba(0,0,0,.18),
    0 60px 120px rgba(0,0,0,.12);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 2; opacity: 0; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.46,.64,1), opacity .22s ease;
}
.pc-widget[data-open="true"] .pc-panel {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1; pointer-events: auto;
}
[data-theme=dark] .pc-panel {
  box-shadow:
    0 0 0 1px rgba(77,158,208,.14),
    0 24px 60px rgba(0,0,0,.45),
    0 60px 120px rgba(0,0,0,.3);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.pc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; flex-shrink: 0;
  background: linear-gradient(130deg, #0a2a44 0%, #1a5590 60%, #1E70B8 100%);
  color: #fff; position: relative; overflow: hidden;
}
.pc-header::after {
  content: '';
  position: absolute; top: -40%; right: -6%;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 70%);
  pointer-events: none;
}
.pc-header-left {
  display: flex; align-items: center; gap: 11px; position: relative; z-index: 1;
}
.pc-header-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.pc-header-title {
  font-size: .95rem; font-weight: 800; letter-spacing: -.3px; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.pc-header-sub {
  font-size: .71rem; color: rgba(255,255,255,.6); margin-top: 2px;
}
.pc-unread-total {
  display: none;
  background: #ef4444; color: #fff; font-size: .65rem; font-weight: 800;
  border-radius: 999px; padding: 1px 7px; line-height: 17px; letter-spacing: .3px;
}
.pc-unread-total.show { display: inline-flex; }
.pc-close {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.8); width: 32px; height: 32px;
  border-radius: 8px; font-size: 1.05rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.pc-close:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ── Auth fallback ───────────────────────────────────────────────────────── */
.pc-auth-msg {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 32px; text-align: center;
  background: var(--bsf-bg2, #fff);
}
.pc-auth-icon-wrap {
  width: 76px; height: 76px;
  background: linear-gradient(135deg, #e5f1fb, #cde6f7);
  border-radius: 22px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center;
  color: #1E70B8; flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(30,112,184,.15);
}
[data-theme=dark] .pc-auth-icon-wrap {
  background: rgba(30,112,184,.15);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.pc-auth-msg h3 {
  font-size: 1.05rem; font-weight: 800; color: var(--bsf-text, #213743);
  margin: 0 0 8px; letter-spacing: -.3px;
}
.pc-auth-msg p {
  font-size: .87rem; opacity: .6; color: var(--bsf-text, #213743);
  margin: 0 0 24px; max-width: 300px; line-height: 1.55;
}
.pc-auth-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 26px;
  background: linear-gradient(135deg, #1E70B8, #0c3d6e);
  color: #fff; border-radius: 12px;
  font-size: .88rem; font-weight: 700; text-decoration: none;
  box-shadow: 0 6px 20px rgba(30,112,184,.32);
  transition: transform .15s, box-shadow .15s;
}
.pc-auth-cta:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30,112,184,.4); }

/* ── Body 2 columns ──────────────────────────────────────────────────────── */
.pc-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ── Left — contacts ─────────────────────────────────────────────────────── */
.pc-contacts-panel {
  width: 295px; flex-shrink: 0;
  border-right: 1px solid var(--bsf-stroke, rgba(12,48,76,.08));
  display: flex; flex-direction: column; overflow: hidden;
  background: #f4f7fa;
}
[data-theme=dark] .pc-contacts-panel {
  background: #0c1e30;
  border-right-color: rgba(77,158,208,.1);
}

.pc-search-wrap { padding: 12px 12px 6px; flex-shrink: 0; }
.pc-search-inner {
  display: flex; align-items: center; gap: 7px;
  background: var(--bsf-bg2, #fff);
  border: 1.5px solid var(--bsf-stroke, rgba(12,48,76,.1));
  border-radius: 11px; padding: 8px 12px;
  transition: border-color .2s, box-shadow .2s;
}
.pc-search-inner:focus-within {
  border-color: #1E70B8;
  box-shadow: 0 0 0 3px rgba(30,112,184,.1);
}
[data-theme=dark] .pc-search-inner {
  background: #112131; border-color: rgba(77,158,208,.14);
}
.pc-search-icon { color: var(--bsf-muted, #5A7A90); flex-shrink: 0; display: flex; }
.pc-search {
  border: none; background: transparent; outline: none;
  font-size: .82rem; color: var(--bsf-text, #213743); font-family: inherit; width: 100%;
}
.pc-search::placeholder { color: var(--bsf-muted, #5A7A90); opacity: .75; }

.pc-contacts-label {
  padding: 8px 15px 4px;
  font-size: .67rem; font-weight: 700; letter-spacing: .9px;
  text-transform: uppercase; color: var(--bsf-muted, #5A7A90);
  flex-shrink: 0;
}

.pc-contacts-list {
  flex: 1; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(30,112,184,.18) transparent;
}
.pc-contacts-list::-webkit-scrollbar { width: 4px; }
.pc-contacts-list::-webkit-scrollbar-track { background: transparent; }
.pc-contacts-list::-webkit-scrollbar-thumb {
  background: rgba(30,112,184,.18); border-radius: 4px;
}

.pc-contact-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; cursor: pointer;
  position: relative; transition: background .14s;
}
.pc-contact-item::before {
  content: '';
  position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; background: #1E70B8;
  border-radius: 0 3px 3px 0;
  opacity: 0; transition: opacity .15s;
}
.pc-contact-item:hover  { background: rgba(30,112,184,.06); }
.pc-contact-item.active {
  background: linear-gradient(90deg, rgba(30,112,184,.11), rgba(30,112,184,.03));
}
.pc-contact-item.active::before { opacity: 1; }
.pc-contact-item.has-unread .pc-contact-name { font-weight: 700; }
.pc-contact-item.has-unread .pc-contact-preview { font-weight: 500; opacity: .75; }

/* Avatar with gradient color by index */
.pc-contact-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 800; color: #fff; text-transform: uppercase;
  letter-spacing: -.5px;
}
.pc-contact-avatar[data-ci="0"] { background: linear-gradient(135deg, #1E70B8, #0a2a44); }
.pc-contact-avatar[data-ci="1"] { background: linear-gradient(135deg, #059669, #064e3b); }
.pc-contact-avatar[data-ci="2"] { background: linear-gradient(135deg, #d97706, #78350f); }
.pc-contact-avatar[data-ci="3"] { background: linear-gradient(135deg, #7c3aed, #3b0764); }
.pc-contact-avatar[data-ci="4"] { background: linear-gradient(135deg, #db2777, #700028); }
.pc-contact-avatar[data-ci="5"] { background: linear-gradient(135deg, #0891b2, #0c4a6e); }
.pc-contact-avatar:not([data-ci]) { background: linear-gradient(135deg, #1E70B8, #0a2a44); }

.pc-contact-info  { flex: 1; min-width: 0; }
.pc-contact-name  {
  font-size: .86rem; font-weight: 500; color: var(--bsf-text, #213743);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.pc-contact-preview {
  font-size: .74rem; color: var(--bsf-muted, #5A7A90);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px; opacity: .8;
}
.pc-contact-badge {
  flex-shrink: 0; min-width: 20px; height: 20px;
  background: #ef4444; color: #fff; font-size: .65rem; font-weight: 800;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; box-shadow: 0 2px 8px rgba(239,68,68,.38);
  animation: pcBadgePop .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pcBadgePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.pc-no-contacts, .pc-loading {
  padding: 36px 16px; text-align: center;
  font-size: .83rem; color: var(--bsf-muted, #5A7A90);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* ── Right — messages ────────────────────────────────────────────────────── */
.pc-messages-panel {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bsf-bg2, #fff); min-width: 0;
}

/* Thread header */
.pc-thread-header {
  display: none; align-items: center; gap: 12px;
  padding: 12px 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--bsf-stroke, rgba(12,48,76,.07));
  background: var(--bsf-bg2, #fff);
}
.pc-thread-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #1E70B8, #0a2a44);
  box-shadow: 0 0 0 2px var(--bsf-bg2,#fff), 0 0 0 3.5px #1E70B8;
}
.pc-thread-info  { flex: 1; min-width: 0; }
.pc-thread-name  {
  font-size: .9rem; font-weight: 700; color: var(--bsf-text, #213743);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-thread-status {
  font-size: .71rem; color: var(--bsf-muted, #5A7A90); margin-top: 1px;
  display: flex; align-items: center; gap: 5px;
}
.pc-thread-status::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2);
}

/* Messages body */
.pc-messages-body {
  flex: 1; overflow-y: auto;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bsf-bg2, #fff);
  scrollbar-width: thin;
  scrollbar-color: rgba(30,112,184,.12) transparent;
}
.pc-messages-body::-webkit-scrollbar { width: 4px; }
.pc-messages-body::-webkit-scrollbar-track { background: transparent; }
.pc-messages-body::-webkit-scrollbar-thumb {
  background: rgba(30,112,184,.12); border-radius: 4px;
}
[data-theme=dark] .pc-messages-body { background: #0f1f30; }

/* Empty state */
.pc-empty-state {
  margin: auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pc-empty-icon {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, #e5f1fb, #cde6f7);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  color: #1E70B8;
  box-shadow: 0 8px 24px rgba(30,112,184,.12);
}
[data-theme=dark] .pc-empty-icon { background: rgba(30,112,184,.15); }
.pc-empty-title { font-size: .9rem; font-weight: 700; color: var(--bsf-text,#213743); opacity: .65; }
.pc-empty-sub   { font-size: .8rem; color: var(--bsf-muted,#5A7A90); opacity: .6; }
.pc-select-hint { color: var(--bsf-muted,#5A7A90); font-size: .88rem; opacity: .55; }

/* Day separator */
.pc-day-sep {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; margin: 10px 0;
  font-size: .68rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--bsf-muted, #5A7A90);
}
.pc-day-sep::before, .pc-day-sep::after {
  content: ''; flex: 1; height: 1px;
  background: var(--bsf-stroke, rgba(12,48,76,.08));
}

/* Message bubbles */
.pc-msg {
  max-width: 66%; padding: 10px 14px 5px;
  border-radius: 18px;
  font-size: .875rem; line-height: 1.55; word-break: break-word;
  position: relative;
  animation: pcMsgIn .2s cubic-bezier(.34,1.4,.64,1);
}
@keyframes pcMsgIn {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.pc-msg.mine {
  background: linear-gradient(140deg, #1a67b0, #0d3e78);
  color: #fff; align-self: flex-end;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 14px rgba(30,112,184,.22);
  margin-top: 2px;
}
.pc-msg.theirs {
  background: #eef2f6; color: var(--bsf-text, #213743);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  margin-top: 2px;
}
[data-theme=dark] .pc-msg.theirs { background: #1a3654; box-shadow: none; }

/* Spacing between groups */
.pc-msg.mine  + .pc-msg.theirs,
.pc-msg.theirs + .pc-msg.mine  { margin-top: 12px; }

.pc-msg-meta {
  font-size: .64rem; margin-top: 3px; opacity: .65;
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
}
.pc-msg.theirs .pc-msg-meta { justify-content: flex-start; }

/* ── Compose ──────────────────────────────────────────────────────────────── */
.pc-compose {
  display: none; flex-shrink: 0;
  padding: 12px 14px; gap: 10px; align-items: flex-end;
  border-top: 1px solid var(--bsf-stroke, rgba(12,48,76,.08));
  background: var(--bsf-bg2, #fff);
}
[data-theme=dark] .pc-compose { border-top-color: rgba(77,158,208,.09); }

.pc-compose-input {
  flex: 1; min-height: 42px; max-height: 130px; resize: none;
  background: #f4f7fa;
  border: 1.5px solid var(--bsf-stroke, rgba(12,48,76,.1));
  border-radius: 12px; padding: 10px 14px;
  font-size: .875rem; font-family: inherit; outline: none;
  color: var(--bsf-text, #213743); line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
}
.pc-compose-input:focus {
  border-color: #1E70B8;
  box-shadow: 0 0 0 3px rgba(30,112,184,.1);
  background: var(--bsf-bg2, #fff);
}
[data-theme=dark] .pc-compose-input {
  background: #0c1e30; border-color: rgba(77,158,208,.14);
}
[data-theme=dark] .pc-compose-input:focus {
  background: #0f2438; border-color: rgba(30,112,184,.5);
}

.pc-compose-send {
  flex-shrink: 0; width: 42px; height: 42px;
  background: linear-gradient(140deg, #1E70B8, #0c3d72);
  color: #fff; border: none; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  box-shadow: 0 4px 16px rgba(30,112,184,.3);
}
.pc-compose-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 7px 22px rgba(30,112,184,.4);
}
.pc-compose-send:active:not(:disabled) { transform: scale(.94); }
.pc-compose-send:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

/* ── Topbar badge ─────────────────────────────────────────────────────────── */
#pcTopbarBadge {
  display: none;
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #ef4444; color: #fff;
  border-radius: 999px; font-size: .6rem; font-weight: 800;
  align-items: center; justify-content: center; line-height: 16px;
  box-shadow: 0 0 0 2px var(--bsf-glass, #fff);
  animation: pcBadgePop .28s cubic-bezier(.34,1.56,.64,1);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pc-panel {
    width: 100vw; height: 100dvh; border-radius: 0;
    top: 0; left: 0; transform: none; max-height: none;
  }
  .pc-widget[data-open="true"] .pc-panel { transform: none; }
  .pc-contacts-panel { width: 230px; }
}

@media (max-width: 500px) {
  .pc-body { flex-direction: column; }
  .pc-contacts-panel {
    width: 100%; height: 64px; flex-shrink: 0; flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--bsf-stroke, rgba(12,48,76,.08));
  }
  .pc-search-wrap, .pc-contacts-label { display: none; }
  .pc-contacts-list {
    display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 8px 10px; gap: 8px; align-items: center;
    flex: 1; scrollbar-width: none;
  }
  .pc-contacts-list::-webkit-scrollbar { display: none; }
  .pc-contact-item {
    flex-direction: column; align-items: center; text-align: center;
    padding: 4px 8px; gap: 3px; min-width: 54px; border-radius: 8px;
    flex-shrink: 0;
  }
  .pc-contact-item::before { display: none; }
  .pc-contact-item.active { background: rgba(30,112,184,.1); }
  .pc-contact-info  { display: none; }
  .pc-contact-avatar { width: 34px; height: 34px; font-size: .75rem; }
  .pc-contact-badge {
    position: absolute; top: 0; right: 2px;
    min-width: 14px; height: 14px; font-size: .57rem; padding: 0 3px;
  }
}
