/*
 * AnimeRadar statistics view - Material reference profile board.
 * Loaded after the shared redesign stylesheet. All rules are deliberately
 * scoped to #view-stats so existing routes and behaviour stay untouched.
 */

/* -------------------------------------------------------------------------- */
/* Statistics hub tabs                                                        */
/* -------------------------------------------------------------------------- */

html body #view-stats .profile-hub-tabs {
  min-height: 46px;
  display: flex !important;
  align-items: stretch;
  gap: 2px;
  margin: 0 0 22px !important;
  overflow-x: auto;
  border: 0 !important;
  border-bottom: 1px solid var(--md-outline) !important;
  scrollbar-width: none;
}

html body #view-stats .profile-hub-tabs::-webkit-scrollbar {
  display: none;
}

html body #view-stats .profile-hub-tabs .mobile-section-tab {
  position: relative;
  min-width: max-content;
  min-height: 44px;
  display: grid !important;
  place-items: center;
  padding: 0 18px !important;
  border: 0 !important;
  border-radius: 7px 7px 0 0 !important;
  background: transparent !important;
  color: var(--md-muted) !important;
  box-shadow: none !important;
  font-size: 11px !important;
  font-weight: 520 !important;
}

html body #view-stats .profile-hub-tabs .mobile-section-tab.active {
  color: var(--md-secondary) !important;
}

html body #view-stats .profile-hub-tabs .mobile-section-tab.active::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: -1px;
  left: 7px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--md-secondary);
}

/* -------------------------------------------------------------------------- */
/* KPI tiles (#statsGrid)                                                     */
/* -------------------------------------------------------------------------- */

html body #view-stats #statsGrid.stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 12px !important;
  margin: 0 0 20px !important;
}

html body #view-stats #statsGrid .stat-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--md-primary) 10%, var(--md-surface-variant)), var(--md-surface-variant)) !important;
  transition: border-color .18s var(--md-motion), box-shadow .18s var(--md-motion);
}

html body #view-stats #statsGrid .stat-card:hover {
  border-color: color-mix(in srgb, var(--md-primary) 55%, var(--md-outline)) !important;
  box-shadow: var(--md-elevation-2) !important;
}

html body #view-stats #statsGrid .stat-card strong {
  font-size: 25px !important;
}

html body #view-stats #statsGrid .stat-card .stat-help {
  margin-top: 8px;
  color: var(--md-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
}

/* -------------------------------------------------------------------------- */
/* Genre breakdown                                                            */
/* -------------------------------------------------------------------------- */

html body #view-stats .genre-bars {
  gap: 11px !important;
}

html body #view-stats .genre-bar {
  padding: 3px 0;
}

html body #view-stats .genre-bar > span {
  overflow: hidden;
  color: var(--md-on-surface) !important;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body #view-stats .genre-bar-fill {
  height: 8px;
}

html body #view-stats .genre-bar-fill i {
  display: block;
  height: 100%;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--md-primary) 80%, black), var(--md-secondary)) !important;
  transition: width .3s var(--md-motion);
}

html body #view-stats .genre-bar > b {
  color: var(--md-on-surface);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: right;
}

/* -------------------------------------------------------------------------- */
/* Admin: product analytics                                                   */
/* -------------------------------------------------------------------------- */

html body #view-stats .product-analytics-panel {
  margin-top: 26px !important;
  border-style: dashed !important;
  border-color: color-mix(in srgb, var(--md-outline) 70%, transparent) !important;
  background: color-mix(in srgb, var(--md-surface-variant) 92%, transparent) !important;
}

html body #view-stats .product-analytics-head {
  align-items: flex-start !important;
  gap: 18px !important;
}

html body #view-stats .product-analytics-head p {
  max-width: 640px;
  margin: 6px 0 0;
  color: var(--md-muted);
  font-size: 12px;
  line-height: 1.5;
}

html body #view-stats .product-analytics-controls {
  align-items: flex-end;
  gap: 8px;
}

html body #view-stats .product-analytics-controls label {
  gap: 5px;
  color: var(--md-muted);
  font-size: 11px;
  font-weight: 600;
}

html body #view-stats .product-analytics-controls select {
  min-height: 38px !important;
  min-width: 148px;
}

html body #view-stats #productAnalyticsRefresh {
  min-height: 38px !important;
}

html body #view-stats .product-analytics-status {
  margin: 8px 0 16px !important;
  color: var(--md-muted) !important;
  font-size: 12px !important;
}

html body #view-stats .product-analytics-summary.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 9px !important;
  margin-bottom: 4px !important;
}

html body #view-stats .product-analytics-summary .stat-card {
  min-height: 78px !important;
  padding: 12px !important;
}

html body #view-stats .product-analytics-summary .stat-card strong {
  font-size: 20px !important;
}

html body #view-stats .product-analytics-card h3 {
  margin: 0 0 10px !important;
  color: var(--md-on-surface) !important;
  font-size: 13px !important;
}

html body #view-stats .product-analytics-row {
  border-bottom-color: var(--md-outline) !important;
  transition: border-color .18s var(--md-motion);
}

html body #view-stats .product-analytics-row:hover {
  border-bottom-color: color-mix(in srgb, var(--md-primary) 45%, var(--md-outline)) !important;
}

html body #view-stats .product-analytics-row strong {
  color: var(--md-on-surface);
  font-size: 12px;
}

html body #view-stats .product-analytics-row small {
  color: var(--md-muted);
  font-size: 10px;
}

html body #view-stats .product-analytics-row > b,
html body #view-stats .product-analytics-funnel > b {
  color: var(--md-secondary);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------- */
/* Admin: app statistics                                                      */
/* -------------------------------------------------------------------------- */

html body #view-stats .app-profile-statistics-panel {
  margin-top: 16px !important;
  border-style: dashed !important;
  border-color: color-mix(in srgb, var(--md-outline) 70%, transparent) !important;
  background: color-mix(in srgb, var(--md-surface-variant) 92%, transparent) !important;
}

html body #view-stats .app-profile-statistics-head {
  align-items: flex-start !important;
  gap: 16px !important;
}

html body #view-stats #appStatisticsStatus.app-release-status {
  border-left: 3px solid var(--md-primary) !important;
  background: color-mix(in srgb, var(--md-primary) 10%, transparent) !important;
  color: var(--md-on-surface) !important;
  font-size: 12px !important;
}

html body #view-stats .app-statistics-grid {
  gap: 14px !important;
}

html body #view-stats .app-statistics-grid > .content-band {
  padding: 16px !important;
}

html body #view-stats .app-statistics-grid h3 {
  margin: 0 0 10px !important;
  font-size: 14px !important;
}

html body #view-stats .app-stat-summary span {
  border-color: var(--md-outline) !important;
  border-radius: var(--md-radius-control) !important;
  background: var(--md-surface-elevated) !important;
}

html body #view-stats .app-stat-summary b {
  color: var(--md-on-surface);
}

html body #view-stats .app-stat-summary small {
  color: var(--md-muted);
}

html body #view-stats .app-statistics-grid li {
  border-bottom-color: color-mix(in srgb, var(--md-outline) 70%, transparent) !important;
  color: var(--md-muted);
  font-size: 12px;
}

html body #view-stats .app-statistics-grid li code {
  color: var(--md-on-surface);
}

html body #view-stats .app-statistics-grid li b {
  color: var(--md-secondary);
  font-variant-numeric: tabular-nums;
}

html body #view-stats .app-statistics-disclaimer {
  color: var(--md-dim) !important;
  font-size: 11px !important;
}

/* -------------------------------------------------------------------------- */
/* Tablet: 960px                                                              */
/* -------------------------------------------------------------------------- */

@media (max-width: 959px) {
  html body #view-stats #statsGrid.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  html body #view-stats .product-analytics-head,
  html body #view-stats .app-profile-statistics-head {
    display: grid !important;
  }

  html body #view-stats .product-analytics-summary.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Mobile: 760px                                                              */
/* -------------------------------------------------------------------------- */

@media (max-width: 760px) {
  html body #view-stats .profile-hub-tabs {
    width: calc(100vw - 24px);
    margin-bottom: 16px !important;
  }

  html body #view-stats .profile-hub-tabs .mobile-section-tab {
    min-height: 40px;
    padding-inline: 13px !important;
    font-size: 10px !important;
  }

  html body #view-stats #statsGrid.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }

  html body #view-stats #statsGrid .stat-card strong {
    font-size: 20px !important;
  }

  html body #view-stats .genre-bar-fill {
    height: 7px;
  }

  html body #view-stats .product-analytics-summary.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
