/* ═══════════════════════════════════════════════════════════════════════
   CAMALARM CRM — Page Clients premium (v1.0)
   ═══════════════════════════════════════════════════════════════════════
   Toutes les règles sont scopées à #tab-clients-scope pour ne jamais
   déborder sur les autres pages du CRM.

   Couleurs : héritées des variables CRM (--crm-bl, --crm-or)
   Typographies : Inter (corps) + Comfortaa (titres si dispo)
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────────────
   Container global
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: #1F2937;
}

/* ───────────────────────────────────────────────────────────────────────
   Header
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #E5E7EB;
}
#tab-clients-scope .clp-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#tab-clients-scope .clp-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-family: 'Comfortaa', 'Inter', sans-serif;
  font-weight: 600;
  font-size: 1.6rem;
  color: #1F2937;
  letter-spacing: -0.02em;
}
#tab-clients-scope .clp-title svg {
  width: 26px;
  height: 26px;
  color: var(--crm-bl, #0F3D67);
}
#tab-clients-scope .clp-subtitle {
  font-size: 0.9rem;
  color: #6B7280;
  margin-left: 38px;
}

/* Bouton Nouveau client (orange CAMALARM) */
#tab-clients-scope .clp-btn-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--crm-or, #E65100);
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(230, 81, 0, 0.2);
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}
#tab-clients-scope .clp-btn-new:hover {
  background: #B23E00;
}
#tab-clients-scope .clp-btn-new:active {
  transform: translateY(1px);
}
#tab-clients-scope .clp-btn-new-icon {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

/* ───────────────────────────────────────────────────────────────────────
   Barre de recherche
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-search-bar {
  position: relative;
  margin-bottom: 16px;
}
#tab-clients-scope .clp-search-bar input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 16px;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #1F2937;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#tab-clients-scope .clp-search-bar input::placeholder {
  color: #9CA3AF;
}
#tab-clients-scope .clp-search-bar input:focus {
  border-color: var(--crm-or, #E65100);
  box-shadow: 0 0 0 3px rgba(230, 81, 0, 0.10);
}
#tab-clients-scope .clp-search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  pointer-events: none;
}
#tab-clients-scope .clp-search-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ───────────────────────────────────────────────────────────────────────
   Filtres
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
#tab-clients-scope .clp-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid #E5E7EB;
  border-radius: 20px;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
}
#tab-clients-scope .clp-filter-tab:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
}
#tab-clients-scope .clp-filter-tab.active {
  background: var(--crm-or, #E65100);
  color: #ffffff;
  border-color: var(--crm-or, #E65100);
  box-shadow: 0 1px 2px rgba(230, 81, 0, 0.2);
}
#tab-clients-scope .clp-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
#tab-clients-scope .clp-filter-tab.active .clp-filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ───────────────────────────────────────────────────────────────────────
   Tableau premium (cartes par ligne)
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-table-wrap {
  background: #F5F7FA;
  border-radius: 12px;
  padding: 8px 0;
  overflow-x: auto;
}
#tab-clients-scope .clp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  table-layout: auto;
}
#tab-clients-scope .clp-table thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border: 0;
  background: transparent;
}
#tab-clients-scope .clp-col-actions {
  width: 120px;
}
#tab-clients-scope .clp-col-type {
  width: 130px;
}
#tab-clients-scope .clp-col-tel {
  width: 130px;
}
#tab-clients-scope .clp-col-city {
  width: 140px;
}

#tab-clients-scope .clp-table tbody tr {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
#tab-clients-scope .clp-table tbody tr:hover {
  background: #FAFAFA;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

#tab-clients-scope .clp-table tbody td {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: #1F2937;
  border: 0;
  vertical-align: middle;
}
#tab-clients-scope .clp-table tbody td:first-child {
  border-radius: 10px 0 0 10px;
}
#tab-clients-scope .clp-table tbody td:last-child {
  border-radius: 0 10px 10px 0;
}

/* Cellule Nom : nom + sous-ligne société */
#tab-clients-scope .clp-name-main {
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
#tab-clients-scope .clp-name-sub {
  font-size: 0.78rem;
  color: #6B7280;
  margin-top: 2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

/* Cellule email/tel/ville : tronquage */
#tab-clients-scope .clp-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: inline-block;
  vertical-align: middle;
  color: #475569;
  font-size: 0.86rem;
}
#tab-clients-scope .clp-empty-cell {
  color: #CBD5E1;
  font-style: italic;
  font-size: 0.82rem;
}

/* ───────────────────────────────────────────────────────────────────────
   Badges de type
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
#tab-clients-scope .clp-type-particulier { background: #EDE9FE; color: #6D28D9; }
#tab-clients-scope .clp-type-pro          { background: #DBEAFE; color: #1D4ED8; }
#tab-clients-scope .clp-type-copropriete  { background: #D1FAE5; color: #047857; }
#tab-clients-scope .clp-type-institution  { background: #FEF3C7; color: #B45309; }

/* ───────────────────────────────────────────────────────────────────────
   Quick actions au survol
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-quick-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#tab-clients-scope .clp-table tbody tr:hover .clp-quick-actions {
  opacity: 1;
}
#tab-clients-scope .clp-qa-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #6B7280;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: color 0.15s ease, background 0.15s ease;
}
#tab-clients-scope .clp-qa-btn:hover {
  color: var(--crm-or, #E65100);
  background: rgba(230, 81, 0, 0.08);
}
#tab-clients-scope .clp-qa-btn svg {
  width: 16px;
  height: 16px;
}

/* ───────────────────────────────────────────────────────────────────────
   État vide
   ─────────────────────────────────────────────────────────────────────── */
#tab-clients-scope .clp-empty {
  text-align: center;
  padding: 60px 20px;
}
#tab-clients-scope .clp-empty-icon {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.5;
}
#tab-clients-scope .clp-empty-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
#tab-clients-scope .clp-empty-sub {
  font-size: 0.88rem;
  color: #9CA3AF;
}

/* ───────────────────────────────────────────────────────────────────────
   Panneau latéral détail client
   ─────────────────────────────────────────────────────────────────────── */
.clp-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.clp-detail-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.clp-detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: #ffffff;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
.clp-detail-panel.open {
  transform: translateX(0);
}

.clp-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #E5E7EB;
}
.clp-detail-title-block {
  flex: 1;
  min-width: 0;
}
.clp-detail-title {
  margin: 0;
  font-family: 'Comfortaa', 'Inter', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clp-detail-subtitle {
  font-size: 0.82rem;
  color: #6B7280;
  margin-top: 4px;
}
.clp-detail-close {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #6B7280;
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.clp-detail-close:hover {
  background: #F3F4F6;
  color: #111827;
}

.clp-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}
.clp-detail-section {
  margin-bottom: 20px;
}
.clp-detail-section:last-child { margin-bottom: 0; }

.clp-detail-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.clp-detail-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.88rem;
}
.clp-detail-row + .clp-detail-row {
  border-top: 1px solid #F3F4F6;
}
.clp-detail-row-label {
  width: 100px;
  flex-shrink: 0;
  color: #6B7280;
  font-size: 0.78rem;
  padding-top: 1px;
}
.clp-detail-row-value {
  flex: 1;
  color: #111827;
  word-break: break-word;
  min-width: 0;
}
.clp-detail-row-value a {
  color: var(--crm-bl, #0F3D67);
  text-decoration: none;
}
.clp-detail-row-value a:hover { text-decoration: underline; }
.clp-detail-row-value .clp-tva-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  background: rgba(15, 61, 103, 0.08);
  color: var(--crm-bl, #0F3D67);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
}

.clp-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid #E5E7EB;
  background: #F9FAFB;
}
.clp-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: 1px solid #E5E7EB;
  background: #ffffff;
  color: #374151;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.clp-action-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
#tab-clients-scope .clp-empty-icon svg {
  width: 56px;
  height: 56px;
  color: #CBD5E1;
}
.clp-action-btn:hover {
  background: #F3F4F6;
  border-color: #D1D5DB;
  color: #111827;
}
.clp-action-primary {
  background: var(--crm-bl, #0F3D67);
  color: #ffffff;
  border-color: var(--crm-bl, #0F3D67);
}
.clp-action-primary:hover {
  background: #0a2a48;
  color: #ffffff;
  border-color: #0a2a48;
}

/* ───────────────────────────────────────────────────────────────────────
   Responsive
   ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #tab-clients-scope .clp-header {
    flex-direction: column;
    align-items: stretch;
  }
  #tab-clients-scope .clp-btn-new {
    align-self: flex-end;
  }
  #tab-clients-scope .clp-table {
    min-width: 720px;
  }
  #tab-clients-scope .clp-quick-actions {
    opacity: 1;  /* toujours visibles sur mobile */
  }
  .clp-detail-actions {
    grid-template-columns: 1fr;
  }
}
