/**
 * Chris Beard APS - AJAX Product Search Styles
 * Matches the JCB brand identity: Yellow (#ffcd00), Black (#000000), Dark Gray (#333333)
 */

.cb-ajax-search-wrap {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

.cb-ajax-search-form {
  position: relative;
  width: 100%;
}

/* Search Bar Wrapper (Matches Image 3) */
.cb-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  background-color: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.cb-search-input-wrapper:focus-within {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 205, 0, 0.6);
}

/* Text Input */
.cb-search-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 8px 40px 8px 15px !important;
  font-size: 1rem;
  font-weight: 400;
  color: #111111;
  background-color: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  line-height: 1.5;
  font-family: inherit;
}

.cb-search-input::placeholder {
  color: #000;
  opacity: 1;
}

/* Hide default browser search cancel buttons */
.cb-search-input::-webkit-search-decoration,
.cb-search-input::-webkit-search-cancel-button,
.cb-search-input::-webkit-search-results-button,
.cb-search-input::-webkit-search-results-decoration {
  display: none;
}

/* Clear Button */
.cb-search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0 10px;
  color: #8c8f94;
  cursor: pointer;
  transition: color 0.15s ease;
  outline: none;
}

.cb-ajax-search-wrap.has-value .cb-search-clear {
  display: flex;
}

.cb-search-clear:hover {
  color: #000000;
}

/* Loading Spinner */
.cb-search-spinner {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.cb-search-spinner::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #ffcd00;
  border-radius: 50%;
  animation: cb-spin 0.6s linear infinite;
}

.cb-ajax-search-wrap.is-loading .cb-search-spinner {
  display: flex;
}

.cb-ajax-search-wrap.is-loading .cb-search-clear {
  display: none !important;
}

@keyframes cb-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Yellow Submit Button (Matches Image 3) */
.cb-search-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--jcb-yellow, #ffcd00);
  border: none;
  color: #000000;
  padding: 0 24px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.cb-search-submit:hover,
.cb-search-submit:focus {
  background-color: #e5b800;
  color: #000000;
  outline: none;
}

.cb-search-submit i,
.cb-search-submit svg {
  font-size: 1.25rem;
}

/* ========================================================
   Live Search Dropdown
   ======================================================== */
.cb-search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  z-index: 9999;
  text-align: left;
  max-height: 480px;
  overflow-y: auto;
}

/* Results List */
.cb-search-results-list {
  display: flex;
  flex-direction: column;
}

/* Individual Result Row */
.cb-search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none !important;
  color: #1e293b !important;
  transition: background-color 0.15s ease;
}

.cb-search-result-item:last-child {
  border-bottom: none;
}

.cb-search-result-item:hover,
.cb-search-result-item.cb-selected {
  background-color: #fef9c3; /* Subtle warm yellow highlight */
  color: #000000 !important;
}

/* Thumbnail */
.cb-result-thumb {
  width: 52px;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
  background-color: #f8fafc;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cb-result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Info Column */
.cb-result-info {
  flex: 1 1 auto;
  min-width: 0;
}

.cb-result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 4px 0;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-search-result-item:hover .cb-result-title,
.cb-search-result-item.cb-selected .cb-result-title {
  color: #000000;
}

.cb-result-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.775rem;
  color: #64748b;
  margin-bottom: 2px;
}

.cb-result-sku {
  background-color: #e2e8f0;
  color: #1e293b;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-weight: 600;
}

.cb-result-category {
  color: #475569;
}

.cb-result-stock {
  display: inline-block;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 3px;
}

.cb-result-stock.in-stock {
  color: #15803d;
  background-color: #dcfce7;
}

.cb-result-stock.out-of-stock {
  color: #b91c1c;
  background-color: #fee2e2;
}

/* Price Column */
.cb-result-price-wrap {
  text-align: right;
  flex-shrink: 0;
  padding-left: 8px;
}

.cb-result-price {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.cb-result-price del {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-right: 4px;
}

.cb-result-price ins {
  text-decoration: none;
  color: #b91c1c;
}

.cb-result-price-suffix {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

/* View All Footer */
.cb-search-results-footer {
  background-color: #ffffff;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.04);
}

.cb-search-view-all {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d70b8 !important;
  text-decoration: none !important;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.cb-search-view-all:hover,
.cb-search-view-all:focus {
  color: #004499 !important;
  text-decoration: underline !important;
}

.cb-search-view-all svg {
  display: none !important;
}

/* No Results & Message */
.cb-search-message {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 0.925rem;
}

.cb-search-message i,
.cb-search-message svg {
  display: block;
  margin: 0 auto 8px auto;
  color: #94a3b8;
}

/* Mobile Adjustments */
@media (max-width: 576px) {
  .cb-search-input {
    padding: 10px 14px;
    font-size: 0.9rem;
  }
  .cb-search-submit {
    padding: 0 18px;
  }
  .cb-result-thumb {
    width: 44px;
    height: 44px;
  }
  .cb-result-title {
    font-size: 0.875rem;
  }
  .cb-result-price {
    font-size: 0.9rem;
  }
}

/* Sidebar Adjustments (.list-search) */
.list-search .cb-ajax-search-wrap {
  max-width: 100%;
}

.list-search .cb-search-input-wrapper {
  border: 1px solid #000000;
  border-radius: 0;
  box-shadow: none;
}

.list-search .cb-search-submit {
  border-left: 1px solid #000000;
  border-radius: 0;
  padding: 0 20px;
}

.list-search .cb-search-input {
  padding: 10px 14px;
}
