/**
 * TGWV Widget: Sidebar bài viết mới nhất
 * (.widget-tgwv-sidebar-recent-articles)
 */

.tgwv-w-sidebar-recent {
  --tgwv-sidebar-recent-brand: var(--tgwv-brand);
  --tgwv-sidebar-recent-item-title: var(--tgwv-color-dark);
  --tgwv-sidebar-recent-border: rgba(15, 23, 42, 0.1);
  --tgwv-sidebar-recent-muted: #64748b;
  --tgwv-sidebar-recent-surface: var(--tgwv-color-light);

  margin: 0 0 1.25rem;
  overflow: hidden;
  border: 1px solid var(--tgwv-sidebar-recent-border);
  border-radius: 12px;
  background: var(--tgwv-sidebar-recent-surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

/* —— Tiêu đề widget —— */
.tgwv-w-sidebar-recent__head {
  padding: 8px 10px;
  background: var(--tgwv-sidebar-recent-brand);
}

.tgwv-w-sidebar-recent__title {
  margin: 0;
  padding: 0 0 0 0.7rem;
  border-left: 3px solid #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--tgwv-color-light);
  overflow-wrap: anywhere;
}

/* —— Nội dung —— */
.tgwv-w-sidebar-recent__body {
  padding: 0.45rem 0.6rem 0.6rem;
  background: var(--tgwv-sidebar-recent-surface);
}

.tgwv-w-sidebar-recent__empty {
  margin: 0.35rem 0;
  padding: 0.9rem 0.75rem;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--tgwv-sidebar-recent-muted);
  background: #f8fafc;
  border: 1px dashed var(--tgwv-sidebar-recent-border);
  border-radius: 8px;
}

.tgwv-w-sidebar-recent__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tgwv-w-sidebar-recent__item {
  margin: 0;
  border-bottom: 1px solid var(--tgwv-sidebar-recent-border);
}

.tgwv-w-sidebar-recent__item:last-child {
  border-bottom: none;
}

.tgwv-w-sidebar-recent__link {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.7rem 0.45rem;
  margin: 0;
  background: transparent;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.tgwv-w-sidebar-recent__link:hover,
.tgwv-w-sidebar-recent__link:focus-visible {
  background: rgba(15, 23, 42, 0.035);
  color: inherit;
  text-decoration: none;
  transform: translateX(2px);
}

.tgwv-w-sidebar-recent__link:focus-visible {
  outline: 2px solid var(--tgwv-sidebar-recent-brand);
  outline-offset: -2px;
}

.tgwv-w-sidebar-recent__thumb-wrap {
  flex: 0 0 84px;
  width: 84px;
  height: 63px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #eef0f3;
  box-shadow: 0 0 0 1px var(--tgwv-sidebar-recent-border);
}

.tgwv-w-sidebar-recent__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.25s ease;
}

.tgwv-w-sidebar-recent__link:hover .tgwv-w-sidebar-recent__thumb,
.tgwv-w-sidebar-recent__link:focus-visible .tgwv-w-sidebar-recent__thumb {
  transform: scale(1.045);
}

.tgwv-w-sidebar-recent__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.05rem;
}

.tgwv-w-sidebar-recent__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.38;
  color: var(--tgwv-sidebar-recent-item-title);
  transition: color 0.15s ease;
  overflow-wrap: anywhere;
}

.tgwv-w-sidebar-recent__link:hover .tgwv-w-sidebar-recent__name,
.tgwv-w-sidebar-recent__link:focus-visible .tgwv-w-sidebar-recent__name {
  color: var(--tgwv-sidebar-recent-brand);
}

.tgwv-w-sidebar-recent__date {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 12px;
  line-height: 1.3;
  color: var(--tgwv-sidebar-recent-muted);
}

.tgwv-w-sidebar-recent__date-icon {
  font-size: 15px;
  line-height: 1;
  width: 1em;
  text-align: center;
  opacity: 0.9;
}

/* Không ảnh */
.tgwv-w-sidebar-recent__list:not(.tgwv-w-sidebar-recent__list--with-thumb) .tgwv-w-sidebar-recent__link {
  align-items: center;
}

/* Không có tiêu đề: body có padding trên */
.tgwv-w-sidebar-recent:not(:has(.tgwv-w-sidebar-recent__head)) .tgwv-w-sidebar-recent__body {
  padding-top: 0.75rem;
}

.tgwv-w-sidebar-recent__footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.65rem 1rem 0.75rem;
  border-top: 1px solid var(--tgwv-sidebar-recent-border);
  background: #f8fafc;
}

.tgwv-w-sidebar-recent__view-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tgwv-sidebar-recent-brand);
  text-decoration: none;
}

.tgwv-w-sidebar-recent__view-all::after {
  content: "→";
  transition: transform 0.18s ease;
}

.tgwv-w-sidebar-recent__view-all:hover,
.tgwv-w-sidebar-recent__view-all:focus-visible {
  text-decoration: underline;
  color: var(--tgwv-sidebar-recent-brand);
}

.tgwv-w-sidebar-recent__view-all:hover::after,
.tgwv-w-sidebar-recent__view-all:focus-visible::after {
  transform: translateX(2px);
}

.tgwv-w-sidebar-recent__view-all:focus-visible {
  outline: 2px solid var(--tgwv-sidebar-recent-brand);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (max-width: 575.98px) {
  .tgwv-w-sidebar-recent {
    border-radius: 10px;
  }

  .tgwv-w-sidebar-recent__head {
    padding: 8px 10px;
  }

  .tgwv-w-sidebar-recent__body {
    padding-inline: 0.45rem;
  }

  .tgwv-w-sidebar-recent__link {
    gap: 0.65rem;
    padding: 0.65rem 0.35rem;
  }

  .tgwv-w-sidebar-recent__thumb-wrap {
    flex-basis: 72px;
    width: 72px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tgwv-w-sidebar-recent__link,
  .tgwv-w-sidebar-recent__thumb,
  .tgwv-w-sidebar-recent__view-all::after {
    transition: none;
  }

  .tgwv-w-sidebar-recent__link:hover,
  .tgwv-w-sidebar-recent__link:focus-visible,
  .tgwv-w-sidebar-recent__link:hover .tgwv-w-sidebar-recent__thumb,
  .tgwv-w-sidebar-recent__link:focus-visible .tgwv-w-sidebar-recent__thumb {
    transform: none;
  }
}
