/**
 * @file
 * Search integration styles for Commercial Pro theme.
 * Focuses on search form integration and autocomplete functionality.
 * Optimized with CSS custom properties and consolidated selectors.
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES
   ========================================================================== */
:root {
  /* Search Integration Colors */
  --search-form-bg: rgba(255, 255, 255, 0.1);
  --search-form-bg-hover: rgba(255, 255, 255, 0.15);
  --search-form-bg-focus: rgba(255, 255, 255, 0.2);
  --search-form-border: rgba(255, 255, 255, 0.2);
  --search-form-border-hover: rgba(255, 255, 255, 0.3);
  --search-form-border-focus: var(--primary-color, #ff6b35);
  
  /* Search Form Text Colors */
  --search-form-text: #333333;
  --search-form-placeholder: #666666;
  --search-form-button: #333;
  
  /* Search Page Colors */
  --search-page-bg: white;
  --search-page-border: #ddd;
  --search-page-text: #333;
  --search-page-placeholder: #999;
  --search-page-button: var(--primary-color, #ff6b35);
  
  /* Info & Empty States */
  --search-info-bg: #f8f9fa;
  --search-info-border: #2B5A87;
  --search-info-text: #495057;
  --search-empty-bg: white;
  --search-empty-border: #e9ecef;
  --search-empty-text: #6c757d;
  
  /* Search Form Layout */
  --search-form-border-radius: 25px;
  --search-form-padding: 8px 15px;
  --search-form-min-width: 200px;
  --search-form-button-size: 40px;
  
  /* Search Transitions */
  --search-form-transition: all 0.3s ease;
  
  /* Search Shadows */
  --search-form-focus-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
  
  /* Backdrop Effects */
  --search-backdrop-blur: blur(10px);
}

/* ==========================================================================
   SEARCH FORM BASE STYLES
   ========================================================================== */

/* Search block wrapper */
.search-block-wrapper {
  position: relative;
  width: 100%;
}

/* General search form selectors - for non-header forms */
:is(.search-form, .search-block-form):not(.header-main .search-form) {
  display: flex;
  align-items: center;
  background: var(--search-form-bg);
  backdrop-filter: var(--search-backdrop-blur);
  transition: var(--search-form-transition);


  background: var(--header-search-bg);
  border: 1px solid var(--header-search-border);
  border-radius: var(--header-search-border-radius);
  padding: var(--header-search-padding);
  margin: 0;
}

:is(.search-form, .search-block-form):not(.header-main .search-form):hover {
  background: var(--search-form-bg-hover);
  border-color: var(--search-form-border-hover);
}

:is(.search-form, .search-block-form):not(.header-main .search-form):focus-within {
  background: var(--search-form-bg-focus);
  border-color: var(--search-form-border-focus);
  box-shadow: var(--search-form-focus-shadow);
}

/* ==========================================================================
   SEARCH INPUT STYLES
   ========================================================================== */

/* Search input selectors - for non-header forms */
:is(.search-form, .search-block-form):not(.header-main .search-form) :is(
  input[type="search"],
  .form-control
) {
  background: transparent;
  border: none;
  outline: none;
  color: var(--search-form-text);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  min-width: var(--search-form-min-width);
}

:is(.search-form, .search-block-form):not(.header-main .search-form) :is(
  input[type="search"]::placeholder,
  .form-control::placeholder
) {
  color: var(--search-form-placeholder);
}

/* ==========================================================================
   SEARCH BUTTON STYLES
   ========================================================================== */

/* Search button selectors - for non-header forms */
:is(.search-form, .search-block-form):not(.header-main .search-form) :is(
  .search-submit,
  button[type="submit"],
  .btn-search
) {
  background: transparent;
  border: none;
  color: var(--search-form-button);
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--search-form-transition);
  border-radius: 50%;
  width: var(--search-form-button-size);
  height: var(--search-form-button-size);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

:is(.search-form, .search-block-form):not(.header-main .search-form) :is(
  .search-submit:hover,
  button[type="submit"]:hover,
  .btn-search:hover
) {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

:is(.search-form, .search-block-form):not(.header-main .search-form) :is(
  .search-submit:active,
  button[type="submit"]:active,
  .btn-search:active
) {
  transform: scale(0.95);
}

/* Hide submit button text if any */
:is(.search-form, .search-block-form) :is(
  .search-submit .js-form-submit,
  button[type="submit"] .js-form-submit
) {
  display: none;
}

/* ==========================================================================
   SEARCH PAGE SPECIFIC STYLES
   ========================================================================== */

.page-search .content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.page-search .search-form {
  background: var(--search-page-bg);
  border: 2px solid var(--search-page-border);
  margin-bottom: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.page-search .search-form input[type="search"] {
  color: var(--search-page-text);
  border-radius: 10px;
}

.page-search .search-form input[type="search"]::placeholder {
  color: var(--search-page-placeholder);
}

.page-search .search-form .search-submit {
  color: var(--search-page-button);
}

/* ==========================================================================
   SEARCH INFO & EMPTY STATES
   ========================================================================== */

/* Search results count and info */
.search-info {
  background: var(--search-info-bg);
  padding: 16px 24px;
  border-radius: 8px;
  margin-bottom: 24px;
  border-left: 4px solid var(--search-info-border);
  font-size: 14px;
  color: var(--search-info-text);
}

/* No results message */
.search-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--search-empty-bg);
  border-radius: 12px;
  border: 1px solid var(--search-empty-border);
  margin: 40px 0;
}

.search-empty h3 {
  color: var(--search-empty-text);
  margin-bottom: 16px;
  font-size: 1.5rem;
}

/* ==========================================================================
   AUTOCOMPLETE STYLING
   ========================================================================== */

.ui-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
}

.ui-autocomplete .ui-menu-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.ui-autocomplete .ui-menu-item:hover,
.ui-autocomplete .ui-menu-item.ui-state-focus {
  background: #f8f9fa;
}

.ui-autocomplete .ui-menu-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   SEARCH ANIMATIONS
   ========================================================================== */

.search-result-item {
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
  :is(.search-form, .search-block-form):not(.header-main .search-form) :is(
    input[type="search"],
    .form-control
  ) {
    min-width: 150px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .header-search {
    width: 100%;
    margin-bottom: 1rem;
  }
}

@media (max-width: 576px) {
  :is(.search-form, .search-block-form):not(.header-main .search-form) :is(
    input[type="search"],
    .form-control
  ) {
    min-width: 120px;
    padding: 6px 10px;
  }
}

/* ==========================================================================
   ACCESSIBILITY & DARK MODE
   ========================================================================== */

/* Focus styles for accessibility */
:is(.search-form, .search-block-form) :is(
  input[type="search"]:focus,
  .form-control:focus,
  button:focus,
  .search-submit:focus
) {
  outline: 2px solid var(--search-form-border-focus);
  outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .page-search .search-form {
    background: #2d3748;
    border-color: #4a5568;
  }

  .page-search .search-form input[type="search"] {
    color: #e2e8f0;
  }

  .page-search .search-form input[type="search"]::placeholder {
    color: #a0aec0;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :is(.search-form, .search-block-form) {
    border: 2px solid;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
} 