/* ========================================
   SEARCH OVERLAY - Buscador de Productos
   ======================================== */

/* ===== OVERLAY BASE ===== */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow-y: auto;
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.search-overlay-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER DEL BUSCADOR ===== */
.search-overlay-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 20px;
  position: sticky;
  top: 0;
  background: transparent;
  z-index: 10;
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 14px 18px;
  transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

.search-input-wrapper .search-icon {
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  margin-right: 12px;
}

.search-overlay-input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  font-size: 16px;
  color: #fff;
  outline: none !important;
  font-family: inherit;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
  padding: 0 !important;
  margin: 0;
  border-radius: 0 !important;
}

.search-overlay-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-clear-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.search-clear-btn:hover {
  color: #fff;
}

.search-close-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  padding: 8px 16px;
  font-weight: 500;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.search-close-btn:hover {
  opacity: 0.7;
}

/* ===== CONTENIDO ===== */
.search-overlay-content {
  flex: 1;
  padding: 24px 0;
}

/* ===== SUGERENCIAS ===== */
.search-suggestions h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 16px;
}

.suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}

.suggestion-tag {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.suggestion-tag:hover {
  background: #fff;
  color: #1D1D1D;
  border-color: #fff;
}

/* Categorías */
.search-categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  transition: padding-left 0.2s ease;
}

.search-category-link:hover {
  padding-left: 8px;
}

.search-category-link svg {
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
}

.search-category-link:hover svg {
  opacity: 1;
  transform: translateX(4px);
}

/* ===== LOADING ===== */
.search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: rgba(255, 255, 255, 0.8);
}

.search-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.search-loading p {
  font-size: 14px;
  margin: 0;
}

/* ===== RESULTADOS ===== */
.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#search-results-count {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.search-view-all {
  font-size: 14px;
  color: #fff;
  text-decoration: underline;
  font-weight: 500;
}

.search-view-all:hover {
  opacity: 0.7;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* Card de producto en resultados */
.search-product-card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.search-product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.search-product-image {
  position: relative;
  aspect-ratio: 3/4;
  background: #f5f5f5;
  overflow: hidden;
  min-height: 240px;
}

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

.search-product-card:hover .search-product-image img {
  transform: scale(1.05);
}

.search-product-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff4d6d;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.search-product-info {
  padding: 14px;
  background: #fff;
}

.search-product-name {
  font-size: 15px;
  font-weight: 500;
  color: #1D1D1D;
  margin: 0 0 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-product-price {
  font-size: 16px;
  font-weight: 600;
  color: #1D1D1D;
  margin: 0;
}

.search-product-category {
  font-size: 12px;
  color: #999;
  margin: 6px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== SIN RESULTADOS ===== */
.search-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.search-no-results svg {
  margin-bottom: 20px;
  opacity: 0.7;
  color: #fff;
}

.search-no-results h3 {
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  margin: 0 0 8px;
}

.search-no-results p {
  font-size: 14px;
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
}

/* ===== ANIMACIONES ===== */
.search-overlay.active .search-overlay-container {
  animation: slideUp 0.3s ease;
}

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

/* Animación de entrada para productos */
.search-product-card {
  animation: fadeInProduct 0.3s ease forwards;
  opacity: 0;
}

@keyframes fadeInProduct {
  to {
    opacity: 1;
  }
}

.search-product-card:nth-child(1) { animation-delay: 0.05s; }
.search-product-card:nth-child(2) { animation-delay: 0.1s; }
.search-product-card:nth-child(3) { animation-delay: 0.15s; }
.search-product-card:nth-child(4) { animation-delay: 0.2s; }
.search-product-card:nth-child(5) { animation-delay: 0.25s; }
.search-product-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .search-overlay-container {
    padding: 16px;
  }

  .search-overlay-header {
    padding: 8px 0 16px;
  }

  .search-input-wrapper {
    padding: 10px 14px;
  }

  .search-overlay-input {
    font-size: 16px; /* Previene zoom en iOS */
  }

  .search-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .suggestion-tags {
    gap: 8px;
  }

  .suggestion-tag {
    padding: 6px 12px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .search-overlay-header {
    gap: 12px;
  }

  .search-close-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .search-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .search-product-name {
    font-size: 13px;
  }

  .search-product-price {
    font-size: 14px;
  }
}

/* ===== NO SCROLL CUANDO ESTÁ ABIERTO ===== */
body.search-open {
  overflow: hidden;
}
