/* I. Định nghĩa biến màu riêng cho khu vực AI */
:root {
  --color-text-dark: black;
  --color-bg: white;
  --color-bg-hover: #ced4da;
  --color-bg-click: #bfd7ff;
  --color-bg-big-card: white;
  --color-bg-dropdown-menu: white;
  --color-bg-small-card: rgb(33 150 243);
}

/* II. Thanh Bộ lọc chung (Filter Bar) */
.explore-content {
  background-color: var(--color-dark-bg);
  padding-top: 20px;
  padding-left: 20px;
}

.filter-bar {
  display: flex;
  align-items: center;
}

/* III. Bộ lọc thả xuống (Dropdown Filter) */
.dropdown-filter {
  position: relative;
  user-select: none;
  z-index: 20;
}

.filter-button {
  background-color: transparent;
  color: var(--color-text-dark);
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  gap: 10px; /* Thêm khoảng cách nhỏ giữa các thành phần */
  white-space: nowrap;
}

.filter-button:hover {
  background-color: var(--color-bg-hover);
}

/* YÊU CẦU 3: MÀU NỀN KHÁC KHI CLICK/MENU MỞ */
.dropdown-filter.open .filter-button {
  background-color: var(--color-bg-click);
  color: var(--color-text-dark);

  /* Loại bỏ/giảm độ mờ nếu có */
  opacity: 1;
}

/* Định dạng icon "Loại"*/
.sort-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  margin-left: 10px;
}

/* Định dang icon "Mục đích" */
.purpose-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  margin-left: 10px;
}

.arrow-icon-button {
  width: 25px;
  height: 25px;
}

/* Định dạng icon "Down" */
.filter-button .arrow {
  margin-left: 5px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--color-bg-dropdown-menu);
  list-style: none;
  padding: 8px 0;
  margin-top: 5px;
  border-radius: 8px;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: none; /* Mặc định ẩn */
}

.dropdown-menu li {
  color: var(--color-text-dark);
  padding: 10px 18px;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.95em;
  transition: background-color 0.2s;
  /* Bật Flexbox để căn icon */
  display: flex;
  align-items: center;
  gap: 15px; /* Khoảng cách giữa icon và chữ (lớn hơn) */
}

.dropdown-menu li:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-dark);
  margin: 0px 5px 0px;
  border-radius: 8px;
}

.dropdown-menu li.selected {
  background-color: var(--color-bg-click);
  color: var(--color-text-dark);
  margin: 0px 5px 0px;
  border-radius: 8px;
}

/*Phần hiển thị chức năng "Loại" */
.dropdown-filter.open .dropdown-menu {
  display: block;
}

/* Định dạng wrapper của icon trong list */
.list-icon-wrapper img {
  width: 25px; /* Kích thước nhỏ cho icon list */
  height: 25px;
  object-fit: contain;
  /* Có thể dùng filter: invert(1) nếu icon gốc là màu đen và nền là màu tối */
}

/* IV. Thanh Tìm kiếm (Search Bar) */
.search-ai-container {
  display: flex;
  align-items: center;
  margin-left: 20px;
}

.search-input {
  width: 100%;
  height: 45px;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  background-color: #edf2fb; /* Nền ô tìm kiếm */
  color: var(--color-text-dark-light);
  font-size: 1em;
  outline: none;
  /* Loại bỏ viền và nút Search để trông giống hình hơn */
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.search-button {
  background-color: #edf2fb;
  color: var(--color-text-dark);
  padding: 10px 15px;
  border: none;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  transition: background-color 0.2s;
}

.search-button:hover {
  background-color: var(--color-bg-hover);
}

.search-icon-img {
  width: 25px;
  height: 25px;
  object-fit: contain; /* Giữ tỷ lệ khung hình */
  vertical-align: middle; /* Căn giữa hình ảnh */
}

/* V. Khu vực Grid Bài Viết (4 cột, tự điều chỉnh) */
.article-grid-container {
  /* Sử dụng Grid để tạo lưới 4 cột */
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1em;

  padding: 1em;
  width: 100%;
  margin-top: 2em;
  margin-bottom: 300px;
  margin-left: 10px;
}

/* Container cho mỗi bài viết */
.ai-article-card {
  width: 320px;
  position: relative;
  box-sizing: border-box; /* Quan trọng để padding không làm tràn width */
  border-radius: 0.75rem;
  background-color: white;
  margin-bottom: 300px;
}

/* Lớp bọc chung để tạo hiệu ứng trượt lên */
.ai-article-content-wrapper {
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease-in-out;
}

/* Hiệu ứng HOVER: trượt toàn bộ nội dung lên */
.ai-article-card:hover .ai-article-content-wrapper {
  transform: translateY(-10px); /* Kéo nội dung lên 10px */
}

/*---V.PHẦN BÀI VIẾT---*/
/*1.KHUNG NHỎ*/
.card {
  position: relative;
  width: 260px;
  height: 80px;
  margin-left: auto;
  margin-right: auto;
  background-color: var(--color-bg-small-card);
  border-radius: 7px;
  justify-content: space-between;
  top: 30px;
  z-index: 10; /* Cao hơn .info-footer và .card_back */
  overflow: hidden; /* Quan trọng để ảnh không bị tràn */
  box-shadow: 0 10px 15px -3px rgba(33, 150, 243, 0.4),
    0 4px 6px -4px rgba(33, 150, 243, 0.4);
  transition: transform 0.3s ease-in-out;
}

.ai-article-card:hover .card {
  /* Đẩy khung xanh lên 5px (Giá trị âm) */
  transform: translateY(-15px);
}

/*2.KHUNG LỚN*/
.card_back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Chiều cao của Card + chiều cao của info-footer */
  height: calc(100% + 280px);
  background-color: var(--color-bg-big-card);
  z-index: 1; /* Nằm dưới .card và .info-footer */
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
  /* === BỔ SUNG để làm nổi bật card khi chưa hover === */
  border: 5px solid #e0e0e0; /* Viền xám nhạt */
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Hiệu ứng HOVER: Phóng to phần nền xám và thêm bóng */
.ai-article-card:hover .card_back {
  /* Phóng to nền và thêm bóng */
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
  border: 5px solid transparent; /* Loại bỏ viền khi hover để bóng đổ chi phối */
}

/* --- 3. PHẦN THÔNG TIN (Info Footer - Icon, Tiêu đề, Buttons) --- */

/* Lớp bọc cho data và btns để căn chỉnh vị trí tuyệt đối */
.info-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  border-bottom-left-radius: 7px;
  border-bottom-right-radius: 7px;
  padding: 0.7em 0.5em 0.5em 0.5em;
  z-index: 20; /* Cao hơn .card_back và .card */
  box-sizing: border-box;
  margin-top: 15px;
}

/* --- CÁC PHẦN TỬ CON CỦA CARD (Dựa trên code gốc) --- */

/* Data - Icon và Text */
.data {
  display: flex;
  flex-direction: row;
  margin-left: 15px;
}

.img {
  width: 3em;
  height: 3em;
  background-color: #252525;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 30px;
}
.icon-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text {
  display: flex;
  justify-content: center;
  flex-direction: column;
  margin-left: 0.5em;
  font-family: "Inter", sans-serif; /* Đổi sang Inter */
  color: var(--color-text-dark);
  margin-top: 30px;
}

.text_m {
  font-weight: bold;
  font-size: 1em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.text_s a {
  font-size: 0.8em;
  color: var(--color-text-dark);
  transition: color 0.2s;
}

.text_s a:hover {
  color: var(--color-secondary);
}

/* Giới thiệu AI  */

.ai-description {
  margin-top: 10px;
  margin-bottom: 5px; /* Khoảng cách với các nút Likes/Comments (nếu nằm sau mô tả) */
  font-size: 0.85em;
  color: var(--color-text-light);
  line-height: 1.4;
  padding-left: 15px;
  padding-right: 15px;
}

/* Buttons -love, save */
.buttons {
  display: flex;
  justify-self: space-between;
  gap: 1.5em;
  transition: opacity 0.3s ease-in-out, margin-top 0.3s ease-in-out;
  padding-left: 170px;
  align-items: center;
}

/* XEM CHI TIẾT */

.ai-article-view {
  display: inline-flex;
}

.view-button {
  cursor: pointer;
  margin-left: -160px;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  border: none;
  outline: none;
  box-shadow: 0 4px 6px -1px rgba(33, 150, 243, 0.4),
    0 2px 4px -2px rgba(33, 150, 243, 0.4);
  color: rgb(255 255 255);
  font-weight: 700;
  font-size: 15px;
  padding: 0.5rem 1rem;
  background-color: rgb(33 150 243);
  border-radius: 20px;
  text-transform: uppercase;
}

/* THẢ TIM */
.love-counter {
  cursor: pointer;
  /* Đảm bảo icon và text nằm ngang */
  display: flex;
  align-items: center;
  gap: 0.25em; /* Khoảng cách nhỏ giữa icon và số */
  font-size: 1.1em;
  font-weight: 500;
}

/* Định dạng chữ số */
.love-count-text {
  /* Đảm bảo chữ số không bị ẩn */
  margin-left: 2px;
  margin-top: 5px;
  font-size: 1.1em;
  white-space: nowrap; /* Ngăn chữ bị ngắt dòng */
}

.love-button input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.love-button {
  display: block;
  position: relative;
  cursor: pointer;
  font-size: 15px;
  user-select: none;
  transition: 100ms;
}

.checkmark {
  top: 0;
  left: 0;
  height: 1.5em;
  width: 1.5em;
  transition: 100ms;
  animation: dislove_effect 400ms ease;
}

.love-button input:checked ~ .checkmark path {
  fill: #ff5353;
  stroke-width: 0;
}

.love-button input:checked ~ .checkmark {
  animation: love_effect 400ms ease;
}

.love-button:hover {
  transform: scale(1.1);
}

@keyframes love_effect {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes dislove_effect {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

/* LƯU LẠI */
.save-button {
  --color: black;
  --size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  font-size: var(--size);
  user-select: none;
  margin-right: 100px;
}

.save-button:hover {
  transform: scale(1.1);
}

.save-button .save-regular {
  position: absolute;
  animation: keyframes-fill 0.5s;
  transform-origin: top;
}

.save-button .save-solid {
  position: absolute;
  animation: keyframes-fill 0.5s;
  display: none;
  transform-origin: top;
}

.save-button input:checked ~ .save-regular {
  display: none;
}

.save-button input:checked ~ .save-solid {
  display: block;
  fill: #ffff00;
}

.save-button input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

@keyframes keyframes-fill {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scaleY(1.2);
  }
}

/* === IX. MODAL/POPUP XEM CHI TIẾT === */

/* Lớp che phủ toàn màn hình (Overlay) */
.modal-overlay {
  display: none; /* Mặc định ẩn */
  position: fixed; /* Giữ cố định khi cuộn */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Màu nền đen mờ */
  z-index: 1000; /* Đảm bảo nằm trên mọi thứ */
  overflow-y: auto; /* Cho phép cuộn nếu nội dung dài */
  justify-content: center;
  align-items: center;
}

/* Khung chứa nội dung Modal */
.modal-content {
  background-color: var(--color-bg);
  margin: 50px auto; /* Đẩy xuống một chút và căn giữa */
  padding: 25px;
  border-radius: 12px;
  width: 80%; /* Chiều rộng khung */
  max-width: 700px; /* Chiều rộng tối đa */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.8); /* Bắt đầu nhỏ hơn */
  opacity: 0; /* Bắt đầu ẩn */
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

/* Hiển thị Modal khi được kích hoạt bằng JS */
.modal-overlay.active {
  display: flex;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
  margin-bottom: 15px;
}

.modal-header h2 {
  font-size: 1.5em;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2em;
  cursor: pointer;
  color: #555;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #000;
}

.modal-body-scrollable {
  max-height: 70vh; /* Giới hạn chiều cao nội dung */
  overflow-y: auto; /* Cho phép cuộn nội dung */
  line-height: 1.6;
}

/* === IX. MODAL/POPUP XEM CHI TIẾT (Tiếp theo) === */

/* Định dạng chung cho nội dung bài viết trong Modal */
.article-detail-view {
  /* Sử dụng font Inter đã được định nghĩa cho bài viết */
  font-family: "Inter", sans-serif;
  padding: 10px; /* Thêm padding nhỏ bên trong nếu cần */
}

/* Tiêu đề chính của bài viết trong Modal */
.article-detail-view h2 {
  color: #333;
  font-size: 1.8em;
  font-weight: 700;
  margin-top: 0; /* Loại bỏ margin trên cùng */
  margin-bottom: 20px;
}

/* Tiêu đề cấp 3 (Ưu điểm, Nhược điểm, Tổng kết) */
.article-detail-view h3 {
  color: #007bff; /* Màu xanh nổi bật */
  font-size: 1.4em;
  font-weight: 600;
  margin-top: 30px;
  margin-bottom: 15px;
  padding-bottom: 5px;
  border-bottom: 2px solid #e9ecef; /* Đường kẻ nhẹ */
}

/* Tiêu đề cấp 4 (Tiêu đề con: Tăng tốc code, Debugging,...) */
.article-detail-view h4 {
  color: #555;
  font-size: 1.1em;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 10px;
}

/* Định dạng đoạn văn */
.article-detail-view p {
  margin-top: 10px;
  margin-bottom: 15px;
  line-height: 1.6;
  color: #495057;
}

/* Định dạng danh sách (Ưu/Nhược điểm chi tiết) */
.article-detail-view ul {
  list-style: disc; /* Dùng dấu chấm */
  padding-left: 25px;
  margin-bottom: 20px;
}

.article-detail-view li {
  margin-bottom: 8px;
  line-height: 1.5;
  color: #495057;
}

/* Định dạng đường kẻ ngang */
.article-detail-view hr {
  border: 0;
  border-top: 1px solid #dee2e6;
  margin: 30px 0;
}

/* Định dạng Bảng tóm tắt (Table) */
.article-detail-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9em;
  /* Hiệu ứng bóng nhẹ cho bảng */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.article-detail-view th,
.article-detail-view td {
  border: 1px solid #e9ecef; /* Viền mỏng và nhẹ */
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.article-detail-view th {
  background-color: #f8f9fa; /* Nền xám nhạt cho tiêu đề cột */
  color: #333;
  font-weight: 600;
  width: 30%; /* Cố định cột tiêu chí (Tiêu chí, Khuyến nghị) */
}

.article-detail-view table tbody tr:nth-child(even) {
  background-color: #fcfcfc; /* Xen kẽ màu dòng */
}
