/* ==========================================================================
   HOMESCHOOL MANAGER - LEADERBOARD STYLES
   Estética unificada con Mi Aventura de Estudio (Homeschool)
   ========================================================================== */

:root {
  /* Paleta visual de Homeschool (Luz, amigable, pedagógico y moderno) */
  --bg-main: #f0f9ff;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border-card: #e2e8f0;
  --border-focus: #c7d2fe;
  --border-accent: #a5b4fc;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-dark: #0f172a;
  
  --gold: #f59e0b;
  --gold-bg: #fef3c7;
  --gold-border: #fde68a;
  --gold-text: #92400e;
  
  --silver: #94a3b8;
  --silver-bg: #f1f5f9;
  --silver-border: #cbd5e1;
  --silver-text: #475569;
  
  --bronze: #d97706;
  --bronze-bg: #ffedd5;
  --bronze-border: #fed7aa;
  --bronze-text: #9a3412;
  
  --success: #10b981;
  --success-bg: #d1fae5;
  --success-border: #6ee7b7;
  --success-text: #065f46;
  
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 20px -5px rgba(79, 70, 229, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  padding: 1rem;
  line-height: 1.5;
}

@media (min-width: 768px) {
  body {
    padding: 2rem;
  }
}

.container {
  max-width: 58rem;
  margin: 0 auto;
}

/* ── Top Header Navigation ─────────────────────────────────────── */
header.header-nav {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  border: 4px solid var(--border-focus);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: 768px) {
  header.header-nav {
    flex-direction: row;
  }
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 2.75rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}

.brand-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  background-color: var(--primary-light);
  border: 1px solid var(--border-accent);
  color: var(--primary);
  border-radius: var(--radius-pill);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-pill:hover {
  transform: translateY(-2px);
}

.btn-refresh {
  background-color: #f1f5f9;
  border: 2px solid #cbd5e1;
  color: #334155;
}

.btn-refresh:hover {
  background-color: #e2e8f0;
  box-shadow: var(--shadow-sm);
}

.btn-app {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.btn-app:hover {
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.4);
}

/* ── Banner: Sesión del Estudiante Actual ──────────────────────── */
.student-banner {
  background-color: #ffffff;
  border: 2px solid #c7d2fe;
  background-image: linear-gradient(135deg, #ffffff 60%, #eef2ff 100%);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .student-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.student-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.student-avatar {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.student-text h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
}

.student-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.level-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background-color: #e0e7ff;
  color: #4338ca;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.student-pills {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pill-stat {
  background-color: #ffffff;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem;
  text-align: center;
  min-width: 80px;
  box-shadow: var(--shadow-sm);
}

.pill-stat.gold {
  background-color: var(--gold-bg);
  border-color: var(--gold-border);
}

.pill-stat-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.pill-stat.gold .pill-stat-val {
  color: var(--gold-text);
}

.pill-stat-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pill-stat.gold .pill-stat-lbl {
  color: #b45309;
}

/* ── Panel de Estadísticas Globales ───────────────────────────── */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

@media (min-width: 640px) {
  .stats-overview {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-metric-card {
  background-color: #ffffff;
  border: 2px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-metric-card .num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-dark);
}

.stat-metric-card .num.green { color: #059669; }
.stat-metric-card .num.gold { color: #d97706; }
.stat-metric-card .num.orange { color: #ea580c; }

.stat-metric-card .lbl {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Podio Top 3 (Cuadro de Honor) ────────────────────────────── */
.podium-container {
  margin-bottom: 2rem;
}

.section-heading {
  font-size: 1.35rem;
  font-weight: 800;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.podium-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: flex-end;
}

@media (min-width: 768px) {
  .podium-grid {
    grid-template-columns: 1fr 1.12fr 1fr;
  }
  .podium-card.rank-1 { order: 2; }
  .podium-card.rank-2 { order: 1; }
  .podium-card.rank-3 { order: 3; }
}

.podium-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  border: 3px solid var(--border-card);
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

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

.podium-card.rank-1 {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 50%);
  border-width: 4px;
}

.podium-card.rank-2 {
  border-color: #cbd5e1;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 50%);
}

.podium-card.rank-3 {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 50%);
}

.podium-medal {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.podium-card.rank-1 .podium-medal {
  width: 68px;
  height: 68px;
  font-size: 2.5rem;
  background-color: var(--gold-bg);
  border: 3px solid var(--gold);
}

.podium-card.rank-2 .podium-medal {
  background-color: var(--silver-bg);
  border: 3px solid var(--silver);
}

.podium-card.rank-3 .podium-medal {
  background-color: var(--bronze-bg);
  border: 3px solid var(--bronze);
}

.rank-badge-pill {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background-color: var(--text-dark);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

.podium-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-dark);
}

.podium-phone {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.podium-metrics-box {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
}

.podium-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.podium-metric .val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.podium-metric .val.gold { color: #d97706; }
.podium-metric .val.green { color: #059669; }
.podium-metric .val.orange { color: #ea580c; }

.podium-metric .lbl {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Panel Principal de Clasificación ─────────────────────────── */
.table-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 2px solid var(--border-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}

.controls-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.search-field {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-field input {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 2.4rem;
  background-color: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.search-field input:focus {
  border-color: var(--primary);
  background-color: #ffffff;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  background-color: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
}

.filter-tab {
  padding: 0.45rem 0.9rem;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tab.active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Filas de Estudiantes ─────────────────────────────────────── */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.student-row {
  background-color: #ffffff;
  border: 2px solid #f1f5f9;
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.student-row:hover {
  border-color: var(--border-focus);
  background-color: #f8fafc;
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.student-row.is-me {
  background-color: #f5f3ff;
  border-color: #c7d2fe;
}

.row-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 220px;
}

.rank-pill {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: #f1f5f9;
  color: #475569;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-pill.r1 { background-color: var(--gold-bg); color: var(--gold-text); border: 1px solid var(--gold-border); }
.rank-pill.r2 { background-color: var(--silver-bg); color: var(--silver-text); border: 1px solid var(--silver-border); }
.rank-pill.r3 { background-color: var(--bronze-bg); color: var(--bronze-text); border: 1px solid var(--bronze-border); }

.avatar-bubble {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c7d2fe, #e0e7ff);
  color: var(--primary);
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.student-meta h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.me-chip {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  background-color: var(--success-bg);
  color: var(--success-text);
  font-weight: 800;
}

.student-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.subject-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-card);
}

.row-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-item .val {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-item .val.green { color: #059669; }
.stat-item .val.gold { color: #d97706; }
.stat-item .val.orange { color: #ea580c; }

.stat-item .lbl {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Modal de Detalle de Ejercicios ──────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.show {
  display: flex;
}

.modal-sheet {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 3px solid var(--border-focus);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-top {
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-top h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.5rem;
}

.btn-close:hover {
  color: var(--text-dark);
}

.modal-content-list {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.exercise-entry {
  background-color: #f8fafc;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.exercise-info h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-dark);
}

.exercise-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.exercise-stars {
  font-size: 1rem;
  font-weight: 800;
  color: #d97706;
  white-space: nowrap;
}

/* ── Estados (Cargando / Vacío) ───────────────────────────────── */
.state-container {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e0e7ff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
