/* 🔍 Premium Search Bar */
.search-bar-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  margin-bottom: 20px;
  z-index: 10;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-color, #ffffff);
  border: 2px solid var(--border-color, #e2e8f0);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 6px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 20px var(--shadow-color, rgba(0, 0, 0, 0.08)),
    0 1px 3px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  margin: 0;
  position: relative;
  overflow: hidden;
}

/* Subtle gradient overlay */
.search-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
  border-radius: inherit;
}

.search-bar:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 30px var(--shadow-color, rgba(0, 0, 0, 0.12)),
    0 2px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border-color: var(--accent-color, #ff6347);
}

.search-bar:focus-within {
  border-color: var(--accent-color, #ff6347);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 
    0 12px 40px rgba(255, 99, 71, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.1),
    0 0 0 4px rgba(255, 99, 71, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
  padding: 0;
}

.search-icon-sb {
  color: var(--text-secondary, #64748b);
  pointer-events: none;
  margin-right: 20px;
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.3s ease;
}

.search-bar:focus-within .search-icon-sb {
  color: var(--accent-color, #ff6347);
  transform: translateY(-50%) scale(1.1);
}

.search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-color, #2d3748);
  width: 80%;
  padding: 16px 0px 16px 48px;
  margin-left: 9px;
  font-family: inherit;
  flex: 1;
  transition: all 0.3s ease;
}

.search-input::placeholder {
  color: var(--text-secondary, #64748b);
  transition: all 0.3s ease;
}

.search-bar:focus-within .search-input::placeholder {
  color: var(--accent-color, #ff6347);
  opacity: 0.7;
}


/* ❌ Clear Button */
.clear-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: var(--text-secondary, #64748b);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-button:hover {
  background-color: var(--hover-bg, #f1f5f9);
  color: var(--text-color, #2d3748);
}

.search-button {
  background: linear-gradient(135deg, var(--accent-color, #ff6347) 0%, #e55339 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 99, 71, 0.25);
  position: relative;
  overflow: hidden;
}

.search-button:hover {
  background: linear-gradient(135deg, #e55339 0%, #dc2626 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 99, 71, 0.4);
}

.search-button:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(255, 99, 71, 0.3);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-color, #ffffff);
  border: 2px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 4px 6px; /* tighter padding */
  box-shadow: 0 2px 6px var(--shadow-color);
}

/* 📌 Actions Container (📷 + 🎤 + ❌) */
.search-actions {
  display: flex;
  align-items: center;
  gap: 6px; /* space between buttons */
  position: absolute;
  right: 110px; /* keeps all before the Search button */
  top: 50%;
  transform: translateY(-50%);
}

/* 📷 Image Upload Button */
.image-upload-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-in-out;
}

.image-upload-button svg {
  color: #10b981; /* green color for image upload */
  font-size: 18px;
}

.image-upload-button:hover {
  background-color: rgba(16, 185, 129, 0.1);
  transform: scale(1.1);
}

/* 🎤 Voice Button */
.voice-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-in-out;
}

.voice-button svg {
  color: #ff6600; /* matches Search button */
  font-size: 18px;
}

.voice-button:hover {
  background-color: rgba(255, 102, 0, 0.1);
  transform: scale(1.1);
}

/* Listening Glow Animation */
.voice-button.listening {
  background-color: rgba(255, 102, 0, 0.2);
}

.voice-button.listening svg {
  color: #ff6600;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { text-shadow: 0 0 5px var(--accent-color, #ff6347); }
  50% { text-shadow: 0 0 15px var(--accent-color, #ff6347); }
  100% { text-shadow: 0 0 5px var(--accent-color, #ff6347); }
}

/* 📷 Image Preview Styles */
.image-preview-container {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  margin-top: 8px;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.image-preview {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  display: block;
}

.remove-image-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-image-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.processing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color, #e2e8f0);
  border-top: 2px solid var(--accent-color, #ff6347);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Dark Mode 🎤 */
body.dark-mode .voice-button svg {
  color: #ffa64d;
}

body.dark-mode .voice-button:hover {
  background-color: rgba(255, 166, 77, 0.15);
}

/* Dark Mode 📷 */
body.dark-mode .image-upload-button svg {
  color: #34d399;
}

body.dark-mode .image-upload-button:hover {
  background-color: rgba(52, 211, 153, 0.15);
}

/* 📌 Dropdown Styles */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  margin-top: 8px;
  max-height: 400px;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease-out;
}

.suggestions-section {
  padding: 12px 0;
}

.suggestions-section:not(:last-child) {
  border-bottom: 1px solid var(--border-light, #f1f5f9);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0;
}

.suggestion-item:hover {
  background-color: var(--hover-bg, #f8fafc);
}

.suggestion-icon {
  color: var(--text-secondary, #64748b);
  flex-shrink: 0;
}

.suggestion-text {
  color: var(--text-color, #2d3748);
  font-size: 14px;
  flex: 1;
}

.suggestion-text mark {
  background-color: var(--accent-light, #fed7d7);
  color: var(--accent-color, #ff6347);
  padding: 0 2px;
  border-radius: 2px;
}

.recent-item .suggestion-icon {
  color: var(--blue-500, #3b82f6);
}

.popular-item .suggestion-icon {
  color: var(--green-500, #10b981);
}

.no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
}

.default-suggestions {
  max-height: 350px;
  overflow-y: auto;
}

/* Scrollbar */
.search-dropdown::-webkit-scrollbar {
  width: 6px;
}
.search-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.search-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-color, #e2e8f0);
  border-radius: 3px;
}
.search-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #64748b);
}

/* Responsive */
@media (max-width: 768px) {
  .search-bar-container {
    max-width: 100%;
  }
  .search-bar {
    border-radius: 10px;
    padding: 2px;
    margin: 0;
  }
  .search-input {
    font-size: 16px;
    padding: 10px 0;
  }
  .search-button {
    padding: 10px 16px;
    font-size: 13px;
  }
  .search-dropdown {
    border-radius: 10px;
    margin-top: 6px;
  }
  .suggestion-item {
    padding: 14px 16px;
  }
}

@media (max-width: 480px) {
  .search-bar-container {
    padding-top: 40px;
    max-width: 100vw;
    margin: 0 0 10px 0;
  }
  .search-bar {
    margin: 8px 2vw;
    border-radius: 8px;
    padding: 1px;
    min-width: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  }
  .search-input-wrapper {
    padding: 0 4px;
  }
  .search-input {
    font-size: 15px;
    padding: 8px 0 8px 32px;
  }
  .search-icon-sb {
    left: 8px;
    width: 18px;
    height: 18px;
  }
  .search-button {
    padding: 7px 10px;
    font-size: 11px;
    border-radius: 6px;
  }
  .search-actions {
    position: static;
    transform: none;
    gap: 4px;
    margin-left: auto;
  }
  .clear-button,
  .voice-button,
  .image-upload-button {
    padding: 2px;
  }
  .search-dropdown {
    border-radius: 8px;
    margin-top: 4px;
    font-size: 13px;
    left: 0;
    right: 0;
    min-width: 0;
    max-width: 100vw;
  }
  .suggestion-item {
    padding: 10px 10px;
    font-size: 13px;
  }
}

/* Dark Theme */
[data-theme="dark"] .search-bar-container {
  --bg-color: #2d3748;
  --text-color: #e2e8f0;
  --text-secondary: #a0aec0;
  --border-color: #4a5568;
  --border-light: #4a5568;
  --hover-bg: #4a5568;
  --shadow-color: #ffffff12;
  --accent-light: #744210;
  --blue-500: #63b3ed;
  --green-500: #68d391;
}

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