/**
 * YouTube Playlist LMS-Style Component
 * Minimalist design with blue accents and soft shadows
 */

:root {
  --yt-primary-blue: #4285f4;
  --yt-light-blue: #e8f0fe;
  --yt-dark-blue: #1a73e8;
  --yt-text-primary: #202124;
  --yt-text-secondary: #5f6368;
  --yt-text-muted: #9aa0a6;
  --yt-border-light: #e8eaed;
  --yt-border-lighter: #f1f3f4;
  --yt-background: #ffffff;
  --yt-background-hover: #f8f9fa;
  --yt-shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.08);
  --yt-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
  --yt-shadow-active: 0 1px 6px rgba(66, 133, 244, 0.15);
  --yt-radius: 8px;
  --yt-radius-small: 4px;
  --sidebar-width: 300px;
  --video-height: 400px;
}

.youtube-playlist-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--yt-background);
  border-radius: var(--yt-radius);
  box-shadow: var(--yt-shadow-soft);
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.youtube-playlist-container:hover {
  box-shadow: var(--yt-shadow-hover);
}

/* Loading and Error States */
.playlist-loading,
.playlist-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--yt-text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--yt-border-light);
  border-top: 3px solid var(--yt-primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.playlist-error {
  color: #d93025;
  background: #fce8e6;
  border: 1px solid #f9ab9d;
  border-radius: var(--yt-radius-small);
  margin: 20px;
}

/* Header */
.playlist-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--yt-border-lighter);
  background: linear-gradient(135deg, var(--yt-light-blue) 0%, rgba(255, 255, 255, 0.8) 100%);
}

.playlist-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--yt-text-primary);
  line-height: 1.3;
}

.playlist-description {
  margin: 0;
  color: var(--yt-text-secondary);
  font-size: 14px;
  line-height: 1.4;
  max-width: 600px;
}

/* Main Layout */
.playlist-layout {
  display: flex;
  min-height: var(--video-height);
}

/* Sidebar */
.playlist-sidebar {
  width: var(--sidebar-width);
  background: var(--yt-background-hover);
  border-right: 1px solid var(--yt-border-light);
  overflow-y: auto;
  max-height: 600px;
}

.video-list {
  padding: 8px;
}

.video-item {
  display: flex;
  padding: 12px;
  margin-bottom: 4px;
  border-radius: var(--yt-radius-small);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: var(--yt-background);
}

.video-item:hover {
  background: var(--yt-background-hover);
  transform: translateY(-1px);
  box-shadow: var(--yt-shadow-soft);
}

.video-item.active {
  background: var(--yt-light-blue);
  border-color: var(--yt-primary-blue);
  box-shadow: var(--yt-shadow-active);
}

.video-thumbnail {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 45px;
  margin-right: 12px;
  border-radius: var(--yt-radius-small);
  overflow: hidden;
  background: var(--yt-border-lighter);
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.video-item:hover .video-thumbnail img {
  transform: scale(1.05);
}

.video-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 2px;
  font-weight: 500;
}

.video-info {
  flex: 1;
  min-width: 0;
}

.video-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--yt-text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-item.active .progress-indicator {
    color: #357ABD;
    font-weight: 700;
}

/* Player Section */
.playlist-player {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.video-wrapper {
  position: relative;
  width: 100%;
  height: var(--video-height);
  background: #000;
}

.video-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Current Video Info */
.current-video-info {
  padding: 20px 24px;
  background: var(--yt-background);
  border-top: 1px solid var(--yt-border-lighter);
}

.current-video-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--yt-text-primary);
  line-height: 1.4;
}

.current-video-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.video-progress-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    width: 100%;
}

.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-ring {
    width: 28px;
    height: 28px;
    transform: rotate(-90deg);
    flex-shrink: 0;
}

.progress-ring-bg {
    stroke: #e5e7eb;
    stroke-width: 2;
}

.progress-ring-circle {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 79;
    stroke-dashoffset: 79;
    transition: stroke-dashoffset 0.3s ease;
}

.progress-wrapper.completed .progress-ring-circle {
    stroke: #10b981;
}

.progress-text {
    font-size: 9px;
    font-weight: 600;
    color: #374151;
    min-width: 25px;
    text-align: left;
}

.progress-wrapper.completed .progress-text {
    color: #10b981;
}

.mark-done-btn {
    background: #fff !important;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mark-done-btn:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.mark-done-btn.completed {
    color: #16a34a;
    border-color: #16a34a;
}

.mark-done-btn.completed:hover {
    background-color: #f0fdf4;
}

.video-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 12px;
}

.mark-done-main-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mark-done-main-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.mark-done-main-btn.completed {
    background-color: #f0fdf4;
    border-color: #16a34a;
    color: #16a34a;
}

.mark-done-main-btn.completed:hover {
    background-color: #dcfce7;
}

.current-video-meta .video-duration {
  font-size: 13px;
  color: var(--yt-text-secondary);
  background: var(--yt-border-lighter);
  padding: 4px 8px;
  border-radius: var(--yt-radius-small);
}

.current-video-description {
  margin: 0;
  font-size: 14px;
  color: var(--yt-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Responsive Design */
@media (max-width: 768px) {
  .playlist-layout {
    flex-direction: column;
  }
  
  .playlist-sidebar {
    width: 100%;
    max-height: 200px;
    order: 2;
  }
  
  .playlist-player {
    order: 1;
  }
  
  .video-wrapper {
    height: 250px;
  }
  
  .playlist-header {
    padding: 16px;
  }
  
  .playlist-title {
    font-size: 20px;
  }
  
  .current-video-info {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .video-item {
    padding: 8px;
  }
  
  .video-thumbnail {
    width: 60px;
    height: 34px;
    margin-right: 8px;
  }
  
  .video-title {
    font-size: 12px;
  }
  
  .current-video-title {
    font-size: 16px;
  }
}

/* Accessibility */
.video-item:focus {
  outline: 2px solid var(--yt-primary-blue);
  outline-offset: 2px;
}

/* Smooth scrolling for sidebar */
.playlist-sidebar {
  scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
.playlist-sidebar::-webkit-scrollbar {
  width: 6px;
}

.playlist-sidebar::-webkit-scrollbar-track {
  background: var(--yt-border-lighter);
}

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

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

/* Error styling for shortcode */
.youtube-playlist-error {
  background: #fce8e6;
  border: 1px solid #f9ab9d;
  color: #d93025;
  padding: 16px;
  border-radius: var(--yt-radius-small);
  margin: 16px 0;
  font-size: 14px;
}