.sidebar-tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--bordure);
}

.sidebar-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--texte-secondaire);
}

.sidebar-tab:hover {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
}

.sidebar-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.sidebar-tab i {
  font-size: 14px;
}

.sidebar-onglet {
  flex: 1;
  overflow-y: auto;
  display: none;
  /* ===== FIX: Permet scroll ===== */
  min-height: 0;
}

.sidebar-onglet.active {
  display: flex;
  flex-direction: column;
  /* ===== FIX: Permet scroll dans enfants ===== */
  min-height: 0;
  overflow: hidden;
}

.messagerie-section {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--bordure);
  padding-bottom: 8px;
}

.messagerie-section:last-child {
  border-bottom: none;
}

.messagerie-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--texte-secondaire);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.messagerie-section-header i {
  font-size: 14px;
}

.messagerie-section-header .btn-icon-small {
  margin-left: auto;
  padding: 4px 6px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--texte-secondaire);
}

.messagerie-section-header .btn-icon-small:hover {
  background: var(--fond-secondaire);
  border-color: var(--accent);
  color: var(--accent);
}

.contacts-liste, .conversations-liste {
  padding: 0 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-item, .conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  background: transparent;
}

.contact-item:hover, .conversation-item:hover {
  background: var(--fond-secondaire);
}

.contact-item.active, .conversation-item.active {
  background: var(--accent);
  color: white;
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
  position: relative;
  flex-shrink: 0;
}

.contact-avatar .statut-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--fond-primaire);
}

.statut-en-ligne {
  background: #10b981;
}

.statut-hors-ligne {
  background: #6b7280;
}

.statut-absent {
  background: #f59e0b;
}

.statut-ne-pas-deranger {
  background: #ef4444;
}

.contact-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-nom {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--texte-primaire);
}

.contact-item.active .contact-nom,
.conversation-item.active .contact-nom {
  color: white;
}

.contact-statut {
  font-size: 12px;
  color: var(--texte-secondaire);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-item.active .contact-statut,
.conversation-item.active .contact-statut {
  color: rgba(255, 255, 255, 0.8);
}

.contact-badge {
  min-width: 20px;
  height: 20px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  flex-shrink: 0;
}

.contact-item.active .contact-badge {
  background: white;
  color: var(--accent);
}

.conversation-item {
  padding: 12px;
}

.conversation-participants {
  display: flex;
  margin-right: 8px;
  flex-shrink: 0;
}

.conversation-participants .contact-avatar {
  width: 32px;
  height: 32px;
  margin-left: -8px;
  font-size: 13px;
  border: 2px solid var(--fond-primaire);
}

.conversation-participants .contact-avatar:first-child {
  margin-left: 0;
}

.conversation-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-titre {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--texte-primaire);
}

.conversation-item.active .conversation-titre {
  color: white;
}

.conversation-dernier-message {
  font-size: 12px;
  color: var(--texte-secondaire);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.conversation-item.active .conversation-dernier-message {
  color: rgba(255, 255, 255, 0.8);
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conversation-date {
  font-size: 11px;
  color: var(--texte-tertiaire);
  white-space: nowrap;
}

.conversation-item.active .conversation-date {
  color: rgba(255, 255, 255, 0.7);
}

.empty-messagerie {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--texte-secondaire);
}

.empty-messagerie i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-messagerie h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--texte-primaire);
}

.empty-messagerie p {
  font-size: 13px;
  line-height: 1.5;
  max-width: 250px;
}

.avatar-humain {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: inherit;
  color: white;
}

.message .avatar-humain {
  width: 36px;
  height: 36px;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
}

.compteur-en-ligne {
  font-weight: 600;
  color: #10b981;
}

.interface-appel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--fond-primaire);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 2001;
  min-width: 400px;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.interface-appel-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  backdrop-filter: blur(2px);
}

.interface-appel.mode-plein-ecran {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  transform: none;
  border-radius: 0;
  padding: 0;
}

.interface-appel.mode-compact {
  min-width: 320px;
  max-width: 400px;
}

.appel-video-container {
  display: none;
  position: relative;
  width: 100%;
  min-height: 400px;
  max-height: calc(100vh - 200px);
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
}

.interface-appel.mode-plein-ecran .appel-video-container {
  border-radius: 0;
  max-height: calc(100vh - 120px);
  min-height: auto;
}

.appel-video-container.active {
  display: flex;
}

.video-distant {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1a1a1a;
}

.video-distant:not([src]):not([srcObject]) {
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-local {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 200px;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--fond-primaire);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: #1a1a1a;
}

.video-local:not([src]):not([srcObject]) {
  background: #1a1a1a;
}

.appel-contenu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.appel-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 64px;
}

.appel-info {
  text-align: center;
}

.appel-info h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--texte-primaire);
}

.appel-info p {
  font-size: 14px;
  margin: 0;
  color: var(--texte-secondaire);
}

.appel-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--fond-primaire);
  border-radius: 12px;
}

.interface-appel.mode-plein-ecran .appel-controls {
  background: rgba(0, 0, 0, 0.8);
  border-radius: 0;
  gap: 16px;
  padding: 20px;
}

.appel-controls-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-appel {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-appel:hover {
  transform: scale(1.1);
}

.btn-appel-success {
  background: #10b981;
  color: white;
}

.btn-appel-success:hover {
  background: #059669;
}

.btn-appel-danger {
  background: #ef4444;
  color: white;
}

.btn-appel-danger:hover {
  background: #dc2626;
}

.btn-appel-mute {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
  border: 1px solid var(--bordure);
}

.btn-appel-mute:hover {
  background: var(--fond-tertiaire);
}

.btn-appel-mute.muted {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-appel-secondary {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
  border: 1px solid var(--bordure);
}

.btn-appel-secondary:hover {
  background: var(--fond-tertiaire);
}

.btn-appel-secondary.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-appel-record {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
  border: 1px solid var(--bordure);
}

.btn-appel-record:hover {
  background: var(--fond-tertiaire);
}

.btn-appel-record.recording {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
  animation: pulse-record 1.5s infinite;
}

@keyframes pulse-record {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn-appel-fullscreen {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
  border: 1px solid var(--bordure);
}

.btn-appel-fullscreen:hover {
  background: var(--fond-tertiaire);
}

.contact-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.btn-contact-action {
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--texte-secondaire);
  font-size: 12px;
}

.btn-contact-action:hover {
  background: var(--fond-secondaire);
  color: var(--texte-primaire);
}

.btn-contact-action.btn-call {
  color: #10b981;
  border-color: #10b981;
}

.btn-contact-action.btn-call:hover {
  background: #10b981;
  color: white;
}

.contact-item.active .btn-contact-action {
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.contact-item.active .btn-contact-action:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

@media (max-width: 768px) {
  .sidebar-tabs {
    padding: 8px;
    gap: 6px;
  }

  .sidebar-tab {
    padding: 8px;
    font-size: 12px;
  }

  .sidebar-tab span {
    display: none;
  }

  .contact-avatar, .conversation-participants .contact-avatar {
    width: 36px;
    height: 36px;
  }

  .conversation-participants .contact-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .interface-appel {
    min-width: 280px;
    padding: 24px;
  }

  .appel-avatar {
    width: 100px;
    height: 100px;
    font-size: 48px;
  }

  .btn-appel {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .appel-controls {
    gap: 12px;
  }
}
