/* ============================================================
   EPG Timeline Guide
   ============================================================ */

.epg-page {
  overflow-x: hidden;
}

.epg-main {
  max-width: 100%;
  margin: 0 auto;
  padding: 12px 0 40px;
}

/* Toolbar */
.epg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  max-width: 1440px;
  margin: 0 auto 12px;
}

.epg-toolbar-left,
.epg-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.epg-tool-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 20, 32, 0.9);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 750;
  transition: 0.15s;
}

.epg-tool-btn:hover {
  border-color: var(--border-hover);
  color: #fff;
}

.epg-tool-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #fff;
}

.epg-date-label {
  font-size: 13px;
  font-weight: 750;
  color: var(--text-soft);
  margin-left: 4px;
}

.fav-only-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.fav-only-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* Grid shell */
.epg-grid-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 160px 1fr;
  grid-template-rows: 40px 1fr;
  max-height: calc(100vh - 180px);
  overflow: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  /* smooth momentum scroll on touch */
  -webkit-overflow-scrolling: touch;
}

.epg-sticky-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #0c101c;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.epg-time-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 40px;
  background: #0c101c;
  border-bottom: 1px solid var(--border);
  min-width: max-content;
}

.epg-hour-tick {
  flex: 0 0 180px; /* 1 hour = 180px */
  width: 180px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  font-weight: 750;
  color: var(--text-muted);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
}

.epg-hour-tick.now-line {
  color: var(--accent);
}

.epg-channel-col {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #0a0d18;
  border-right: 1px solid var(--border);
  min-height: max-content;
}

.epg-channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.12s;
}

.epg-channel-row:hover {
  background: rgba(255, 63, 129, 0.06);
}

.epg-ch-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: #141a29;
  flex-shrink: 0;
}

.epg-ch-fallback {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #141a29;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #6b7589;
  flex-shrink: 0;
}

.epg-ch-name {
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.epg-programmes {
  position: relative;
  min-width: max-content;
}

.epg-prog-row {
  position: relative;
  height: 64px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.epg-prog-block {
  position: absolute;
  top: 6px;
  height: 52px;
  border-radius: 8px;
  padding: 6px 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 40px;
}

.epg-prog-block:hover {
  transform: translateY(-1px);
  z-index: 5;
  border-color: rgba(255, 63, 129, 0.5);
}

.epg-prog-block.live {
  background: linear-gradient(135deg, rgba(255, 63, 129, 0.22), rgba(255, 63, 129, 0.08));
  border-color: rgba(255, 63, 129, 0.35);
}

.epg-prog-block.upcoming {
  background: rgba(20, 28, 45, 0.95);
  border-color: var(--border);
}

.epg-prog-block.past {
  background: rgba(14, 18, 28, 0.7);
  opacity: 0.55;
}

.epg-prog-title {
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epg-prog-time {
  font-size: 9px;
  font-weight: 650;
  color: var(--text-muted);
  margin-top: 2px;
}

.epg-now-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

.epg-now-marker::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* Loading */
.epg-loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.epg-loading-hint {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 4px;
}

/* Mobile */
@media (max-width: 700px) {
  .epg-grid-wrap {
    grid-template-columns: 120px 1fr;
    max-height: calc(100vh - 200px);
  }

  .epg-channel-row {
    padding: 0 6px;
    gap: 6px;
  }

  .epg-ch-logo,
  .epg-ch-fallback {
    width: 28px;
    height: 28px;
  }

  .epg-ch-name {
    font-size: 10px;
  }

  .epg-hour-tick {
    flex-basis: 140px;
    width: 140px;
  }

  .epg-toolbar {
    padding: 10px 12px;
  }
}
