/* ============================================================
   EventPulseChat — style.css (FIXED)
   Key fix: .tab-content is hidden by default,
   only .tab-content.active (set by JS) is visible.
   The JS also directly sets style.display — belt & suspenders.
   ============================================================ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #0d1117;
  --bg-card:     #161b22;
  --bg-hover:    #1f2937;
  --accent:      #00ff88;
  --accent-dim:  #00cc6a;
  --red:         #ff4444;
  --blue:        #4fa3e0;
  --text:        #e6edf3;
  --text-dim:    #8b949e;
  --border:      #30363d;
  --tab-active:  #00ff88;
  --radius:      10px;
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ───────────────────────────────────────────────── */
.header {
  background: linear-gradient(90deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
  border-bottom: 2px solid var(--accent);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: 1px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 68, 68, 0.15);
  border: 1px solid var(--red);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

.countdown-display {
  font-size: 0.8rem;
  color: var(--text-dim);
}

#countdown {
  color: var(--accent);
  font-weight: 700;
}

/* ─── Tabs Navigation ──────────────────────────────────────── */
.tabs-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs-nav::-webkit-scrollbar { display: none; }

.tabs-list {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: max-content;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
  outline: none;
}

.tab-button:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── ACTIVE TAB — clear visual highlight ─── */
.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(0, 255, 136, 0.07);
}

.tab-icon { font-size: 1.2rem; }
.tab-label { font-size: 0.65rem; }

/* ─── Main Content ─────────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ─── Tab Content Panels ───────────────────────────────────── */
/*
   CRITICAL FIX:
   All panels start hidden. JS adds .active class AND sets
   style.display = 'block' on the selected panel.
   Both mechanisms together prevent any flash of wrong content.
*/
.tab-content {
  display: none;  /* hidden by default */
}

.tab-content.active {
  display: block; /* shown when JS adds .active class */
  animation: fadeIn 0.2s ease;
}

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

/* ─── Sport Header ─────────────────────────────────────────── */
.sport-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sport-header h2 {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  color: var(--text);
}

/* ─── Games Grid ───────────────────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ─── Game Card ────────────────────────────────────────────── */
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  outline: none;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.12);
}

.game-card.live {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(255, 68, 68, 0.2);
}

/* League badge — top left of card */
.card-league-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  margin-bottom: 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Live badge */
.live-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

/* Teams row */
.teams-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.team-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  text-align: center;
}

.team-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
}

.team-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.team-record {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.vs-separator {
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Score row */
.score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
}

.score {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  min-width: 30px;
  text-align: center;
}

.score-dash {
  font-size: 1rem;
  color: var(--text-dim);
}

/* Status row */
.status-row {
  text-align: center;
  margin: 6px 0;
}

.game-status {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 20px;
}

.game-status.status-live {
  color: var(--red);
  background: rgba(255, 68, 68, 0.1);
}

.game-status.status-final {
  color: var(--accent-dim);
  background: rgba(0, 204, 106, 0.08);
}

/* League name */
.league-name {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card event name */
.card-event-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card datetime */
.card-datetime {
  font-size: 0.65rem;
  color: var(--blue);
  text-align: center;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* No-games & Loading messages */
.no-games-msg,
.loading-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.no-games-msg small {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 520px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close-btn:hover { background: var(--red); border-color: var(--red); }
.modal-close-btn:focus-visible { outline: 2px solid var(--accent); }

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  padding-right: 40px;
  color: var(--text);
  line-height: 1.3;
}

/* Date + status row */
.modal-datetime-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.modal-datetime {
  font-size: 0.78rem;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.modal-status-badge {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  padding: 2px 9px;
  border-radius: 20px;
}

.modal-scoreline {
  display: flex;
  flex-direction: row;       /* ← HORIZONTAL: team | scores | team */
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  margin-bottom: 20px;
}

.modal-team {
  display: flex;
  flex-direction: column;    /* logo stacked above name */
  align-items: center;
  gap: 6px;
  flex: 1;
  text-align: center;
  min-width: 0;
}

.modal-team-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  animation: logoFadeIn 0.3s ease;
}

@keyframes logoFadeIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-team-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.modal-team-abbr {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
}

.modal-team-record { font-size: 0.72rem; color: var(--text-dim); }

/* Score block — centre column, scores side by side */
.modal-scores {
  display: flex;
  flex-direction: row;       /* ← HORIZONTAL: away-score – home-score */
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 6px;
}

.modal-score {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.modal-score-dash { font-size: 1.4rem; color: var(--text-dim); line-height: 1; }

.modal-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 0.82rem;
}

.modal-meta dt { color: var(--text-dim); white-space: nowrap; }
.modal-meta dd { color: var(--text); }

/* ─── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .main-content { padding: 12px; }
  .games-grid { grid-template-columns: 1fr; }
  .tab-button { padding: 10px 12px; }
  .tab-label  { display: none; }
  .tab-icon   { font-size: 1.4rem; }
  .modal-box  { padding: 16px; }
  .modal-score { font-size: 1.8rem; }
  .modal-team-logo { width: 44px; height: 44px; }
  .modal-team-name { font-size: 0.78rem; max-width: 80px; }
}

@media (max-width: 900px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}
