/* Styles pour la page de recherche */

/* Container avec marges pour éviter que le contenu touche les bords */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Barre de recherche principale */
.main-search-bar {
  margin-bottom: 30px;
}

.search-form-main {
  max-width: 600px;
  margin: 0 auto;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid #e1e5e9;
  border-radius: 50px;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.search-input-wrapper:focus-within {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-input-main {
  flex: 1;
  padding: 15px 20px;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
}

.search-btn-main {
  padding: 15px 20px;
  background: #007bff;
  border: none;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.search-btn-main:hover {
  background: #0056b3;
}

/* Layout avec sidebar */
.search-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 30px;
  margin-top: 30px;
}

/* Sidebar des filtres */
.filters-sidebar {
  background: white;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 20px;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e1e5e9;
}

.filters-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.filters-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-filters-btn {
  display: none;
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-filters-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.clear-filters {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
}

.clear-filters:hover {
  color: #0056b3;
}

/* Sections de filtres */
.filter-section {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.filter-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.filter-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 15px 0;
}

/* Filtre de prix */
.price-filter {
  space-y: 15px;
}

.price-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.price-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  min-width: 0;
  box-sizing: border-box;
}

.price-separator {
  color: #666;
  font-weight: 500;
}

.price-ranges {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.price-range-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
}

.price-range-option input[type="radio"] {
  margin-right: 8px;
}

/* Filtre de disponibilité */
.availability-filter {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  position: relative;
}

.filter-checkbox input[type="checkbox"] {
  margin-right: 10px;
}

/* Filtre de marque */
.brand-filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.brand-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 0;
}

.brand-option input[type="checkbox"] {
  margin-right: 8px;
  accent-color: #007bff;
}

.brand-option label {
  cursor: pointer;
  flex: 1;
  color: #333;
  transition: color 0.2s ease;
}

.brand-option:hover label {
  color: #007bff;
}

/* Supprimé: styles filtre de note (rating) */

/* Bouton d'application des filtres */
.filter-actions {
  margin-top: 20px;
}

.apply-filters-btn {
  width: 100%;
  padding: 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.apply-filters-btn:hover {
  background: #0056b3;
}

/* Contenu principal */
.search-content {
  min-height: 400px;
}

/* Bouton toggle filtres mobile */
.mobile-filters-toggle {
  display: none;
  margin-bottom: 20px;
}

.toggle-filters-btn {
  width: 100%;
  padding: 12px 16px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.toggle-filters-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.toggle-filters-btn i {
  font-size: 14px;
}

.filter-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Barre de tri */
.sort-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding: 15px 20px;
  background: white;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
}

.results-info {
  font-size: 14px;
  color: #666;
}

.results-count {
  font-weight: 600;
  color: #333;
}

.sort-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-options label {
  font-size: 14px;
  color: #666;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  .search-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .mobile-filters-toggle {
    display: block;
  }

  .filters-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 90%;
    max-width: 350px;
    height: 100vh;
    background: white;
    z-index: 9999;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
  }

  .filters-sidebar.show {
    left: 0;
  }

  .filters-sidebar::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .filters-sidebar.show::before {
    opacity: 1;
    visibility: visible;
  }

  .search-content {
    order: 1;
  }

  .sort-bar {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .sort-options {
    justify-content: space-between;
  }

  /* Amélioration des filtres sur mobile */
  .filter-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
  }

  .filter-title {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .price-inputs {
    flex-direction: column;
    gap: 8px;
  }

  .price-input {
    width: 100%;
    padding: 10px 12px;
  }

  .price-separator {
    text-align: center;
    margin: 5px 0;
  }

  .brand-filter {
    max-height: 150px;
  }

  .brand-option,
  .rating-option {
    padding: 8px 0;
    font-size: 15px;
  }

  .apply-filters-btn {
    padding: 14px;
    font-size: 16px;
    border-radius: 8px;
  }

  .close-filters-btn {
    display: block !important;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 10px;
  }

  .search-input-main {
    padding: 12px 15px;
    font-size: 14px;
  }

  .search-btn-main {
    padding: 12px 15px;
  }

  .filters-sidebar {
    padding: 15px;
  }
}

/* Section breadcrumb */
.breadcrumb-section {
  background-color: #f8f9fa;
  padding: 1rem 0;
  border-bottom: 1px solid #e9ecef;
}

.breadcrumb {
  background: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  color: #6c757d;
  margin: 0 0.5rem;
}

.breadcrumb-item a {
  color: #2048ad;
  text-decoration: none;
  transition: color 0.3s ease;
}

.breadcrumb-item a:hover {
  color: #1a3a8a;
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #6c757d;
}

/* Section principale de recherche */
.search-page-section {
  padding: 2rem 0;
  min-height: 60vh;
}

/* En-tête de la page */
.search-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e9ecef;
}

.search-header .page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2048ad;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.search-results-count {
  font-size: 1.1rem;
  color: #6c757d;
  margin: 0;
}

/* Formulaire de recherche avancée */
.advanced-search-form {
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.search-filters .filter-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.filter-group .form-control {
  padding: 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background-color: #ffffff;
}

.filter-group .form-control:focus {
  border-color: #2048ad;
  box-shadow: 0 0 0 0.2rem rgba(32, 72, 173, 0.25);
  outline: none;
}

.search-submit {
  background: linear-gradient(135deg, #2048ad 0%, #1a3a8a 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
}

.search-submit:hover {
  background: linear-gradient(135deg, #1a3a8a 0%, #152e6b 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(32, 72, 173, 0.3);
}

/* Grille des produits */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

@media (max-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

/* Carte produit */
.product-card {
  background: #ffffff;
  border: 1px solid #f0f0f0;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  border-color: #e0e0e0;
}

.product-image {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

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

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

.product-image .no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #adb5bd;
  background-color: #f8f9fa;
}

.stock-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stock-badge.out-of-stock {
  background-color: #dc3545;
  color: white;
}

.stock-badge.low-stock {
  background-color: #ffc107;
  color: #212529;
}

.product-info {
  padding: 1.25rem;
}

.product-name {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.product-name a {
  color: #212529;
  text-decoration: none;
  transition: color 0.3s ease;
}

.product-name a:hover {
  color: #2048ad;
}

.product-description {
  color: #6c757d;
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.product-price {
  margin-bottom: 1rem;
}

.product-price .price {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2048ad;
}

.product-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.product-actions .btn {
  flex: 1;
  min-width: 120px;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  text-decoration: none;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, #2048ad 0%, #1a3a8a 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1a3a8a 0%, #152e6b 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: #2048ad;
  border: 1px solid #2048ad;
}

.btn-outline:hover {
  background: #2048ad;
  color: white;
}

.btn-secondary {
  background: #6c757d;
  color: white;
  cursor: not-allowed;
}

.btn-secondary:disabled {
  opacity: 0.6;
}

/* Section aucun résultat */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e9ecef;
}

.no-results-icon {
  margin-bottom: 1.5rem;
  color: #adb5bd;
}

.no-results h2 {
  font-size: 1.75rem;
  color: #495057;
  margin-bottom: 1rem;
}

.no-results p {
  font-size: 1.1rem;
  color: #6c757d;
  margin-bottom: 2rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.no-results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Pagination */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.pagination {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.25rem;
}

.page-item {
  display: flex;
}

.page-link {
  padding: 0.75rem 1rem;
  color: #2048ad;
  text-decoration: none;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.page-link:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.page-item.active .page-link {
  background-color: #2048ad;
  border-color: #2048ad;
  color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .search-filters .filter-row {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .search-submit {
    grid-column: 1 / -1;
    justify-self: center;
    width: auto;
  }
}

@media (max-width: 768px) {
  .search-header .page-title {
    font-size: 2rem;
  }

  .search-filters .filter-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }

  .product-actions {
    flex-direction: column;
  }

  .product-actions .btn {
    min-width: auto;
  }

  .no-results-actions {
    flex-direction: column;
    align-items: center;
  }

  .no-results-actions .btn {
    width: 200px;
  }
}

@media (max-width: 480px) {
  .search-page-section {
    padding: 1rem 0;
  }

  .advanced-search-form {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .search-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .search-header .page-title {
    font-size: 1.75rem;
  }

  .products-grid {
    grid-template-columns: 1fr;
  }

  .product-card {
    margin-bottom: 1rem;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .page-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* Animation pour le chargement */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-card {
  animation: fadeInUp 0.5s ease-out;
}

.product-card:nth-child(1) {
  animation-delay: 0.1s;
}
.product-card:nth-child(2) {
  animation-delay: 0.2s;
}
.product-card:nth-child(3) {
  animation-delay: 0.3s;
}
.product-card:nth-child(4) {
  animation-delay: 0.4s;
}

/* États de chargement pour les boutons */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Amélioration de l'accessibilité */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible pour l'accessibilité */
.btn:focus-visible,
.form-control:focus-visible,
.page-link:focus-visible {
  outline: 2px solid #2048ad;
  outline-offset: 2px;
}

/* Styles pour les messages de toast (si utilisés) */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1050;
}

.toast {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-bottom: 0.5rem;
  padding: 1rem;
  min-width: 300px;
  animation: slideInRight 0.3s ease-out;
}

.toast.success {
  border-left: 4px solid #28a745;
}

.toast.error {
  border-left: 4px solid #dc3545;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Styles pour les suggestions de recherche en temps réel */
.search-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  margin-top: 2px;
}

.search-suggestions.show {
  display: block;
  animation: fadeInDown 0.2s ease-out;
}

.suggestion-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f8f9fa;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background-color: #f8f9fa;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-image {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  margin-right: 0.75rem;
  background-color: #f8f9fa;
  flex-shrink: 0;
}

.suggestion-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 0.8rem;
}

.suggestion-content {
  flex: 1;
  min-width: 0;
}

.suggestion-name {
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #6c757d;
}

.suggestion-price {
  font-weight: 600;
  color: #2048ad;
}

.suggestion-stock {
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
}

.suggestion-stock.in-stock {
  background-color: #d4edda;
  color: #155724;
}

.suggestion-stock.low-stock {
  background-color: #fff3cd;
  color: #856404;
}

.suggestion-stock.out-of-stock {
  background-color: #f8d7da;
  color: #721c24;
}

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

/* Amélioration de la position relative pour le conteneur de recherche */
.search-wrapper {
  position: relative;
}

/* Correction spécifique pour éviter le déplacement du bouton de recherche */
.search-suggestions {
  position: absolute !important;
  top: calc(100% + 2px) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 9999 !important;
  /* S'assurer que les suggestions ne prennent pas d'espace dans le flux */
  margin: 0 !important;
  padding: 0 !important;
}

/* S'assurer que le search-wrapper ne change pas de taille */
.search-wrapper.has-suggestions {
  overflow: visible;
}

/* Styles pour éviter tout conflit avec le layout flex */
.search-wrapper > .search-suggestions {
  flex: none !important;
  position: absolute !important;
}