/* Chemin : /mutuelleapp/public/assets/css/style.css */
/* CSS principal — MutuelleApp v1.0 */

/* =====================================================
   VARIABLES & RESET
   ===================================================== */
:root {
  --couleur-primaire:   #1E3A5F;
  --couleur-secondaire: #2E75B6;
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --border-color: #e2e8f0;
  --bg-page: #f0f4f8;
  --bg-card: #ffffff;
  --text-dark: #1a202c;
  --text-muted: #718096;
  --success: #38a169;
  --warning: #d69e2e;
  --danger: #e53e3e;
  --info: #3182ce;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--bg-page);
  line-height: 1.5;
}

a { color: var(--couleur-secondaire); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================
   LAYOUT PRINCIPAL (Sidebar + Contenu)
   ===================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--couleur-primaire);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo { height: 40px; border-radius: 6px; }

.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 13px; font-weight: 600;
  line-height: 1.3;
  color: rgba(255,255,255,0.95);
}

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.8);
  font-size: 13.5px;
  transition: all 0.2s;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
}

.nav-link.active { font-weight: 600; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 50;
  box-shadow: var(--shadow);
}

.hamburger {
  display: none;
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--couleur-primaire);
  padding: 4px 8px;
}

.topbar-title {
  font-weight: 700;
  color: var(--couleur-primaire);
  font-size: 15px;
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-name { font-weight: 500; color: var(--text-dark); }

/* =====================================================
   CONTENU PRINCIPAL
   ===================================================== */
.content { padding: 24px; flex: 1; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--couleur-primaire);
}

/* =====================================================
   CARTES
   ===================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfc;
}

.card-header h3 { font-size: 15px; font-weight: 600; color: var(--couleur-primaire); margin: 0; }

.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

.card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border-color);
  background: #fafbfc;
}

.card-danger { border-color: #fed7d7; }
.card-danger .card-header { background: #fff5f5; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 20px; }

/* =====================================================
   KPI DASHBOARD
   ===================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: transform 0.2s;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon { font-size: 28px; margin-bottom: 8px; }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--couleur-primaire); }
.kpi-positive .kpi-value { color: var(--success); }
.kpi-negative .kpi-value { color: var(--danger); }

/* =====================================================
   PROGRESS BAR
   ===================================================== */
.progress-bar-container {
  width: 100%;
  height: 20px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--couleur-secondaire), var(--couleur-primaire));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  transition: width 0.5s;
  min-width: 30px;
}

.progress-stats { display: flex; gap: 12px; flex-wrap: wrap; }

/* =====================================================
   DASHBOARD GRID
   ===================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* =====================================================
   TABLEAUX
   ===================================================== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  background: #fafbfc;
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table tbody tr:hover { background: #f7fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.table-sm th, .table-sm td { padding: 7px 12px; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-xs     { font-size: 11px; }
.text-sm     { font-size: 12px; }

.actions-cell { white-space: nowrap; }

/* =====================================================
   GRILLE DE COTISATIONS
   ===================================================== */
.grille-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
}

.grille-table { min-width: 900px; }

.grille-cell {
  width: 70px;
  min-width: 60px;
  height: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  vertical-align: middle;
  transition: opacity 0.2s;
  border: 1px solid #e2e8f0;
}

.grille-cell[data-editable="true"] {
  cursor: pointer;
}

.grille-cell[data-editable="true"]:hover {
  opacity: 0.75;
  outline: 2px solid var(--couleur-secondaire);
  outline-offset: -2px;
}

.col-membre { min-width: 200px; max-width: 240px; }
.col-bilan  { min-width: 100px; }
.col-actions{ min-width: 90px; white-space: nowrap; }

.sticky-col {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

.bilan-cell { vertical-align: middle; }

.bilan-pct {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.bilan-ok      { color: var(--success); }
.bilan-partiel { color: var(--warning); }
.bilan-retard  { color: var(--danger); }

.grille-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #ddd;
}

/* =====================================================
   MODALE
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--couleur-primaire); }

.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--danger); }

.modal-body  { padding: 20px; }
.modal-footer{ display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--border-color); margin-top: 16px; }

.montant-attendu-display {
  font-size: 20px;
  font-weight: 700;
  color: var(--couleur-primaire);
  padding: 8px 0;
}

/* =====================================================
   FORMULAIRES
   ===================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
select, textarea {
  padding: 8px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-dark);
  background: #fff;
  transition: border-color 0.2s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--couleur-secondaire);
  box-shadow: 0 0 0 3px rgba(46,117,182,0.12);
}

textarea { resize: vertical; min-height: 80px; }

.form-control { width: 100%; }

.form-group-btn {
  justify-content: flex-end;
  align-items: flex-end;
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
}

.filter-form .form-row { align-items: flex-end; }

.required { color: var(--danger); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] { width: auto; }

.color-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-input-group input[type="color"] {
  width: 44px; height: 38px;
  padding: 2px; cursor: pointer;
}

.color-input-group input[type="text"] { flex: 1; }

.inline-form .form-row { margin-bottom: 0; }

.info-list { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.info-list dt { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.info-list dd { color: var(--text-dark); }

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--couleur-primaire);
  border-bottom: 2px solid var(--couleur-secondaire);
  padding-bottom: 6px;
  margin: 20px 0 14px;
}

/* =====================================================
   BOUTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary   { background: var(--couleur-primaire);   color: #fff; border-color: var(--couleur-primaire); }
.btn-secondary { background: #e2e8f0; color: var(--text-dark); border-color: #e2e8f0; }
.btn-outline   { background: transparent; color: var(--couleur-primaire); border-color: var(--couleur-primaire); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-whatsapp  { background: #25D366; color: #fff; border-color: #25D366; }
.btn-block     { width: 100%; justify-content: center; }

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 7px;  font-size: 11px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.ml-2 { margin-left: 8px; }

/* =====================================================
   BADGES
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-lg { font-size: 14px; padding: 4px 14px; }

.badge-primary   { background: #ebf4ff; color: var(--couleur-primaire); }
.badge-success   { background: #f0fff4; color: var(--success); }
.badge-warning   { background: #fffff0; color: var(--warning); }
.badge-danger    { background: #fff5f5; color: var(--danger); }
.badge-secondary { background: #f7fafc; color: var(--text-muted); }
.badge-info      { background: #ebf8ff; color: var(--info); }

.badge-statut-paye    { background: #f0fff4; color: var(--success); }
.badge-statut-partiel { background: #fffff0; color: var(--warning); }
.badge-statut-nonpaye { background: #fff5f5; color: var(--danger); }

/* =====================================================
   FLASH MESSAGES
   ===================================================== */
.flash-zone { padding: 0 20px; }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 13.5px;
}

.flash-success { background: #f0fff4; border: 1px solid #c6f6d5; color: #276749; }
.flash-error   { background: #fff5f5; border: 1px solid #fed7d7; color: #c53030; }
.flash-info    { background: #ebf8ff; border: 1px solid #bee3f8; color: #2c5282; }

.flash-close { background: none; border: none; cursor: pointer; font-size: 18px; color: inherit; opacity: 0.6; padding: 0; flex-shrink: 0; }
.flash-close:hover { opacity: 1; }

/* =====================================================
   AUTH (page de connexion)
   ===================================================== */
.auth-body {
  background: linear-gradient(135deg, var(--couleur-primaire) 0%, var(--couleur-secondaire) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-header { text-align: center; margin-bottom: 28px; }

.auth-logo { max-height: 70px; margin-bottom: 16px; }

.auth-logo-placeholder {
  width: 70px; height: 70px;
  background: var(--couleur-primaire);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: #fff;
  margin: 0 auto 16px;
}

.auth-title { font-size: 22px; font-weight: 700; color: var(--couleur-primaire); margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-footer { text-align: center; margin-top: 16px; font-size: 11px; color: rgba(255,255,255,0.6); }

/* =====================================================
   MAGIC LINK (page publique)
   ===================================================== */
.magic-body {
  background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
  min-height: 100vh;
  padding: 20px;
}

.magic-container { max-width: 600px; margin: 0 auto; }

.magic-header {
  text-align: center;
  padding: 30px 20px 20px;
  background: var(--couleur-primaire);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}

.magic-logo { max-height: 60px; margin-bottom: 12px; }

.magic-logo-placeholder {
  width: 60px; height: 60px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto 12px;
}

.magic-header h1 { font-size: 20px; font-weight: 700; }
.magic-subtitle { font-size: 12px; opacity: 0.75; margin-top: 4px; }

.magic-member-card {
  background: #fff;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.magic-member-header { display: flex; gap: 16px; align-items: center; }

.magic-avatar {
  width: 56px; height: 56px;
  background: var(--couleur-secondaire);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.magic-member-info h2 { font-size: 18px; font-weight: 700; }
.magic-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.magic-solde-card {
  background: #fff;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.magic-solde-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.magic-solde-item { text-align: center; }
.magic-solde-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.magic-solde-value { font-size: 18px; font-weight: 700; }
.magic-solde-alert { background: #fff5f5; border-radius: var(--radius); padding: 8px; }

.magic-cotisations { background: #fff; padding: 20px; border-bottom: 1px solid var(--border-color); }
.magic-cotisations h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--couleur-primaire); }

.magic-mois-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.magic-mois-cell {
  border-radius: var(--radius);
  padding: 8px 4px;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.05);
}

.magic-mois-nom { font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.magic-mois-montant { font-size: 16px; }

.magic-adhesion { background: #fff; padding: 20px; border-bottom: 1px solid var(--border-color); }
.magic-adhesion h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--couleur-primaire); }

.magic-payment-btn { padding: 16px; text-align: center; }

.magic-footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--text-muted);
  background: #fff;
  border-top: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius) var(--radius);
}

.magic-error-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin: 40px auto;
  max-width: 400px;
}

.magic-error-icon { font-size: 48px; margin-bottom: 20px; }
.magic-error-card h1 { font-size: 20px; color: var(--danger); margin-bottom: 12px; }

/* =====================================================
   FICHE MEMBRE (membre/show)
   ===================================================== */
.member-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.magic-link-box input { font-size: 11px; color: var(--text-muted); }

/* =====================================================
   TOAST (notification légère)
   ===================================================== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--couleur-primaire);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
}

@keyframes toastIn  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* =====================================================
   RESPONSIVE MOBILE (< 768px)
   ===================================================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }

  .hamburger { display: block; }

  .main-wrapper { margin-left: 0; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .member-detail-grid { grid-template-columns: 1fr; }

  .magic-mois-grid { grid-template-columns: repeat(4, 1fr); }
  .magic-solde-grid { grid-template-columns: repeat(2, 1fr); }

  .grille-wrapper { font-size: 11px; }
  .page-header { flex-direction: column; align-items: flex-start; }

  .form-row { flex-direction: column; }
  .filter-form .form-row { flex-direction: row; }

  .content { padding: 14px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .magic-mois-grid { grid-template-columns: repeat(3, 1fr); }
}
