/**
 * Typeahead Search Custom Styles
 * Beautiful autocomplete dropdown with images, icons, and metadata
 * Author: Curbside.bio
 * Date: November 2025
 */

/* ========================================
   Typeahead Container
   ======================================== */
.typeahead-container {
  position: relative;
  width: 100%;
}

.typeahead-input-wrapper {
  position: relative;
}

/* ========================================
   Typeahead Dropdown
   ======================================== */
.typeahead-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  margin-top: 8px;
  max-height: 450px;
  overflow-y: auto;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e5e7eb;
}

.typeahead-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Custom scrollbar */
.typeahead-dropdown::-webkit-scrollbar {
  width: 6px;
}

.typeahead-dropdown::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

.typeahead-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.typeahead-dropdown::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========================================
   Dropdown Header
   ======================================== */
.typeahead-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.typeahead-header-title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.typeahead-count {
  font-size: 12px;
  color: #94a3b8;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* ========================================
   Typeahead Items
   ======================================== */
.typeahead-items {
  padding: 8px;
}

.typeahead-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}

.typeahead-item:hover,
.typeahead-item.active {
  background: #f1f5f9;
  border-color: #e2e8f0;
  transform: translateX(4px);
}

.typeahead-item:active {
  transform: scale(0.98);
}

/* ========================================
   Item Image/Icon
   ======================================== */
.typeahead-item-image {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
}

.typeahead-item-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

/* Icon variations */
.typeahead-item-icon.icon-treatment {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.typeahead-item-icon.icon-doctor {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.typeahead-item-icon.icon-article {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* ========================================
   Item Content
   ======================================== */
.typeahead-item-content {
  flex: 1;
  min-width: 0; /* For text truncation */
}

.typeahead-item-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 4px 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.typeahead-item-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================
   Item Meta
   ======================================== */
.typeahead-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.typeahead-meta-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typeahead-meta-badge.badge-condition {
  background: #dbeafe;
  color: #1e40af;
}

.typeahead-meta-badge.badge-treatment {
  background: #d1fae5;
  color: #065f46;
}

.typeahead-meta-badge.badge-doctor {
  background: #ede9fe;
  color: #5b21b6;
}

.typeahead-meta-badge i {
  font-size: 10px;
}

/* Rating stars */
.typeahead-rating {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: #fbbf24;
}

.typeahead-rating i {
  font-size: 10px;
}

.typeahead-rating-text {
  font-size: 11px;
  color: #64748b;
  margin-left: 4px;
}

/* ========================================
   Item Arrow
   ======================================== */
.typeahead-item-arrow {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 12px;
  transition: all 0.2s ease;
}

.typeahead-item:hover .typeahead-item-arrow {
  background: #0d6efd;
  color: #ffffff;
  transform: translateX(2px);
}

/* ========================================
   Empty State
   ======================================== */
.typeahead-empty {
  padding: 40px 20px;
  text-align: center;
}

.typeahead-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 28px;
}

.typeahead-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 8px 0;
}

.typeahead-empty-text {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

/* ========================================
   Loading State
   ======================================== */
.typeahead-loading {
  padding: 24px;
  text-align: center;
}

.typeahead-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: typeahead-spin 0.8s linear infinite;
}

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

.typeahead-loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: #64748b;
}

/* ========================================
   Dropdown Footer
   ======================================== */
.typeahead-footer {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.typeahead-footer-link {
  font-size: 13px;
  color: #0d6efd;
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.typeahead-footer-link:hover {
  color: #0a58ca;
}

.typeahead-footer-link i {
  font-size: 12px;
}

.typeahead-footer-hint {
  font-size: 12px;
  color: #94a3b8;
}

/* ========================================
   Keyboard Navigation Hints
   ======================================== */
.typeahead-keyboard-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #94a3b8;
}

.typeahead-key {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ========================================
   Section Divider
   ======================================== */
.typeahead-section-divider {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  .typeahead-dropdown {
    max-height: 350px;
    border-radius: 8px;
    margin-top: 6px;
  }

  .typeahead-item {
    padding: 10px;
    gap: 10px;
  }

  .typeahead-item-image,
  .typeahead-item-icon {
    width: 40px;
    height: 40px;
  }

  .typeahead-item-icon {
    font-size: 18px;
  }

  .typeahead-item-title {
    font-size: 14px;
  }

  .typeahead-item-subtitle {
    font-size: 12px;
  }

  .typeahead-footer {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .typeahead-keyboard-hint {
    display: none;
  }
}

/* ========================================
   Highlight Matched Text
   ======================================== */
.typeahead-highlight {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}

/* ========================================
   Special: Quick Actions
   ======================================== */
.typeahead-quick-action {
  border-left: 3px solid #0d6efd;
  background: #eff6ff;
}

.typeahead-quick-action:hover {
  background: #dbeafe;
  border-left-color: #0a58ca;
}

/* ========================================
   Animation Enhancements
   ======================================== */
.typeahead-item {
  animation: typeaheadFadeIn 0.3s ease;
}

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

/* Staggered animation for items */
.typeahead-item:nth-child(1) { animation-delay: 0.05s; }
.typeahead-item:nth-child(2) { animation-delay: 0.1s; }
.typeahead-item:nth-child(3) { animation-delay: 0.15s; }
.typeahead-item:nth-child(4) { animation-delay: 0.2s; }
.typeahead-item:nth-child(5) { animation-delay: 0.25s; }
