/**
 * AVIHPSAM Video Sidebar Styles
 * Collapsible video playlist sidebar for topic pages
 */

/* ============================================
   VIDEO SIDEBAR CONTAINER
   ============================================ */

#video-sidebar {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.video-sidebar {
  background: var(--bg-secondary, #f8f5f0);
  border: 1px solid var(--border-color, #e0d6c8);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.video-sidebar.collapsed .video-sidebar-content {
  display: none;
}

/* ============================================
   SIDEBAR HEADER
   ============================================ */

.video-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--primary-color, #8B4513);
  color: white;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.video-sidebar-header:hover {
  background: var(--primary-dark, #6d3610);
}

.video-sidebar-icon {
  font-size: 1.1rem;
}

.video-sidebar-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.video-sidebar-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.video-sidebar-toggle {
  font-size: 1.2rem;
  font-weight: bold;
  width: 24px;
  text-align: center;
}

/* ============================================
   SIDEBAR CONTENT
   ============================================ */

.video-sidebar-content {
  padding: 8px;
}

.video-curated-badge {
  background: linear-gradient(135deg, #d4af37 0%, #f5d742 100%);
  color: #3d2600;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================
   VIDEO CARDS
   ============================================ */

.video-card {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.video-card:hover {
  background: rgba(0, 0, 0, 0.05);
}

.video-card:focus {
  outline: 2px solid var(--primary-color, #8B4513);
  outline-offset: 2px;
}

.video-card.playing {
  background: rgba(139, 69, 19, 0.08);
}

/* Thumbnail */
.video-thumbnail {
  position: relative;
  width: 168px;
  min-width: 168px;
  height: 94px;
  border-radius: 8px;
  overflow: hidden;
  background: #ddd;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* YouTube-style duration badge */
.video-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  font-family: 'Roboto', 'Arial', sans-serif;
}

.video-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.video-card:hover .video-play-icon {
  opacity: 1;
}

.video-card.playing .video-play-icon {
  opacity: 1;
  background: var(--primary-color, #8B4513);
}

/* Video Info */
.video-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 2px;
}

.video-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color, #0f0f0f);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.video-channel {
  font-size: 0.75rem;
  color: var(--text-muted, #606060);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.video-views {
  font-size: 0.75rem;
  color: var(--text-muted, #606060);
  line-height: 1.4;
}

.video-now-playing {
  font-size: 0.65rem;
  color: var(--primary-color, #8B4513);
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   LOADING STATE
   ============================================ */

.video-loading {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted, #666);
}

.video-loading-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border: 3px solid var(--border-color, #e0d6c8);
  border-top-color: var(--primary-color, #8B4513);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.video-loading p {
  font-size: 0.85rem;
  margin: 0;
}

/* ============================================
   EMPTY & ERROR STATES
   ============================================ */

.video-empty,
.video-error {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted, #666);
  font-size: 0.85rem;
}

.video-empty p,
.video-error p {
  margin: 0;
}

/* ============================================
   VIDEO MODAL
   ============================================ */

.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.video-modal.active {
  opacity: 1;
  visibility: visible;
}

.video-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
}

.video-modal-content {
  position: relative;
  width: 90vw;
  max-width: 960px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.video-modal.active .video-modal-content {
  transform: scale(1);
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1a1a1a;
  color: white;
}

.video-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 50px);
}

.video-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.video-modal-close:hover {
  opacity: 1;
}

.video-modal-player {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  background: #000;
}

.video-modal-player iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

@media (max-width: 1200px) {
  #video-sidebar {
    position: static;
    max-height: none;
    margin-top: 24px;
  }

  .video-sidebar {
    max-width: 100%;
  }

  .video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .video-modal-content {
    width: 100vw;
    max-width: none;
    height: 100vh;
    border-radius: 0;
  }

  .video-modal-player {
    padding-top: 0;
    height: calc(100vh - 56px);
  }

  .video-modal-player iframe {
    position: static;
    width: 100%;
    height: 100%;
  }

  .video-thumbnail {
    width: 120px;
    min-width: 120px;
    height: 68px;
  }

  .video-list {
    grid-template-columns: 1fr;
  }

  .video-duration {
    font-size: 0.7rem;
    padding: 1px 3px;
  }
}

@media (max-width: 480px) {
  .video-sidebar-header {
    padding: 10px 12px;
  }

  .video-card {
    padding: 6px;
    gap: 8px;
  }

  .video-thumbnail {
    width: 100px;
    min-width: 100px;
    height: 56px;
  }

  .video-title {
    font-size: 0.8rem;
  }

  .video-channel,
  .video-views {
    font-size: 0.7rem;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
  .video-sidebar {
    background: #2a2520;
    border-color: #3d352d;
  }

  .video-card {
    background: transparent;
  }

  .video-card:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  .video-card.playing {
    background: rgba(201, 166, 107, 0.1);
  }

  .video-title {
    color: #e8e0d5;
  }

  .video-channel,
  .video-views {
    color: #a0978c;
  }

  .video-loading,
  .video-empty,
  .video-error {
    color: #a0978c;
  }
}

/* Dark mode class-based (for explicit toggle) */
.dark-mode .video-sidebar,
[data-theme="dark"] .video-sidebar {
  background: #2a2520;
  border-color: #3d352d;
}

.dark-mode .video-card,
[data-theme="dark"] .video-card {
  background: transparent;
}

.dark-mode .video-card:hover,
[data-theme="dark"] .video-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dark-mode .video-title,
[data-theme="dark"] .video-title {
  color: #e8e0d5;
}

.dark-mode .video-channel,
.dark-mode .video-views,
[data-theme="dark"] .video-channel,
[data-theme="dark"] .video-views {
  color: #a0978c;
}
