/* ====== VARIABLES ====== */
:root {
  --color-primary: #5B3FE0;
  --color-primary-dark: #4527A0;
  --color-primary-light: #EDE9FE;
  --color-gold: #B8860B;
  --color-silver: #78838C;
  --color-bronze: #C97B3D;
  --color-success: #22C55E;
  --color-danger: #EF4444;
  --color-bg-from: #EEF1FC;
  --color-bg-to: #F6F7FC;
  --color-card: #FFFFFF;
  --color-text: #1F2430;
  --color-text-muted: #6B7280;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 4px 20px rgba(31, 36, 48, 0.08);
  --shadow-card-hover: 0 8px 28px rgba(31, 36, 48, 0.14);
  --font-heading: 'Baloo 2', cursive;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* ====== ESTILO GENERAL ====== */
body {
  font-family: var(--font-body);
  margin: 0;
  color: var(--color-text);
  background: linear-gradient(180deg, var(--color-bg-from) 0%, var(--color-bg-to) 260px);
  background-attachment: fixed;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px 48px;
}

h1, h2 {
  font-family: var(--font-heading);
  color: var(--color-primary-dark);
}

/* ====== HERO ====== */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #8B5CF6 100%);
  color: #fff;
  padding: 36px 28px;
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 32px;
}

.hero-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-emoji {
  font-size: 2.8rem;
  line-height: 1;
}

.hero h1 {
  color: #fff;
  font-size: 1.9rem;
  margin: 0 0 4px;
}

.hero p {
  margin: 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

/* ====== SECCIONES ====== */
section {
  background: var(--color-card);
  padding: 26px;
  margin-bottom: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

section h2 {
  font-size: 1.25rem;
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--color-primary-light);
}

.footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 24px 0 40px;
}

/* ====== KPI CARDS (tiempo de sesión) ====== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  text-align: center;
}

.kpi-card {
  border-radius: var(--radius-md);
  padding: 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 10px rgba(31, 36, 48, 0.05);
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

.kpi-icon { font-size: 26px; margin-bottom: 6px; }

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  margin-top: 4px;
}

.kpi-blue   { background: linear-gradient(135deg, #E0ECFF, #F3F8FF); color: #1D4ED8; }
.kpi-green  { background: linear-gradient(135deg, #DCFCE7, #F0FDF4); color: #15803D; }
.kpi-orange { background: linear-gradient(135deg, #FFE9D6, #FFF6EE); color: #C2410C; }

/* ====== GRAFICOS ====== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.plot-container {
  width: 100%;
  height: 380px;
  background: #FBFBFE;
  border: 1px solid #ECEFF7;
  border-radius: var(--radius-md);
  padding: 6px;
}

.plot-container.table-card {
  height: 380px;
  overflow-y: auto;
  padding: 14px;
}

/* ====== TABLAS ====== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid #ECEFF7;
}

.plot-container.table-card .table-wrap {
  border: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 420px;
}

thead {
  background: linear-gradient(135deg, var(--color-primary), #7C5CFA);
  color: #fff;
}

thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #F0F1F7;
  transition: background-color 0.15s;
}

tbody tr:nth-child(even) { background-color: #F8F9FD; }
tbody tr:hover { background-color: var(--color-primary-light); }

tbody td {
  padding: 10px 14px;
  color: var(--color-text);
}

/* Colores semánticos para la tabla de trofeos */
#schoolsTrophiesTable td:nth-child(2) { color: var(--color-gold); font-weight: 700; }
#schoolsTrophiesTable td:nth-child(3) { color: var(--color-silver); font-weight: 700; }
#schoolsTrophiesTable td:nth-child(4) { color: var(--color-bronze); font-weight: 700; }
#schoolsTrophiesTable td:nth-child(5) { color: var(--color-primary-dark); font-weight: 800; }

#usersBySchoolTable td:nth-child(2) { text-align: right; font-weight: 600; }

/* ====== BOTONES DE PAGINACIÓN ====== */
.pagination {
  margin-top: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

button {
  background: linear-gradient(135deg, var(--color-primary), #7C5CFA);
  border: none;
  color: white;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
  box-shadow: 0 2px 8px rgba(91, 63, 224, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(91, 63, 224, 0.4);
}

button:disabled {
  background: #D8DCE8;
  color: #9AA0AE;
  cursor: not-allowed;
  box-shadow: none;
}

#usersPageInfo, #schoolsPageInfo {
  display: inline-block;
  margin: 0 6px;
  font-weight: 700;
  color: var(--color-text-muted);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 600px) {
  .hero { padding: 26px 20px; border-radius: 0 0 20px 20px; }
  .hero-emoji { font-size: 2.2rem; }
  .hero h1 { font-size: 1.5rem; }
  .page { padding: 0 16px 40px; }
  section { padding: 18px; }

  table { font-size: 12px; min-width: 0; }
  thead { display: none; }
  tbody td {
    display: block;
    text-align: right;
    padding: 6px 12px;
    border-bottom: 1px solid #eee;
  }
  tbody td::before {
    content: attr(data-label);
    float: left;
    font-weight: 700;
    color: var(--color-primary-dark);
  }
}
