/* ═══════════════════════════════════════════════
   STAT POPUP — Wikimind AI v5
   Bouton sidebar + popup statistiques modèles
═══════════════════════════════════════════════ */

/* ── Bouton dans la sidebar ── */
#stat-sidebar-btn {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0;
  flex-shrink: 0;
}
#stat-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
#stat-sidebar-btn img {
  width: 20px; height: 20px;
  border-radius: 4px;
  object-fit: contain;
}

/* ── Overlay ── */
#stat-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 20000;
  align-items: center;
  justify-content: center;
}
#stat-popup-overlay.open {
  display: flex;
}

/* ── Panel principal ── */
#stat-popup {
  background: #0d0d0d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  width: 680px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
  animation: statPopIn 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  overflow: hidden;
}

@keyframes statPopIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Header ── */
#stat-popup-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

#stat-popup-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
#stat-popup-icon img {
  width: 22px; height: 22px;
  object-fit: contain;
}

#stat-popup-title-wrap {
  flex: 1;
}
#stat-popup-title-wrap h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
#stat-popup-title-wrap p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #555;
}

#stat-popup-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #666;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
#stat-popup-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}
#stat-popup-close svg { width: 14px; height: 14px; }

/* ── Summary row (totaux) ── */
#stat-summary-row {
  display: flex;
  gap: 1px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.015);
}

.stat-summary-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin: 0 4px;
}
.stat-summary-card:first-child { margin-left: 0; }
.stat-summary-card:last-child  { margin-right: 0; }

.stat-summary-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-summary-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #444;
}

/* ── Scrollable body ── */
#stat-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
#stat-popup-body::-webkit-scrollbar { width: 4px; }
#stat-popup-body::-webkit-scrollbar-thumb { background: #222; border-radius: 4px; }

/* ── Loading / empty state ── */
#stat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 0;
  color: #444;
  font-size: 0.85rem;
}
.stat-spinner {
  width: 22px; height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: statSpin 0.7s linear infinite;
}
@keyframes statSpin { to { transform: rotate(360deg); } }

/* ── Model card ── */
.stat-model-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.stat-model-card:hover {
  border-color: rgba(255, 255, 255, 0.13);
}
.stat-model-card:last-child { margin-bottom: 0; }

/* ── Card header ── */
.stat-model-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.stat-model-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.stat-model-logo img {
  width: 18px; height: 18px;
  object-fit: contain;
}
.stat-model-names {
  flex: 1;
  min-width: 0;
}
.stat-model-display {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.stat-model-api {
  font-size: 0.68rem;
  color: #444;
  font-family: 'Geist Mono', monospace;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-model-count {
  font-size: 0.68rem;
  color: #555;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  padding: 3px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Métriques ── */
.stat-model-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-metric {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-metric-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
}

.stat-metric-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-metric-value.accent-cps  { color: #4ade80; }
.stat-metric-value.accent-time { color: #60a5fa; }
.stat-metric-value.accent-len  { color: #f59e0b; }

.stat-metric-sub {
  font-size: 0.6rem;
  color: #444;
  letter-spacing: 0.02em;
}

/* ── Barre de progression CPS ── */
.stat-cps-bar-wrap {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-cps-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.stat-cps-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #4ade80, #22d3ee);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-cps-bar-label {
  font-size: 0.6rem;
  color: #4ade80;
  font-weight: 700;
  white-space: nowrap;
  min-width: 52px;
  text-align: right;
}

/* ── No data state ── */
.stat-no-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 50px 0;
  color: #444;
  font-size: 0.82rem;
  text-align: center;
}
.stat-no-data svg { opacity: 0.3; }

/* ── Footer ── */
#stat-popup-footer {
  padding: 12px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.stat-footer-note {
  font-size: 0.68rem;
  color: #333;
}
#stat-refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #666;
  font-family: 'Geist', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  transition: all 0.12s;
}
#stat-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #aaa;
  border-color: rgba(255, 255, 255, 0.15);
}
#stat-refresh-btn svg { width: 12px; height: 12px; }
#stat-refresh-btn.loading svg {
  animation: statSpin 0.7s linear infinite;
}

/* ── Provider section dividers ── */
.stat-provider-section {
  margin-bottom: 6px;
}
.stat-provider-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 4px 8px;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #333;
}
.stat-provider-label img {
  width: 13px; height: 13px;
  object-fit: contain;
  border-radius: 2px;
  opacity: 0.5;
}
