/* =========================================================
   PTK LIVE SEARCH — PREMIUM MOTION
   โทนดำ–ทอง / มีมิติ / มีแอนิเมชัน / SAFE MODE
========================================================= */

/* =========================
   SEARCH WRAPPER
========================= */
.ptk-search-box {
  position: relative;
  width: 100%;
  isolation: isolate;
}

/* แสงพื้นหลังรอบช่องค้นหา */
.ptk-search-box::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(212,170,78,.18), transparent 34%),
    radial-gradient(circle at 82% 70%, rgba(255,214,120,.10), transparent 32%);
  opacity: .45;
  filter: blur(10px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}

.ptk-search-box:focus-within::before {
  opacity: .9;
  transform: scale(1.015);
}

/* =========================
   SEARCH INPUT
========================= */
#ptk-search-input {
  width: 100%;
  height: 50px;
  padding: 0 48px 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(212,170,78,.18);
  background:
    linear-gradient(180deg, rgba(34,34,34,.98) 0%, rgba(22,22,22,.98) 100%);
  color: #fff;
  outline: none;
  font-size: 14px;
  letter-spacing: .01em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.035),
    0 8px 22px rgba(0,0,0,.22);
  transition:
    border-color .22s ease,
    box-shadow .22s ease,
    background .22s ease,
    transform .22s ease;
}

#ptk-search-input::placeholder {
  color: rgba(255,255,255,.42);
  transition: color .2s ease;
}

#ptk-search-input:hover {
  border-color: rgba(212,170,78,.32);
  background:
    linear-gradient(180deg, rgba(38,38,38,.99) 0%, rgba(24,24,24,.99) 100%);
}

#ptk-search-input:focus {
  border-color: rgba(226,184,83,.72);
  background:
    linear-gradient(180deg, rgba(40,40,40,.99) 0%, rgba(24,24,24,.99) 100%);
  box-shadow:
    0 0 0 4px rgba(212,170,78,.10),
    0 14px 30px rgba(0,0,0,.30),
    inset 0 1px 0 rgba(255,255,255,.05);
  transform: translateY(-1px);
}

#ptk-search-input:focus::placeholder {
  color: rgba(255,255,255,.58);
}

/* ไอคอนประกายด้านขวา */
.ptk-search-box::after {
  content: "✦";
  position: absolute;
  right: 17px;
  top: 25px;
  transform: translateY(-50%);
  color: #d8ad50;
  font-size: 15px;
  text-shadow: 0 0 14px rgba(212,170,78,.7);
  pointer-events: none;
  animation: ptkSearchSpark 2.8s ease-in-out infinite;
}

/* =========================
   RESULT DROPDOWN
========================= */
#ptk-search-result {
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  right: 0;
  z-index: 9999;

  display: none;
  max-height: 430px;
  overflow-y: auto;
  overflow-x: hidden;

  border-radius: 16px;
  border: 1px solid rgba(212,170,78,.18);
  background:
    linear-gradient(180deg, rgba(28,28,28,.97) 0%, rgba(17,17,17,.98) 100%);
  box-shadow:
    0 24px 60px rgba(0,0,0,.46),
    0 0 0 1px rgba(255,255,255,.02),
    inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  transform-origin: top center;
  animation: ptkSearchDropdownIn .24s cubic-bezier(.2,.8,.2,1);
}

/* เส้นประกายทองด้านบน dropdown */
#ptk-search-result::before {
  content: "";
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  height: 2px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(212,170,78,.25) 18%,
      rgba(255,220,130,.9) 50%,
      rgba(212,170,78,.25) 82%,
      transparent 100%
    );
  box-shadow: 0 0 16px rgba(212,170,78,.32);
}

/* scrollbar */
#ptk-search-result::-webkit-scrollbar {
  width: 8px;
}

#ptk-search-result::-webkit-scrollbar-track {
  background: transparent;
}

#ptk-search-result::-webkit-scrollbar-thumb {
  background:
    linear-gradient(
      180deg,
      rgba(212,170,78,.32),
      rgba(255,255,255,.12)
    );
  border-radius: 999px;
}

#ptk-search-result::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(
      180deg,
      rgba(226,184,83,.48),
      rgba(255,255,255,.18)
    );
}

/* =========================
   GROUP
========================= */
.ptk-search-group {
  position: relative;
  padding: 8px 0 10px;
}

.ptk-search-group + .ptk-search-group {
  border-top: 1px solid rgba(255,255,255,.06);
}

.ptk-search-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #dbb35b;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.ptk-search-group-title::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d4aa4e, transparent);
  box-shadow: 0 0 10px rgba(212,170,78,.28);
}

/* =========================
   RESULT ITEM
========================= */
.ptk-item {
  position: relative;
  padding: 0;
  opacity: 0;
  transform: translateY(7px);
  animation: ptkSearchItemIn .28s ease forwards;
}

.ptk-item:nth-child(1) { animation-delay: .02s; }
.ptk-item:nth-child(2) { animation-delay: .05s; }
.ptk-item:nth-child(3) { animation-delay: .08s; }
.ptk-item:nth-child(4) { animation-delay: .11s; }
.ptk-item:nth-child(5) { animation-delay: .14s; }
.ptk-item:nth-child(6) { animation-delay: .17s; }

.ptk-item a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;

  color: #fff;
  text-decoration: none;

  border-left: 2px solid transparent;
  background: transparent;

  transition:
    background .18s ease,
    border-color .18s ease,
    transform .18s ease,
    box-shadow .18s ease;
}

.ptk-item a::after {
  content: "›";
  flex: 0 0 auto;
  margin-left: 4px;
  color: rgba(212,170,78,.55);
  font-size: 20px;
  line-height: 1;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity .18s ease, transform .18s ease, color .18s ease;
}

.ptk-item:hover a,
.ptk-item:focus-within a {
  background:
    linear-gradient(
      90deg,
      rgba(212,170,78,.11) 0%,
      rgba(255,255,255,.028) 56%,
      transparent 100%
    );
  border-left-color: #d4aa4e;
  transform: translateX(3px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}

.ptk-item:hover a::after,
.ptk-item:focus-within a::after {
  opacity: 1;
  transform: translateX(0);
  color: #e4bd67;
}

/* =========================
   THUMBNAIL
========================= */
.ptk-item-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  overflow: hidden;

  border-radius: 12px;
  border: 1px solid rgba(212,170,78,.16);
  background:
    radial-gradient(circle at 35% 25%, #2c2c2c 0%, #161616 72%);

  box-shadow:
    0 8px 18px rgba(0,0,0,.24),
    inset 0 1px 0 rgba(255,255,255,.035);

  transition:
    border-color .2s ease,
    transform .2s ease,
    box-shadow .2s ease;
}

.ptk-item:hover .ptk-item-thumb,
.ptk-item:focus-within .ptk-item-thumb {
  border-color: rgba(226,184,83,.55);
  transform: scale(1.035);
  box-shadow:
    0 10px 22px rgba(0,0,0,.32),
    0 0 18px rgba(212,170,78,.10);
}

.ptk-item-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.09) 0%,
      transparent 36%,
      transparent 72%,
      rgba(212,170,78,.06) 100%
    );
}

.ptk-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .28s ease, filter .28s ease;
}

.ptk-item:hover .ptk-item-thumb img,
.ptk-item:focus-within .ptk-item-thumb img {
  transform: scale(1.08);
  filter: contrast(1.04) saturate(1.04);
}

.ptk-item-thumb.is-empty::after {
  content: "PTK";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(212,170,78,.65);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-shadow: 0 0 12px rgba(212,170,78,.18);
}

/* =========================
   CONTENT
========================= */
.ptk-item-content {
  min-width: 0;
  flex: 1 1 auto;
}

.ptk-item-title {
  margin-bottom: 5px;
  overflow: hidden;

  color: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  transition: color .18s ease;
}

.ptk-item:hover .ptk-item-title,
.ptk-item:focus-within .ptk-item-title {
  color: #f3ddb0;
}

.ptk-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 4px;
}

/* ประเภท */
.ptk-type {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;

  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.035);

  color: rgba(255,255,255,.66);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.ptk-item-price {
  color: #e4bc63;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  text-shadow: 0 0 12px rgba(212,170,78,.10);
}

/* =========================
   STATES
========================= */
.ptk-loading,
.ptk-empty,
.ptk-error {
  position: relative;
  padding: 20px 14px;
  text-align: center;
  color: rgba(255,255,255,.62);
  font-size: 13px;
}

.ptk-loading::before {
  content: "";
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 8px;
  vertical-align: -3px;

  border-radius: 50%;
  border: 2px solid rgba(212,170,78,.18);
  border-top-color: #d4aa4e;

  animation: ptkSearchSpin .72s linear infinite;
}

.ptk-empty::before {
  content: "◇";
  margin-right: 7px;
  color: #d4aa4e;
}

.ptk-error {
  color: #e19a9a;
}

/* =========================
   ANIMATIONS
========================= */
@keyframes ptkSearchDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-7px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ptkSearchItemIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ptkSearchSpark {
  0%, 100% {
    opacity: .45;
    transform: translateY(-50%) scale(.92) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.08) rotate(12deg);
  }
}

@keyframes ptkSearchSpin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   MOBILE
========================= */
@media (max-width: 768px) {

  #ptk-search-input {
    height: 47px;
    padding: 0 44px 0 13px;
    border-radius: 13px;
    font-size: 13px;
  }

  .ptk-search-box::after {
    right: 15px;
    top: 23px;
    font-size: 14px;
  }

  #ptk-search-result {
    top: calc(100% + 7px);
    max-height: 370px;
    border-radius: 13px;
  }

  .ptk-item a {
    gap: 10px;
    padding: 10px 12px;
  }

  .ptk-item:hover a,
  .ptk-item:focus-within a {
    transform: translateX(2px);
  }

  .ptk-item-thumb {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    border-radius: 10px;
  }

  .ptk-item-title {
    font-size: 13px;
  }

  .ptk-item-price {
    font-size: 12px;
  }

  .ptk-type {
    min-height: 19px;
    padding: 2px 7px;
    font-size: 10px;
  }
}

/* =========================
   ACCESSIBILITY
========================= */
@media (prefers-reduced-motion: reduce) {

  .ptk-search-box::after,
  .ptk-loading::before,
  #ptk-search-result,
  .ptk-item {
    animation: none !important;
  }

  #ptk-search-input,
  .ptk-item a,
  .ptk-item-thumb,
  .ptk-item-thumb img {
    transition: none !important;
  }

  .ptk-item {
    opacity: 1;
    transform: none;
  }
}
