/* ═══════════════════════════════════════════════════════════════════════
   CAMALARM CRM — Dashboard Premium (T170l)
   Page : Accueil (#tab-home-scope)
   ═══════════════════════════════════════════════════════════════════════
   Direction : cohérence avec Historique + Factures (T170j/k)
   - Comfortaa pour titres / Inter pour UI / Inter pour montants
   - KPI cards fond foncé #1F2937
   - Cartes blanches pour les listes, pas de vibration au hover
   - Pills colorées discrètes
   ═══════════════════════════════════════════════════════════════════════ */

/* Polices déjà importées par l'autre CSS, mais on s'assure */
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

#tab-home-scope {
  --cam-bg:        #F5F7FA;
  --cam-card:      #FFFFFF;
  --cam-card-hover:#F9FAFB;
  --cam-text:      #1F2937;
  --cam-text-2:    #6B7280;
  --cam-text-3:    #9CA3AF;
  --cam-border:    #E5E7EB;
  --cam-border-l:  #F3F4F6;
  --cam-orange:    #E65100;
  --cam-orange-l:  #FFF3E0;
  --cam-success:   #059669;
  --cam-warning:   #F59E0B;
  --cam-danger:    #DC2626;
  --cam-info:      #0284C7;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cam-text);
  background: var(--cam-bg);
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 16px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════ 1. HEADER ═══════════════════ */
#tab-home-scope .crm-page-header {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 24px !important;
  padding: 0 0 24px 0 !important;
  margin: 0 0 20px 0 !important;
  border-bottom: 1px solid var(--cam-border) !important;
  background: transparent !important;
}

#tab-home-scope .crm-page-title {
  font-family: 'Comfortaa', 'Inter', sans-serif !important;
  font-size: 1.5rem !important;          /* 24px */
  font-weight: 600 !important;
  color: var(--cam-text) !important;
  letter-spacing: -0.3px !important;
  line-height: 1.25 !important;
  margin: 0 0 6px 0 !important;
}

#tab-home-scope .crm-page-title #welcomeUser {
  color: var(--cam-orange) !important;
  font-weight: 700 !important;
}

#tab-home-scope .crm-page-subtitle {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.875rem !important;
  color: var(--cam-text-2) !important;
  margin: 0 !important;
  line-height: 1.55 !important;
}

#tab-home-scope .crm-page-actions {
  display: flex !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

#tab-home-scope .crm-btn {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  padding: 9px 16px !important;
  border-radius: 8px !important;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap;
  line-height: 1.4 !important;
  height: auto !important;
}

#tab-home-scope .crm-btn-ghost {
  background: var(--cam-card) !important;
  color: var(--cam-text) !important;
  border: 1px solid var(--cam-border) !important;
}

#tab-home-scope .crm-btn-ghost:hover {
  background: var(--cam-card-hover) !important;
  border-color: var(--cam-text-3) !important;
}

#tab-home-scope .crm-btn-accent {
  background: var(--cam-orange) !important;
  color: #ffffff !important;
  border: 1px solid var(--cam-orange) !important;
  box-shadow: 0 1px 2px rgba(230, 81, 0, 0.15);
}

#tab-home-scope .crm-btn-accent:hover {
  background: #B23E00 !important;
  border-color: #B23E00 !important;
  box-shadow: 0 2px 6px rgba(230, 81, 0, 0.25);
}

#tab-home-scope .crm-btn-sm {
  padding: 6px 12px !important;
  font-size: 0.8125rem !important;
}

/* ═══════════════════ 2. KPI GRID ═══════════════════ */
#tab-home-scope .crm-kpi-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 16px !important;
  margin: 0 0 24px 0 !important;
}

#tab-home-scope .crm-kpi {
  background: #1F2937 !important;
  color: #ffffff !important;
  padding: 20px !important;
  border-radius: 12px !important;
  border: 0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  transition: box-shadow 150ms ease;
  /* Pas de transform au hover (anti-vibration) */
}

#tab-home-scope .crm-kpi:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
}

/* Label avec icône SVG inline */
#tab-home-scope .crm-kpi-label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  color: #9CA3AF !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  margin-bottom: 12px !important;
}

#tab-home-scope .crm-kpi-label svg {
  width: 14px;
  height: 14px;
  stroke: #9CA3AF;
  flex-shrink: 0;
}

/* Valeur KPI : Comfortaa, large */
#tab-home-scope .crm-kpi-value {
  font-family: 'Comfortaa', 'Inter', sans-serif !important;
  font-size: 1.6rem !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  line-height: 1.15 !important;
  margin-bottom: 6px !important;
  letter-spacing: -0.3px;
}

#tab-home-scope .crm-kpi-delta {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.75rem !important;
  font-weight: 400 !important;
  color: #9CA3AF !important;
}

#tab-home-scope .crm-kpi-delta.up    { color: #34D399 !important; }
#tab-home-scope .crm-kpi-delta.down  { color: #F87171 !important; }
#tab-home-scope .crm-kpi-delta.neutral { color: #9CA3AF !important; }

/* ═══════════════════ 3. GRILLES (3 colonnes / 2 colonnes) ═══════════════════ */
#tab-home-scope .crm-grid-3 {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 16px !important;
  margin: 0 0 16px 0 !important;
}

#tab-home-scope .crm-grid-2 {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 16px !important;
  margin: 0 !important;
}

/* ═══════════════════ 4. CARDS ═══════════════════ */
#tab-home-scope .crm-card {
  background: var(--cam-card) !important;
  border: 1px solid var(--cam-border) !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  display: flex !important;
  flex-direction: column !important;
  min-height: 240px;
}

#tab-home-scope .crm-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--cam-border-l) !important;
  background: transparent !important;
}

#tab-home-scope .crm-card-title {
  font-family: 'Comfortaa', 'Inter', sans-serif !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  color: var(--cam-text) !important;
  margin: 0 !important;
  letter-spacing: -0.1px !important;
}

#tab-home-scope .crm-card-body {
  padding: 8px 0 !important;
  flex: 1;
  overflow-y: auto;
}

#tab-home-scope .crm-card-body.flush {
  padding: 0 !important;
}

/* ═══════════════════ 5. ITEMS DE LISTE PREMIUM ═══════════════════ */
#tab-home-scope .cam-dash-item {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 20px !important;
  cursor: pointer;
  transition: background 150ms ease !important;
  border-bottom: 1px solid var(--cam-border-l) !important;
}

#tab-home-scope .cam-dash-item:last-child {
  border-bottom: 0 !important;
}

#tab-home-scope .cam-dash-item:hover {
  background: var(--cam-card-hover) !important;
}

#tab-home-scope .cam-dash-item-main {
  flex: 1;
  min-width: 0;
}

#tab-home-scope .cam-dash-item-title {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: var(--cam-text) !important;
  line-height: 1.35 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tab-home-scope .cam-dash-item-sub {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.75rem !important;
  font-weight: 400 !important;
  color: var(--cam-text-2) !important;
  margin-top: 2px;
  line-height: 1.35 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tab-home-scope .cam-dash-item-amount {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  color: var(--cam-text) !important;
  white-space: nowrap;
}

#tab-home-scope .cam-dash-empty {
  padding: 36px 20px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  color: var(--cam-text-3);
  font-style: italic;
}

/* ═══════════════════ 6. PILLS STATUT ═══════════════════ */
#tab-home-scope .cam-dash-pill {
  display: inline-flex !important;
  align-items: center !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.6875rem !important;     /* 11px */
  font-weight: 500 !important;
  padding: 3px 9px !important;
  border-radius: 12px !important;
  letter-spacing: 0;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}

#tab-home-scope .cam-dash-pill-gray {
  background: #F3F4F6 !important;
  color: #6B7280 !important;
}

#tab-home-scope .cam-dash-pill-blue {
  background: #E0F2FE !important;
  color: #0284C7 !important;
}

#tab-home-scope .cam-dash-pill-green {
  background: #D1FAE5 !important;
  color: #059669 !important;
}

#tab-home-scope .cam-dash-pill-orange {
  background: #FFF3E0 !important;
  color: #E65100 !important;
}

#tab-home-scope .cam-dash-pill-amber {
  background: #FEF3C7 !important;
  color: #D97706 !important;
}

#tab-home-scope .cam-dash-pill-red {
  background: #FEE2E2 !important;
  color: #DC2626 !important;
}

/* ═══════════════════ 7. RESPONSIVE ═══════════════════ */
@media (max-width: 1024px) {
  #tab-home-scope .crm-grid-3 {
    grid-template-columns: 1fr 1fr !important;
  }
  #tab-home-scope .crm-grid-3 .crm-card:nth-child(3) {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  #tab-home-scope {
    padding: 16px 12px;
  }

  #tab-home-scope .crm-page-header {
    flex-direction: column !important;
    gap: 12px !important;
  }

  #tab-home-scope .crm-page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  #tab-home-scope .crm-page-actions .crm-btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  #tab-home-scope .crm-grid-3,
  #tab-home-scope .crm-grid-2 {
    grid-template-columns: 1fr !important;
  }

  #tab-home-scope .crm-grid-3 .crm-card:nth-child(3) {
    grid-column: span 1;
  }

  #tab-home-scope .crm-kpi-value {
    font-size: 1.4rem !important;
  }

  #tab-home-scope .cam-dash-item {
    padding: 12px 16px !important;
    gap: 8px !important;
  }
}
