/**
 * 图片搜索功能专用样式
 * 包含模态框、上传区域、预览和结果展示样式
 */

/* 图片搜索模态框样式 */
.image-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

.image-search-modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
  background: linear-gradient(135deg, #ff5000, #ff8000);
  border-radius: 12px 12px 0 0;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0;
}

.close-modal {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 20px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* 上传区域样式 */
.upload-area {
  border: 2px dashed #e0e0e0;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  margin: 24px;
  transition: all 0.3s ease;
  background: #fafafa;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 80, 0, 0.1), transparent);
  transition: left 0.6s ease;
}

.upload-area:hover::before {
  left: 100%;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #ff5000;
  background: #fff5f0;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 80, 0, 0.1);
}

.upload-icon {
  font-size: 64px;
  color: #e0e0e0;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
  color: #ff5000;
  transform: scale(1.1);
}

.upload-text {
  font-size: 16px;
  color: #666;
  margin-bottom: 20px;
  font-weight: 500;
}

.upload-btn {
  background: linear-gradient(135deg, #ff5000, #ff8000);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255, 80, 0, 0.3);
}

.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 80, 0, 0.4);
}

.upload-btn:active {
  transform: translateY(0);
}

/* 处理进度样式 */
.processing-progress {
  margin: 0 24px 24px;
  display: none;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff5000, #ff8000);
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.progress-text {
  font-size: 14px;
  color: #666;
  text-align: center;
  margin: 0;
}

/* 图片预览样式 */
.image-preview {
  margin: 0 24px 24px;
  text-align: center;
  display: none;
}

.preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border: 3px solid white;
  transition: all 0.3s ease;
}

.preview-image:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

/* 搜索结果样式 */
.search-results {
  margin: 0 24px 24px;
  display: none;
}

.results-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #ff5000;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 4px;
}

/* 自定义滚动条 */
.results-grid::-webkit-scrollbar {
  width: 6px;
}

.results-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.results-grid::-webkit-scrollbar-thumb {
  background: #ff5000;
  border-radius: 3px;
}

.results-grid::-webkit-scrollbar-thumb:hover {
  background: #ff8000;
}

.result-item {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.result-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(255, 80, 0, 0.2);
}

.result-image {
  position: relative;
  height: 120px;
  overflow: hidden;
}

.result-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.result-item:hover .result-image img {
  transform: scale(1.1);
}

.similarity-score {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-info {
  padding: 12px;
}

.result-title {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-price {
  font-size: 14px;
  font-weight: 700;
  color: #ff5000;
  margin-bottom: 4px;
}

.result-merchant {
  font-size: 11px;
  color: #666;
}

/* 无结果状态 */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.no-results i {
  font-size: 48px;
  color: #e0e0e0;
  margin-bottom: 16px;
  display: block;
}

.no-results p {
  margin: 0;
  font-size: 14px;
}

/* 搜索操作按钮 */
.search-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
  border-radius: 0 0 12px 12px;
}

.cancel-btn,
.search-image-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  min-width: 80px;
}

.cancel-btn {
  background: #f0f0f0;
  color: #666;
}

.cancel-btn:hover {
  background: #e0e0e0;
  transform: translateY(-1px);
}

.search-image-btn {
  background: linear-gradient(135deg, #ff5000, #ff8000);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 80, 0, 0.3);
}

.search-image-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 80, 0, 0.4);
}

.search-image-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .modal-header {
    padding: 16px 20px;
  }
  
  .modal-title {
    font-size: 18px;
  }
  
  .upload-area {
    margin: 20px;
    padding: 30px 16px;
  }
  
  .upload-icon {
    font-size: 48px;
  }
  
  .upload-text {
    font-size: 14px;
  }
  
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }
  
  .result-image {
    height: 100px;
  }
  
  .search-actions {
    padding: 16px 20px;
  }
  
  .cancel-btn,
  .search-image-btn {
    padding: 8px 20px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .search-actions {
    flex-direction: column;
  }
  
  .cancel-btn,
  .search-image-btn {
    width: 100%;
  }
}

/* 加载动画 */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #ff5000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

/* 错误状态 */
.error-message {
  background: #ffe6e6;
  color: #d63031;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 16px 24px;
  border-left: 4px solid #d63031;
  display: none;
}

.error-message.show {
  display: block;
  animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 成功状态 */
.success-message {
  background: #e6f7e6;
  color: #27ae60;
  padding: 12px 16px;
  border-radius: 6px;
  margin: 16px 24px;
  border-left: 4px solid #27ae60;
  display: none;
}

.success-message.show {
  display: block;
  animation: slideInUp 0.3s ease;
}