/**
 * CodersGrow Store Instant Live Search - Stylesheet
 * High-performance, conversion-focused real-time search interface
 *
 * @package CodersGrow
 * @version 1.0.0
 */

/* ==========================================================================
   1. SEARCH CONTAINER & INPUT BAR
   ========================================================================== */
.cg-store-search-container {
  position: relative;
  width: 100%;
  margin-bottom: 2rem;
  clear: both;
  z-index: 20;
  font-family: var(--cg-font-body, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.cg-store-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 4px 14px 4px 16px;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.06), 0 1px 3px -1px rgba(15, 23, 42, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.cg-store-search-bar:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
}

.cg-store-search-bar:focus-within {
  border-color: #B42332;
  box-shadow: 0 0 0 4px rgba(180, 35, 50, 0.12), 0 4px 14px -2px rgba(180, 35, 50, 0.08);
}

.cg-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  margin-right: 12px;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.cg-store-search-bar:focus-within .cg-search-icon {
  color: #B42332;
}

.cg-store-search-input {
  width: 100%;
  height: 46px;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  color: #0f172a !important;
  font-family: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.cg-store-search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* Remove default webkit search decoration */
.cg-store-search-input::-webkit-search-decoration,
.cg-store-search-input::-webkit-search-cancel-button,
.cg-store-search-input::-webkit-search-results-button,
.cg-store-search-input::-webkit-search-results-decoration {
  display: none;
}

/* Clear button */
.cg-search-clear {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: 6px;
}

.cg-search-clear:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* Spinner indicator */
.cg-search-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #B42332;
  border-radius: 50%;
  animation: cg-spin 0.6s linear infinite;
  flex-shrink: 0;
  margin-left: 8px;
}

@keyframes cg-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   2. SEARCH DROPDOWN POPUP
   ========================================================================== */
.cg-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.16), 0 6px 14px -3px rgba(15, 23, 42, 0.08);
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 25;
  box-sizing: border-box;
  animation: cgDropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.cg-search-dropdown::-webkit-scrollbar {
  width: 6px;
}
.cg-search-dropdown::-webkit-scrollbar-track {
  background: #f8fafc;
}
.cg-search-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Section Header */
.cg-search-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px 16px;
  font-family: var(--cg-font-head, 'Outfit', sans-serif);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
}

.cg-search-section-header:first-child {
  border-top: none;
  border-top-left-radius: 13px;
  border-top-right-radius: 13px;
}

.cg-search-section-count {
  font-size: 0.7rem;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* Result item */
.cg-search-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  text-decoration: none !important;
  color: inherit !important;
  border-bottom: 1px solid #f8fafc;
  transition: all 0.15s ease;
  cursor: pointer;
}

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

.cg-search-item:hover,
.cg-search-item.cg-item-active {
  background: #fef2f2;
}

.cg-search-item-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cg-search-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cg-search-item-thumb svg {
  color: #64748b;
}

.cg-search-item-details {
  flex: 1;
  min-width: 0;
}

.cg-search-item-title {
  font-family: var(--cg-font-head, 'Outfit', sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cg-search-item:hover .cg-search-item-title,
.cg-search-item.cg-item-active .cg-search-item-title {
  color: #B42332;
}

.cg-search-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #64748b;
}

.cg-search-item-category {
  display: inline-block;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.72rem;
}

.cg-search-item-date {
  color: #94a3b8;
  font-size: 0.74rem;
}

.cg-search-item-price {
  font-family: var(--cg-font-head, 'Outfit', sans-serif);
  font-weight: 700;
  font-size: 0.92rem;
  color: #15803d;
  margin-left: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.cg-search-item-price del {
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 500;
}

.cg-search-item-price ins {
  text-decoration: none;
  color: #15803d;
}

/* Arrow indicator on hover */
.cg-search-item-arrow {
  color: #cbd5e1;
  margin-left: 10px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cg-search-item:hover .cg-search-item-arrow,
.cg-search-item.cg-item-active .cg-search-item-arrow {
  color: #B42332;
  transform: translateX(3px);
}

/* Footer "View All" Button */
.cg-search-dropdown-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  border-bottom-left-radius: 13px;
  border-bottom-right-radius: 13px;
}

.cg-search-view-all-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #B42332 !important;
  text-decoration: none !important;
  transition: color 0.15s ease;
}

.cg-search-view-all-btn:hover {
  color: #8F1725 !important;
  text-decoration: underline !important;
}

/* Empty State */
.cg-search-empty {
  padding: 32px 20px;
  text-align: center;
  color: #64748b;
}

.cg-search-empty-icon {
  margin: 0 auto 10px auto;
  color: #cbd5e1;
  display: block;
}

.cg-search-empty-title {
  font-family: var(--cg-font-head, 'Outfit', sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 4px;
}

.cg-search-empty-sub {
  font-size: 0.82rem;
  color: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
  .cg-store-search-container {
    margin-bottom: 1.5rem;
  }
  .cg-store-search-input {
    font-size: 0.92rem !important;
    height: 42px;
  }
  .cg-search-dropdown {
    max-height: 400px;
  }
}
