/* ═══════════════════════════════════════════════════════════════
   css/stats.css  —  Draven AI · Statistics Panel
   ═══════════════════════════════════════════════════════════════ */

/* ── Backdrop (solo móvil) ──────────────────────────────────── */
#draven-stats-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1100; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
#draven-stats-backdrop.st-backdrop-show {
  opacity: 1; pointer-events: auto;
}
@media (min-width: 921px) {
  #draven-stats-backdrop { display: none !important; }
}

/* ── Panel principal ─────────────────────────────────────────── */
#draven-stats-panel {
  position: fixed; top: 0; right: 0;
  width: 400px; min-width: 320px; max-width: 480px;
  height: 100dvh;
  background: var(--surface, #09090c);
  border-left: 1px solid var(--border, #1e1e24);
  display: flex; flex-direction: column;
  z-index: 1101;
  transform: translateX(110%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s;
  overflow: hidden;
}
#draven-stats-panel.st-open {
  transform: translateX(0);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.45);
}

/* Empujar el chat en desktop */
body.st-body-open #spa-root,
body.st-body-open .main-layout,
body.st-body-open .chat-layout {
  padding-right: 400px;
  transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 920px) {
  #draven-stats-panel {
    width: 100%; min-width: unset; max-width: unset; border-left: none;
  }
  body.st-body-open #spa-root,
  body.st-body-open .main-layout,
  body.st-body-open .chat-layout { padding-right: 0; }
}

/* ── Header ──────────────────────────────────────────────────── */
.st-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 14px; height: 52px;
  border-bottom: 1px solid var(--border, #1e1e24);
  flex-shrink: 0; gap: 6px;
  background: var(--surface, #09090c);
}
.st-header-left {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
}
.st-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent-dim, rgba(100, 116, 248, 0.12));
  color: var(--accent, #6474f8);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.st-title {
  font-size: 13px; font-weight: 600; color: var(--text, #eeeef0);
}
.st-close {
  width: 30px; height: 30px; border-radius: 7px; border: none;
  background: transparent; color: var(--text-2, #8a8a96);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.14s; flex-shrink: 0;
}
.st-close:hover {
  background: var(--surface-3, #161619); color: var(--text, #eeeef0);
}

/* ── Body + scroll ───────────────────────────────────────────── */
.st-body {
  flex: 1; overflow-y: auto; min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #1e1e24) transparent;
}
.st-content {
  padding: 16px; display: flex; flex-direction: column; gap: 16px;
}

/* ── Loading / error ─────────────────────────────────────────── */
.st-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 120px; color: var(--text-2, #8a8a96); font-size: 13px;
}
.st-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border, #1e1e24);
  border-top-color: var(--accent, #6474f8);
  border-radius: 50%; animation: st-spin 0.7s linear infinite;
}
@keyframes st-spin { to { transform: rotate(360deg); } }
.st-error {
  padding: 32px 16px; text-align: center;
  color: var(--text-2, #8a8a96); font-size: 13px;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.st-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.st-card {
  background: var(--surface-3, #161619);
  border: 1px solid var(--border, #1e1e24);
  border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.15s;
}
.st-card:hover {
  border-color: var(--accent-dim, rgba(100, 116, 248, 0.3));
}
.st-card-icon { color: var(--accent, #6474f8); opacity: 0.75; }
.st-card-val {
  font-size: 28px; font-weight: 700; color: var(--text, #eeeef0); line-height: 1;
}
.st-card-lbl {
  font-size: 11px; color: var(--text-2, #8a8a96);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Streak banner ───────────────────────────────────────────── */
.st-streak {
  background: linear-gradient(135deg,
    rgba(250, 179, 135, 0.12) 0%,
    rgba(100, 116, 248, 0.08) 100%);
  border: 1px solid rgba(250, 179, 135, 0.25);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; font-weight: 500; color: #fab387;
  text-align: center;
}

/* ── Sections ────────────────────────────────────────────────── */
.st-section { display: flex; flex-direction: column; gap: 10px; }
.st-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-2, #8a8a96);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ── Model bars ──────────────────────────────────────────────── */
.st-bars { display: flex; flex-direction: column; gap: 9px; }
.st-bar-row { display: flex; align-items: center; gap: 8px; }
.st-bar-label {
  font-size: 12px; color: var(--text, #eeeef0);
  min-width: 100px; max-width: 130px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st-bar-track {
  flex: 1; height: 6px;
  background: var(--surface-3, #161619);
  border-radius: 99px; overflow: hidden;
}
.st-bar-fill {
  height: 100%; width: 0%;
  background: var(--accent, #6474f8);
  border-radius: 99px;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.st-bar-pct {
  font-size: 11px; color: var(--text-2, #8a8a96);
  min-width: 32px; text-align: right;
}

/* ── Activity chart ──────────────────────────────────────────── */
.st-activity {
  display: flex; align-items: flex-end; gap: 3px;
  height: 72px; padding-bottom: 18px; position: relative;
}
.st-act-col {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px; flex: 1;
}
.st-act-bar {
  width: 100%; min-height: 4px; border-radius: 3px 3px 0 0;
  background: var(--border, #1e1e24);
  transition: background 0.2s, opacity 0.2s;
}
.st-act-bar.active {
  background: var(--accent, #6474f8); opacity: 0.7;
}
.st-act-bar.active:hover { opacity: 1; }
.st-act-lbl {
  font-size: 9px; color: var(--text-2, #8a8a96);
  white-space: nowrap; user-select: none;
}

/* ── Category pills ──────────────────────────────────────────── */
.st-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.st-pill {
  padding: 5px 11px; border-radius: 99px;
  /* color-mix may not work in older browsers — fallback to accent */
  background: rgba(100, 116, 248, 0.1);
  background: color-mix(in srgb, var(--c, #6474f8) 12%, transparent);
  border: 1px solid rgba(100, 116, 248, 0.25);
  border: 1px solid color-mix(in srgb, var(--c, #6474f8) 28%, transparent);
  color: var(--c, #6474f8);
  font-size: 12px; font-weight: 500;
}

/* ── Footer stat ─────────────────────────────────────────────── */
.st-footer {
  font-size: 12px; color: var(--text-2, #8a8a96);
  text-align: center; padding: 4px 0 8px;
}
.st-footer strong { color: var(--text, #eeeef0); }

/* ── Tema claro ──────────────────────────────────────────────── */
html.theme-light #draven-stats-panel,
body.theme-light  #draven-stats-panel {
  background: var(--surface, #ffffff);
  border-left-color: var(--border, rgba(0, 0, 0, 0.08));
}
html.theme-light .st-card,
body.theme-light  .st-card {
  background: var(--surface-3, #f5f5f7);
}
