/* =========================
   PAGE
========================= */
.posts-page {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* (Bạn đã bỏ heading "Bài viết mới" rồi -> có thể giữ class này nếu chỗ khác dùng) */
.posts-heading {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 32px;
  letter-spacing: -1px;
  color: #0f172a;
}

/* =========================
   SEARCH BAR + SUGGEST
========================= */
/* =========================
   BODY
========================= */
.post-body {
  padding: 20px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  /* Ensure full width for spacing */
  margin-bottom: 12px;
}

.badge-free {
  font-size: 11px;
  /* Slightly larger */
  font-weight: 700;
  color: #065f46;
  background: #ecfdf5;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  border: 1px solid #a7f3d0;
  display: inline-block;
}

.badge-pro {
  font-size: 11px;
  font-weight: 800;
  color: #9a3412;
  background: #fff7ed;
  padding: 4px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
  border: 1px solid #fed7aa;
}

.post-date {
  font-size: 13px;
  /* Stronger date */
  color: #64748b;
  font-weight: 500;
  margin-left: auto;
  /* Push to right just in case */
}

.post-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.4;
  color: #0f172a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: auto;
  /* Allow natural height */
  min-height: 50px;
  /* Ensure alignment if short */
}

.post-excerpt {
  color: #475569;
  font-size: 15px;
  /* Better readability */
  line-height: 1.6;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  /* Limit to 3 lines */
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: justify;
  /* Neater block */
}

.posts-search {
  position: relative;
  margin-bottom: 24px;
}

.posts-search__box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #eef2f7;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(2, 6, 23, 0.04);
  transition: all 0.2s ease;
}

.posts-search__box:focus-within {
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.06);
  transform: translateY(-1px);
}

.posts-search__box i {
  color: #94a3b8;
  font-size: 14px;
}

#posts-search-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

#posts-search-input::placeholder {
  color: #94a3b8;
  font-weight: 600;
}

.posts-search__clear {
  border: 0;
  background: #f1f5f9;
  color: #334155;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: all 0.15s ease;
}

.posts-search__clear:hover {
  background: #e2e8f0;
  transform: scale(1.02);
}

/* Suggest dropdown */
.posts-search__suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #eef2f7;
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.12);
  z-index: 50;
}

.posts-search__title {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
}

.posts-search__item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  background: #fff;
  cursor: pointer;
  display: block;
  transition: background 0.15s ease;
}

.posts-search__item:hover {
  background: #f8fafc;
}

.posts-search__itemTitle {
  font-size: 14px;
  font-weight: 750;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 4px;
}

.posts-search__itemMeta {
  font-size: 12px;
  color: #94a3b8;
}

.posts-search__more {
  width: 100%;
  border: 0;
  cursor: pointer;
  padding: 12px 14px;
  background: rgba(59, 130, 246, 0.06);
  color: #1d4ed8;
  font-weight: 800;
  font-size: 13px;
  transition: all 0.15s ease;
}

.posts-search__more:hover {
  background: rgba(59, 130, 246, 0.1);
}

.posts-search__empty {
  padding: 14px;
  font-size: 13px;
  color: #64748b;
}

/* highlight */
.posts-search mark {
  background: rgba(250, 204, 21, 0.35);
  padding: 0 3px;
  border-radius: 6px;
}

/* =========================
   GRID
========================= */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 28px;
}

/* =========================
   CARD (REMODERNIZED)
========================= */
.post-card {
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid #f1f5f9;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05),
    0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.post-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: #e2e8f0;
}

/* PRO VARIANT */
.post-card--pro {
  border-color: #fef08a;
  background: #ffffff;
}

.post-card--pro:hover {
  border-color: #fde047;
}

/* THUMBNAIL FIX */
.post-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  /* Standard video format */
  background: #f1f5f9;
  /* Light bg for contained images */
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* ✅ Show FULL image (no crop) */
  transition: transform 0.6s ease;
}

.post-card:hover .post-thumb img {
  transform: scale(1.05);
  /* Gentle zoom */
}

/* FOOTER FIX */
.post-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: center;
  /* Center content */
}

.read-more {
  width: 100%;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #3b82f6;
  background: #eff6ff;
  padding: 10px;
  border-radius: 12px;
  transition: all 0.2s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.read-more:hover {
  background: #3b82f6;
  color: #ffffff;
  gap: 6px;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* =========================
   LOADING / ERROR (đỡ bị trống UI)
========================= */
.loading {
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px dashed #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  font-weight: 700;
  text-align: center;
}

.error {
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.06);
  color: #991b1b;
  font-weight: 800;
  text-align: center;
}

/* =========================
   PAGINATION
========================= */
.posts-pagination {
  margin-top: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.posts-pagination button {
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.posts-pagination button:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}

.posts-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.posts-pagination span {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  margin: 0 12px;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 640px) {
  .posts-page {
    padding: 24px 16px;
  }

  .posts-search {
    margin-bottom: 18px;
  }

  .posts-search__box {
    padding: 12px 14px;
    border-radius: 16px;
  }

  #posts-search-input {
    font-size: 14px;
  }

  .posts-grid {
    gap: 24px;
    grid-template-columns: 1fr;
  }

  .post-card {
    border-radius: 16px;
  }

  .post-body {
    padding: 20px;
  }

  .post-title {
    font-size: 18px;
    height: auto;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .post-excerpt {
    -webkit-line-clamp: 2;
    line-clamp: 2;
    margin-bottom: 16px;
  }

  .badge-pro,
  .badge-free {
    padding: 3px 8px;
    font-size: 9px;
  }

  .posts-search__suggest {
    border-radius: 16px;
  }
}