/* ──────────────────────────────────────────────────────────────
   Screen: Analytics (onglet Stats)
   Grandes tuiles chiffrées, listes top clients / dormants, CTA.
   Design : emphase sur les chiffres (Inter Bold 36px), hiérarchie
   claire, fond surface neutre pour contraster avec les actions.
   ────────────────────────────────────────────────────────────── */

/* ── Overview : courbe activité gauche + 3 KPI droite ───── */
.analytics-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (min-width: 700px) {
  .analytics-overview { grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr); }
}

/* Chart card (gauche) */
.analytics-chart-card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.analytics-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.analytics-chart-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--secondary);
  margin: 0 0 4px;
}

.analytics-chart-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.6px;
  line-height: 1;
}

.analytics-chart-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
}
.analytics-chart-delta.up   { background: rgba(52,199,89,0.13);  color: #1E9942; }
.analytics-chart-delta.down { background: rgba(255,59,48,0.13);  color: #CC2B22; }
.analytics-chart-delta.flat { background: rgba(142,142,147,0.13); color: var(--secondary); }

/* Toggle 7j / 30j (segmented) */
.analytics-chart-toggle {
  display: inline-flex;
  background: var(--bg, #F2F2F7);
  border: 1px solid var(--separator);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.analytics-chart-toggle button {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.analytics-chart-toggle button.active {
  background: var(--card, #fff);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
html.dark .analytics-chart-toggle { background: rgba(255,255,255,0.05); }
html.dark .analytics-chart-toggle button.active { background: var(--primary); color: var(--text-inverse, #fff); }

/* SVG chart */
.analytics-chart-svg {
  width: 100%;
  height: 140px;
  margin-top: auto;
  overflow: visible;
  display: block;
}
.analytics-chart-svg .area {
  fill: url(#analyticsGrad);
  opacity: 0.35;
}
.analytics-chart-svg .line {
  fill: none;
  stroke: url(#analyticsStroke);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: analyticsDraw 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes analyticsDraw { to { stroke-dashoffset: 0; } }
.analytics-chart-svg .dot {
  fill: var(--card, #fff);
  stroke: #FF7A1A;
  stroke-width: 2;
  r: 4;
  cursor: pointer;
  transition: r 0.15s;
}
.analytics-chart-svg .dot:hover { r: 6; }
.analytics-chart-svg .label {
  font-size: 10px;
  fill: var(--secondary);
  text-anchor: middle;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.analytics-chart-svg .tooltip-bg {
  fill: var(--primary);
  rx: 6;
}
.analytics-chart-svg .tooltip-txt {
  fill: var(--text-inverse, #fff);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  font-family: inherit;
}

/* KPI stack droite */
.analytics-kpi-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.analytics-kpi {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
}
.analytics-kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.analytics-kpi-icon.phone   { background: rgba(176,141,230,0.16); color: #7E5CBE; }
.analytics-kpi-icon.points  { background: rgba(255,201,60,0.18);  color: #C48A00; }
.analytics-kpi-icon.notif   { background: rgba(255,122,26,0.16);  color: #D95900; }
html.dark .analytics-kpi-icon.phone  { color: #C8A8FF; }
html.dark .analytics-kpi-icon.points { color: #FFD966; }
html.dark .analytics-kpi-icon.notif  { color: #FFA366; }
.analytics-kpi-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.analytics-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.4px;
  line-height: 1;
}
.analytics-kpi-label {
  font-size: 11px;
  color: var(--secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.analytics-kpi-hint {
  font-size: 11px;
  color: var(--text-muted, var(--secondary));
  line-height: 1.3;
}

/* ── Grille de tuiles (legacy, conservée pour compat — plus affichée par défaut) ─── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .analytics-grid { grid-template-columns: repeat(4, 1fr); }
}

.analytics-tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  border: 1px solid var(--separator);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
}

.analytics-tile-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.6px;
  line-height: 1;
}

.analytics-tile-label {
  font-size: 12px;
  color: var(--secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.analytics-tile-hint {
  font-size: 11px;
  color: var(--text-muted, var(--secondary));
  margin-top: auto;
  padding-top: 4px;
  line-height: 1.3;
}

/* ── Bloc dernière notif ─────────────────────────────────── */
.analytics-last-notif {
  background: var(--blue-soft);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.analytics-last-notif-label {
  font-size: 11px;
  color: var(--blue);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.analytics-last-notif-msg {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 4px;
}
.analytics-last-notif-meta {
  font-size: 11px;
  color: var(--secondary);
}

/* ── 2 listes côte à côte (top / dormants) ──────────────── */
.analytics-lists {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .analytics-lists { grid-template-columns: 1fr 1fr; }
}

.analytics-list {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--separator);
}

.analytics-list-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.analytics-list-title .icon { font-size: 14px; color: var(--primary); }

.analytics-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 13px;
}
.analytics-list-row:last-child { border-bottom: none; }

.analytics-rank {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inverse, #fff);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.analytics-list-name {
  flex: 1;
  color: var(--primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-list-value {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.analytics-list-empty {
  color: var(--secondary);
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}

/* ── CTA "Envoie une notif aux dormants" ─────────────────── */
.analytics-cta {
  background: linear-gradient(135deg, var(--blue), #4A8FFF);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.analytics-cta-msg {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  margin: 0;
}
.analytics-cta-btn {
  background: #fff;
  color: var(--blue);
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}
.analytics-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

/* ── Skeleton pour analytics (placeholder initial) ───────── */
.analytics-skeleton { display: flex; flex-direction: column; gap: 10px; }

/* Dark mode : ajustements */
html.dark .analytics-cta {
  background: linear-gradient(135deg, #3C6FD9, #4A8FFF);
}
html.dark .analytics-cta-btn {
  background: var(--card);
  color: var(--blue);
}
