/* ==========================================================================
   SEARCH BY VOICE + SEARCH BY IMAGE STYLES
   Bám sát 100% Đặc tả Kịch bản, Sơ đồ Sequence và Activity Diagram
   ========================================================================== */

/* 1. Thanh SearchBar 3 Mode: [ Input | 🎤 | 📷 | 🔍 ] */
.search-box-multimodal {
  position: relative;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 9999px;
  padding: 4px 6px 4px 18px;
  width: 100%;
  max-width: 520px;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.search-box-multimodal:focus-within {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-input-field {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: #1e293b;
  background: transparent;
  padding: 8px 4px;
}

.search-actions-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-action-icon-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-action-icon-btn:hover {
  background: #f1f5f9;
  color: #4f46e5;
}

.search-action-icon-btn.primary-search-btn {
  background: #4f46e5;
  color: #ffffff;
}

.search-action-icon-btn.primary-search-btn:hover {
  background: #4338ca;
  transform: scale(1.05);
}

/* 2. Modals (Voice & Image) */
.search-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.search-modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.search-modal-card {
  background: #ffffff;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-icon-btn {
  background: #f8fafc;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close-icon-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.modal-card-body {
  padding: 24px;
  text-align: center;
}

/* Waveform Canvas */
.waveform-canvas-box {
  background: #0f172a;
  border-radius: 14px;
  padding: 12px;
  margin: 16px 0;
  overflow: hidden;
}

.waveform-canvas-box canvas {
  width: 100%;
  height: 90px;
  display: block;
}

.voice-timer-display {
  font-family: monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: 8px;
}

.voice-status-label {
  font-size: 0.92rem;
  color: #64748b;
  margin-bottom: 20px;
}

.voice-control-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-stop-recording {
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-stop-recording:hover {
  background: #dc2626;
  transform: scale(1.03);
}

/* Image Search Modal */
.image-upload-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.image-option-card {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 20px 12px;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.image-option-card:hover {
  border-color: #4f46e5;
  background: #eef2ff;
}

.image-option-card i {
  font-size: 1.8rem;
  color: #4f46e5;
}

.image-preview-wrapper {
  position: relative;
  max-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  display: inline-block;
  background: #0f172a;
}

.image-preview-wrapper img {
  max-width: 100%;
  max-height: 300px;
  display: block;
  user-select: none;
}

.image-crop-box {
  position: absolute;
  border: 2px solid #06b6d4;
  background: rgba(6, 182, 212, 0.2);
  cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.image-crop-box::after {
  content: 'Kéo để chọn vùng';
  position: absolute;
  top: -24px;
  left: 0;
  background: #06b6d4;
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Badges for Search Results */
.search-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.badge-voice {
  background: #e0e7ff;
  color: #4338ca;
}

.badge-image {
  background: #ccfbf1;
  color: #0f766e;
}

.badge-similarity-tag {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
  display: inline-block;
}

/* Custom Toasts */
.custom-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 20px;
  border-radius: 9999px;
  font-size: 0.92rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  animation: toastFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
}

.custom-toast.hide {
  opacity: 0;
  transform: translate(-50%, 15px);
}

.custom-toast.toast-error {
  background: #dc2626;
}

.custom-toast.toast-info {
  background: #2563eb;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 4. Filter Sidebar & Results Header */
.search-results-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 18px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.view-toggle-btns {
  display: flex;
  gap: 6px;
}

.view-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #64748b;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-btn.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
}

/* List view mode */
.products-grid.list-view {
  grid-template-columns: 1fr !important;
}

.products-grid.list-view .product-card {
  display: flex;
  flex-direction: row;
}

.products-grid.list-view .product-image-box {
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}
