/* =============================================================
   SEARCH UPGRADE v2.1.1 — Uncle Kam Tax Intelligence Engine
   - Desktop: enhanced dropdown with type badges, highlight, keyboard nav
   - Desktop: larger, rounder Google-style hero search field (min-width: 1024px)
   - Mobile: full-screen overlay (max-width: 767px)
   All scoped under .tie-plugin-root to avoid WordPress theme conflicts.
   ============================================================= */

/* ---- SIDEBAR CTA TITLE (missing from design-system.css) ---- */
.tie-sidebar-cta-title {
  font-family: var(--tie-font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--tie-white);
  margin-bottom: 10px;
  line-height: 1.3;
}

/* ---- MATCHED TEXT HIGHLIGHT ---- */
.tie-plugin-root mark.tie-search-highlight {
  background: transparent;
  color: var(--tie-yellow, #F6B820);
  font-weight: 700;
}

/* ---- HERO SEARCH DROPDOWN ENHANCEMENTS ---- */
.tie-plugin-root .tie-search-suggestions {
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.08);
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tie-plugin-root .tie-search-suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.tie-plugin-root .tie-search-suggestion-item:last-child { border-bottom: none; }
.tie-plugin-root .tie-search-suggestion-item:hover,
.tie-plugin-root .tie-search-suggestion-item.selected { background: #f8f9ff; }
.tie-plugin-root .tie-search-suggestion-item.selected {
  outline: 2px solid var(--tie-yellow, #F6B820);
  outline-offset: -2px;
}
.tie-plugin-root .tie-search-suggestion-text { flex: 1; min-width: 0; }
.tie-plugin-root .tie-search-suggestion-name {
  font-family: var(--tie-font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--tie-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tie-plugin-root .tie-search-suggestion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.tie-plugin-root .tie-search-suggestion-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}
.tie-plugin-root .tie-search-suggestion-cat {
  font-size: 12px;
  color: var(--tie-text-muted);
}
.tie-plugin-root .tie-search-suggestion-savings {
  font-family: var(--tie-font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--tie-green, #16a34a);
  white-space: nowrap;
  flex-shrink: 0;
}
.tie-plugin-root .tie-search-no-results {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 13px;
  color: var(--tie-text-muted);
  font-family: var(--tie-font-body);
}
.tie-plugin-root .tie-search-no-results-icon { font-size: 18px; }

/* ---- DESKTOP ENLARGED HERO SEARCH (min-width: 1024px only) ---- */
@media (min-width: 1024px) {
  .tie-plugin-root .tie-hero-search-wrap { max-width: 780px; }
  .tie-plugin-root .tie-hero-search-input {
    padding: 22px 200px 22px 28px;
    border-radius: 50px;
    font-size: 17px;
    height: auto;
    line-height: 1.4;
  }
  .tie-plugin-root .tie-hero-search-input:focus {
    border-color: var(--tie-yellow, #F6B820);
    box-shadow: 0 8px 40px rgba(0,0,0,0.25), 0 0 0 4px rgba(246,184,32,0.18);
  }
  .tie-plugin-root .tie-hero-search-btn {
    right: 8px;
    padding: 14px 32px;
    border-radius: 40px;
    font-size: 14px;
  }
  .tie-plugin-root .tie-search-suggestions {
    border-radius: 20px;
    top: calc(100% + 10px);
  }
}

/* ---- MOBILE: prevent hero input from capturing focus (overlay handles it) ---- */
@media (max-width: 767px) {
  .tie-plugin-root .tie-hero-search-wrap { cursor: pointer; }
  .tie-plugin-root .tie-hero-search-input {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .tie-plugin-root .tie-hero-search-btn { pointer-events: none; }
}

/* ---- MOBILE FULL-SCREEN SEARCH OVERLAY ---- */
#tie-mobile-search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #fff;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tie-mobile-search-overlay.open {
  display: flex;
  animation: tieOverlayIn 0.22s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes tieOverlayIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tie-mobile-search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
.tie-mobile-search-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #1a1a2e;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tie-mobile-search-back:hover,
.tie-mobile-search-back:active { background: #f3f4f6; }
.tie-mobile-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: #f5f6fa;
  border-radius: 50px;
  padding: 0 16px;
  gap: 10px;
  height: 48px;
  border: 2px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.tie-mobile-search-input-wrap:focus-within {
  background: #fff;
  border-color: #F6B820;
}
.tie-mobile-search-icon { color: #9ca3af; flex-shrink: 0; }
.tie-mobile-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #1a1a2e;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-width: 0;
  -webkit-appearance: none;
}
.tie-mobile-search-input::placeholder { color: #9ca3af; }
.tie-mobile-search-input::-webkit-search-cancel-button { display: none; }
.tie-mobile-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: #d1d5db;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.tie-mobile-search-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.tie-mobile-search-hints { padding: 20px 16px 12px; }
.tie-mobile-search-hints-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 12px;
}
.tie-mobile-search-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tie-mobile-search-chip {
  padding: 8px 16px;
  background: #f3f4f6;
  color: #1a1a2e;
  border: none;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.tie-mobile-search-chip:active { background: #e5e7eb; }
.tie-mobile-search-results { padding: 0 0 24px; }
.tie-mobile-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  min-height: 60px;
}
.tie-mobile-result-item:active { background: #f8f9ff; }
.tie-mobile-result-left { flex: 1; min-width: 0; }
.tie-mobile-result-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tie-mobile-result-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tie-mobile-result-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}
.tie-mobile-result-cat {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tie-mobile-result-savings {
  font-size: 12px;
  font-weight: 700;
  color: #16a34a;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}
#tie-mobile-search-overlay mark.tie-search-highlight {
  background: transparent;
  color: #F6B820;
  font-weight: 700;
}
.tie-mobile-no-results { padding: 48px 24px; text-align: center; }
.tie-mobile-no-results-icon { font-size: 40px; margin-bottom: 12px; }
.tie-mobile-no-results-text {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.tie-mobile-no-results-hint {
  font-size: 13px;
  color: #6b7280;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
