/*
Theme Name: xudua news
Theme URI: https://example.com/my-custom-theme
Author: Nhóm Sáng tạo trẻ
Author URI: https://example.com
Description: A modern starter theme for WordPress.
Version: 1.3.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: xudua-news
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* Reset & Basic Styles */
:root {
  --primary-color: #333333;
  --text-color: #000000;
  --bg-color: #ffffff;
  --brand-color: #d1111a; 
  --border-color: #e5e5e5;
  --meta-color: #888888;
  --font-family: Arial, Helvetica, sans-serif;
  --font-family-serif: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  color: var(--text-color);
  background-color: var(--bg-color);
  line-height: 1.5;
}

/* Alignment Classes */
.alignleft, .has-text-align-left {
  text-align: left;
}
.alignright, .has-text-align-right {
  text-align: right;
}
.aligncenter, .has-text-align-center {
  text-align: center;
}
.alignjustify, .has-text-align-justify {
  text-align: justify;
}

.site-container {
  max-width: 1300px; /* Tăng chiều rộng tổng thể của trang web để các cột có thêm nhiều không gian hiển thị */
  margin: 0 auto;
  padding: 0 15px;
}

/* Header & Navigation */
.site-header {
  background: var(--brand-color);
  position: relative;
}

.site-nav {
  display: flex;
  align-items: center;
  padding: 10px 0;
  position: relative;
}

.home-icon {
  margin-right: 15px;
}

.home-icon svg {
  fill: var(--bg-color);
}

.home-icon a {
  display: flex;
  align-items: center;
}

.custom-logo-link {
  display: inline-block;
}

.custom-logo {
  max-height: 40px;
  width: auto;
  display: block;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--bg-color);
  cursor: pointer;
  padding: 5px;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  flex: 1;
}

.site-nav a {
  text-decoration: none;
  color: var(--bg-color);
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

.site-nav a:hover, .site-nav li.current-menu-item > a {
  opacity: 0.8;
  text-decoration: underline;
}

.search-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--bg-color);
  margin-left: 25px; /* Increase spacing from menu */
}

/* Search Overlay Styling */
.search-overlay {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #fff;
  padding: 15px 0;
  z-index: 1000;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  border-top: 1px solid #eee;
}

.search-overlay.active {
  display: block;
}

.search-overlay .search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.search-overlay .search-field {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  outline: none;
}

.search-overlay .search-submit {
  background: var(--brand-color);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.search-overlay .search-close {
  font-size: 30px;
  cursor: pointer;
  color: #888;
  padding: 0 10px;
}

/* Main Content Area - 3 Columns Layout */
.main-news-area {
  margin-top: 30px;
  margin-bottom: 40px;
  display: grid;
  grid-template-columns: 28% 40% 28%; /* Cân bằng lại tỷ lệ: thu hẹp cột giữa, mở rộng 2 cột bên */
  gap: 2%;
}

/* Left Column */
.news-left-col {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Dùng gap thay vì space-between để khoảng cách đều nhau */
}

.news-left-item {
  display: flex;
  gap: 15px;
  border-bottom: 1px dashed #ddd;
  padding-bottom: 15px;
  margin-bottom: 0;
}

.news-left-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-left-thumb {
  flex-shrink: 0;
  width: 120px; /* Tăng kích thước ảnh bên trái một chút cho cân đối */
}

.news-left-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/10;
  object-fit: cover;
  display: block;
}

.news-left-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  font-weight: bold;
}

.news-left-title a {
  text-decoration: none;
  color: #333;
  /* Giới hạn tiêu đề tối đa 3 dòng, phần thừa sẽ biến thành dấu ... */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-left-title a:hover {
  color: var(--brand-color);
}

/* Center Column */
.news-center-col {
  display: flex;
  flex-direction: column;
}

.news-center-thumb {
  margin-bottom: 15px;
}

.news-center-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9; /* Đổi thành 16/9 để ảnh giữa bớt cao, giúp layout gọn hơn */
  object-fit: cover;
  display: block;
}

.news-center-title {
  margin: 0 0 10px 0;
  font-size: 26px;
  font-weight: bold;
  line-height: 1.3;
}

.news-center-title a {
  text-decoration: none;
  color: #000;
}

.news-center-title a:hover {
  color: var(--brand-color);
}

.news-center-excerpt {
  margin: 0;
  font-size: 16px;
  color: #555;
  line-height: 1.5;
}

/* Right Column */
.news-right-col {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Giảm gap giữa 2 bài viết xuống 15px */
}

.news-right-item {
  display: flex;
  flex-direction: column;
  gap: 8px; /* Giảm gap giữa ảnh và chữ */
  margin-bottom: 0;
}

.news-right-item:last-child {
  margin-bottom: 0;
}

.news-right-thumb {
  margin-bottom: 0;
}

.news-right-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9; /* Giảm chiều cao ảnh thành 16:9 giống ảnh giữa */
  object-fit: cover;
  display: block;
}

.news-right-title {
  margin: 0;
  font-size: 15px; /* Giảm font size bằng với cột trái */
  font-weight: bold;
  line-height: 1.4; /* Tăng nhẹ line-height cho dễ đọc */
}

.news-right-title a {
  text-decoration: none;
  color: #222;
  /* Giới hạn tiêu đề tối đa 4 dòng */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-right-title a:hover {
  color: var(--brand-color);
}

/* Responsive Main News Area */
@media (max-width: 992px) {
  .main-news-area {
    grid-template-columns: 100%;
    gap: 30px;
  }
  
  .news-center-col {
    order: -1; /* Move center to top on mobile */
  }
}

/* Category Sections */
.category-section {
  margin-top: 40px;
  margin-bottom: 40px;
}

.category-header {
  border-bottom: 2px solid var(--brand-color);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.category-title {
  background-color: var(--brand-color);
  color: var(--bg-color);
  margin: 0;
  padding: 5px 15px;
  font-size: 18px;
  font-weight: bold;
  text-transform: uppercase;
}

.category-title a {
  color: var(--bg-color);
  text-decoration: none;
}

.category-posts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.cat-post {
  display: flex;
  flex-direction: column;
}

.cat-post-thumb {
  margin-bottom: 10px;
}

.cat-post-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/10;
  object-fit: cover;
}

.cat-post-title {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  line-height: 1.3;
}

.cat-post-title a {
  color: #000000;
  text-decoration: none;
}

.cat-post-title a:hover {
  color: var(--brand-color);
}

/* Single Post Layout */
.single-layout-wrapper {
  display: grid;
  grid-template-columns: 68% 29%; /* Mở rộng khu vực bên phải (sidebar) để tiêu đề có thêm không gian */
  gap: 3%;
  margin-top: 40px;
  margin-bottom: 60px;
}

.single-main-content {
  display: flex;
  flex-direction: column;
}

.single-main-content .entry-title {
  font-size: 32px;
  margin-bottom: 15px;
  font-weight: bold;
}

.single-main-content .entry-meta {
  font-size: 14px;
  color: var(--meta-color);
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.single-sidebar .widget-title {
  font-size: 20px;
  border-bottom: 2px solid var(--brand-color);
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.sidebar-latest-posts {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.sidebar-latest-post {
  display: flex;
  gap: 12px; /* Giảm gap để nhường chỗ cho chữ */
  align-items: center;
  border-bottom: 1px dotted var(--border-color);
  padding-bottom: 15px;
}

.sidebar-latest-post:last-child {
  border-bottom: none;
}

.sidebar-thumb {
  width: 75px; /* Giảm nhẹ ảnh để nhường chỗ cho tiêu đề */
  flex-shrink: 0;
}

.sidebar-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 1/1;
  object-fit: cover;
}

.sidebar-info .sidebar-post-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.sidebar-info .sidebar-post-title a {
  text-decoration: none;
  color: var(--text-color);
  /* Giới hạn số dòng để tiêu đề không bị quá dài */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-info .sidebar-post-title a:hover {
  color: var(--brand-color);
}

/* Article Action Bar */
.article-action-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 60px;
  flex-shrink: 0;
  position: sticky;
  top: 100px;
  height: max-content;
  z-index: 10;
}

.action-btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 30px;
  padding: 5px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.font-zoom-group {
  gap: 5px;
  padding: 10px 5px;
}

.font-zoom-group button {
  background: none;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #333;
}

.zoom-indicator {
  font-size: 14px;
  font-weight: bold;
  margin: 5px 0;
}

.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--brand-color);
  color: var(--brand-color);
}

.comment-anchor-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.share-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.comment-count-indicator {
  font-size: 12px;
  color: #888;
  font-weight: bold;
}

.action-divider {
  width: 30px;
  border: 0;
  border-top: 1px solid #eee;
  margin: 5px 0;
}

@media (max-width: 992px) {
  .article-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    top: auto;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    background: #fff;
    padding: 10px;
    box-shadow: 0 -2px 15px rgba(0,0,0,0.1);
    height: auto;
    gap: 0;
  }
  .action-btn-group, .action-btn {
    flex-direction: row;
    border-radius: 20px;
    box-shadow: none;
    border-color: #f0f0f0;
  }
  .share-btns {
    flex-direction: row;
  }
  .font-zoom-group {
    flex-direction: row;
    padding: 2px 8px;
  }
  .action-divider {
    display: none;
  }
  .single-main-content {
    padding-bottom: 80px; /* Space for sticky bar */
  }
}

/* Custom Comments Area */
.comments-area {
  margin-top: 60px;
  border-top: 2px solid #eee;
  padding-top: 40px;
}

.comments-header-wrapper {
  margin-bottom: 30px;
}

.comments-title {
  font-size: 24px;
  font-weight: bold;
  margin: 0;
}

.comments-title .red-bar {
  color: var(--brand-color);
  font-weight: 900;
  margin-right: 5px;
}

.comment-input-wrapper {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  border: 1px solid #e0e0e0;
  padding: 10px;
  border-radius: 5px;
  background: #fdfdfd;
}

.comment-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.comment-avatar img, .comment-avatar svg {
  border-radius: 50%;
  display: block;
  width: 100%;
  height: 100%;
}

.comment-form-field {
  flex: 1;
}

.comment-form-field textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
}

.form-submit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-limit {
  font-size: 13px;
  color: #666;
  font-weight: bold;
}

.submit-btn.red-btn {
  background-color: var(--brand-color);
  color: white;
  border: none;
  padding: 10px 25px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
}

.submit-btn.red-btn:hover {
  opacity: 0.9;
}

.comment-form-author, .comment-form-email, .comment-form-captcha {
  margin-bottom: 10px;
}
.comment-form-author input, .comment-form-email input, .comment-form-captcha input[type="text"] {
  padding: 10px;
  width: 100%;
  max-width: 300px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Responsive */
@media (max-width: 992px) {
  .article-body-wrapper {
    flex-direction: column;
  }
  .article-action-bar {
    flex-direction: row;
    width: 100%;
    position: static;
    justify-content: center;
    margin-bottom: 20px;
  }
  .action-divider {
    transform: rotate(90deg);
  }
  .single-layout-wrapper {
    grid-template-columns: 100%;
  }
  .featured-post {
    grid-template-columns: 100%;
  }
  .featured-post-thumb { margin-bottom: 15px; }
  .category-posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .grid-posts-row {
    grid-template-columns: 100%;
  }
  .category-posts-grid {
    grid-template-columns: 100%;
  }
  .menu-toggle {
    display: block;
  }
  .site-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--brand-color);
    flex-direction: column;
    padding: 15px;
    z-index: 100;
  }
  .site-nav.toggled ul {
    display: flex;
  }
}

/* General Layout Fallbacks */
.site-content {
  padding: 40px 0;
}
.post-item {
  margin-bottom: 40px;
  border-bottom: 1px solid #eeeeee;
  padding-bottom: 20px;
}
@media (max-width: 992px) {
  .single-main-content {
    padding-bottom: 80px; /* Space for sticky bar */
  }
  .single-sidebar {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
  }
}

.site-footer {
  margin-top: 60px;
  padding: 40px 0;
  clear: both;
  border-top: 1px solid #eeeeee;
  text-align: center;
  font-size: 14px;
  color: #666666;
}

/* Ensure text justification for content imported from Word/Mammoth */
.entry-content p:not(.has-text-align-center):not(.has-text-align-right):not([style*="center"]):not([style*="right"]),
.entry-content div:not(.has-text-align-center):not(.has-text-align-right):not([style*="center"]):not([style*="right"]),
.entry-content li:not(.has-text-align-center):not(.has-text-align-right):not([style*="center"]):not([style*="right"]) {
  text-align: justify !important;
}

/* Center all images in the content */
.entry-content img {
  display: block;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Center tables containing images */
.entry-content table:has(img) {
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Fix for Mammoth docx images in tables: use flexbox to add gap and prevent cropping */
.entry-content table:has(img) {
  display: flex !important;
  flex-direction: column;
  width: 100%;
  margin-bottom: 20px;
}
.entry-content table:has(img) tbody {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Khoảng cách giữa các hàng ngang */
  width: 100%;
}
.entry-content table:has(img) tr {
  display: flex;
  gap: 15px; /* Khoảng cách giữa các cột (các ảnh) */
  width: 100%;
  align-items: flex-start; /* Để ảnh giữ nguyên chiều cao tự nhiên, không bị kéo dãn */
}
.entry-content table td:has(img) {
  flex: 1; /* Chia đều độ rộng cho các ảnh */
  padding: 0 !important;
  border: none !important;
  display: flex;
  flex-direction: column;
  gap: 15px; /* Thêm khoảng cách giữa các ảnh nằm chồng lên nhau trong cùng 1 cột */
}
/* Hide empty paragraphs that Word often generates which cause overflow */
.entry-content table td:has(img) p:empty,
.entry-content table td:has(img) p:not(:has(img)) {
  display: none !important;
}
/* Ensure intermediate wrappers like <p> inherit properly */
.entry-content table td:has(img) > * {
  margin: 0 !important;
  padding: 0 !important;
}
.entry-content table td img {
  width: 100% !important;
  height: auto !important; /* Cho ảnh tự động chiều cao theo tỷ lệ gốc */
  object-fit: contain !important; /* Đảm bảo không bao giờ bị cắt ảnh */
  display: block !important;
}

/* Forcibly hide any scrollbars on the table or wrappers */
.entry-content figure.wp-block-table:has(img),
.entry-content figure.wp-block-table:has(img) *,
.entry-content table:has(img) * {
  scrollbar-width: none !important; /* Firefox */
  -ms-overflow-style: none !important; /* IE/Edge */
}
.entry-content figure.wp-block-table:has(img)::-webkit-scrollbar,
.entry-content figure.wp-block-table:has(img) *::-webkit-scrollbar,
.entry-content table:has(img) *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
/* Print Styles */
@media print {
  @page {
    size: A4 portrait;
    margin: 2cm;
  }

  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .site-footer,
  .single-sidebar,
  .article-action-bar,
  .comments-area,
  .entry-meta,
  .site-nav,
  .widget-area {
    display: none !important;
  }

  .single-layout-wrapper {
    display: block !important;
  }

  .single-main-content {
    width: 100% !important;
    display: block !important;
    padding: 0 !important;
  }

  .article-body-wrapper {
    display: block !important;
  }

  .entry-title {
    font-size: 24pt !important;
    margin-bottom: 20px !important;
  }

  .entry-content {
    font-size: 12pt !important;
    line-height: 1.5 !important;
  }

  .entry-content img {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
  }
}

/* Related Posts Bottom Area */
.related-bottom-area {
  margin-top: 50px;
  margin-bottom: 30px;
}

.related-section-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 20px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--brand-color);
  padding-bottom: 5px;
  display: inline-block;
}

.related-posts-list-container {
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  padding: 20px;
}

.related-item-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.related-item-row:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.related-item-thumb {
  flex-shrink: 0;
  width: 220px;
}

.related-item-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  margin: 0 !important;
}

.related-item-info {
  display: flex;
  flex-direction: column;
}

.related-item-title {
  margin: 0 0 10px 0;
  font-size: 16px !important;
  font-weight: bold;
  line-height: 1.4;
}

.related-item-title a {
  color: #222;
  text-decoration: none !important;
}

.related-item-title a:hover {
  color: var(--brand-color);
}

.related-item-excerpt {
  margin: 0;
  color: #555;
  font-size: 14px !important;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .related-item-row {
    flex-direction: column;
  }
  .related-item-thumb {
    width: 100%;
  }
}

/* --- SINGLE POST META & SAPO --- */
.custom-entry-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 15px;
  color: #666;
  margin-bottom: 20px;
}

.custom-author, .custom-posted-on {
  display: flex;
  align-items: center;
  gap: 5px;
}

.custom-author a {
  font-weight: bold;
  color: #000;
  text-decoration: none;
}

.custom-author a:hover {
  color: var(--brand-color);
  text-decoration: underline;
}

.meta-separator {
  color: #ccc;
}

.entry-sapo {
  font-size: 16px;
  line-height: 1.6;
  color: #333;
}

/* --- AUTHOR ARCHIVE LIST --- */
.author-posts-list {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-top: 20px;
}

.author-list-item {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
}

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

.author-item-thumb {
  flex-shrink: 0;
  width: 300px;
}

.author-item-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

.author-item-content {
  display: flex;
  flex-direction: column;
}

.author-item-content.no-thumb {
  width: 100%;
}

.author-item-title {
  margin: 0 0 10px 0;
  font-size: 20px;
  font-weight: bold;
  line-height: 1.3;
}

.author-item-title a {
  color: #222;
  text-decoration: none;
}

.author-item-title a:hover {
  color: var(--brand-color);
}

.author-item-category {
  margin-bottom: 8px;
}

.author-item-category a {
  color: #009966; /* Greenish color from screenshot */
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.author-item-category a:hover {
  text-decoration: underline;
}

.author-item-excerpt {
  color: #555;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 768px) {
  .author-list-item {
    flex-direction: column;
  }
  .author-item-thumb {
    width: 100%;
  }
  
  /* Ẩn sidebar "Bài Viết Mới Nhất" trên mobile */
  .single-sidebar {
    display: none !important;
  }
}
