/* ═══════════════════════════════════════════
   Schedule Page — ตารางแข่งขัน (Enhanced UI)
   ═══════════════════════════════════════════ */

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

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

/* ── Stagger reveal ── */
#page-schedule .sched-reveal {
  opacity: 0;
}

#page-schedule .sched-reveal.sched-revealed,
#page-schedule .sched-reveal.dash-revealed {
  animation: schedCardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

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

/* ── Hero Banner ── */
.sched-hero {
  position: relative;
  background: linear-gradient(135deg, #0c4a6e 0%, #1e40af 42%, #312e81 100%);
  border-radius: 20px;
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

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

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

.sched-hero-orb.o1 {
  width: 200px;
  height: 200px;
  background: #38bdf8;
  top: -70px;
  right: -30px;
}

.sched-hero-orb.o2 {
  width: 150px;
  height: 150px;
  background: #818cf8;
  bottom: -50px;
  left: 8%;
  animation-delay: -3s;
}

.sched-hero-orb.o3 {
  width: 100px;
  height: 100px;
  background: #22d3ee;
  top: 30%;
  left: 50%;
  animation-delay: -5s;
}

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

.sched-hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.55;
}

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

.sched-hero-left { flex: 1; min-width: 220px; }

.sched-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}

.sched-hero-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: schedLiveDot 1.5s ease-in-out infinite;
}

@keyframes schedLiveDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.sched-hero-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.sched-hero-sub {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  max-width: 440px;
  line-height: 1.55;
}

.sched-hero-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

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

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

.sched-stat-pill.live-pill {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
}

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

.sched-stat-label {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 3px;
  font-weight: 500;
}

.sched-hero-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sched-hero-ring {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sched-hero-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
  animation: schedDotPulse 2.5s ease-in-out infinite;
}

.sched-hero-dot.red    { background: #ef4444; animation-delay: 0s; }
.sched-hero-dot.blue   { background: #3b82f6; animation-delay: 0.3s; }
.sched-hero-dot.green  { background: #22c55e; animation-delay: 0.6s; }
.sched-hero-dot.yellow { background: #eab308; animation-delay: 0.9s; }

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

/* ── Section headers ── */
.sched-section-wrap {
  margin-bottom: 28px;
}

.sched-section-hdr {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sched-section-hdr h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sched-section-hdr p {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

/* ── Bracket section ── */
#page-schedule .bracket-section {
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  border: 1px solid #e2e8f0;
  transition: box-shadow 0.25s;
}

#page-schedule .bracket-section:hover {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 12px 32px rgba(15, 23, 42, 0.08);
}

#page-schedule .competition-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

#page-schedule .competition-tabs::-webkit-scrollbar { display: none; }

#page-schedule #category-tabs {
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #fff, #f8fafc);
}

#page-schedule .comp-tab {
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border: 1.5px solid transparent;
  border-bottom: 1.5px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent;
}

#page-schedule .comp-tab:hover:not(.active) {
  color: #1e293b;
  background: #fff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

#page-schedule .comp-tab.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

/* ── Bracket header ── */
#page-schedule .bracket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04), transparent);
  flex-wrap: wrap;
  gap: 12px;
}

#page-schedule .bracket-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

#page-schedule .bracket-header small {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 3px;
}

/* ── Bracket grid ── */
#page-schedule .bracket-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 22px;
}

#page-schedule .bracket-round {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  transition: transform 0.2s, box-shadow 0.2s;
}

#page-schedule .bracket-round:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

#page-schedule .bracket-round-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #cbd5e1;
}

/* ── Bracket match cards ── */
#page-schedule .bracket-match {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

#page-schedule .bracket-match::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #e2e8f0, #93c5fd, #e2e8f0);
  opacity: 0;
  transition: opacity 0.2s;
}

#page-schedule .bracket-match:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.25);
}

#page-schedule .bracket-match:hover::before { opacity: 1; }

#page-schedule .bracket-match.status-live {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.08), 0 4px 16px rgba(239, 68, 68, 0.1);
}

#page-schedule .bracket-match.status-live::before {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), #ef4444, rgba(239, 68, 68, 0.2));
  opacity: 1;
}

#page-schedule .bracket-match.status-completed {
  border-color: rgba(34, 197, 94, 0.3);
}

#page-schedule .bracket-match.status-completed::before {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.2), #22c55e, rgba(34, 197, 94, 0.2));
  opacity: 1;
}

#page-schedule .bracket-match-status {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#page-schedule .bracket-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.82rem;
  transition: background 0.15s;
  border-radius: 8px;
}

#page-schedule .bracket-team .bt-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

#page-schedule .bracket-team .bt-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#page-schedule .bracket-team.winner {
  font-weight: 700;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.1), transparent);
  padding: 6px 8px;
  margin: 0 -8px;
  border-left: 3px solid #22c55e;
  border-radius: 0 8px 8px 0;
  animation: schedWinnerIn 0.4s ease;
}

@keyframes schedWinnerIn {
  from { opacity: 0.6; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

#page-schedule .bracket-champion-banner {
  text-align: center;
  padding: 12px 16px;
  margin-top: 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d;
  font-size: 0.9rem;
  animation: schedChampionPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes schedChampionPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Empty state ── */
#page-schedule .empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}

#page-schedule .empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: schedEmptyFloat 3s ease-in-out infinite;
}

@keyframes schedEmptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

#page-schedule .empty-state .empty-text {
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Full schedule section ── */
.sched-full-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  border: 1px solid #e2e8f0;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.06);
}

#page-schedule .sched-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Filter bar — scoped overrides */
#page-schedule .schedule-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 4px;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
}

#page-schedule .sched-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  color: #64748b;
  white-space: nowrap;
}

#page-schedule .sched-filter-btn:hover {
  background: #fff;
  color: #1e293b;
  border-color: #e2e8f0;
}

#page-schedule .sched-filter-btn.active.all {
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.25);
}

#page-schedule .sched-filter-btn.active.live {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#page-schedule .sched-filter-btn.active.upcoming {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

#page-schedule .sched-filter-btn.active.completed {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

/* Match cards — enhanced */
#page-schedule .sched-match-card {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  margin-bottom: 10px;
  transition: box-shadow 0.22s, border-color 0.22s, transform 0.22s;
  animation: schedCardEntrance 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--sched-i, 0) * 60ms);
}

@keyframes schedCardEntrance {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#page-schedule .sched-match-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  transform: translateY(-2px);
}

#page-schedule .sched-match-card.status-live {
  border-left: 4px solid #ef4444;
}

#page-schedule .sched-match-card.status-upcoming {
  border-left: 4px solid #2563eb;
}

#page-schedule .sched-match-card.status-completed {
  border-left: 4px solid #22c55e;
}

#page-schedule .sched-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.4px;
  padding: 14px 2px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#page-schedule .sched-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #e2e8f0, transparent);
}

#page-schedule .sched-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc, #fff);
  border: 1.5px dashed #e2e8f0;
}

#page-schedule .sched-empty-state .empty-icon {
  font-size: 2.8rem;
  margin-bottom: 10px;
  animation: schedEmptyFloat 3s ease-in-out infinite;
}

/* Filter list transition */
#sched-list-wrap {
  animation: schedListFade 0.25s ease;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
  #page-schedule .bracket-grid {
    grid-template-columns: 1fr;
  }

  .sched-hero-content {
    flex-direction: column;
  }

  .sched-hero-right {
    width: 100%;
    align-items: flex-start;
  }

  .sched-hero-ring {
    width: 100%;
    justify-content: center;
  }
}

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

  .sched-hero-title { font-size: 1.45rem; }

  .sched-full-wrap {
    padding: 16px;
    border-radius: 14px;
  }

  #page-schedule .bracket-grid { padding: 16px; }

  #page-schedule .schedule-filter-bar {
    gap: 6px;
    padding: 6px;
  }

  #page-schedule .sched-filter-btn {
    padding: 7px 12px;
    font-size: 0.72rem;
    flex: 1;
    justify-content: center;
    min-width: calc(50% - 6px);
  }

  #page-schedule .sched-vs-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  #page-schedule .sched-vs-team.away {
    flex-direction: row;
    text-align: left;
  }

  #page-schedule .sched-vs-team.away > div {
    text-align: left !important;
  }
}

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

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

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

  #page-schedule .competition-tabs { padding: 10px; }

  #page-schedule .comp-tab {
    padding: 8px 12px;
    font-size: 0.72rem;
  }

  #page-schedule .sched-filter-btn {
    min-width: calc(50% - 6px);
  }

  #page-schedule .sched-card-header {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

@media (max-width: 360px) {
  .sched-hero          { padding: 16px 14px; border-radius: 14px; }
  .sched-hero-title    { font-size: 1.1rem; }
  .sched-stat-pill     { padding: 6px 10px; min-width: 56px; }
  .sched-stat-num      { font-size: 1rem; }
  .sched-full-wrap     { padding: 10px; border-radius: 12px; }

  #page-schedule .comp-tab        { padding: 6px 10px; font-size: 0.68rem; }
  #page-schedule .sched-filter-btn { min-width: 100%; font-size: 0.68rem; }
  #page-schedule .bracket-grid    { padding: 8px; gap: 8px; }
  #page-schedule .sched-vs-score  { font-size: 1rem; }
  #page-schedule .sched-team-name { font-size: 0.74rem; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #page-schedule,
  #page-schedule .sched-reveal,
  #page-schedule .sched-match-card,
  #page-schedule .bracket-match,
  #page-schedule .empty-state .empty-icon,
  #page-schedule .sched-empty-state .empty-icon,
  .sched-hero-orb,
  .sched-hero-badge-dot,
  .sched-hero-dot,
  #sched-list-wrap {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  #page-schedule .sched-reveal { opacity: 1; }
}
