.epg-view {
  /* Algarismos de largura fixa: sem isso a grade de horarios treme a cada
     atualizacao, porque 1 e mais estreito que 0 nas fontes proporcionais. */
  font-feature-settings: "tnum";
  /* Passado recua (dessaturado, frio); ao vivo avanca (verde cheio). Os dois
     eram #5fc99a — identicos —, entao o guia nao distinguia o que ja passou do
     que esta no ar agora. */
  --past: #8d9a96;
  --live: #3ddc84;
  --future: #8c9cf0;

  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(228, 32, 47, 0.05), transparent 60%),
    var(--bg-primary);
}

.epg-header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.epg-header h2 {
  font-size: 24px;
  letter-spacing: 0.3px;
}

.epg-page-info {
  font-size: 18px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.epg-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 22px;
}

.epg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
}

.epg-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: var(--radius-sm);
}

.epg-legend-item.state-past .epg-legend-dot { background: var(--past); }
.epg-legend-item.state-future .epg-legend-dot { background: var(--future); }

.epg-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.epg-channels-pane {
  width: 480px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

.epg-channel-item {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(42, 42, 62, 0.5);
  transition: background 0.12s;
}

.epg-channel-item:hover {
  background: var(--surface-a);
}

.epg-channel-item.selected {
  background: rgba(228, 32, 47, 0.14);
  box-shadow: inset 4px 0 0 var(--accent);
}

.epg-channel-item.focused {
  background: var(--surface-b);
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.epg-ch-num {
  font-size: 18px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.epg-ch-name {
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.epg-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.epg-date-bar {
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
}

.epg-date-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border-top: 2px solid transparent;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.epg-date-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.epg-date-weekday {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.2;
}

.epg-date-date {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.epg-date-item.day-past { border-top-color: rgba(95, 201, 154, 0.45); }
.epg-date-item.day-past .epg-date-weekday { color: rgba(95, 201, 154, 0.8); }
.epg-date-item.day-future { border-top-color: rgba(140, 156, 240, 0.45); }
.epg-date-item.day-future .epg-date-weekday { color: rgba(140, 156, 240, 0.8); }

.epg-date-item.today {
  border: 1px solid var(--accent-dim);
  border-top-width: 2px;
}

.epg-date-item.selected {
  background: var(--accent);
  color: var(--bg-primary);
  border-top-color: transparent;
}

.epg-date-item.selected .epg-date-weekday {
  color: var(--bg-primary);
  opacity: 0.85;
}

.epg-date-item.focused {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.epg-programmes-pane {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
}

.epg-programme-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 15px 24px 15px 28px;
  cursor: pointer;
  border-bottom: 1px solid rgba(42, 42, 62, 0.5);
  transition: background 0.12s;
}

.epg-programme-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--row-color, var(--border));
}

.epg-programme-item.state-past { --row-color: var(--past); }
.epg-programme-item.state-live { --row-color: var(--live); }
.epg-programme-item.state-future { --row-color: var(--future); }

.epg-programme-item:hover {
  background: var(--surface-a);
}

.epg-programme-item.state-past .epg-prog-time { color: var(--past); }

.epg-programme-item.state-future .epg-prog-time { color: var(--future); }

.epg-programme-item.state-live {
  background: linear-gradient(90deg, rgba(95, 201, 154, 0.12), rgba(95, 201, 154, 0.04) 55%, transparent);
}
.epg-programme-item.state-live::before {
  box-shadow: 0 0 14px 1px rgba(95, 201, 154, 0.32);
  animation: epgRailPulse 2.4s ease-in-out infinite;
}
.epg-programme-item.state-live .epg-prog-time { color: var(--live); }

.epg-programme-item.focused {
  background: var(--surface-b);
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.epg-programme-item.focused .epg-prog-title { color: var(--text-primary); }
.epg-programme-item.focused .epg-prog-desc { opacity: 1; }

.epg-prog-time-col {
  flex-shrink: 0;
  width: 86px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 2px;
}

.epg-prog-time {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.epg-prog-dur {
  margin-top: 3px;
  font-size: 18px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.epg-replay-glyph {
  width: 14px;
  height: 14px;
  color: var(--past);
  vertical-align: -2px;
  margin-right: 3px;
}

.epg-prog-body {
  flex: 1;
  min-width: 0;
}

.epg-prog-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.epg-now-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--danger);
  padding: 4px 12px 4px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 1px;
  box-shadow: var(--glow-accent);
}

.epg-now-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: epgDotPulse 1.2s ease-in-out infinite;
}

.epg-prog-desc {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.epg-no-data {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 20px;
}

@keyframes epgRailPulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

@keyframes epgDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .epg-programme-item.state-live::before,
  .epg-now-dot { animation: none; }
}
