/* ============================================================
   DESIGN PREMIUM — Gestion de Tontine
   Palette : Bleu profond / Violet / Or (tontine)
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --secondary: #7c3aed;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --dark: #1e293b;
  --light: #f8fafc;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-dark: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --gradient-sidebar: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.25);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf3 100%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-900);
  min-height: 100vh;
  font-size: 14px;
}

/* ============================================================
   SIDEBAR — Design glassmorphism avec dégradé
   ============================================================ */
#sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--gradient-sidebar);
  color: #fff;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  transition: all 0.3s ease;
  overflow-y: auto;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.sidebar-header {
  padding: 28px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.1);
  backdrop-filter: blur(10px);
}

.sidebar-header h5 {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h5 i {
  font-size: 1.5rem;
  color: var(--accent-light);
  filter: drop-shadow(0 2px 4px rgba(245,158,11,0.4));
}

.sidebar-header small {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#sidebar .nav { padding: 16px 12px; }

#sidebar .nav-item { margin-bottom: 4px; }

#sidebar .nav-link {
  color: rgba(255,255,255,0.8);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

#sidebar .nav-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

#sidebar .nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: translateX(4px);
}

#sidebar .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#sidebar .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--accent-light);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px var(--accent-light);
}

.user-card {
  margin: 12px;
  padding: 16px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
}

.user-card .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  margin-right: 10px;
  box-shadow: 0 4px 8px rgba(79,70,229,0.3);
}

.logout-link {
  color: rgba(255,255,255,0.6) !important;
  margin: 8px 12px;
  padding: 10px 16px !important;
  border-radius: var(--radius-sm);
}

.logout-link:hover {
  background: rgba(239,68,68,0.2) !important;
  color: #fca5a5 !important;
}

/* ============================================================
   CONTENU PRINCIPAL
   ============================================================ */
#content {
  flex-grow: 1;
  min-height: 100vh;
  background: transparent;
}

.top-header {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gray-200);
  padding: 18px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.top-header h4 {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.5px;
  color: var(--gray-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-header .breadcrumb-custom {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 4px;
}

main { padding: 32px; }

/* ============================================================
   CARTES STATISTIQUES — Design moderne
   ============================================================ */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.stat-card.success::before { background: var(--gradient-success); }
.stat-card.warning::before { background: var(--gradient-warning); }
.stat-card.info::before    { background: var(--gradient-info); }
.stat-card.danger::before  { background: linear-gradient(135deg, #f43f5e 0%, #f97316 100%); }

.stat-card .stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: 0 8px 16px rgba(79,70,229,0.25);
  margin-bottom: 16px;
}

.stat-card.success .stat-icon { background: var(--gradient-success); box-shadow: 0 8px 16px rgba(16,185,129,0.25); }
.stat-card.warning .stat-icon { background: var(--gradient-warning); box-shadow: 0 8px 16px rgba(245,158,11,0.25); }
.stat-card.info .stat-icon    { background: var(--gradient-info);    box-shadow: 0 8px 16px rgba(6,182,212,0.25); }
.stat-card.danger .stat-icon  { background: linear-gradient(135deg, #f43f5e 0%, #f97316 100%); box-shadow: 0 8px 16px rgba(244,63,94,0.25); }

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-card .stat-trend {
  font-size: 0.8rem;
  margin-top: 8px;
  color: var(--success);
  font-weight: 500;
}

/* ============================================================
   CARTES GÉNÉRIQUES
   ============================================================ */
.card {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  background: linear-gradient(135deg, #fafbfc 0%, #f5f7fa 100%);
  border-bottom: 1px solid var(--gray-200);
  padding: 18px 24px;
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header i { color: var(--primary); }

.card-body { padding: 24px; }

/* ============================================================
   TABLEAUX — Design épuré
   ============================================================ */
.table {
  margin-bottom: 0;
  color: var(--gray-700);
}

.table thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-700);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}

.table-hover tbody tr {
  transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
  background: linear-gradient(90deg, rgba(79,70,229,0.03) 0%, rgba(124,58,237,0.03) 100%);
  transform: scale(1.001);
}

.table a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.table a:hover { color: var(--primary-dark); }

/* ============================================================
   BADGES — Design moderne
   ============================================================ */
.badge {
  padding: 6px 12px;
  font-weight: 600;
  font-size: 0.72rem;
  border-radius: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

.badge.bg-primary   { background: var(--gradient-primary) !important; }
.badge.bg-success   { background: var(--gradient-success) !important; }
.badge.bg-warning   { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important; color: #fff !important; }
.badge.bg-danger    { background: linear-gradient(135deg, #f43f5e 0%, #dc2626 100%) !important; }
.badge.bg-info      { background: var(--gradient-info) !important; }
.badge.bg-secondary { background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important; }

/* ============================================================
   BOUTONS — Élégants avec effets
   ============================================================ */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: 9px 18px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before { width: 300px; height: 300px; }

.btn-primary {
  background: var(--gradient-primary);
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79,70,229,0.4);
  color: #fff;
}

.btn-success {
  background: var(--gradient-success);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16,185,129,0.4);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #f43f5e 0%, #dc2626 100%);
  box-shadow: 0 4px 12px rgba(244,63,94,0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(244,63,94,0.4);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(245,158,11,0.4);
  color: #fff;
}

.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-outline-danger {
  border: 1.5px solid var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ============================================================
   FORMULAIRES — Inputs modernes
   ============================================================ */
.form-control, .form-select {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  background: #fff;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
  outline: none;
}

.form-label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

/* ============================================================
   ALERTES — Design moderne
   ============================================================ */
.alert {
  border: none;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid;
}

.alert-success {
  background: linear-gradient(90deg, rgba(16,185,129,0.1) 0%, rgba(16,185,129,0.05) 100%);
  color: #065f46;
  border-left-color: var(--success);
}

.alert-danger {
  background: linear-gradient(90deg, rgba(239,68,68,0.1) 0%, rgba(239,68,68,0.05) 100%);
  color: #991b1b;
  border-left-color: var(--danger);
}

.alert-warning {
  background: linear-gradient(90deg, rgba(245,158,11,0.1) 0%, rgba(245,158,11,0.05) 100%);
  color: #92400e;
  border-left-color: var(--warning);
}

.alert-info {
  background: linear-gradient(90deg, rgba(6,182,212,0.1) 0%, rgba(6,182,212,0.05) 100%);
  color: #155e75;
  border-left-color: var(--info);
}

/* ============================================================
   MODALS — Design glassmorphism
   ============================================================ */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-header {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  padding: 20px 24px;
}

.modal-header .modal-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-header .btn-close {
  filter: invert(1) brightness(2);
}

.modal-body { padding: 24px; }

.modal-footer {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 16px 24px;
}

/* ============================================================
   ONGLETS — Design moderne
   ============================================================ */
.nav-tabs {
  border-bottom: 2px solid var(--gray-200);
  gap: 4px;
}

.nav-tabs .nav-link {
  border: none;
  color: var(--gray-500);
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all 0.2s ease;
  position: relative;
}

.nav-tabs .nav-link:hover {
  color: var(--primary);
  background: rgba(79,70,229,0.05);
}

.nav-tabs .nav-link.active {
  color: var(--primary);
  background: #fff;
}

.nav-tabs .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  border-radius: 3px 3px 0 0;
}

.tab-content {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px;
}

/* ============================================================
   PAGE DE CONNEXION
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: var(--gradient-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245,158,11,0.2) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124,58,237,0.3) 0%, transparent 70%);
  bottom: -200px;
  left: -200px;
  border-radius: 50%;
}

.login-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #fff;
  box-shadow: 0 10px 30px rgba(79,70,229,0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(79,70,229,0.4); }
  50%      { box-shadow: 0 10px 40px rgba(79,70,229,0.6); }
}

/* ============================================================
   ANIMATIONS GLOBALES
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-in { animation: fadeIn 0.5s ease; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -260px;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  #sidebar.show { left: 0; }
  main { padding: 20px; }
  .stat-card .stat-value { font-size: 1.4rem; }
}

/* Scrollbar personnalisée */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ============================================================
   UTILITAIRES
   ============================================================ */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hover-lift { transition: transform 0.3s ease; }
.hover-lift:hover { transform: translateY(-4px); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state i {
  font-size: 4rem;
  color: var(--gray-300);
  margin-bottom: 16px;
}