/* ═══════════════════════════════════════════
   Reports Page — รายงานผล (Enhanced UI)
   ═══════════════════════════════════════════ */

#page-reports {
  animation: rpPageIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes rpPageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Stagger reveal ── */
#page-reports .rp-reveal {
  opacity: 0;
}

#page-reports .rp-reveal.rp-revealed,
#page-reports .rp-reveal.dash-revealed {
  animation: rpCardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes rpCardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Hero Banner ── */
.rp-hero {
  position: relative;
  background: linear-gradient(135deg, #1c1917 0%, #78350f 38%, #b45309 72%, #ca8a04 100%);
  border-radius: 20px;
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 20px 50px rgba(28, 25, 23, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.rp-hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.rp-hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(55px);
  opacity: 0.45;
  animation: rpOrbFloat 8s ease-in-out infinite;
}

.rp-hero-orb.o1 {
  width: 220px;
  height: 220px;
  background: #fbbf24;
  top: -80px;
  right: -40px;
}

.rp-hero-orb.o2 {
  width: 160px;
  height: 160px;
  background: #f97316;
  bottom: -60px;
  left: 8%;
  animation-delay: -3s;
}

.rp-hero-orb.o3 {
  width: 120px;
  height: 120px;
  background: #fde68a;
  top: 25%;
  left: 55%;
  animation-delay: -5s;
}

@keyframes rpOrbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(10px, -14px) scale(1.08); }
}

.rp-hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.5;
  pointer-events: none;
}

.rp-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.rp-hero-left { flex: 1; min-width: 240px; }

.rp-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

.rp-hero-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow: 0 0 8px #fbbf24;
  animation: rpPulse 2s ease-in-out infinite;
}

@keyframes rpPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.rp-hero-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
}

.rp-hero-sub {
  font-size: 0.88rem;
  opacity: 0.88;
  line-height: 1.55;
  max-width: 520px;
  margin-bottom: 20px;
}

.rp-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rp-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  min-width: 72px;
  transition: transform 0.2s, background 0.2s;
}

.rp-stat-pill:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.15);
}

.rp-stat-pill.gold-pill {
  background: rgba(251, 191, 36, 0.2);
  border-color: rgba(251, 191, 36, 0.35);
}

.rp-stat-num {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

.rp-stat-label {
  font-size: 0.65rem;
  opacity: 0.85;
  margin-top: 2px;
  white-space: nowrap;
}

.rp-hero-right {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rp-hero-trophy {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  animation: rpTrophyFloat 4s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

@keyframes rpTrophyFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

/* ── Page layout ── */
.reports-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Leader cards ── */
.rp-leaders {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.rp-leader-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid transparent;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s;
}

.rp-leader-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
  pointer-events: none;
}

.rp-leader-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.rp-leader-card:hover::before { opacity: 1; }

.rp-leader-card.sports {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #93c5fd;
}

.rp-leader-card.athletics {
  background: linear-gradient(135deg, #fef2f2 0%, #ffe4e6 100%);
  border-color: #fda4af;
}

.rp-leader-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.rp-leader-info { flex: 1; min-width: 0; }

.rp-leader-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.rp-leader-card.sports .rp-leader-label { color: #1d4ed8; }
.rp-leader-card.athletics .rp-leader-label { color: #be123c; }

.rp-leader-name {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-leader-card.sports .rp-leader-name { color: #1e3a8a; }
.rp-leader-card.athletics .rp-leader-name { color: #881337; }

.rp-leader-score {
  text-align: right;
  flex-shrink: 0;
}

.rp-leader-score-label {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.75;
}

.rp-leader-score-val {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.rp-leader-card.sports .rp-leader-score-val { color: #1e3a8a; }
.rp-leader-card.athletics .rp-leader-score-val { color: #881337; }

/* ── Report cards ── */
.rp-section {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.25s;
}

.rp-section:hover {
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

.rp-section-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.rp-section-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.rp-section-icon.sports-icon {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}

.rp-section-icon.athletics-icon {
  background: linear-gradient(135deg, #ffe4e6, #fecdd3);
}

.rp-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.rp-section-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rp-section-body {
  padding: 18px 22px;
}

/* ── Tables ── */
.rp-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
  margin-bottom: 4px;
}

.rp-table-wrap::-webkit-scrollbar { height: 6px; }
.rp-table-wrap::-webkit-scrollbar-track { background: #f8fafc; border-radius: 3px; }
.rp-table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 480px;
}

.rp-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.rp-table th.center { text-align: center; }

.rp-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}

.rp-table tbody tr {
  animation: rpRowIn 0.4s ease both;
}

.rp-table tbody tr:hover td {
  background: #f8fafc;
}

.rp-table tbody tr:last-child td { border-bottom: none; }

@keyframes rpRowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

.rp-table .event-name {
  font-weight: 600;
  color: var(--text);
}

.rp-table .score-cell {
  text-align: center;
  font-weight: 600;
}

.rp-table .score-cell.top-score {
  color: var(--primary);
  font-weight: 700;
  background: rgba(37, 99, 235, 0.06);
}

/* ── House badge ── */
.rp-house {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
  border: 1px solid transparent;
}

.rp-house.gold { background: rgba(251, 191, 36, 0.15); border-color: rgba(251, 191, 36, 0.3); }
.rp-house.silver { background: rgba(148, 163, 184, 0.15); border-color: rgba(148, 163, 184, 0.3); }
.rp-house.bronze { background: rgba(180, 83, 9, 0.12); border-color: rgba(180, 83, 9, 0.25); }

/* ── Totals block ── */
.rp-totals {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.rp-totals-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 12px;
  color: var(--text);
}

.rp-totals-title span { font-size: 1.1rem; }

/* ── Score grid (mobile-friendly totals) ── */
.rp-score-grid {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.rp-score-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  transition: transform 0.2s;
}

.rp-score-item:hover { transform: scale(1.02); }

.rp-score-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.82rem;
}

.rp-score-item-val {
  font-size: 1.15rem;
  font-weight: 700;
}

/* ── Athletics event blocks ── */
.rp-ath-events {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rp-ath-event {
  border: 1px solid #f1f5f9;
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rp-ath-event:hover {
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.rp-ath-event-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

.rp-ath-event-icon { font-size: 1.2rem; }

.rp-ath-event-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.rp-ath-event-body { padding: 12px 14px; }

/* ── Empty state ── */
.rp-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.rp-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.6;
  animation: rpTrophyFloat 3s ease-in-out infinite;
}

.rp-empty-text {
  font-size: 0.88rem;
}

/* ── Admin actions ── */
.rp-admin-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.rp-admin-bar .btn {
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.rp-admin-bar .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
}

/* ── Medal column headers ── */
.rp-medal-th {
  font-size: 1rem !important;
  text-align: center !important;
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
  .rp-hero {
    padding: 22px 20px;
    border-radius: 16px;
  }

  .rp-hero-content {
    flex-direction: column;
    align-items: stretch;
  }

  .rp-hero-right {
    align-self: center;
  }

  .rp-hero-trophy {
    width: 80px;
    height: 80px;
    font-size: 2.4rem;
  }

  .rp-leaders {
    grid-template-columns: 1fr;
  }

  .rp-leader-card {
    padding: 16px 18px;
  }

  .rp-section-hdr,
  .rp-section-body {
    padding: 14px 16px;
  }

  .rp-totals .rp-table-wrap { display: none; }
  .rp-totals .rp-score-grid { display: grid; }
}

@media (max-width: 480px) {
  .rp-hero-stats { gap: 8px; }

  .rp-stat-pill {
    padding: 8px 12px;
    min-width: 64px;
    flex: 1;
  }

  .rp-stat-num { font-size: 1.15rem; }

  .rp-leader-icon {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .rp-leader-score-val { font-size: 1.35rem; }

  .rp-score-grid {
    grid-template-columns: 1fr;
  }

  .rp-section-icon {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }
}

@media (max-width: 360px) {
  .rp-hero         { padding: 16px 14px; border-radius: 14px; }
  .rp-hero-title   { font-size: 1.2rem; }
  .rp-stat-pill    { padding: 6px 10px; min-width: 52px; }
  .rp-stat-num     { font-size: 0.95rem; }
  .rp-hero-trophy  { width: 60px; height: 60px; font-size: 1.8rem; }

  .rp-leader-card        { padding: 12px 14px; gap: 10px; }
  .rp-leader-icon        { width: 38px; height: 38px; font-size: 1.1rem; }
  .rp-leader-score-val   { font-size: 1.1rem; }
  .rp-section-hdr,
  .rp-section-body       { padding: 12px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #page-reports,
  #page-reports .rp-reveal,
  .rp-hero-orb,
  .rp-hero-badge-dot,
  .rp-hero-trophy,
  .rp-empty-icon,
  .rp-table tbody tr,
  .rp-leader-card,
  .rp-score-item {
    animation: none !important;
    transition: none !important;
  }

  #page-reports .rp-reveal {
    opacity: 1;
  }
}
