/* Header Product Search Modal */

/* Bouton shortcode */
.wpb-product-search-button {
  display: inline-block;
  padding: 8px 16px;
  background-color: #333;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-decoration: none;
}

.wpb-product-search-button:hover {
  background-color: #555;
}

.wpb-product-search-button:active {
  background-color: #222;
}

/* Modale */
.wpb-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.wpb-modal-overlay.wpb-open {
  opacity: 1;
  visibility: visible;
}

.wpb-modal-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease,
    transform 0.3s ease;
  overflow: hidden;
}

.wpb-modal-overlay.wpb-open .wpb-modal-container {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Header de la modale */
.wpb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.wpb-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.wpb-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.wpb-modal-close:hover {
  color: #333;
}

/* Champ de recherche */
.wpb-modal-search-field {
  padding: 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.wpb-modal-search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  box-sizing: border-box;
}

.wpb-modal-search-input:focus {
  outline: none;
  border-color: #333;
  box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.1);
}

/* Zone des résultats */
.wpb-modal-results {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.wpb-modal-results.wpb-loading {
  justify-content: center;
  align-items: center;
}

.wpb-modal-empty-state {
  text-align: center;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.wpb-modal-empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Grille de résultats */
.wpb-product-search-results {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  overflow: scroll;
  height: 800px;
}

@media (min-width: 480px) {
  .wpb-product-search-results {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Assure que les cartes produits s'adaptent bien */
.wpb-product-search-results .wpbridge-product-card {
  height: 100%;
}

/* Masquer le scroll du body quand la modale est ouverte */
body.wpb-modal-open {
  overflow: hidden;
}

/* Bouton dans menu */
.wpb-product-search-menu-item {
  list-style: none;
  display: inline-flex;
  align-items: center;
}

.wpb-product-search-button--menu {
  padding: 8px 16px;
  background-color: transparent;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  text-decoration: none;
  display: inline-block;
  margin-left: 12px;
}

.wpb-product-search-button--menu:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.wpb-product-search-button--menu:active {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Bouton flottant */
.wpb-floating-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #333;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition:
    background-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
  z-index: 9997;
  padding: 0;
  line-height: 1;
}

.wpb-floating-button svg {
  width: 32px;
}

.wpb-floating-button:hover {
  background-color: #555;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wpb-floating-button:active {
  background-color: #222;
  transform: scale(0.95);
}

.wpb-floating-button:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Bouton flottant de secours (caché par défaut si menu trouvé) */
.wpb-floating-button--fallback {
  display: none;
}

/* Affiche le fallback si aucun bouton ne s'est injecté dans le menu */
body.wpb-show-floating-fallback .wpb-floating-button--fallback {
  display: flex;
}

/* Responsive mobile */
@media (max-width: 600px) {
  .wpb-modal-container {
    width: 95%;
    max-height: 90vh;
  }

  .wpb-modal-header {
    padding: 16px;
  }

  .wpb-modal-title {
    font-size: 16px;
  }

  .wpb-modal-close {
    width: 28px;
    height: 28px;
    font-size: 20px;
  }

  .wpb-modal-search-field {
    padding: 16px;
  }

  .wpb-modal-results {
    padding: 16px;
  }

  .wpb-product-search-button {
    padding: 6px 12px;
    font-size: 13px;
  }

  .wpb-floating-button {
    width: 48px;
    height: 48px;
    bottom: 20px;
    right: 20px;
    font-size: 20px;
  }

  .wpb-product-search-button--menu {
    padding: 6px 12px;
    font-size: 13px;
    margin-left: 8px;
  }
}
