/**
 * Product Search Component Styles
 *
 * @package OnlinePharmacy
 * @since 1.0.0
 */

/* ================================================
   SEARCH TRIGGER BUTTON (in header)
   ================================================ */
.header-main__search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.header-main__search-trigger:hover {
  background-color: rgba(105, 163, 168, 0.1);
}

.header-main__search-icon {
  width: 24px;
  height: 24px;
}

/* ================================================
   SEARCH DROPDOWN OVERLAY
   ================================================ */
.search-dropdown {
  position: fixed;
  top: 124px;
  left: 0;
  width: 100%;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1001;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  padding-bottom: 20px;
}

.search-dropdown.is-hidden {
  display: none;
}

.search-dropdown.is-open {
  transform: translateY(0);
  opacity: 1;
}

/* Search Dropdown Header */
.search-dropdown__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 100px;
  border-bottom: 1px solid #f4f4f4;
}

.search-dropdown__title {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  color: #2e3f3b;
  margin: 0;
}

.search-dropdown__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search-dropdown__close:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.search-dropdown__close-icon {
  width: 24px;
  height: 24px;
}

/* Search Dropdown Content - 45% width, centered */
.search-dropdown__content {
  max-width: 50%;
  padding: 24px 100px;
}

@media (max-width: 1024px) {
  .search-dropdown__content {
    max-width: 70%;
  }
  .search-dropdown__title {
    font-size: 34px;
  }
}
 
@media (max-width: 768px) {
  .search-dropdown__header {
    padding: 16px 16px 0px 16px;
  }
  .search-dropdown__close-icon {
    width: 20px;
    height: 20px;
  }
  .header-main__search-icon {
    width: 22px;
    height: 22px;
  }
  .search-dropdown__content {
    max-width: 100%;
    padding: 16px;
  }
}
 
/* Product Search Component */
.product-search {
  position: relative;
  width: 100%;
}

.product-search__form {
  width: 100%;
}

/* Input wrapper - acts as the visual "input" with button inside */
.product-search__input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #e0e0e0;
  border-radius: 50px;
  background: #ffffff;
  padding: 4px 4px 4px 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.product-search__input-wrapper:focus-within {
  border-color: #69a3a8;
  box-shadow: 0 0 0 3px rgba(105, 163, 168, 0.15);
}

.product-search__input {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 50px 0 0 50px;
  padding: 10px 16px 10px 24px;
  font-family: "Outfit", sans-serif;
  font-weight: 400;
  font-size: 16px;
  background: transparent;
  color: #2e3f3b;
}

.product-search__input::placeholder {
  color: #696969;
  font-weight: 400;
  font-size: 16px;
}

.product-search__input:focus {
  outline: none;
}

/* Search Button - appears inside the input wrapper */
.product-search__button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  min-width: 110px;
  padding: 10px 20px;
  border-radius: 50px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  background: #DBEDEB;
  color: #2E3F3B;
  font-weight: 600;
  font-size: 1rem;
}

/* Chevron icon in button */
.product-search__button-chevron {
  width: 16px;
  height: 16px;
  transition: opacity 0.2s ease;
  transform: translateY(1px);
}

.product-search__button.is-loading .product-search__button-chevron {
  opacity: 0;
}

.product-search__button:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
  opacity: 0.6;
}

.product-search__button:disabled:hover {
  background: #e0e0e0;
}

.product-search__button.is-loading {
  pointer-events: none;
}

.product-search__button-text {
  transition: opacity 0.2s ease;
}

.product-search__button-text.is-hidden {
  opacity: 0;
}

/* Loading Spinner */
.product-search__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-right-color: #ffffff;
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.product-search__spinner.is-visible {
  opacity: 1;
  visibility: visible;
  animation: searchSpinner 0.7s linear infinite;
}

@keyframes searchSpinner {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
} 

/* Dropdown Container */
.product-search__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  background-color: #ffffff;
  border-radius: 15px;
  box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.product-search__dropdown.is-hidden {
  display: none;
}

/* Custom Scrollbar */
.product-search__dropdown::-webkit-scrollbar {
  width: 6px;
}

.product-search__dropdown::-webkit-scrollbar-track {
  background: #f4f4f4;
  border-radius: 3px;
}

.product-search__dropdown::-webkit-scrollbar-thumb {
  background: #d3d5de;
  border-radius: 3px;
}

.product-search__dropdown::-webkit-scrollbar-thumb:hover {
  background: #696969;
}

/* Results Container */
.product-search__results {
  padding: 8px 0;
}

.product-search__results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Individual Result Item */
.product-search__result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f4f4f4;
}

.product-search__result-item:last-child {
  border-bottom: none;
}

.product-search__result-item:hover,
.product-search__result-item.is-focused {
  background-color: #ebf8f2;
}

.product-search__result-item:focus {
  outline: none;
  background-color: #ebf8f2;
}

/* Result Info */
.product-search__result-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.product-search__result-name {
  font-weight: 500;
  font-size: 15px;
  color: #2e3f3b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-search__result-price {
  font-weight: 400;
  font-size: 14px;
  color: #696969;
}

.product-search__result-price del {
  color: #d3d5de;
  margin-right: 4px;
}

.product-search__result-price ins {
  text-decoration: none;
  color: #3f7756;
  font-weight: 600;
}

/* Stock Status */
.product-search__result-stock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
  margin-left: 16px;
}

.product-search__result-stock .stock-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.product-search__result-stock.in-stock {
  color: #69a3a8;
}

.product-search__result-stock.in-stock .stock-indicator {
  background-color: #69a3a8;
}

.product-search__result-stock.out-of-stock {
  color: #b22234;
}

.product-search__result-stock.out-of-stock .stock-indicator {
  background-color: #b22234;
}

/* Search Highlight */
.product-search__highlight {
  background-color: rgba(105, 163, 168, 0.2);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* No Results State */
.product-search__no-results {
  padding: 28px 20px;
  text-align: center;
  color: #696969;
}

.product-search__no-results p {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.product-search__no-results p:last-child {
  margin-bottom: 0;
}

.product-search__no-results strong {
  color: #2e3f3b;
}

.product-search__suggestion {
  font-size: 13px;
  color: #696969;
}

/* Error State */
.product-search__error {
  padding: 28px 20px;
  text-align: center;
  color: #ff6565;
}

.product-search__error p {
  margin: 0;
  font-size: 14px;
}

/* Footer with Count and Load More */
.product-search__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  background-color: #f4f4f4;
  border-radius: 0 0 15px 15px;
}

.product-search__count {
  font-size: 13px;
  color: #696969;
}

/* Load More Button */
.product-search__load-more {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: #2e3f3b;
  color: #ffffff;
  border: none;
  border-radius: 50px;
  font-family: "Outfit", sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

.product-search__load-more:hover {
  background-color: #69a3a8;
}

.product-search__load-more:active {
  background-color: #3f7756;
}

.product-search__load-more.is-loading {
  pointer-events: none;
  opacity: 0.8;
}

.product-search__load-more.is-loading .product-search__load-more-text {
  opacity: 0.7;
}

.product-search__load-more-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-right-color: #ffffff;
  border-radius: 50%;
}

.product-search__load-more.is-loading .product-search__load-more-spinner {
  display: block;
  animation: loadMoreSpinner 0.7s linear infinite;
}

@keyframes loadMoreSpinner {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .product-search {
    max-width: 100%;
  }

  .product-search__input-wrapper {
    padding: 3px 3px 3px 0;
  }

  .product-search__input {
    padding: 8px 12px 8px 16px;
    font-size: 15px;
  }

  .product-search__button {
    min-width: 90px;
    padding: 8px 16px;
    font-size: 1rem;
  }

  .product-search__button-chevron {
    width: 14px;
    height: 14px;
  }

  .product-search__dropdown {
    max-height: 60vh;
  }

  .product-search__result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .product-search__result-stock {
    margin-left: 0;
  }
}
