/* ==========================================================================
   Content Areas
   ========================================================================== */
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
}

.content-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.content-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

/* ==========================================================================
   Topic Lists
   ========================================================================== */
.topic-list {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.topic-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition);
  cursor: pointer;
}

.topic-item:last-child {
  border-bottom: none;
}

.topic-item:hover {
  background-color: var(--bg-secondary);
}

.topic-item.pinned {
  background-color: rgba(0, 136, 204, 0.05);
}

.topic-item.featured {
  background-color: rgba(255, 193, 7, 0.05);
}

/* Hide video overlay when video is playing - higher specificity */
.topic-tiles-view .topic-item.video-playing .video-overlay {
  opacity: 0 !important;
  transition: opacity var(--transition);
}

.topic-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-right: 1rem;
  flex-shrink: 0;
}

.topic-icon.pinned {
  color: var(--primary-color);
}

.topic-icon.featured {
  color: #ffc107;
}

.topic-content {
  flex: 1;
  min-width: 0;
}

.topic-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-color);
  margin: 0.5em 0 0.5rem 0;
  line-height: 1.4;
  text-decoration: none;
}

.topic-title a {
  color: var(--primary-color);
  text-decoration: none;
}

.topic-title a:hover {
  color: var(--primary-hover);
}


[data-theme="dark"].topic-title a {
  color: var(--primary-color);
}

[data-theme="dark"].topic-title a:hover {
  color: var(--primary-hover);
}

.topic-excerpt {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.topic-category,
.topic-tag {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

.topic-category {
  background-color: var(--primary-color);
  color: white;
}

.topic-category:hover {
  background-color: var(--primary-hover);
  color: white;
}

.topic-tag {
  background-color: var(--border-color);
  color: var(--text-muted);
}

.topic-tag:hover {
  background-color: var(--text-muted);
  color: white;
}

.difficulty-badge {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.difficulty-beginner {
  background-color: #d4edda;
  color: #155724;
}

.difficulty-intermediate {
  background-color: #fff3cd;
  color: #856404;
}

.difficulty-advanced {
  background-color: #f8d7da;
  color: #721c24;
}

.topic-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: 1rem;
  min-width: 100px;
  flex-shrink: 0;
}

.topic-activity {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.topic-views {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */
.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.breadcrumb-separator {
  color: var(--text-muted);
  margin: 0 0.25rem;
}

.breadcrumb-current {
  color: var(--text-color);
  font-weight: 600;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Layout Switcher Controls
   ========================================================================== */
.layout-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.layout-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.layout-btn:hover {
  background-color: var(--bg-secondary);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.layout-btn.active {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.layout-btn .material-icons {
  font-size: 1.25rem;
}

/* ==========================================================================
   Topic Container Layouts
   ========================================================================== */
.topic-container {
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: all var(--transition);
}

/* List View (Default) - Make these more specific */
.topic-list-view .topic-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition);
  cursor: pointer;
}

.topic-list-view .topic-item:last-child {
  border-bottom: none;
}

.topic-list-view .topic-item:hover {
  background-color: var(--bg-secondary);
}

/* Hide tile content in list view */
.topic-list-view .topic-tile-content {
  display: none;
}

/* Ensure list content is visible in list view */
.topic-list-view .topic-list-content {
  display: flex;
  align-items: flex-start;
  width: 100%;
}

/* Tile View - Make these more specific */
.topic-tiles-view {
  background: none;
  border: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.topic-tiles-view .topic-item {
  background-color: var(--card-bg);
  
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  display: block;
  padding: 0;
}

.topic-tiles-view .topic-item:hover {
   box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Hide list content in tile view */
.topic-tiles-view .topic-list-content {
  display: none;
}

/* Ensure tile content is visible in tile view */
.topic-tiles-view .topic-tile-content {
  display: block;
}

/* ==========================================================================
   Tile View Specific Styles
   ========================================================================== */
.topic-media-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.topic-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.topic-video-container,
.topic-image,
.topic-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.topic-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition);
}

.topic-video.loaded {
  opacity: 1;
}

/* Video container shows featured image as background until video loads */
.topic-video-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.topic-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform var(--transition);
}

.topic-tiles-view .topic-item:hover .topic-image {
  transform: scale(1.1);
}

.topic-placeholder {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
}

.placeholder-icon {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* Video overlay */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition);
}

.topic-tiles-view .topic-item:hover .video-overlay {
  opacity: 0;
}

.play-icon {
  font-size: 3rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Topic badges */
.topic-badges {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pinned-badge {
  background: rgba(0, 136, 204, 0.9);
  color: white;
}

.featured-badge {
  background: rgba(255, 193, 7, 0.9);
  color: white;
}

.badge .material-icons {
  font-size: 1rem;
}

/* Tile info section */
.topic-tile-info {
  padding: 1rem;
}

.topic-tiles-view .topic-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.75rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

.topic-tiles-view .topic-title a {
  color: var(--text-color);
  text-decoration: none;
  transition: color var(--transition);
}

.topic-tiles-view .topic-title a:hover {
  color: var(--primary-color);
}

.topic-tiles-view .topic-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topic-tiles-view .topic-category {
  align-self: flex-start;
  padding: 0.25rem 0.5rem;
  background-color: var(--primary-color);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--transition);
}

.topic-tiles-view .topic-category:hover {
  background-color: var(--primary-hover);
  color: white;
}

.topic-stats-inline {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-item .material-icons {
  font-size: 1rem;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1024px) {
  .topic-tiles-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .layout-controls {
    align-self: flex-end;
  }
  
  .topic-tiles-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .topic-tile-info {
    padding: 0.75rem;
  }
}

@media (max-width: 480px) {

  .topic-tiles-view {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .topic-icon {display: none;}

  .layout-controls {
    align-self: stretch;
    justify-content: center;
  }
  
  .layout-btn {
    flex: 1;
    max-width: 80px;
  }
}

/* ==========================================================================
   Special States for Tiles
   ========================================================================== */
.topic-tiles-view .topic-item.pinned {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px rgba(0, 136, 204, 0.2);
}

.topic-tiles-view .topic-item.featured {
  border-color: #ffc107;
  box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.2);
}

/* Dark theme adjustments */
[data-theme="dark"] .badge {
  border-color: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .video-overlay {
  background: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .topic-placeholder {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
}

/* Animation for layout transitions */
.topic-container.layout-transitioning {
  pointer-events: none;
}

.topic-container.layout-transitioning .topic-item {
  transition: all 0.3s ease;
}