/* Gallery Grid */
#lightgallery-masonry {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1199px) and (min-width: 768px), (max-width: 992px) {
  #lightgallery-masonry {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 576px) {
  #lightgallery-masonry {
    grid-template-columns: repeat(2, 1fr);
  }
}

.input-field,
.input-area {
  font-size: 14px;
  font-weight: 400;
  padding: 10px 20px;
  border-radius: 15px;
  border: solid 1px #c9c9c9;
  width: 100%;
  box-sizing: border-box;
  transition: all ease 0.3s;
  height: 42px;
}

.input-field:focus,
.input-area:focus {
  border: solid 1px #ff6806;
  outline: #ff6806;
}

.custom-btn {
  border-radius: 10px;
  font-size: 16px;
  padding: 3px 15px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.custom-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  border: none;
}

.btn-primary:hover {
  background: #0e1541;
  border: none;
}

@media (max-width: 576px) {
  .btn-search span {
    display: none;
  }
}

.header-input {
  font-size: 15px;
  font-weight: 500;
  color: #0e1541;
}

.modal-content {
  border-radius: 15px !important;
}

.btn-cancel {
  background-color: #d6d6d6;
  border: none;
  border-radius: 10px;
  padding: 5px 1em;
}

.btn-cancel:hover {
  background-color: #c2c2c2;
  border: none;
}

.btn-search-submit {
  background-color: #0e1541;
  border: none;
  border-radius: 10px;
  padding: 5px 1em;
}

.btn-search-submit:hover {
  background-color: #ff6806;
}

.banner-title {
  font-size: 2em;
  font-weight: bold;
  color: #0e1541;
}

.banner-desc {
  font-size: 16px;
  max-width: 700px;
  color: #a8a8a8;
  font-weight: 300 !important;
}

.header-ex {
  margin-top: 50px;
  color: #ff6806;
}

@media (max-width: 768px) {
  .banner-title {
    font-size: 25px;
  }

  .banner-desc {
    font-size: 13px;
  }

  .header-ex {
    margin-top: 30px;
    font-size: 12px;
  }
}

/* Gallery Item */
.gallery-item {
  width: 100%;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background: #e7e7e7;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.gallery-item img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.gallery-item img:hover {
  transform: scale(1.05);
}

/* LightGallery Customization */
.lg-outer {
  background-color: rgba(0, 0, 0, 0.95) !important;
}

/* ปรับขนาดรูปภาพให้ไม่ซ้อนทับ - ใช้ JavaScript ควบคุม */
.lg-outer .lg-item .lg-img-wrap {
  max-height: calc(100vh - 300px) !important;
  transition: max-height 0.3s ease;
  margin-top: 50px;
}

.lg-outer .lg-item .lg-image {
  max-height: calc(100vh - 300px) !important;
  object-fit: contain;
  transition: max-height 0.3s ease;
}

/* Caption positioning - อยู่เหนือ thumbnail */
.lg-sub-html {
  position: absolute !important;
  bottom: 90px !important;
  /* ให้ห่างจาก thumbnail */
  left: 0;
  right: 0;
  width: 100%;
  min-height: auto !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: visible !important;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
  color: white;
  padding: 15px 20px;
  box-sizing: border-box;
  text-align: center;
  z-index: 1100;
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Thumbnail positioning */
.lg-thumb-outer {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100px !important;
  background: rgba(0, 0, 0, 0.95) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 0;
  z-index: 1050;
}

/* ซ่อนปุ่ม toggle thumbnail */
.lg-toggle-thumb {
  display: none !important;
}

/* ปรับขนาด thumbnail */
.lg-thumb-outer .lg-thumb-item {
  height: 80px !important;
  width: 80px !important;
  margin: 0 5px !important;
}

.lg-thumb-outer .lg-thumb-item img {
  height: 100% !important;
  width: 100% !important;
  object-fit: cover !important;
  border-radius: 4px;
}

/* Responsive thumbnail */
@media (max-width: 768px) {
  .lg-thumb-outer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 80px !important;
    background: rgba(0, 0, 0, 0.95) !important;
    padding: 5px 0 !important;
    z-index: 1090 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
  }

  .lg-thumb-outer .lg-thumb-item {
    height: 60px !important;
    width: 60px !important;
    margin: 0 3px !important;
  }
}

/* Caption content styles */
.gallery-subhtml {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.3;
  color: #fff;
}

.gallery-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: #00d4ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.gallery-desc {
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
  color: #e0e0e0;
  line-height: 1.2;
}

.gallery-products a {
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  border-radius: 15px;
  padding: 5px 10px;
  font-size: 0.8em;
  font-weight: 400;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  margin-top: 1em;
  transition: all 0.2s ease;
}

.gallery-products a:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.gallery-links a.line-button {
  color: #06c755;
  text-decoration: none;
  border: 2px solid #06c755;
  border-radius: 20px;
  padding: 6px 14px;
  display: inline-block;
  font-weight: 600;
  transition: all 0.3s ease;
  background: rgba(6, 199, 85, 0.1);
  backdrop-filter: blur(5px);
  margin-top: 1em;
}

.gallery-links a.line-button:hover {
  background-color: #06c755;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.4);
}

/* ปรับ scrollbar ใน caption */
.lg-sub-html::-webkit-scrollbar {
  width: 4px;
}

.lg-sub-html::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.lg-sub-html::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

/* ปรับ control buttons */
.lg-prev,
.lg-next {
  top: 50% !important;
  transform: translateY(-50%) !important;
  margin-top: -80px !important;
}

.lg-close {
  top: 20px !important;
  right: 20px !important;
}

/* Animation improvements */
.lg-item {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}

/* Ensure proper spacing - ใช้ JavaScript ควบคุม */
.lg-outer .lg-item.lg-current {
  padding: 20px !important;
}

.lg-toogle-thumb {
  display: none !important;
}

.lg-counter {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  margin-top: -40px !important;
  /* ปรับให้อยู่กลางพื้นที่รูปภาพ */
  z-index: 1080 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  padding: 5px 10px !important;
  border-radius: 15px !important;
  font-size: 14px !important;
}

#pagination {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  /* ห้าม wrap */
  overflow-x: auto;
  /* ให้เลื่อนซ้ายขวาได้ถ้าปุ่มเยอะ */
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  /* สำหรับ smooth scroll บนมือถือ */
}

#pagination button {
  flex: 0 0 auto;
  /* ปุ่มไม่ยืดและไม่หด */
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background-color: #ffffff;
  color: #0e1541;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(14, 21, 65, 0.1);
  outline: none;
  margin: 0 4px;
  cursor: pointer;
  white-space: nowrap;
}

#pagination button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px #0e15413a;
}

#pagination button.btn-warning {
  background-color: #0e1541 !important;
  color: #ffffff !important;
  border-color: #0e1541;
  box-shadow: 0 4px 12px #0e15413f;
}

#pagination .ellipsis {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  border: none;
  background: transparent;
  font-size: 18px;
  color: #bbb;
  cursor: default;
  margin: 0 8px;
  user-select: none;
  box-shadow: none;
}

#paginate-pre {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease;
}

#paginate-pre.fade-out {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 992px) {
  #pagination button {
    width: 36px;
    height: 36px;
    font-size: 14px;
    margin: 0 3px;
  }

  #lightgallery-masonry {
    grid-template-columns: repeat(3, 1fr);
  }
  .lg-thumb-outer {
    display: none !important;
  }
  .lg-sub-html {
    bottom: 10px !important;
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    padding: 10px 15px;
    font-size: 0.9rem;
  }
  .lg-outer .lg-item .lg-img-wrap {
    margin-top: 80px;
  }
  .lg-prev,
  .lg-next {
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin-top: -40px !important;
  }
}

@media (max-width: 576px) {
  #pagination button {
    width: 30px;
    height: 30px;
    font-size: 12px;
    margin: 0 2px;
  }

  #lightgallery-masonry {
    grid-template-columns: repeat(2, 1fr);
  }
}
