/* TRENDING CARDS — dùng chung layout1 + library (trending-grid / trending-card) */
.trending-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.trending-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.trending-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

a.trending-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.trending-card-image {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.trending-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trending-card-image-placeholder {
  font-size: 3rem;
  color: #ccc;
}

.trending-card-pdf-preview {
  width: 100%;
  height: 200px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f7f7f7;
  overflow-x: auto;
  overflow-y: hidden;
}

.trending-card-pdf-page {
  flex-shrink: 0;
  width: calc(50% - 2px);
  height: 100%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.trending-card-pdf-page canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.trending-card-pdf-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-secondary, #64748b);
  font-size: 0.85rem;
}

.trending-card-content {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.trending-card-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.trending-card-badge {
  display: flex;
  gap: 0.5rem;
}

.badge-item {
  padding: 0.25rem 0.625rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-institution {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-subject {
  background: #f3e5f5;
  color: #6a1b9a;
}

.trending-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #0f172a);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.trending-card-title a {
  color: inherit;
  text-decoration: none;
}

.trending-card-title a:hover {
  color: var(--primary, #2563eb);
}

.trending-card-description {
  font-size: 0.85rem;
  color: var(--text-secondary, #64748b);
  margin-bottom: 1rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.trending-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
  margin-top: auto;
}

.trending-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #64748b);
  flex-wrap: wrap;
}

.trending-card-stats span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.trending-card-stats .mr-2 {
  margin-right: 0.5rem;
}

@media (max-width: 1200px) {
  .trending-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .trending-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .trending-card-content {
    padding: 1rem;
  }

  .trending-card-title {
    font-size: 0.9rem;
  }

  .trending-card-description {
    font-size: 0.8rem;
  }

  .trending-card-image,
  .trending-card-pdf-preview {
    height: 160px;
  }

  .trending-card-stats {
    font-size: 0.75rem;
    gap: 0.75rem;
  }
}

@media (max-width: 767px) {
  .trending-card-title {
    font-size: 0.85rem !important;
  }
}