/* ──────────────────────────────────────────────────────────────
   Screen: Clients (onglet Clients du bottom-nav)
   Extrait du mono-fichier index.html (J5c).
   Regroupe :
   - Liste clients (clients-list, client-row, client-avatar, client-info, client-id, client-meta)
   - Actions rangée (btn-rename, nickname-input, btn-point, btn-history, client-points)
   - Historique déroulant (client-history, history-table)
   - Badges (client-reward-badge, client-notif-badge)
   - Toolbar (client-toolbar, client-search-input, client-sort-select)
   - Pagination (btn-show-more)
   - Undo toast (toast-undo, toast-undo-btn)
   - Empty state + onboarding (empty-clients, onboarding-*)
   ────────────────────────────────────────────────────────────── */

.client-count {
  font-size: 13px;
  color: var(--secondary);
  font-weight: 500;
}

.client-search-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--separator);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #FAFAFA;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 12px;
  color: var(--primary);
}

.client-search-input:focus { border-color: var(--blue); background: #fff; }

.clients-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--separator);
  border-radius: 12px;
  overflow: hidden;
}

.client-row {
  background: var(--card);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.client-row:first-child { border-radius: 12px 12px 0 0; }
.client-row:last-child  { border-radius: 0 0 12px 12px; }
.client-row:only-child  { border-radius: 12px; }

.client-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--secondary);
}
/* Client avec surnom : avatar "plein" — couleur de marque avec initiales blanches.
   Utilise --text pour le fond (s'adapte light/dark) et --text-inverse pour
   les lettres (reste lisible peu importe le thème). */
.client-avatar.filled {
  background: var(--text);
  color: var(--text-inverse);
  font-size: 13px;
}

.client-info { flex: 1; min-width: 0; }

.client-id {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
/* Le span du nom prend tout l'espace dispo et tronque proprement (audit L2-5 dashboard) */
.client-id > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-rename {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1;
  opacity: 0.7;
  flex-shrink: 0;
}

.nickname-input {
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-bottom: 1.5px solid var(--accent, #007AFF);
  background: transparent;
  outline: none;
  width: 130px;
  padding: 0 2px;
  color: inherit;
}

.client-meta {
  font-size: 12px;
  color: var(--secondary);
}

.client-points {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  min-width: 32px;
  text-align: center;
  letter-spacing: -0.5px;
}

.btn-point {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, background 0.15s;
  font-weight: 300;
  line-height: 1;
}

.btn-point:active   { transform: scale(0.88); }
.btn-point:disabled { background: var(--separator); cursor: default; transform: none; }

.btn-history {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--separator);
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-history:hover { background: #F0F0F5; }
.btn-history.open  { background: var(--primary); color: #fff; border-color: var(--primary); }

.client-history {
  display: none;
  padding: 10px 14px 12px;
  background: #F9F9FB;
  border-top: 1px solid var(--separator);
  font-size: 12px;
  color: var(--secondary);
}

.history-table { width: 100%; border-collapse: collapse; }
.history-table th { text-align: left; padding: 2px 0 4px; color: var(--muted, #8E8E93); font-weight: 500; }
.history-table th:last-child { text-align: right; }
.history-table td { padding: 3px 0; border-top: 1px solid var(--separator); }
.history-table td:last-child { text-align: right; font-weight: 600; color: var(--primary); }

/* ── Badges sur une carte client ────────────────────────────── */

.client-reward-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #F59E0B;
  background: rgba(245,158,11,0.1);
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 3px;
}

/* Ligne dédiée aux canaux de notif (push / SMS) sous la date */
.client-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.client-notif-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,179,119,0.1);
  color: var(--green);
  line-height: 1;
  white-space: nowrap;
}
.client-notif-badge--sms {
  background: rgba(0,102,255,0.1);
  color: var(--blue);
}

/* ── Toolbar (search + sort) ────────────────────────────────── */

.client-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* Wrapper pour positionner la loupe et la croix autour de l'input */
.client-search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.client-search-wrap .client-search-input {
  flex: 1;
  margin-bottom: 0;
  padding-left: 38px;
  padding-right: 36px;
}

.client-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--secondary);
  pointer-events: none;
}

.client-search-clear {
  position: absolute;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--separator);
  color: var(--secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.client-search-clear:hover { background: var(--primary); color: var(--text-inverse, #fff); }

.client-sort-select {
  padding: 11px 10px;
  border: 1.5px solid var(--separator);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: #FAFAFA;
  color: var(--primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  min-width: 110px;
}

.client-sort-select:focus { border-color: var(--blue); background: #fff; }

/* ── Pagination ─────────────────────────────────────────────── */

.btn-show-more {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1.5px solid var(--separator);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--secondary);
  margin-top: 10px;
  transition: background 0.15s;
}

.btn-show-more:hover { background: var(--separator); }

/* ── Undo toast (après +1 point) ────────────────────────────── */

.toast-undo {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary);
  color: #fff;
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.toast-undo.show { transform: translateX(-50%) translateY(0); }

.toast-undo-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.toast-undo-btn:hover { background: rgba(255,255,255,0.35); }

/* ── Empty state + onboarding ───────────────────────────────── */

.empty-clients {
  text-align: center;
  padding: 32px 20px;
  color: var(--secondary);
  font-size: 14px;
}

.empty-clients .empty-icon { font-size: 32px; margin-bottom: 8px; }

.onboarding-steps {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--primary);
}

.onboarding-step.done { color: var(--green); }

.step-check, .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-check {
  background: var(--green);
  color: #fff;
}

.step-num {
  background: var(--bg);
  color: var(--secondary);
  border: 1.5px solid var(--separator);
}

/* Bouton de nettoyage des cartes fantômes — discret, plein largeur, visible
   uniquement quand des candidates existent (injecté par renderPhantomBar). */
.btn-clean-phantom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  margin: 4px 0 12px;
  padding: 10px 12px;
  background: #FFF8EC;
  color: #8A5A00;
  border: 1.5px solid #F2D9A8;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-clean-phantom:hover  { background: #FCEFD4; }
.btn-clean-phantom:active { transform: scale(0.98); }
.btn-clean-phantom-sub {
  font-size: 11px;
  font-weight: 500;
  color: #B07A2E;
}
