/* ===== VARIABLES CSS ===== */
:root {
  --primary-color: #0d6efd;
  --secondary-color: #6c757d;
  --accent-color: #6c63ff;
  --light-bg: #f8f9fa;
  --white: #ffffff;
  --text-dark: #212529;
  --text-muted: #6c757d;
  --text-secondary: #495057;
  --border-color: #dee2e6;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --border-radius: 0.375rem;
  --transition: all 0.15s ease-in-out;
  --unread-bg: rgba(13, 110, 253, 0.03);
  --hover-bg: rgba(13, 110, 253, 0.05);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

.slide-in-left {
  animation: slideInLeft 0.5s ease-out forwards;
}

/* ===== STRUCTURE GÉNÉRALE ===== */
.display-6 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.display-6 .fas {
  color: var(--primary-color);
  font-size: 2rem;
  vertical-align: middle;
}

.lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* ===== CONTENEUR PRINCIPAL DES MESSAGES ===== */
.card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
  background-color: var(--white);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-body {
  padding: 0;
}

/* ===== LISTE DES MESSAGES ===== */
.list-group-flush {
  border-radius: 0;
}

.list-group-item {
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  background-color: var(--white);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.list-group-item:last-child {
  border-bottom: none;
}

.list-group-item:hover {
  background-color: var(--hover-bg);
  transform: translateX(2px);
}

/* Animation de bordure gauche au hover */
.list-group-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.list-group-item:hover::before {
  transform: translateX(0);
}

/* ===== DIFFÉRENCIATION LU VS NON-LU ===== */
/* Messages non lus */
.list-group-item.fw-bold {
  background-color: var(--unread-bg);
  border-left: 3px solid var(--primary-color);
}

.list-group-item.fw-bold::before {
  transform: translateX(0);
  opacity: 0.7;
}

.list-group-item.fw-bold:hover {
  background-color: var(--hover-bg);
  border-left-color: var(--accent-color);
}

/* Effet de pulsation subtile sur les messages non lus */
.list-group-item.fw-bold .badge {
  animation: pulse 2s infinite;
}

/* Messages lus - style plus discret */
.list-group-item:not(.fw-bold) {
  opacity: 0.85;
}

.list-group-item:not(.fw-bold):hover {
  opacity: 1;
}

/* ===== INDICATEUR DE MESSAGE NON LU ===== */
.badge.bg-primary {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
  border: 2px solid var(--white);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge.bg-primary .fas {
  font-size: 0.4rem;
}

/* ===== TYPOGRAPHIE DANS LES ITEMS ===== */
/* Nom de l'expéditeur */
.list-group-item h6 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
}

.list-group-item.fw-bold h6 {
  color: var(--text-dark);
  font-weight: 700;
}

.list-group-item h6 .fas {
  font-size: 0.75rem;
  color: var(--primary-color);
  opacity: 0.7;
}

/* Sujet du message */
.list-group-item h5 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.list-group-item.fw-bold h5 {
  color: var(--text-dark);
  font-weight: 600;
}

/* Extrait du message */
.list-group-item p.small {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0;
  max-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== DATE ET HEURE ===== */
.text-end small {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
}

.text-end .fas {
  font-size: 0.7rem;
  opacity: 0.6;
  color: var(--primary-color);
}

.text-end .fw-light {
  font-weight: 300;
  opacity: 0.8;
}

/* ===== MESSAGE POUR BOÎTE VIDE ===== */
.text-center.text-muted.p-5 {
  padding: 4rem 2rem !important;
  background: linear-gradient(135deg, var(--light-bg) 0%, rgba(108, 99, 255, 0.02) 100%);
  border-radius: var(--border-radius);
  margin: 0;
}

.text-center.text-muted.p-5 .fas {
  color: var(--text-muted);
  opacity: 0.4;
  margin-bottom: 1.5rem;
}

.text-center.text-muted.p-5 .fs-5 {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.text-center.text-muted.p-5 .small {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== INFORMATION SUPPLÉMENTAIRE ===== */
.mt-3 small {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background-color: var(--light-bg);
  border-radius: var(--border-radius);
  display: inline-block;
  border-left: 3px solid var(--primary-color);
}

.mt-3 small .fas {
  color: var(--primary-color);
  font-size: 0.75rem;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 767.98px) {
  .display-6 {
    font-size: 2rem;
  }
  
  .display-6 .fas {
    font-size: 1.5rem;
  }
  
  .list-group-item {
    padding: 1rem;
  }
  
  .list-group-item h5 {
    font-size: 1rem;
  }
  
  .list-group-item h6 {
    font-size: 0.8rem;
  }
  
  .list-group-item p.small {
    font-size: 0.8rem;
  }
  
  /* Réorganisation sur mobile */
  .list-group-item .d-flex {
    flex-direction: column;
  }
  
  .list-group-item .text-end {
    text-align: left !important;
    margin-top: 0.75rem;
    margin-left: 0 !important;
    align-self: flex-start;
  }
  
  .text-center.text-muted.p-5 {
    padding: 3rem 1.5rem !important;
  }
  
  .text-center.text-muted.p-5 .fas {
    font-size: 2rem;
  }
}

@media (max-width: 575.98px) {
  .list-group-item {
    padding: 0.75rem;
  }
  
  .display-6 {
    font-size: 1.75rem;
  }
  
  .lead {
    font-size: 1rem;
  }
  
  .badge.bg-primary {
    width: 6px;
    height: 6px;
  }
  
  .list-group-item h6 .fas,
  .text-end .fas {
    display: none; /* Masquer les icônes sur très petits écrans */
  }
}

/* ===== ÉTATS DE FOCUS POUR L'ACCESSIBILITÉ ===== */
.list-group-item:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  background-color: var(--hover-bg);
}

.list-group-item:focus::before {
  transform: translateX(0);
}

/* ===== AMÉLIORATIONS VISUELLES ===== */
/* Effet de brillance sur les messages non lus */
.list-group-item.fw-bold::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 1.5s ease;
}

.list-group-item.fw-bold:hover::after {
  left: 100%;
}

/* Ombre portée pour les éléments importants */
.badge.bg-primary {
  filter: drop-shadow(0 2px 4px rgba(13, 110, 253, 0.3));
}

/* ===== ANIMATIONS DE CHARGEMENT ===== */
.list-group-item {
  opacity: 0;
  transform: translateY(20px);
}

.list-group-item.loaded {
  opacity: 1;
  transform: translateY(0);
}

/* ===== PRINT STYLES ===== */
@media print {
  .card {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .list-group-item {
    page-break-inside: avoid;
    border-bottom: 1px solid #000;
  }
  
  .list-group-item::before,
  .list-group-item::after {
    display: none;
  }
  
  .badge {
    background-color: #000 !important;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
  }
}