/* ============================================
   ERC CRM — Feuille de style partagée
   Appelée par toutes les pages HTML
   ============================================ */

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #f4f5f7;
  color: #172b4d;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
  background: #172b4d;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.topbar-nav a:hover  { background: rgba(255,255,255,0.1); color: #fff; }
.topbar-nav a.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }

/* ── BOUTONS ── */
.btn-primary {
  background: #0052cc;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: #0065ff; }

.btn-secondary {
  background: #fff;
  color: #172b4d;
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: #f4f5f7; }

.btn-danger {
  background: none;
  border: 1px solid #de350b;
  color: #de350b;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
}
.btn-danger:hover { background: #de350b; color: #fff; }

.btn-save {
  background: #0052cc;
  border: none;
  color: #fff;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
}
.btn-save:hover { background: #0047b3; }

.btn-reset {
  background: none;
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: #6b778c;
  cursor: pointer;
}
.btn-reset:hover { border-color: #172b4d; color: #172b4d; }

.btn-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #6b778c;
  line-height: 1;
  padding: 2px 6px;
}
.btn-close:hover { color: #172b4d; }

/* ── TOOLBAR ── */
.toolbar {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.search-input {
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  width: 240px;
  background: #fff;
  color: #172b4d;
}
.search-input:focus { outline: none; border-color: #0052cc; }

.filter-select {
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  background: #fff;
  color: #172b4d;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: #0052cc; }

.count-label { font-size: 14px; color: #6b778c; margin-left: auto; }

/* ── TABLE ── */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
thead tr { background: #f8f9fa; border-bottom: 2px solid #e0e0e0; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: #6b778c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f4f5f7; }
td { padding: 12px 16px; font-size: 14px; color: #172b4d; }
td.muted { color: #6b778c; }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #6b778c;
  font-size: 15px;
}

/* ── AVATAR ── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0052cc;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
}
.nom-wrap { display: flex; align-items: center; font-weight: 500; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #e3ecfa;
  color: #0052cc;
}
.badge.cedant       { background: #fff3e0; color: #b45309; }
.badge.acquereur    { background: #e8f5e9; color: #2e7d32; }
.badge.prescripteur { background: #f3e5f5; color: #7b1fa2; }
.badge.partenaire   { background: #e3ecfa; color: #0052cc; }
.badge.ouvert       { background: #e3ecfa; color: #0052cc; }
.badge.gagne        { background: #e8f5e9; color: #2e7d32; }
.badge.perdu        { background: #fce8e6; color: #de350b; }

/* ── OVERLAY ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9,30,66,0.4);
  z-index: 100;
}
.overlay.open { display: block; }

/* ── DRAWER ── */
.drawer {
  position: fixed;
  top: 0;
  right: -540px;
  width: 540px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
}
.drawer.open { right: 0; }

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-header h2 { font-size: 17px; font-weight: 600; }
.drawer-actions { display: flex; gap: 8px; align-items: center; }

.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }

/* ── FORMULAIRES ── */
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #6b778c;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
}
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; flex: 1; }
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: #6b778c;
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: #172b4d;
  background: #fff;
  width: 100%;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #0052cc; }
.form-group input.invalid   { border-color: #ff8f73; }
.form-group textarea        { resize: vertical; min-height: 80px; }

.field-hint { font-size: 11px; color: #de350b; margin-top: 3px; display: none; }
.field-hint.show { display: block; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #172b4d;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s ease;
  pointer-events: none;
}
.toast.show  { transform: translateX(-50%) translateY(0); }
.toast.error { background: #de350b; }
