.playlist-icon-container {
  position: relative;
  width: 24px;
  height: 24px;
}

.playlist-icon-img {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 3px hsl(var(--hue) 95% 70% / 70%));
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
  position: relative;
}

.playlist-corner-icon {
  position: absolute;
  top: 0;
  right: 0;
  width: 15px;
  height: 15px;
  z-index: 51;
  filter: none;
}

.playlist-item-badge {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  vertical-align: middle;
  position: relative;
  z-index: 10;
  filter: drop-shadow(0 0 5px hsl(var(--hue) 95% 70% / 90%)) drop-shadow(0 0 8px hsl(var(--hue) 95% 60% / 80%));
  animation: pulsate-badge 1.5s infinite ease-in-out;
}

@keyframes pulsate-badge {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 5px hsl(var(--hue) 95% 70% / 90%)) drop-shadow(0 0 8px hsl(var(--hue) 95% 60% / 80%));
  }

  50% {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px hsl(var(--hue) 95% 90% / 100%)) drop-shadow(0 0 12px hsl(var(--hue) 95% 80% / 90%))
      drop-shadow(0 0 16px hsl(var(--hue) 95% 70% / 80%));
  }
}

.playlist-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--control-bg-unified);
  backdrop-filter: var(--control-blur-unified);
  border-bottom: 1px solid var(--primary);
  border-radius: 0 0 6px 6px;
  padding: 15px 0;
  margin: -10px -10px 20px;
  width: 100%;
  /* Extend to full width of sidebar */
  padding-left: 10px;
  padding-right: 10px;
  /* Extend to top of sidebar */
  transition: box-shadow 0.3s ease;
}

.playlist-search-row:hover {
  box-shadow: var(--primary-hover-shadow);
}

.playlist-search-container {
  position: relative;
  flex: 1;
}

.search-icon-container {
  position: relative;
  width: 100%;
}

.search-icon-img {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  width: 20px;
  height: 20px;
}

.playlist-search {
  width: 100%;
  padding: 6px 26px 6px 30px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background-color: transparent;
  color: var(--text-color);
  font-size: 0.85em;
  transition:
    box-shadow 0.3s ease,
    border-color 0.3s ease;
  height: 32px;
  box-sizing: border-box;
}

.playlist-search:focus {
  outline: none;
  box-shadow: var(--neon-shadow);
  border-color: var(--primary-glow);
}

.playlist-search::placeholder {
  color: rgb(255 255 255 / 50%);
}

.playlist-search-clear.visible {
  visibility: visible;
}

.playlist-search-clear:hover {
  opacity: 1;
  color: var(--primary);
}

.playlist-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 0.7em;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
}

#playlist-reshuffle-button {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  min-width: 32px;
  height: 32px;
  flex-shrink: 0;
}

#playlist-items {
  margin: 0;
  padding: 0;
  contain: layout style;
  will-change: contents;
  padding-top: 10px; /* Increased padding to create space below the header */
}

.playlist-item {
  display: flex;
  flex-direction: column;
  padding: 8px 5px;
  margin-bottom: 10px;
  border-radius: 4px;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
  border: 1px solid transparent;
  position: relative;
}

.playlist-item:hover {
  box-shadow: var(--primary-light-shadow);
}

.play-next-button {
  position: absolute;
  top: 10px;
  right: 8px;
  background: rgb(0 0 0 / 70%);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  opacity: 0.8;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  box-shadow: 0 0 5px rgb(var(--primary-rgb), 0.5);
}

.play-next-button:hover {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 8px rgb(var(--primary-rgb), 0.7);
}

.play-next-button img {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 3px hsl(var(--hue) 95% 70% / 70%));
}

.playlist-item.current {
  border-color: var(--primary);
  background-color: #000;
  box-shadow: var(--primary-strong-shadow);
}

.playlist-item .thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 3px;
  background-color: rgb(255 255 255 / 10%);
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  margin-bottom: 5px;
}

.playlist-item .title {
  font-size: 0.9em;
  width: 100%;
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.playlist-item .title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.playlist-item .title.text-autoscroll-container {
  justify-content: flex-start;
  padding: 0 5px;
  overflow: hidden;
  width: 100%;
  position: relative;
  z-index: 1;
}

.playlist-item .title.text-autoscroll-container span {
  text-overflow: clip;
  overflow: visible;
  white-space: nowrap;
  max-width: none;
  padding-right: 40px;
}

.playlist-item.current .title {
  color: var(--secondary);
  font-weight: 300;
  opacity: 1;
}

.playlist-item.current .title.text-autoscroll-container {
  justify-content: flex-start;
}

.playlist-item-empty {
  padding: 20px;
  color: var(--text-color);
  opacity: 0.8;
  font-style: italic;
}

.playlist-item-loading {
  padding: 20px;
  color: var(--text-color);
  opacity: 0.8;
  font-style: italic;
}

.playlist-item.playlist-item-loading {
  position: relative;
  opacity: 0.7;
  pointer-events: none;
}

.playlist-item.playlist-item-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgb(var(--primary-rgb), 0.2), transparent);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  z-index: 1;
  border-radius: 4px;
}

@keyframes loading-shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.tooltip {
  position: relative;
}

.tooltip:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-color);
  padding: 5px 10px;
  font-size: 0.8em;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  border-radius: var(--control-radius-box);
  background: var(--control-bg-unified);
  backdrop-filter: var(--control-blur-unified);
  border: var(--control-border-unified);
  box-shadow: var(--control-shadow-unified);
}

#playlist-reshuffle-button:hover::after {
  content: none;
}

/* Keyframes for the "out" (disappearing) animation */
@keyframes shuffle-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-20px) scale(0.95);
  }
}

/* Keyframes for the "in" (appearing) animation */
@keyframes shuffle-in {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Class to apply the "out" animation */
.playlist-item-shuffle-out {
  animation: shuffle-out 0.25s ease-in forwards;
}

/* Class to apply the "in" animation */
.playlist-item-shuffle-in {
  opacity: 0; /* Start invisible */
  animation: shuffle-in 0.25s ease-out forwards;
}
