/**
 * MFM Native Search Engine Styles
 * Design System : Vert MFM (#008b30), Typographie Montserrat, 100% Responsive
 */

/* ==========================================================================
   1. Search Bar Container — ALWAYS VISIBLE (Desktop & Mobile)
   ========================================================================== */
/* Stacking context : La barre de navigation et ses dropdowns doivent TOUJOURS être au-dessus */
.navbar__top-bar2 {
  position: relative !important;
  z-index: 1000 !important;
}

.navbar__top-bar2 .navbar__menu-dropdown,
.navbar__top-bar2 .w-dropdown {
  position: relative !important;
  z-index: 1001 !important;
}

.navbar__top-bar2 .navbar__menu-dropdown-list,
.navbar__top-bar2 .w-dropdown-list {
  position: absolute !important;
  z-index: 1002 !important;
  box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.15), 0 4px 8px -2px rgba(15, 23, 42, 0.05) !important;
}

.navbar__top-bar2 .navbar__menu-complet {
  z-index: 1002 !important;
  box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.18), 0 6px 12px -3px rgba(15, 23, 42, 0.08) !important;
}

#navbar__search-bar,
.navbar__search-bar {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  justify-content: center;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  padding: 8px 0;
  position: relative !important;
  z-index: 800 !important;
}

.mfm-search-container {
  width: 100%;
  max-width: 100% !important;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  box-sizing: border-box;
}

.mfm-search-form {
  position: relative;
  width: 100%;
  margin: 0;
}

/* ==========================================================================
   2. Input Field & Micro-Controls
   ========================================================================== */
.mfm-search-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.mfm-search-input {
  width: 100% !important;
  height: 44px !important;
  background-color: #f8fafc !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 22px !important;
  padding: 0 46px 0 46px !important;
  font-family: 'Montserrat', sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #0f172a !important;
  outline: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  transition: all 0.2s ease-in-out !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

.mfm-search-input::placeholder {
  color: #94a3b8 !important;
  font-size: 13.5px !important;
  font-weight: 400 !important;
}

.mfm-search-input:focus {
  background-color: #ffffff !important;
  border-color: #008b30 !important;
  box-shadow: 0 0 0 3px rgba(0, 139, 48, 0.15) !important;
}

/* Loupe SVG à gauche */
.mfm-search-icon-left {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #008b30;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* Bouton effacer (×) moderne & tactile */
.mfm-search-clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
}

.mfm-search-clear-btn svg {
  display: block;
  pointer-events: none;
  transition: transform 0.18s ease;
}

.mfm-search-clear-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
  transform: translateY(-50%) scale(1.1);
}

.mfm-search-clear-btn:hover svg {
  transform: rotate(90deg);
}

.mfm-search-clear-btn:active {
  transform: translateY(-50%) scale(0.95);
  background: #94a3b8;
  color: #ffffff;
}

/* Spinner de chargement */
.mfm-search-spinner {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: #008b30;
  display: none;
  animation: mfmSearchSpin 0.75s linear infinite;
  z-index: 3;
}

@keyframes mfmSearchSpin {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ==========================================================================
   3. Autocomplete Dropdown Panel
   ========================================================================== */
.mfm-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 36px -6px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.02);
  z-index: 999999;
  max-height: 490px;
  overflow-y: auto;
  display: none;
  animation: mfmFadeDown 0.18s ease-out;
  box-sizing: border-box;
}

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

/* Header section suggestions */
.mfm-search-section-header {
  padding: 8px 16px 4px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
}

/* Catégories suggérées */
.mfm-search-categories-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.mfm-search-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: #166534;
  text-decoration: none;
  transition: all 0.15s ease;
}

.mfm-search-cat-pill:hover {
  background: #008b30;
  color: #ffffff;
  border-color: #008b30;
  transform: translateY(-1px);
}

.mfm-search-cat-count {
  font-size: 11px;
  opacity: 0.75;
}

/* Ligne produit */
.mfm-search-product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  border-bottom: 1px solid #f8fafc;
  transition: background-color 0.15s ease;
  cursor: pointer;
  position: relative;
}

.mfm-search-product-row:hover,
.mfm-search-product-row.is-focused {
  background-color: #f8fafc;
}

.mfm-search-product-row.is-focused::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #008b30;
  border-radius: 0 2px 2px 0;
}

/* Vignette produit */
.mfm-search-product-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
}

/* Informations produit */
.mfm-search-product-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mfm-search-product-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}

.mfm-search-product-row:hover .mfm-search-product-title,
.mfm-search-product-row.is-focused .mfm-search-product-title {
  color: #008b30;
}

.mfm-search-product-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mfm-search-sku-badge {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

.mfm-search-sku-badge.is-sku-match {
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
  border: 1px solid #bbf7d0;
}

.mfm-search-stock-badge {
  font-size: 11px;
  color: #16a34a;
  font-weight: 600;
}

.mfm-search-stock-badge.outofstock {
  color: #dc2626;
}

/* Prix TTC */
.mfm-search-product-price {
  margin-left: auto;
  text-align: right;
  font-size: 15px;
  font-weight: 800;
  color: #008b30;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}

.mfm-search-product-price del {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 400;
  display: block;
}

.mfm-search-product-price ins {
  text-decoration: none;
}

/* Footer / Voir tous les résultats */
.mfm-search-dropdown-footer {
  background: #f8fafc;
  border-top: 1px solid #eef2f6;
  border-radius: 0 0 14px 14px;
  padding: 12px 16px;
}

.mfm-search-see-all-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: #008b30;
  text-decoration: none;
  transition: all 0.15s ease;
}

.mfm-search-see-all-link:hover {
  color: #007026;
  transform: translateX(2px);
}

/* Aucun résultat */
.mfm-search-empty-state {
  padding: 36px 20px;
  text-align: center;
}

.mfm-search-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fef2f2;
  color: #ef4444;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.mfm-search-empty-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px 0;
}

.mfm-search-empty-desc {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

/* ==========================================================================
   4. Mobile Responsive Adaptations (< 992px)
   ========================================================================== */
@media screen and (max-width: 991px) {
  #navbar__search-bar,
  .navbar__search-bar {
    padding: 6px 10px 8px 10px !important;
    position: relative !important;
    height: auto !important;
  }

  #navbar__search-bar .container.navbar {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .mfm-search-container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .mfm-search-input {
    height: 42px !important;
    font-size: 13.5px !important;
    padding: 0 44px 0 42px !important;
  }

  .mfm-search-clear-btn {
    width: 26px !important;
    height: 26px !important;
    right: 12px !important;
  }

  .mfm-search-dropdown {
    left: 0 !important;
    right: 0 !important;
    max-height: 420px;
  }

  .mfm-search-product-title {
    font-size: 12px !important;
    line-height: 1.25 !important;
  }

  .mfm-search-product-thumb {
    width: 44px !important;
    height: 44px !important;
  }

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

/* ==========================================================================
   5. Desktop Layout, Perceived Centering & Boundary Alignment (≥ 992px)
   ========================================================================== */
@media screen and (min-width: 992px) {
  /* Élimination du débordement de 9rem sur la droite de la barre de navigation */
  .navbar__icons-bar {
    max-width: calc(100% - 9rem) !important;
    box-sizing: border-box !important;
  }

  /* Élimination du débordement sur la barre verte supérieure */
  .navbar__top-bar-wrapper {
    max-width: calc(100% - 9rem) !important;
    box-sizing: border-box !important;
  }

  /* Maintien du badge panier dans l'alignement exact de la grille */
  .navbar__icons-bar__icons-wrapper {
    padding-right: 4px;
    box-sizing: border-box;
  }

  /* Alignement strict du conteneur de recherche avec la grille 1200px */
  #navbar__search-bar .container.navbar {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    max-width: 1200px !important;
    box-sizing: border-box !important;
  }

  /* Suppression du double padding (16px container + 16px search) pour alignement au pixel près */
  .mfm-search-container {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
