/* ================================================
   analytics.css — Dashboard de análisis MRP
   ================================================ */

/* ── Estabilidad global de scroll ────────────── */
html {
  scrollbar-gutter: stable;
}

/* ── Layout base ─────────────────────────────── */
.an-wrap {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 20px;
  box-sizing: border-box;
  width: 100%;
}

/* ── Shell común (breadcrumb + tabs + contenido) */
#anApp {
  width: 100%;
  box-sizing: border-box;
}

/* ── Vistas Global y Jugador: mismo ancho base ── */
#globalView,
#playerView {
  width: 100%;
  box-sizing: border-box;
}

/* ── Nav / breadcrumb ────────────────────────── */
.an-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: .88rem;
  color: var(--textMuted, #888);
  width: 100%;
  box-sizing: border-box;
}
.an-nav__back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--gold, #b8982a);
  text-decoration: none;
  font-weight: 600;
  transition: opacity .15s;
}
.an-nav__back:hover { opacity: .75; }
.an-nav__sep { opacity: .4; }
.an-nav__title {
  font-weight: 700;
  color: var(--text, #111);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Estado loading / error ──────────────────── */
.an-loading, .an-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--textMuted, #888);
  font-size: 1rem;
}
.an-error { color: #dc2626; }

/* ── Tabs de vista ───────────────────────────── */
.an-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}
.an-tab {
  padding: 10px 20px;
  border-radius: 14px;
  border: 1.5px solid var(--field-bd, #eee);
  background: var(--field-bg, #fff);
  color: var(--text, #111);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  /* Tamaño estable: el borde siempre ocupa espacio aunque sea transparente */
  min-width: 90px;
}
.an-tab.is-active {
  background: linear-gradient(135deg,#c9a84c 0%,#e8c96a 45%,#b8982a 100%);
  border: 1.5px solid #c9a84c;
  color: #1a1200;
  box-shadow: 0 6px 22px rgba(184,152,42,.35), 0 2px 6px rgba(0,0,0,.1);
}
.an-tab.is-active:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(184,152,42,.45), 0 4px 10px rgba(0,0,0,.12);
  filter: brightness(1.06);
}
.an-tab:hover:not(.is-active) {
  border-color: var(--gold, #b8982a);
  transform: translateY(-2px);
}
.an-player-select {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--field-bd, #ddd);
  background: var(--field-bg, #fff);
  color: var(--text, #111);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.an-player-select:focus { border-color: var(--gold, #b8982a); }

/* ── KPI Grid ────────────────────────────────── */
.an-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.an-kpi {
  background: var(--field-bg, #fff);
  border: 1.5px solid var(--field-bd, #ddd);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  cursor: default;
}
@media (hover: hover) {
  .an-kpi:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    border-color: var(--gold, #b8982a);
  }
  body.dark-mode .an-kpi:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    border-color: var(--gold, #b8982a);
  }
}
.an-kpi__label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--textMuted, #888);
}
.an-kpi__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text, #111);
  line-height: 1;
}
.an-kpi__value--gold { color: var(--gold, #b8982a); }
.an-kpi__sub {
  font-size: .78rem;
  color: var(--textMuted, #888);
}

/* ── Player header ───────────────────────────── */
.an-player-hdr {
  background: var(--field-bg, #fff);
  border: 1.5px solid var(--field-bd, #ddd);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.an-player-hdr__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg,#c9a84c 0%,#e8c96a 45%,#b8982a 100%);
  color: #1a1200;
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(184,152,42,.35);
}
.an-player-hdr__info { flex: 1; min-width: 0; }
.an-player-hdr__name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text, #111);
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.an-player-hdr__meta {
  font-size: .85rem;
  color: var(--textMuted, #888);
}
.an-player-hdr__trend {
  font-size: 1.6rem;
  line-height: 1;
}

/* ── Charts row ──────────────────────────────── */
.an-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 680px) {
  .an-charts { grid-template-columns: 1fr; }
}
.an-chart-card {
  background: var(--field-bg, #fff);
  border: 1.5px solid var(--field-bd, #ddd);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}
.an-chart-card--full {
  grid-column: 1 / -1;
}
.an-chart-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--textMuted, #888);
  margin-bottom: 14px;
}
.an-chart-wrap {
  position: relative;
  height: 180px;
}
.an-empty-chart {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--textMuted, #888);
  font-size: .85rem;
  border: 1.5px dashed var(--field-bd, #ddd);
  border-radius: 10px;
}

/* ── Forma reciente ──────────────────────────── */
.an-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.an-form-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}
.an-form-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  color: #fff;
}
.an-form-dot--W { background: #16a34a; }
.an-form-dot--L { background: #dc2626; }
.an-form-dot--A { background: var(--textMuted, #888); }
.an-form-label {
  font-size: .72rem;
  color: var(--textMuted, #888);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}
.an-streak {
  background: var(--field-bg, #fff);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 600;
}
.an-streak--W { color: #16a34a; border: 1.5px solid rgba(22,163,74,.35); }
.an-streak--L { color: #dc2626; border: 1.5px solid rgba(220,38,38,.35); }
.an-streak--none { color: var(--textMuted, #888); border: 1.5px dashed var(--field-bd, #ddd); }

/* ── Distribución de nivel ───────────────────── */
.an-dist {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  flex: 1;
  margin-top: auto;
  margin-bottom: auto;
}
.an-dist-bar {
  flex: 1;
  min-width: 70px;
  text-align: center;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: .78rem;
  font-weight: 700;
}
.an-dist-bar__val {
  font-size: 1.5rem;
  font-weight: 800;
  display: block;
  line-height: 1.2;
}
.an-dist-bar--high { background: rgba(22,163,74,.12); color: #16a34a; }
.an-dist-bar--mid  { background: rgba(234,179,8,.12);  color: #b45309; }
.an-dist-bar--low  { background: rgba(220,38,38,.1);   color: #dc2626; }

/* ── Top table ───────────────────────────────── */
.an-top-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.an-top-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--textMuted, #888);
  padding: 0 8px 10px;
  border-bottom: 1.5px solid var(--field-bd, #ddd);
}
.an-top-table th:not(:first-child) { text-align: right; }
.an-top-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--field-bd, #ddd);
  color: var(--text, #111);
}
.an-top-table td:not(:first-child):not(:nth-child(2)) { text-align: right; }
.an-top-table tr:last-child td { border-bottom: none; }
.an-top-table tr:hover td { background: rgba(184,152,42,.05); }
.an-pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.an-pos-badge--1 {
  background: linear-gradient(145deg,#f7e97a 0%,#d4a82a 35%,#f0d060 55%,#9a6e10 100%);
  color: #4a2e00;
  border: 1.5px solid rgba(212,168,42,.55);
  box-shadow: 0 3px 10px rgba(184,152,42,.45), inset 0 1px 0 rgba(255,255,255,.55);
}
.an-pos-badge--2 {
  background: linear-gradient(145deg,#f2f2f4 0%,#a0a8b4 35%,#e4e8ec 55%,#6e7888 100%);
  color: #2d3748;
  border: 1.5px solid rgba(140,150,170,.45);
  box-shadow: 0 3px 10px rgba(100,110,130,.28), inset 0 1px 0 rgba(255,255,255,.65);
}
.an-pos-badge--3 {
  background: linear-gradient(145deg,#f0a060 0%,#b05820 35%,#e0884a 55%,#7a3a0a 100%);
  color: #fff;
  border: 1.5px solid rgba(176,88,32,.5);
  box-shadow: 0 3px 10px rgba(176,88,32,.38), inset 0 1px 0 rgba(255,255,255,.3);
}
.an-rank-link {
  color: var(--text, #111);
  text-decoration: none;
  font-weight: 600;
  transition: color .15s;
}
.an-rank-link:hover { color: var(--gold, #b8982a); }

/* ── Insights ────────────────────────────────── */
.an-insights {
  background: var(--field-bg, #fff);
  border: 1.5px solid var(--field-bd, #ddd);
  border-left: 4px solid var(--gold, #b8982a);
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 8px;
}
.an-insights__title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--textMuted, #888);
  margin: 0 0 12px;
}
.an-insights__list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.an-insights__item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: .875rem;
  color: var(--text, #111);
  line-height: 1.5;
  padding: 6px 0;
  border-bottom: 1px solid var(--field-bd, #eee);
}
.an-insights__item:last-child { border-bottom: none; padding-bottom: 0; }
.an-insights__item:first-child { padding-top: 0; }
.an-insights__icon {
  flex-shrink: 0;
  width: 22px;
  font-size: .95rem;
  line-height: 1.5;
}
.an-insights__text { flex: 1; }
.an-insights__item--positive { color: var(--text, #111); }
.an-insights__item--warning  { color: var(--text, #111); }
.an-insights__item--info     { color: var(--text, #111); }

/* ── Badges automáticos de jugador ──────────────────────── */
.an-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.an-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: linear-gradient(135deg,#c9a84c 0%,#e8c96a 45%,#b8982a 100%);
  border: none;
  color: #1a1200;
  letter-spacing: .3px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(184,152,42,.25);
}

/* ── Section title ───────────────────────────── */
.an-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--textMuted, #888);
  margin: 0 0 12px;
}

/* ── Dark mode overrides ─────────────────────── */
body.dark-mode .an-kpi,
body.dark-mode .an-chart-card,
body.dark-mode .an-insights,
body.dark-mode .an-player-hdr {
  background: #1f1f1f;
  border-color: rgba(255,255,255,.1);
}
body.dark-mode .an-insights__item { border-bottom-color: rgba(255,255,255,.07); }
body.dark-mode .an-badge {
  background: linear-gradient(135deg,#c9a84c 0%,#e8c96a 45%,#b8982a 100%);
  border: none;
  color: #1a1200;
}
body.dark-mode .an-top-table th,
body.dark-mode .an-top-table td { border-color: rgba(255,255,255,.1); }
body.dark-mode .an-tab {
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.12);
  color: #fff;
}
body.dark-mode .an-tab.is-active {
  background: linear-gradient(135deg,#c9a84c 0%,#e8c96a 45%,#b8982a 100%);
  border: 1.5px solid #c9a84c;
  color: #1a1200;
  box-shadow: 0 6px 22px rgba(184,152,42,.35), 0 2px 6px rgba(0,0,0,.1);
}
body.dark-mode .an-tab:hover {
  box-shadow: 0 0 0 1.5px var(--gold, #b8982a), 0 4px 16px rgba(184,152,42,.2);
  transform: translateY(-2px);
}
body.dark-mode .an-player-select {
  background: #1f1f1f;
  border-color: rgba(255,255,255,.2);
  color: #fff;
}
body.dark-mode .an-empty-chart {
  border-color: rgba(255,255,255,.15);
}
body.dark-mode .an-streak--none {
  border-color: rgba(255,255,255,.15);
}

/* ── Insight types ───────────────────────────── */
.an-insights__item { padding: 6px 0; list-style: none; font-size: .9rem; line-height: 1.4; }
.an-insights__item--positive { color: var(--green, #2a9d5c); }
.an-insights__item--warning  { color: var(--orange, #e07b30); }
.an-insights__item--info     { color: var(--textColor, #333); }
body.dark-mode .an-insights__item--info { color: #ccc; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-kpi__value { font-size: 1.6rem; }
  .an-player-hdr { padding: 16px; }
  .an-player-hdr__name { font-size: 1.2rem; }
}
