.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 85%;
  max-width: 380px;
  height: 100vh;
  background: var(--secondary);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  will-change: transform;
  z-index: 999;
  display: flex;
  flex-direction: column;
  box-shadow: 5px 0 20px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--primary);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebar-channels {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
}

.sidebar-channels::-webkit-scrollbar {
  width: 6px;
}

.sidebar-channels::-webkit-scrollbar-track {
  background: var(--accent);
  border-radius: 3px;
  margin: 4px 0;
}

.sidebar-channels::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-channels::-webkit-scrollbar-thumb:hover {
  background: var(--highlight);
}

/* Improved channel row with logo, name, quality, and fav button */
.sidebar-channel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-channel:hover {
  border-color: var(--highlight);
  transform: translateX(2px);
}

.sidebar-channel.active {
  border-color: var(--highlight);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.1), rgba(236, 72, 153, 0.05));
}

/* Channel logo visible */
.sidebar-channel .channel-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-channel .channel-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Text wrapper with scrolling support */
.sidebar-channel .channel-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}

/* Scrolling text for long names */
.sidebar-channel .channel-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Truncate instead of potentially pushing button */
  position: relative;
}

.sidebar-channel .channel-name-inner {
  display: inline-block;
  padding-right: 20px;
}

/* Enable scrolling animation for long names */
.sidebar-channel .channel-name.scrolling .channel-name-inner {
  animation: scroll-text 10s linear infinite;
}

@keyframes scroll-text {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

.sidebar-channel .channel-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quality badge */
.sidebar-channel .quality {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.18);
  color: #fecaca;
  border: 1px solid rgba(244, 63, 94, 0.3);
  flex-shrink: 0;
  font-weight: 600;
}

/* Favorite button on right side parallel to name */
.channel-fav {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: auto;
  /* Push to the right edge but respect padding */
}

.channel-fav:hover {
  transform: scale(1.08);
  border-color: rgba(248, 113, 113, 0.6);
}

.channel-fav .fav-icon {
  width: 16px;
  height: 16px;
  fill: transparent;
  stroke: rgba(148, 163, 184, 0.8);
  stroke-width: 2;
  transition: transform 0.2s ease, fill 0.2s ease;
}

.channel-fav.fav-active {
  background: rgba(24, 24, 27, 0.96);
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
}

.channel-fav.fav-active .fav-icon {
  fill: #f43f5e;
  stroke: #f43f5e;
  transform: scale(1.1);
}