/* ================================================================
   DoiHinhTFT — Sidebar Widget: Tìm Kiếm Nhanh (Quick Search)
   Cùng palette với Lịch Cập Nhật / Mẹo TFT / BXH Players.
   File này chỉ phục vụ widget Quick Search, không đụng widget khác.
   ================================================================ */


/* Quick Search đã chuyển lên header; ẩn bản sidebar để không bị lặp. */
#secondary .widget:has(.dhtft-quick-search-widget),
#secondary .bloghash-widget:has(.dhtft-quick-search-widget),
#secondary .widget.widget_dhtft_quick_search,
#secondary .bloghash-widget.widget_dhtft_quick_search {
  display: none !important;
}

/* ── Vô hiệu hóa khung mặc định của widget WP cho widget này ── */
#secondary .widget:has(.dhtft-quick-search-widget),
#secondary .bloghash-widget:has(.dhtft-quick-search-widget),
#secondary .widget.widget_dhtft_quick_search,
#secondary .bloghash-widget.widget_dhtft_quick_search {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
#secondary .widget:has(.dhtft-quick-search-widget)::before,
#secondary .widget:has(.dhtft-quick-search-widget)::after,
#secondary .bloghash-widget:has(.dhtft-quick-search-widget)::before,
#secondary .bloghash-widget:has(.dhtft-quick-search-widget)::after,
#secondary .widget.widget_dhtft_quick_search::before,
#secondary .widget.widget_dhtft_quick_search::after,
#secondary .bloghash-widget.widget_dhtft_quick_search::before,
#secondary .bloghash-widget.widget_dhtft_quick_search::after {
  display: none !important;
}
#secondary .widget:has(.dhtft-quick-search-widget) .widget-title,
#secondary .bloghash-widget:has(.dhtft-quick-search-widget) .widget-title,
#secondary .widget.widget_dhtft_quick_search .widget-title,
#secondary .bloghash-widget.widget_dhtft_quick_search .widget-title {
  display: none !important;
}

/* ── Shell ── */
.dhtft-quick-search-widget {
  --ps-bg:        #0c1020;
  --ps-bg-2:      #0a0e1c;
  --ps-border:    rgba(212,184,150,.1);
  --ps-border-2:  rgba(212,184,150,.18);
  --ps-gold:      #d4b896;
  --ps-gold-dim:  rgba(212,184,150,.55);
  --ps-text:      #e6e6e6;
  --ps-muted:     rgba(230,230,230,.42);
  --ps-radius:    10px;

  /* Cost colors theo TFT */
  --cost-1: #9aa0a6;
  --cost-2: #22c55e;
  --cost-3: #3b82f6;
  --cost-4: #c084fc;
  --cost-5: #fbbf24;

  background: var(--ps-bg);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  overflow: hidden;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--ps-text);
}

/* Corner brackets — đồng bộ widget khác */
.dhtft-quick-search-widget::before {
  content: '';
  position: absolute;
  top: 6px; left: 6px;
  width: 14px; height: 14px;
  border-top: 2px solid var(--ps-gold);
  border-left: 2px solid var(--ps-gold);
  pointer-events: none;
  z-index: 2;
}
.dhtft-quick-search-widget::after {
  content: '';
  position: absolute;
  bottom: 6px; right: 6px;
  width: 14px; height: 14px;
  border-bottom: 2px solid var(--ps-gold);
  border-right: 2px solid var(--ps-gold);
  pointer-events: none;
  z-index: 2;
}

/* ── Header ── */
.dhtft-qs__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ps-border);
  background: rgba(212,184,150,.04);
}
.dhtft-qs__icon { color: var(--ps-gold); flex-shrink: 0; }
.dhtft-qs__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ps-gold);
  flex: 1;
}

/* ── Search field ── */
.dhtft-qs__search-wrap {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ps-border);
  transition: border-color .25s;
}
/* khi idle (chưa gõ) → bỏ luôn border-bottom để widget gọn lại */
.dhtft-qs__search-wrap:has(+ .dhtft-qs__body[data-state="idle"]) {
  border-bottom-color: transparent;
}

.dhtft-qs__field {
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(212,184,150,.2);
  background: rgba(255,255,255,.02);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.dhtft-qs__field:hover {
  border-color: rgba(212,184,150,.32);
  background: rgba(255,255,255,.035);
}
.dhtft-qs__field:focus-within {
  border-color: var(--ps-gold);
  background: rgba(255,255,255,.04);
  box-shadow: 0 0 0 3px rgba(212,184,150,.12);
}

.dhtft-qs__field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(212,184,150,.45);
  pointer-events: none;
  transition: color .18s;
}
.dhtft-qs__field:focus-within .dhtft-qs__field-icon { color: var(--ps-gold); }

.dhtft-qs__input {
  flex: 1;
  width: 100%;
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  height: 100%;
  padding: 0 14px 0 38px !important;
  margin: 0 !important;
  color: rgba(255,255,255,.95) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 40px !important;
  font-family: inherit !important;
  caret-color: var(--ps-gold);
  box-shadow: none !important;
}
.dhtft-qs__input:focus {
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}
/* override placeholder cho mọi engine + override theme */
.dhtft-qs__input::placeholder { color: rgba(230,230,230,.4) !important; opacity: 1 !important; font-weight: 400; }
.dhtft-qs__input::-webkit-input-placeholder { color: rgba(230,230,230,.4) !important; font-weight: 400; }
.dhtft-qs__input:-ms-input-placeholder { color: rgba(230,230,230,.4) !important; font-weight: 400; }
.dhtft-qs__input::-moz-placeholder { color: rgba(230,230,230,.4) !important; opacity: 1 !important; font-weight: 400; }

/* ô tìm có nội dung → chừa chỗ cho nút clear */
.dhtft-qs__field:has(.dhtft-qs__clear:not([hidden])) .dhtft-qs__input {
  padding-right: 36px !important;
}

.dhtft-qs__clear[hidden] { display: none !important; }
.dhtft-qs__clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(255,255,255,.04);
  color: rgba(230,230,230,.55);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s, color .15s, transform .15s;
}
.dhtft-qs__clear:hover {
  background: rgba(212,184,150,.18);
  color: var(--ps-gold);
  transform: translateY(-50%) rotate(90deg);
}

/* ── Body / states ── */
.dhtft-qs__body {
  max-height: 460px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(212,184,150,.25) transparent;
}
/* idle → ẩn body cho widget gọn */
.dhtft-qs__body[data-state="idle"] {
  max-height: 0;
  overflow: hidden;
}
.dhtft-qs__body::-webkit-scrollbar { width: 6px; }
.dhtft-qs__body::-webkit-scrollbar-thumb {
  background: rgba(212,184,150,.22);
  border-radius: 3px;
}
.dhtft-qs__body::-webkit-scrollbar-track { background: transparent; }

/* Loading */
.dhtft-qs__loading {
  padding: 20px 16px;
  text-align: center;
  color: var(--ps-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.dhtft-qs__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(212,184,150,.2);
  border-top-color: var(--ps-gold);
  animation: dhtft-qs-spin .7s linear infinite;
}
@keyframes dhtft-qs-spin { to { transform: rotate(360deg); } }

/* Empty */
.dhtft-qs__empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--ps-muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.dhtft-qs__empty strong { color: var(--ps-gold); }

/* ── Group ── */
.dhtft-qs__group { border-bottom: 1px solid var(--ps-border); }
.dhtft-qs__group:last-child { border-bottom: 0; }

.dhtft-qs__group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(212,184,150,.75);
  background: rgba(212,184,150,.025);
}
.dhtft-qs__group-icon { font-size: 11px; opacity: .85; }
.dhtft-qs__group-count {
  margin-left: auto;
  font-size: 9.5px;
  letter-spacing: .5px;
  background: rgba(212,184,150,.1);
  border: 1px solid rgba(212,184,150,.18);
  color: var(--ps-gold);
  padding: 1px 7px;
  border-radius: 999px;
}

/* ── Item row ── */
.dhtft-qs__item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--ps-text);
  border-bottom: 1px solid rgba(212,184,150,.04);
  transition: background .15s, transform .15s;
}
.dhtft-qs__group .dhtft-qs__item:last-child { border-bottom: 0; }
.dhtft-qs__item:hover,
.dhtft-qs__item.is-active {
  background: rgba(212,184,150,.07);
}
.dhtft-qs__item:hover .dhtft-qs__item-name,
.dhtft-qs__item.is-active .dhtft-qs__item-name { color: var(--ps-gold); }

.dhtft-qs__thumb {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: #1a1f33;
  border: 1px solid rgba(212,184,150,.14);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.dhtft-qs__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Cost rings cho tướng */
.dhtft-qs__thumb--unit { padding: 1.5px; }
.dhtft-qs__thumb--cost-1 { border-color: var(--cost-1); box-shadow: inset 0 0 0 1px rgba(154,160,166,.35); }
.dhtft-qs__thumb--cost-2 { border-color: var(--cost-2); box-shadow: inset 0 0 0 1px rgba(34,197,94,.35); }
.dhtft-qs__thumb--cost-3 { border-color: var(--cost-3); box-shadow: inset 0 0 0 1px rgba(59,130,246,.35); }
.dhtft-qs__thumb--cost-4 { border-color: var(--cost-4); box-shadow: inset 0 0 0 1px rgba(192,132,252,.4); }
.dhtft-qs__thumb--cost-5 { border-color: var(--cost-5); box-shadow: inset 0 0 0 1px rgba(251,191,36,.45); }

/* Item / post thumb */
.dhtft-qs__thumb--item { background: #0f1428; padding: 3px; }
.dhtft-qs__thumb--item img { object-fit: contain; }
.dhtft-qs__thumb--post { background: linear-gradient(135deg, rgba(212,184,150,.14), rgba(212,184,150,.04)); }
.dhtft-qs__thumb--post-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ps-gold);
  font-size: 14px;
  font-weight: 800;
}

.dhtft-qs__item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dhtft-qs__item-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(230,230,230,.92);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s;
}
.dhtft-qs__item-name mark {
  background: rgba(212,184,150,.22);
  color: var(--ps-gold);
  padding: 0 1px;
  border-radius: 2px;
}
.dhtft-qs__item-meta {
  font-size: 11px;
  color: rgba(230,230,230,.42);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Cost / category badge */
.dhtft-qs__item-cost {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: .3px;
  background: rgba(212,184,150,.1);
  color: var(--ps-gold);
  border: 1px solid rgba(212,184,150,.2);
  white-space: nowrap;
}
.dhtft-qs__item-cost--c1 { background: rgba(154,160,166,.1); color: var(--cost-1); border-color: rgba(154,160,166,.3); }
.dhtft-qs__item-cost--c2 { background: rgba(34,197,94,.1); color: var(--cost-2); border-color: rgba(34,197,94,.3); }
.dhtft-qs__item-cost--c3 { background: rgba(59,130,246,.1); color: var(--cost-3); border-color: rgba(59,130,246,.3); }
.dhtft-qs__item-cost--c4 { background: rgba(192,132,252,.12); color: var(--cost-4); border-color: rgba(192,132,252,.32); }
.dhtft-qs__item-cost--c5 { background: rgba(251,191,36,.12); color: var(--cost-5); border-color: rgba(251,191,36,.34); }

/* Footer "xem thêm" */
.dhtft-qs__more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ps-gold-dim);
  background: rgba(212,184,150,.025);
  text-decoration: none;
  border-top: 1px dashed rgba(212,184,150,.12);
  transition: color .15s, background .15s;
}
.dhtft-qs__more:hover { color: var(--ps-gold); background: rgba(212,184,150,.07); }

/* Mobile */
@media screen and (max-width: 480px) {
  .dhtft-qs__body { max-height: 360px; }
  .dhtft-qs__item { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 9px; }
  .dhtft-qs__thumb { width: 32px; height: 32px; }
  .dhtft-qs__item-name { font-size: 12.5px; }
}

/* Quick Search: ảnh tướng dùng icon vuông giống Team Builder */
.dhtft-qs__thumb--unit img {
  object-fit: cover;
  object-position: center center;
}
