/* ========================================
   YOUTUBE SECTION - MODERN STYLES
   Bổ sung CSS cho section nghe nhạc YouTube
   ======================================== */

/* ==================== YOUTUBE SECTION ==================== */
.section-youtube {
  background: var(--color-surface);
  position: relative;
}

.youtube-wrapper {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: var(--space-6);
  margin-top: var(--space-8);
}

/* ==================== YOUTUBE PLAYER ==================== */
.youtube-player-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.youtube-player-container:hover {
  box-shadow: var(--shadow-xl);
}

#youtube-player {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: block;
}

/* Video Info */
.video-info {
  padding: var(--space-5);
  border-bottom: 2px solid var(--color-divider);
  background: var(--color-bg);
}

.video-info h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Video Controls */
.video-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-bg);
}

.control-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.control-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: var(--shadow-lg);
}

.control-btn:active {
  transform: translateY(-1px) scale(1.02);
}

.control-btn-play {
  width: 64px;
  height: 64px;
  font-size: var(--text-xl);
  background: var(--gradient-primary);
  box-shadow: var(--shadow-lg);
}

.control-btn-play:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: var(--shadow-xl);
}

.control-btn.active {
  background: var(--gradient-accent);
  animation: pulse 2s ease-in-out infinite;
}

/* ==================== YOUTUBE SIDEBAR ==================== */
.youtube-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Add Video Box */
.add-video-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.add-video-box:hover {
  box-shadow: var(--shadow-md);
}

.add-video-box h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.add-video-box h3 i {
  color: var(--color-primary);
  font-size: var(--text-xl);
}

.add-video-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.youtube-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
}

.youtube-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.1);
  background: white;
}

.youtube-input::placeholder {
  color: var(--color-text-muted);
}

.btn-add-video {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.btn-add-video:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-add-video:active {
  transform: translateY(0);
}

.btn-add-video i {
  font-size: var(--text-base);
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: rgba(230, 57, 70, 0.05);
  border-radius: var(--radius-md);
}

.input-hint i {
  color: var(--color-primary);
  font-size: var(--text-sm);
}

/* ==================== PLAYLIST ==================== */
.playlist-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 600px;
}

.playlist-section h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.playlist-section h3 i {
  color: var(--color-primary);
  font-size: var(--text-xl);
}

.playlist-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
}

/* Custom Scrollbar */
.playlist-container::-webkit-scrollbar {
  width: 6px;
}

.playlist-container::-webkit-scrollbar-track {
  background: transparent;
}

.playlist-container::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.playlist-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Empty Playlist */
.empty-playlist {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
}

.empty-playlist i {
  font-size: 4rem;
  color: var(--color-border);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-playlist p {
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ==================== PLAYLIST ITEMS ==================== */
.playlist-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  background: transparent;
}

.playlist-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.playlist-item:hover {
  background: var(--color-bg);
  transform: translateX(4px);
}

.playlist-item.active {
  background: linear-gradient(90deg, rgba(230, 57, 70, 0.1) 0%, transparent 100%);
  border-left: 4px solid var(--color-primary);
  padding-left: calc(var(--space-3) - 4px);
}

.playlist-item.active::before {
  opacity: 1;
}

/* Playlist Thumbnail */
.playlist-item-thumbnail {
  position: relative;
  width: 90px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.playlist-item-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-base);
}

.playlist-item:hover .playlist-item-thumbnail img {
  transform: scale(1.1);
}

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-xl);
  opacity: 0;
  transition: all var(--transition-base);
}

.playlist-item:hover .play-overlay,
.playlist-item.active .play-overlay {
  opacity: 1;
}

.play-overlay i {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Playlist Item Info */
.playlist-item-info {
  flex: 1;
  min-width: 0;
}

.playlist-item-info h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
  margin-bottom: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-index {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playlist-item.active .video-index {
  color: var(--color-primary);
}

/* Remove Video Button */
.remove-video-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-danger);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.playlist-item:hover .remove-video-btn {
  opacity: 1;
  transform: scale(1);
}

.remove-video-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.remove-video-btn:active {
  transform: scale(0.95);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.playlist-item {
  animation: fadeInSlide 0.3s ease-out;
}

/* Pulse animation cho nút đang phát */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(230, 57, 70, 0);
  }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .youtube-wrapper {
    grid-template-columns: 1fr 350px;
  }
}

@media (max-width: 768px) {
  .youtube-wrapper {
    grid-template-columns: 1fr;
  }
  
  .youtube-sidebar {
    order: -1;
  }
  
  .playlist-section {
    max-height: 400px;
  }
  
  .video-controls {
    gap: var(--space-2);
    padding: var(--space-4);
  }
  
  .control-btn {
    width: 42px;
    height: 42px;
    font-size: var(--text-sm);
  }
  
  .control-btn-play {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
  }
}

@media (max-width: 480px) {
  .youtube-wrapper {
    gap: var(--space-4);
  }
  
  .add-video-box,
  .playlist-section {
    padding: var(--space-4);
  }
  
  .playlist-item-thumbnail {
    width: 70px;
    height: 48px;
  }
  
  .control-btn {
    width: 38px;
    height: 38px;
    font-size: var(--text-xs);
  }
  
  .control-btn-play {
    width: 48px;
    height: 48px;
    font-size: var(--text-base);
  }
  
  .video-controls {
    gap: var(--space-1);
    padding: var(--space-3);
  }
}

/* ==================== LOADING STATE ==================== */
.youtube-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.youtube-loading i {
  font-size: var(--text-4xl);
  color: var(--color-primary);
  animation: spin 1s linear infinite;
}

/* ==================== UTILITIES ==================== */
.video-controls .control-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.playlist-item[data-playing="true"] .playlist-item-thumbnail::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--color-primary);
  border-radius: var(--radius-md);
  animation: borderPulse 2s ease-in-out infinite;
}

@keyframes borderPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ==================== DARK MODE SUPPORT (Optional) ==================== */
@media (prefers-color-scheme: dark) {
  .video-info,
  .video-controls,
  .youtube-input {
    background: rgba(0, 0, 0, 0.1);
  }
}

/* ==================== ACCESSIBILITY ==================== */
.control-btn:focus-visible,
.btn-add-video:focus-visible,
.youtube-input:focus-visible,
.playlist-item:focus-visible {
  outline: 3px solid rgba(230, 57, 70, 0.5);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .playlist-item,
  .control-btn,
  .play-overlay {
    animation: none;
    transition: none;
  }
}
