/**
 * Custom Search Box Component
 * Completely independent of Bootstrap classes
 * Fully responsive and stable across all screen sizes
 */

/* ===== SEARCH BOX CONTAINER ===== */
.custom-search-form {
  width: 100%;
  max-width: 100%;
  margin: 0 auto 1.5rem auto;
  padding: 0;
}

.custom-search-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
}

.custom-search-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  background-color: #ffffff;
  border: 1px solid #dce3e8;
  border-radius: 0.5rem;
  padding: 0.375rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.custom-search-wrapper:focus-within {
  border-color: #467fcf;
  box-shadow: 0 4px 12px rgba(70, 127, 207, 0.15);
}

/* ===== SEARCH INPUT ===== */
.custom-search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #495057;
  background-color: transparent;
  border: none;
  border-radius: 0.375rem;
  outline: none;
  transition: background-color 0.2s ease;
}

.custom-search-input:focus {
  background-color: rgba(70, 127, 207, 0.04);
}

.custom-search-input::placeholder {
  color: #adb5bd;
  opacity: 1;
}

/* ===== SEARCH CONTROLS (SELECT + BUTTON) ===== */
.custom-search-controls {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ===== SEARCH SELECT ===== */
.custom-search-select {
  min-width: 140px;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #495057;
  background-color: #f8f9fa;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: none;
  border-radius: 0.375rem;
  outline: none;
  cursor: pointer;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-search-select:hover {
  background-color: #e9ecef;
}

.custom-search-select:focus {
  background-color: #e9ecef;
  box-shadow: 0 0 0 0.2rem rgba(70, 127, 207, 0.25);
}

/* ===== SEARCH BUTTON ===== */
.custom-search-button {
  min-width: 48px;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #ffffff;
  background: linear-gradient(135deg, #467fcf 0%, #5d92e0 100%);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 600;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 2px 6px rgba(70, 127, 207, 0.25);
}

.custom-search-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(70, 127, 207, 0.35);
  background: linear-gradient(135deg, #5d92e0 0%, #467fcf 100%);
}

.custom-search-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(70, 127, 207, 0.25);
}

.custom-search-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(70, 127, 207, 0.4);
}

.custom-search-button i {
  font-size: 1rem;
  line-height: 1;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Large Desktop - Extra spacing */
@media (min-width: 1200px) {
  .custom-search-form {
    margin-bottom: 2rem;
  }
}

/* Desktop - Default layout */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .custom-search-container {
    max-width: 750px;
  }
}

/* Tablet - Adjusted spacing */
@media (min-width: 768px) and (max-width: 991.98px) {
  .custom-search-container {
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .custom-search-wrapper {
    gap: 0.375rem;
  }
  
  .custom-search-select {
    min-width: 120px;
  }
  
  .custom-search-button {
    padding: 0.625rem 1rem;
  }
}

/* Mobile - Stacked layout */
@media (max-width: 767.98px) {
  .custom-search-form {
    margin-bottom: 1rem;
  }
  
  .custom-search-container {
    max-width: 100%;
    padding: 0;
  }
  
  .custom-search-wrapper {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  .custom-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem; /* Prevents iOS zoom */
  }
  
  .custom-search-controls {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }
  
  .custom-search-select {
    width: 100%;
    min-width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem; /* Prevents iOS zoom */
  }
  
  .custom-search-button {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-width: 100%;
    min-height: 48px; /* Better touch target */
  }
}

/* Extra Small Mobile - Compact spacing */
@media (max-width: 575.98px) {
  .custom-search-wrapper {
    padding: 0.375rem;
  }
  
  .custom-search-input,
  .custom-search-select,
  .custom-search-button {
    padding: 0.625rem 0.875rem;
  }
}

/* ===== VISIBILITY CONTROL ===== */
/* Override any d-none d-lg-block classes on parent */
.custom-search-form,
.search-box .custom-search-form {
  display: block !important;
}

/* Ensure search box is visible on all screens when wrapped in search-box container */
.search-box {
  display: block !important;
  max-width: 100%;
}

/* ===== PRINT STYLES ===== */
@media print {
  .custom-search-form {
    display: none !important;
  }
}

/* ===== ACCESSIBILITY ===== */
.custom-search-input:focus,
.custom-search-select:focus,
.custom-search-button:focus {
  outline: 2px solid #467fcf;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .custom-search-wrapper {
    border-width: 2px;
  }
  
  .custom-search-button {
    border: 2px solid #ffffff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .custom-search-wrapper,
  .custom-search-input,
  .custom-search-select,
  .custom-search-button {
    transition: none;
  }
}
