/* ================= Tin tức - Nâng cấp với màu chủ đạo #004658 ================= */
/* Không sử dụng :root để tránh xung đột với index.css */

.news-container {
  width: 100%;
  margin: 0;
  padding: 50px 20px;
  min-height: calc(100vh - 180px); /* Trừ chiều cao header và footer */
  box-sizing: border-box;
  background-color: #f8fcfd;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.news-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  z-index: 1;
}

.news-container h1 {
  text-align: center;
  font-size: clamp(2.2rem, 4.5vw, 3.2rem);
  margin-bottom: 50px;
  font-weight: 800;
  color: #004658;
  position: relative;
  padding-bottom: 20px;
  letter-spacing: -0.5px;
  max-width: 1200px;
  width: 100%;
}

.news-container h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 5px;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  border-radius: 3px;
}

#news {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(25px, 4vw, 35px);
  margin: 0 auto;
  max-width: 1400px;
  width: 100%;
  justify-content: center;
  align-items: start;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e1eef2;
  box-shadow: 0 6px 20px rgba(0, 70, 88, 0.1);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  position: relative;
  height: 100%;
  width: 100%;
  max-width: 380px; /* Giới hạn chiều rộng tối đa */
  margin: 0 auto; /* Căn giữa mỗi card */
}

.post-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 16px 32px rgba(0, 70, 88, 0.15);
  border-color: #005a73;
}

.post-thumb {
  width: 100%;
  height: clamp(180px, 30vw, 240px);
  object-fit: cover;
  border-bottom: 4px solid #005a73;
  transition: transform 0.6s ease;
}

.post-card:hover .post-thumb {
  transform: scale(1.08);
}

.post-thumb-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: clamp(180px, 30vw, 240px);
  background: linear-gradient(to bottom, transparent 50%, rgba(0, 70, 88, 0.4) 100%);
  pointer-events: none;
  z-index: 1;
}

.post-card > div {
  padding: clamp(20px, 4vw, 28px);
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  z-index: 2;
  text-align: center; /* Căn giữa nội dung */
}

.post-title {
  font-weight: 800;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: #1a2a32;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  transition: color 0.3s ease;
  text-align: center;
}

.post-card:hover .post-title {
  color: #004658;
}

.post-date {
  color: #ff7e5f;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin-bottom: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 126, 95, 0.1);
  border-radius: 20px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.post-date::before {
  content: "📅";
  font-size: 0.9em;
}

.post-excerpt {
  color: #3a4a52;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  margin-bottom: 24px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-grow: 1;
  font-style: italic;
  opacity: 0.9;
  text-align: center;
}

.read-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: clamp(12px, 2.5vw, 14px) clamp(18px, 4vw, 24px);
  background: linear-gradient(135deg, #004658 0%, #005a73 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  text-align: center;
  margin-top: auto;
  width: 100%;
  max-width: 200px;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  z-index: 1;
  letter-spacing: 0.5px;
  margin-left: auto;
  margin-right: auto;
}

.read-more::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #005a73 0%, #0088a8 100%);
  transition: left 0.4s ease;
  z-index: -1;
}

.read-more:hover {
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 70, 88, 0.3);
}

.read-more:hover::before {
  left: 0;
}

.read-more::after {
  content: "→";
  font-weight: 800;
  font-size: 1.1em;
  transition: transform 0.3s ease;
}

.read-more:hover::after {
  transform: translateX(6px);
}

/* Badge cho bài viết mới */
.post-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 20px;
  z-index: 3;
  box-shadow: 0 4px 10px rgba(255, 126, 95, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================= Responsive Mobile ================= */

/* Mobile màn hình nhỏ (max-width: 480px) */
@media screen and (max-width: 480px) {
  .news-container {
    padding: 30px 15px;
    min-height: calc(100vh - 150px);
  }
  
  .news-container h1 {
    margin-bottom: 30px;
    font-size: 1.9rem;
  }
  
  #news {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  
  .post-card {
    max-width: 100%;
  }
  
  .post-thumb {
    height: 200px;
  }
  
  .post-thumb-overlay {
    height: 200px;
  }
  
  .post-card > div {
    padding: 20px;
  }
  
  .read-more {
    padding: 14px 20px;
    min-height: 52px;
    max-width: 180px;
  }
}

/* Mobile màn hình trung bình (481px - 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  .news-container {
    padding: 40px 20px;
  }
  
  #news {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
  }
  
  .post-card {
    max-width: 100%;
  }
  
  .post-thumb {
    height: 220px;
  }
  
  .post-thumb-overlay {
    height: 220px;
  }
  
  .post-card > div {
    padding: 22px;
  }
  
  .read-more {
    max-width: 190px;
  }
}

/* Điều chỉnh cho màn hình rất nhỏ (max-width: 360px) */
@media screen and (max-width: 360px) {
  .news-container {
    padding: 25px 12px;
  }
  
  .news-container h1 {
    font-size: 1.7rem;
    margin-bottom: 25px;
  }
  
  .post-thumb {
    height: 180px;
  }
  
  .post-thumb-overlay {
    height: 180px;
  }
  
  .post-card > div {
    padding: 18px;
  }
  
  .read-more {
    font-size: 0.95rem;
    padding: 12px 18px;
    max-width: 170px;
  }
}

/* Tablet và desktop nhỏ (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .news-container {
    padding: 60px 30px;
  }
  
  #news {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
  }
  
  .post-card {
    max-width: 100%;
  }
}

/* Desktop lớn (1025px - 1440px) */
@media screen and (min-width: 1025px) and (max-width: 1440px) {
  .news-container {
    padding: 70px 40px;
  }
  
  #news {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 35px;
  }
  
  .post-card {
    max-width: 100%;
  }
}

/* Desktop rất lớn (1441px trở lên) */
@media screen and (min-width: 1441px) {
  .news-container {
    padding: 80px 60px;
  }
  
  #news {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
    max-width: 1600px;
  }
  
  .post-card {
    max-width: 100%;
  }
}

/* Điều chỉnh grid để căn giữa hoàn hảo */
@media screen and (min-width: 769px) {
  #news {
    display: grid;
    place-items: center;
  }
  
  .post-card {
    justify-self: center;
  }
}

/* Đảm bảo các phần tử con cũng căn giữa */
.post-card > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .read-more {
    padding: 16px 24px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 220px;
  }
  
  .post-card {
    border: 1px solid #e1eef2;
  }
  
  .post-card:active {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 70, 88, 0.15);
  }
  
  .read-more:active {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #005a73 0%, #0088a8 100%);
  }
  
  .read-more:hover {
    transform: none;
    box-shadow: 0 6px 15px rgba(0, 70, 88, 0.2);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .news-container {
    background-color: #0f1f24;
  }
  
  .news-container h1 {
    color: #5dbcd2;
  }
  
  .post-card {
    background: #1a2b32;
    border-color: #2a3b42;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
  
  .post-card:hover {
    border-color: #5dbcd2;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  }
  
  .post-title {
    color: #f0f6f8;
  }
  
  .post-card:hover .post-title {
    color: #5dbcd2;
  }
  
  .post-date {
    color: #ff9b83;
    background: rgba(255, 155, 131, 0.15);
  }
  
  .post-excerpt {
    color: #c8d6dd;
  }
  
  .post-thumb {
    border-bottom-color: #4aa8c4;
    opacity: 0.9;
  }
  
  .post-thumb-overlay {
    background: linear-gradient(to bottom, transparent 40%, rgba(29, 78, 96, 0.8) 100%);
  }
  
  .read-more {
    background: linear-gradient(135deg, #4aa8c4 0%, #5dbcd2 100%);
  }
  
  .read-more::before {
    background: linear-gradient(135deg, #5dbcd2 0%, #7ccfe3 100%);
  }
}

/* Hiệu ứng loading cho card */
@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(25px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.post-card {
  animation: cardAppear 0.6s ease forwards;
  opacity: 0;
  animation-delay: calc(var(--card-index, 0) * 0.1s);
}