/* ================================================================
   TechDeft — AJAX Live Search Styles
   Matches the dark-navy (#0F172A) theme palette.
   ================================================================ */

/* ── Search wrap container ──────────────────────────────────────── */
.td-ajax-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

/* ── Form ────────────────────────────────────────────────────────── */
.td-search-form {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 5px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.td-search-form:focus-within {
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Search icon ─────────────────────────────────────────────────── */
.td-search-icon {
  display: flex;
  align-items: center;
  color: #64748B;
  flex-shrink: 0;
}

/* ── Input ───────────────────────────────────────────────────────── */
.td-search-input {
  background: transparent;
  border: none;
  outline: none;
  color: #E2E8F0;
  font-size: 12px;
  font-family: inherit;
  width: 140px;
  min-width: 0;
  caret-color: #3B82F6;
  transition: width 0.25s ease;
}

.td-search-input::placeholder {
  color: #64748B;
}

.td-search-form:focus-within .td-search-input {
  width: 180px;
}

/* ── Spinner (in-input indicator) ────────────────────────────────── */
.td-search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #334155;
  border-top-color: #3B82F6;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.td-search-spinner.is-visible {
  opacity: 1;
  transform: scale(1);
  animation: td-spin 0.7s linear infinite;
}

@keyframes td-spin {
  to { transform: rotate(360deg); }
}

/* ── Submit button ───────────────────────────────────────────────── */
.td-search-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  color: #64748B;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
}

.td-search-submit:hover {
  color: #3B82F6;
}

/* ================================================================
   DROPDOWN
   ================================================================ */
.td-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: #1a1f2e;
  border: 1px solid #263045;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(59, 130, 246, 0.08);
  overflow: hidden;
  z-index: 9999;

  /* Hidden state */
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* When JS removes [hidden] and adds .is-open */
.td-search-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Results list ────────────────────────────────────────────────── */
.td-sr-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.td-sr-list::-webkit-scrollbar {
  width: 4px;
}

.td-sr-list::-webkit-scrollbar-track {
  background: transparent;
}

.td-sr-list::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

/* ── Single result item ──────────────────────────────────────────── */
.td-sr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  outline: none;
}

.td-sr-item:hover,
.td-sr-item.is-active {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: #3B82F6;
}

.td-sr-item + .td-sr-item {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ── Thumbnail ───────────────────────────────────────────────────── */
.td-sr-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #263045;
}

.td-sr-thumb img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.td-sr-item:hover .td-sr-thumb img,
.td-sr-item.is-active .td-sr-thumb img {
  transform: scale(1.05);
}

.td-sr-thumb-placeholder {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
}

/* ── Info block ──────────────────────────────────────────────────── */
.td-sr-info {
  flex: 1;
  min-width: 0;
}

.td-sr-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #E2E8F0;
  line-height: 1.35;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Highlight matching portion of title */
.td-sr-title mark {
  background: rgba(59, 130, 246, 0.25);
  color: #93C5FD;
  border-radius: 2px;
  padding: 0 1px;
}

.td-sr-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.td-sr-cat {
  font-size: 10px;
  font-weight: 700;
  color: #3B82F6;
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.td-sr-date,
.td-sr-time {
  font-size: 10px;
  color: #64748B;
  white-space: nowrap;
}

.td-sr-time::before {
  content: '·';
  margin-right: 6px;
}

/* ── Loading state ───────────────────────────────────────────────── */
.td-sr-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  font-size: 13px;
  color: #64748B;
}

.td-sr-spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #263045;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: td-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Empty / no results ──────────────────────────────────────────── */
.td-sr-empty {
  padding: 28px 16px;
  text-align: center;
  color: #64748B;
}

.td-sr-empty svg {
  margin: 0 auto 10px;
  display: block;
  opacity: 0.4;
}

.td-sr-empty p {
  font-size: 13px;
  color: #94A3B8;
  margin-bottom: 4px;
}

.td-sr-empty p strong {
  color: #CBD5E1;
}

.td-sr-empty span {
  font-size: 11px;
  color: #475569;
}

/* ── "View all results" footer link ──────────────────────────────── */
.td-sr-viewall {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #3B82F6;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(59, 130, 246, 0.04);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.td-sr-viewall:hover {
  background: rgba(59, 130, 246, 0.12);
  color: #60A5FA;
}

.td-sr-viewall em {
  font-style: normal;
  font-weight: 700;
  color: #93C5FD;
}

/* ================================================================
   MOBILE — full width dropdown
   ================================================================ */
@media (max-width: 900px) {
  /* Header nav search hidden on mobile → skip these rules */
  .td-search-dropdown {
    width: calc(100vw - 32px);
    right: -10px;
    left: auto;
  }
}

@media (max-width: 480px) {
  .td-search-dropdown {
    width: calc(100vw - 24px);
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
  }

  .td-search-dropdown.is-open {
    transform: translateX(-50%) translateY(0);
  }

  .td-sr-item {
    padding: 9px 12px;
    gap: 10px;
  }

  .td-sr-thumb,
  .td-sr-thumb img {
    width: 48px;
    height: 48px;
  }
}

/* ================================================================
   ACCESSIBILITY — reduce motion
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .td-search-dropdown,
  .td-sr-thumb img {
    transition: none;
  }

  .td-search-spinner,
  .td-sr-spinner-inline {
    animation: none;
    opacity: 1;
  }
}
