/* =========================
   PLAYER - ACTUAL REDESIGN
========================= */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at top center, rgba(255, 0, 60, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(2, 4, 10, 0.72), rgba(2, 4, 10, 0.92));
  backdrop-filter: blur(18px);
}

.player-overlay.active {
  display: flex;
}

.player-shell {
  position: relative;
  width: min(1680px, 98vw);
  height: min(95vh, 980px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
}

/* =========================
   CLOSE
========================= */
.close-player {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.92);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 50;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.close-player:hover {
  transform: scale(1.06);
  background: rgba(20, 25, 36, 0.98);
  border-color: rgba(255,255,255,0.18);
}

/* =========================
   HEADER
========================= */
.player-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.06);
  background:
    linear-gradient(180deg, rgba(8, 12, 20, 0.96), rgba(5, 8, 15, 0.96));
  box-shadow: 0 14px 36px rgba(0,0,0,0.24);
}

.player-header-left {
  min-width: 0;
}

.player-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}

.player-title {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: -0.05em;
  font-weight: 950;
  color: #fff;
}

.player-meta {
  margin-top: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255,255,255,0.58);
}

.player-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================
   TOOLBAR
========================= */
.player-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(6, 10, 18, 0.86);
  box-shadow: 0 10px 24px rgba(0,0,0,0.16);
}

.tv-controls {
  display: grid;
  grid-template-columns: 180px minmax(260px, 420px);
  gap: 10px;
  align-items: end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.control-group.grow {
  min-width: 0;
}

.control-group label {
  font-size: 0.68rem;
  font-weight: 900;
  color: rgba(255,255,255,0.48);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.control-group select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 0.94rem;
  font-weight: 800;
  outline: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.control-group select:hover,
.control-group select:focus {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}

.control-group select option {
  background: #0f131b;
  color: #fff;
}

.player-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.player-btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 0.90rem;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.player-btn:hover {
  transform: translateY(-1px);
}

.player-btn.subtle:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.18);
}

.player-btn.primary {
  background: linear-gradient(180deg, #ff3346, #e20f24);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 12px 24px rgba(226, 15, 36, 0.28);
}

.player-btn.primary:hover {
  filter: brightness(1.08);
}

.player-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auto-next-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.88);
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.auto-next-toggle input {
  accent-color: #ff3346;
}

/* =========================
   MAIN
========================= */
.player-layout {
  display: block;
  min-height: 0;
  flex: 1;
}

.player-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* =========================
   VIDEO
========================= */
.player-video-card {
  position: relative;
  width: 100%;
  min-height: 0;
  height: clamp(420px, 68vh, 760px);
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.06);
  background:
    radial-gradient(circle at top center, rgba(255, 35, 55, 0.05), transparent 26%),
    linear-gradient(180deg, rgba(10, 13, 20, 1), rgba(2, 4, 8, 1));
  box-shadow:
    0 28px 80px rgba(0,0,0,0.48),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.player-video-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.03), transparent 16%);
  z-index: 1;
}

#playerFrame {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #000;
  position: relative;
  z-index: 0;
}

/* =========================
   FOOTER
========================= */
.player-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(5, 9, 15, 0.78);
}

.player-source,
.player-status {
  font-size: 0.82rem;
  font-weight: 800;
  color: rgba(255,255,255,0.60);
}

/* =========================
   EPISODE PANEL / DROPDOWN
========================= */
.episode-sidebar {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-height: 420px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(8, 11, 18, 0.97);
  box-shadow: 0 24px 60px rgba(0,0,0,0.38);
  z-index: 40;
}

.episode-sidebar.hidden {
  display: none;
}

.episode-sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.episode-sidebar-title {
  font-size: 0.92rem;
  font-weight: 900;
  color: #fff;
}

.episode-sidebar-subtitle {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.56);
}

.episode-sidebar-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.episode-sidebar-list::-webkit-scrollbar {
  width: 8px;
}

.episode-sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

.episode-dropdown-item {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  color: #fff;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.episode-dropdown-item + .episode-dropdown-item {
  margin-top: 6px;
}

.episode-dropdown-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.06);
  transform: translateX(2px);
}

.episode-dropdown-item.active {
  background: linear-gradient(180deg, rgba(255, 51, 70, 0.16), rgba(255, 51, 70, 0.08));
  border-color: rgba(255, 51, 70, 0.28);
}

.episode-dropdown-item .episode-code {
  display: block;
  margin-bottom: 4px;
  font-size: 0.70rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
}

.episode-dropdown-item .episode-name {
  display: block;
  font-size: 0.90rem;
  font-weight: 800;
  line-height: 1.3;
  color: #fff;
}

.empty-state {
  padding: 16px 12px;
  color: rgba(255,255,255,0.54);
  font-size: 0.9rem;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1100px) {
  .player-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tv-controls {
    grid-template-columns: 1fr 1fr;
  }

  .player-toolbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 780px) {
  .player-overlay {
    padding: 10px;
  }

  .player-shell {
    width: 100%;
    height: min(96vh, 1100px);
  }

  .player-header {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 14px;
  }

  .player-toolbar {
    padding: 12px;
  }

  .tv-controls {
    grid-template-columns: 1fr;
  }

  .player-toolbar-actions {
    justify-content: stretch;
  }

  .player-btn,
  .auto-next-toggle {
    width: 100%;
    justify-content: center;
  }

  .player-video-card {
    height: clamp(260px, 46vh, 520px);
  }

  .episode-sidebar {
    width: 100%;
    right: 0;
    left: 0;
  }
}

@media (max-width: 560px) {
  .player-title {
    font-size: 1.35rem;
  }

  .player-meta,
  .player-source,
  .player-status {
    font-size: 0.78rem;
  }

  .player-footer {
    grid-template-columns: 1fr;
  }
}