/* ===================================== */
/* Custom Modal Styles           */
/* ===================================== */
/* MODAL OVERLAY */
/* Modal CSS */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  -webkit-overflow-scrolling: touch; /* Tối ưu cuộn trên iOS */
}
.modal-dialog {
  margin: 5% auto; /* Quay lại sử dụng margin auto để căn giữa */
  max-width: 500px;
  width: 85%; /* Giảm width xuống 85% */
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,.5);
  /* Thêm các thuộc tính sau để đảm bảo căn giữa trên mọi thiết bị */
  position: relative;
  right: 15px;
}
.modal-content {
  display: flex;
  flex-direction: column;
}
.modal-header {
  position: relative;
  padding: 10px;
}
.image-header img {
  width: 100%;
  display: block;
  height: auto; /* Giữ tỷ lệ ảnh */
}
.modal-header .close {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  background: rgba(0,0,0,0.5);
  border: none;
  cursor: pointer;
  width: 40px; /* Tăng kích thước nút */
  height: 40px; /* Tăng kích thước nút */
  border-radius: 50%; /* Bo tròn nút */
  display: flex; /* Căn giữa icon X */
  align-items: center;
  justify-content: center;
  z-index: 1; /* Đảm bảo nút ở trên ảnh */
}
.modal-body {
  padding: 10px;
  font-size: 16px;
  line-height: 1.5; /* Tăng khoảng cách dòng */
  word-wrap: break-word; /* Ngăn văn bản tràn ra ngoài */
}
/* Media queries cho các kích thước thiết bị khác nhau */
/* Thiết bị rất nhỏ */
@media (max-width: 320px) {
  .modal-dialog {
    margin: 5% auto;
    width: calc(100% - 30px); /* Giảm width - tương đương ~85% */
  }
  
  .modal-body {
    font-size: 14px;
    padding: 12px;
  }
  
  .modal-header .close {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}
/* Thiết bị nhỏ */
@media (min-width: 321px) and (max-width: 576px) {
  .modal-dialog {
    margin: 10% auto;
    width: calc(100% - 60px); /* Giảm width - tương đương ~80% */
  }
  
  .modal-body {
    font-size: 15px;
    padding: 15px;
  }
}
/* Thiết bị vừa và lớn */
@media (min-width: 577px) {
  .modal-dialog {
    margin: 5% auto;
    width: 80%; /* Giảm width xuống 80% cho màn hình lớn */
    max-width: 500px;
  }
}
/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
/* Thêm class cho animation */
.modal.show {
  animation: fadeIn 0.3s ease;
}
.modal.show .modal-dialog {
  animation: slideDown 0.3s ease;
}
/* Tối ưu hóa cho thiết bị cảm ứng */
@media (hover: none) {
  .modal-header .close:hover {
    background: rgba(0,0,0,0.7); /* Tăng độ tương phản khi không có hover */
  }
}