/**
 * Frontend styles for HeaderHunt Search Bar.
 * Version: 1.0.0
 * License: GPL-2.0-or-later
 */

/* ==========================================================================
   Reset & Base
   ========================================================================== */

.headerhunt-search-bar-wrap * {
  box-sizing: border-box;
}

.headerhunt-search-bar-wrap {
  width: 100%;
  padding: var(--headerhunt-desktop-padding, 16px 0);
  background-color: var(--headerhunt-bg-color, #f8f9fa);
  clear: both;
  position: relative;
  z-index: 99;
}

/* ==========================================================================
   Sticky Search Bar
   ========================================================================== */

.headerhunt-sticky-spacer {
  display: none;
  box-sizing: border-box;
}

.headerhunt-search-bar-wrap.headerhunt-is-sticky {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 999;
  transition: box-shadow 0.25s ease;
}

/* Compensate for WordPress admin bar when logged in (CSS sticky fallback) */
.admin-bar .headerhunt-search-bar-wrap.headerhunt-is-sticky {
  top: 32px;
}

@media screen and (max-width: 782px) {
  .admin-bar .headerhunt-search-bar-wrap.headerhunt-is-sticky {
    top: 46px;
  }
}

/* Pinned sticky state: position fixed ensures it never breaks under theme overflow:hidden */
.headerhunt-search-bar-wrap.headerhunt-is-sticky.headerhunt-is-stuck {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  z-index: 999999 !important;
  margin: 0 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* Elevation shadow when sticky bar is stuck */
.headerhunt-search-bar-wrap.headerhunt-is-sticky.headerhunt-has-sticky-shadow.headerhunt-is-stuck {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15) !important;
}

/* ==========================================================================
   Search Bar Container & Form
   ========================================================================== */

.headerhunt-search-bar-inner {
  max-width: var(--headerhunt-max-width, 720px);
  margin: 0 auto;
  padding: 0 16px;
}

.headerhunt-search-form {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
  position: relative;
}

.headerhunt-search-field-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--headerhunt-height, 48px);
  background: var(--headerhunt-input-bg, #ffffff);
  border: 1px solid var(--headerhunt-border-color, #e0e0e0);
  border-radius: var(--headerhunt-border-radius, 8px);
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.headerhunt-search-field-wrap:focus-within {
  border-color: var(--headerhunt-focus-border-color, var(--headerhunt-button-bg, #0073aa));
  box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.18);
  outline: none;
}

/* ==========================================================================
   Shapes & Silhouettes
   ========================================================================== */

/* Shape: Rounded */
.headerhunt-shape-rounded .headerhunt-search-field-wrap {
  border-radius: var(--headerhunt-border-radius, 8px);
}

/* Shape: Full Pill */
.headerhunt-shape-pill .headerhunt-search-field-wrap {
  border-radius: 9999px !important;
}

.headerhunt-shape-pill .headerhunt-search-button:not(.headerhunt-btn-circular):not(.headerhunt-btn-inset-pill) {
  border-top-right-radius: 9999px;
  border-bottom-right-radius: 9999px;
  padding-right: 22px;
}

.headerhunt-shape-pill .headerhunt-filter-select-wrap {
  border-top-left-radius: 9999px;
  border-bottom-left-radius: 9999px;
  padding-left: 20px;
}

.headerhunt-shape-pill:not(.headerhunt-has-filter) .headerhunt-search-icon-wrap {
  padding-left: 20px !important;
  padding-right: 10px !important;
}

/* Shape: Sharp Square / Bauhaus */
.headerhunt-shape-square .headerhunt-search-field-wrap,
.headerhunt-shape-square .headerhunt-search-button,
.headerhunt-shape-square .headerhunt-filter-select-wrap {
  border-radius: 0 !important;
}

/* Shape: Soft Modern Curve */
.headerhunt-shape-soft .headerhunt-search-field-wrap {
  border-radius: 16px !important;
}

.headerhunt-shape-soft .headerhunt-search-button:not(.headerhunt-btn-circular):not(.headerhunt-btn-inset-pill) {
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}

.headerhunt-shape-soft .headerhunt-filter-select-wrap {
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}

/* Shape: Asymmetric Leaf */
.headerhunt-shape-asymmetric .headerhunt-search-field-wrap {
  border-radius: 24px 6px 24px 6px !important;
}

.headerhunt-shape-asymmetric .headerhunt-search-button:not(.headerhunt-btn-circular):not(.headerhunt-btn-inset-pill) {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.headerhunt-shape-asymmetric .headerhunt-filter-select-wrap {
  border-top-left-radius: 24px;
  border-bottom-left-radius: 6px;
}

/* Shape: Underline Ghost */
.headerhunt-shape-underline .headerhunt-search-field-wrap {
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 2px solid var(--headerhunt-border-color, #e0e0e0) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.headerhunt-shape-underline .headerhunt-search-field-wrap:focus-within {
  border-bottom-color: var(--headerhunt-focus-border-color, var(--headerhunt-button-bg, #0073aa)) !important;
  box-shadow: none !important;
}

/* Shape: Neo-Brutalist */
.headerhunt-shape-brutalist .headerhunt-search-field-wrap {
  border: 3px solid #000000 !important;
  border-radius: 0 !important;
  box-shadow: 4px 4px 0px #000000 !important;
}

.headerhunt-shape-brutalist .headerhunt-search-button {
  border-left: 3px solid #000000 !important;
  border-radius: 0 !important;
}

/* Shape: Frosted Glass */
.headerhunt-shape-glass .headerhunt-search-field-wrap {
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--headerhunt-border-color, rgba(255, 255, 255, 0.45)) !important;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.12), inset 0 1px 1px 0 rgba(255, 255, 255, 0.6) !important;
  background-clip: padding-box;
}

.headerhunt-shape-glass .headerhunt-search-field-wrap:focus-within {
  border-color: var(--headerhunt-focus-border-color, rgba(255, 255, 255, 0.8)) !important;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.22), 0 0 16px var(--headerhunt-focus-border-color, rgba(99, 102, 241, 0.45)), inset 0 1px 2px rgba(255, 255, 255, 0.8) !important;
}

.headerhunt-shape-glass .headerhunt-search-button {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   Shadows & Depth
   ========================================================================== */

.headerhunt-shadow-subtle .headerhunt-search-field-wrap {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

.headerhunt-shadow-floating .headerhunt-search-field-wrap {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
}

.headerhunt-shadow-brutalist:not(.headerhunt-shape-brutalist) .headerhunt-search-field-wrap {
  box-shadow: 4px 4px 0px #000000;
}

.headerhunt-shadow-glow .headerhunt-search-field-wrap {
  box-shadow: 0 0 24px var(--headerhunt-focus-border-color, rgba(34, 113, 177, 0.4));
}

/* ==========================================================================
   In-Bar Category / Taxonomy Filter Dropdown
   ========================================================================== */

.headerhunt-filter-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px 0 14px;
  border-right: 1px solid var(--headerhunt-border-color, #e0e0e0);
  background: rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}

.headerhunt-filter-select {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--headerhunt-text-color, #333333);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  padding-right: 16px;
  max-width: 135px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: normal;
}

.headerhunt-filter-select:focus {
  outline: none;
}

.headerhunt-filter-arrow {
  position: absolute;
  right: 8px;
  font-size: 9px;
  color: #718096;
  pointer-events: none;
}

/* ==========================================================================
   Search Icon & Input Field
   ========================================================================== */

.headerhunt-search-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 100%;
  padding-left: var(--headerhunt-icon-spacing-left, 18px);
  padding-right: var(--headerhunt-icon-spacing-right, 10px);
  color: var(--headerhunt-icon-color, #888888);
  pointer-events: none;
  line-height: 1;
}

.headerhunt-search-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: inherit;
  pointer-events: none;
  display: block;
}

.headerhunt-has-filter .headerhunt-search-icon-wrap {
  padding-left: 12px;
}

.headerhunt-search-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 10px;
  border: none !important;
  background: transparent !important;
  color: var(--headerhunt-text-color, #333333) !important;
  font-size: 15px;
  font-family: inherit;
  line-height: normal;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
}

.headerhunt-search-input::placeholder {
  color: var(--headerhunt-text-color, #a0aec0);
  opacity: 0.65;
}

.headerhunt-search-input::-webkit-search-cancel-button,
.headerhunt-search-input::-webkit-search-decoration,
.headerhunt-search-input::-webkit-search-results-button,
.headerhunt-search-input::-webkit-search-results-decoration {
  display: none;
}

/* ==========================================================================
   Keyboard Shortcut Badge (⌘K / /)
   ========================================================================== */

.headerhunt-shortcut-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  background: rgba(125, 125, 125, 0.12);
  border: 1px solid rgba(125, 125, 125, 0.22);
  border-radius: 4px;
  color: var(--headerhunt-text-color, #64748b);
  margin-right: 8px;
  user-select: none;
  opacity: 0.85;
  line-height: 1.3;
  flex-shrink: 0;
  cursor: pointer;
}

.headerhunt-shortcut-badge:hover {
  opacity: 1;
  background: rgba(125, 125, 125, 0.2);
}

/* ==========================================================================
   Clear ("X") Button
   ========================================================================== */

.headerhunt-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-right: 8px;
  border: none;
  border-radius: 50%;
  background: #edf2f7;
  color: #718096;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  line-height: 1;
}

.headerhunt-clear-btn:hover {
  background: #e2e8f0;
  color: #2d3748;
}

/* ==========================================================================
   Submit Button
   ========================================================================== */

.headerhunt-search-button {
  flex-shrink: 0;
  height: 100%;
  padding: 0 20px;
  border: none !important;
  border-top-right-radius: inherit;
  border-bottom-right-radius: inherit;
  background: var(--headerhunt-button-bg, #0073aa) !important;
  color: var(--headerhunt-button-text-color, #ffffff) !important;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease, filter 0.2s ease;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0 !important;
}

.headerhunt-search-button:hover,
.headerhunt-search-button:focus {
  opacity: 0.92;
}

.headerhunt-search-button:focus-visible {
  outline: 2px solid var(--headerhunt-button-bg, #0073aa);
  outline-offset: -2px;
}

/* Button Style: Circular */
.headerhunt-search-button.headerhunt-btn-circular {
  width: calc(var(--headerhunt-height, 48px) - 12px) !important;
  height: calc(var(--headerhunt-height, 48px) - 12px) !important;
  border-radius: 50% !important;
  margin: 6px 8px 6px 4px !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Button Style: Inset Pill */
.headerhunt-search-button.headerhunt-btn-inset_pill,
.headerhunt-search-button.headerhunt-btn-inset-pill {
  height: calc(var(--headerhunt-height, 48px) - 12px) !important;
  border-radius: 9999px !important;
  margin: 6px 8px 6px 4px !important;
  padding: 0 18px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Button Style: Icon Only */
.headerhunt-search-button.headerhunt-btn-icon {
  padding: 0 16px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Button Style: Icon + Text */
.headerhunt-search-button.headerhunt-btn-both {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px !important;
}

.headerhunt-btn-icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ==========================================================================
   Live Search Results Dropdown (Ajax)
   ========================================================================== */

.headerhunt-live-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 99999;
  overflow: hidden;
  animation: headerhuntFadeIn 0.18s ease forwards;
  max-height: 420px;
  overflow-y: auto;
}

@keyframes headerhuntFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.headerhunt-live-items {
  padding: 4px 0;
}

.headerhunt-live-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  text-decoration: none;
  color: #2d3748;
  border-bottom: 1px solid #f7fafc;
  transition: background 0.15s ease;
}

.headerhunt-live-item:last-child {
  border-bottom: none;
}

.headerhunt-live-item:hover,
.headerhunt-live-item.headerhunt-result-active {
  background: #f7fafc;
  color: var(--headerhunt-button-bg, #0073aa);
}

.headerhunt-live-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  margin-right: 12px;
  flex-shrink: 0;
  background: #edf2f7;
}

.headerhunt-live-info {
  flex: 1;
  min-width: 0;
}

.headerhunt-live-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a202c;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.headerhunt-live-item:hover .headerhunt-live-title,
.headerhunt-live-item.headerhunt-result-active .headerhunt-live-title {
  color: var(--headerhunt-button-bg, #0073aa);
}

.headerhunt-live-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: #718096;
}

.headerhunt-live-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #edf2f7;
  color: #4a5568;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.headerhunt-live-view-all {
  display: block;
  padding: 10px 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--headerhunt-button-bg, #0073aa);
  background: #f8fafc;
  text-decoration: none;
  border-top: 1px solid #edf2f7;
  transition: background 0.15s ease;
}

.headerhunt-live-view-all:hover {
  background: #edf2f7;
}

/* Loading & Empty States */
.headerhunt-live-loading,
.headerhunt-live-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  font-size: 13px;
  color: #718096;
}

.headerhunt-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 115, 170, 0.2);
  border-top-color: var(--headerhunt-button-bg, #0073aa);
  border-radius: 50%;
  animation: headerhuntSpin 0.6s linear infinite;
}

@keyframes headerhuntSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Accessibility & Helper Classes
   ========================================================================== */

.headerhunt-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.headerhunt-search-bar-wrap--hidden {
  display: none;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 768px) {
  .headerhunt-search-bar-wrap {
    padding: var(--headerhunt-mobile-padding, 12px 16px);
  }
  
  .headerhunt-search-bar-inner {
    padding: 0;
  }

  .headerhunt-filter-select {
    max-width: 95px;
    font-size: 12px;
  }
  
  .headerhunt-search-button {
    padding: 0 14px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .headerhunt-filter-select-wrap {
    padding: 0 6px 0 8px;
  }

  .headerhunt-filter-select {
    max-width: 75px;
    font-size: 11px;
  }

  .headerhunt-search-input {
    font-size: 14px;
    padding: 0 8px;
  }
  
  .headerhunt-search-icon {
    width: 16px;
    height: 16px;
  }
}
