/* live-search.css - Live Search + Pagination (เวอร์ชันล่าสุด ปรับขนาดคงที่ + responsive) */

/* Wrapper หลัก */
.ls-wrapper {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px;
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial;
  position: relative;
}

/* Search Row */
.ls-search-row {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.ls-search-center {
  width: 100%;
  display: flex;
  justify-content: center;
  position: relative;
  flex: none !important; /* ✅ ป้องกันการยืด-หดเมื่อ pagination เปลี่ยน */
}

/* ✅ Search Bar ขนาดคงที่ (Desktop) */
.ls-search-box {
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  width: 800px;
  max-width: 800px;
  min-width: 800px;
  position: relative;
  margin: 0 auto;
}

/* Input */
#live-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 48px 12px 16px;
  border-radius: 28px;
  border: 1px solid #e0e0e0;
  background: #fff;
  font-size: 16px;
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}

#live-search-input:focus {
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  border-color: #c9c9c9;
}

/* ปุ่มค้นหา */
#live-search-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #111;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
#live-search-btn svg { display: block; }

/* ✅ Dropdown Suggestions */
#live-search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(-5px);
  z-index: 9999;
}

#live-search-suggestions.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Items */
.ls-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #f2f2f2;
  text-decoration: none;
  color: #222;
  align-items: center;
}

.ls-item:last-child { border-bottom: 0; }

.ls-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: #f6f6f6;
  flex-shrink: 0;
}

.ls-meta { flex: 1; min-width: 0; }
.ls-title { margin: 0; font-size: 15px; line-height: 1.2; font-weight: 600; }
.ls-excerpt { margin: 4px 0 0; color: #666; font-size: 13px; line-height: 1.3; }

/* Highlight */
.ls-highlight {
  background: #ff8a00;
  color: #fff;
  padding: 0 3px;
  border-radius: 2px;
  display: inline-block;
}

/* Hover / Focus */
.ls-item.focused, #live-search-suggestions .ls-item:hover {
  background: #faf7f0;
}

/* ไม่มีผลลัพธ์ */
.ls-no-results {
  padding: 12px;
  color: #666;
  text-align: center;
  font-style: italic;
}

/* Heading */
.ls-heading {
  margin: 18px 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

/* List */
.ls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid #eee;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.ls-list-item { padding: 4px; border-bottom: 1px solid #f2f2f2; }
.ls-list-item:last-child { border-bottom: 0; }
.ls-list-item a {
  text-decoration: none;
  color: #222;
  display: block;
  font-weight: 500;
}
.ls-list-item a:hover { text-decoration: underline; }

/* ✅ Pagination */
.ls-pagination {
  display: block !important;
  width: 100%;
  text-align: center;
  margin-top: 12px;
}

.ls-pagination a, .ls-pagination span {
  display: inline-block;
  margin: 0 4px;
  padding: 6px 10px;
  background: #f2f2f2;
  border-radius: 4px;
  text-decoration: none;
  color: #111;
}

.ls-pagination a:hover {
  background: #111;
  color: #fff;
}

.ls-pagination .current {
  font-weight: 700;
  background: #111;
  color: #fff;
}

/* ✅ Mobile: Search bar & Pagination 90% ของจอ + อยู่กลาง */
@media (max-width: 820px) {
  .ls-search-center {
    justify-content: center !important;
  }

  .ls-search-box {
    width: 90% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    position: relative;
  }

  #live-search-suggestions {
    width: 100% !important;
    left: 0 !important;
    transform: none !important;
  }

  .ls-pagination {
    width: 90% !important;
    margin: 16px auto 0 auto !important;
    text-align: center;
  }

  .ls-thumb { width: 48px; height: 48px; }
  #live-search-input { font-size: 15px; padding: 10px 44px 10px 12px; }
  #live-search-btn { width: 36px; height: 36px; right: 8px; }
}
