/**
 * France Minéraux Search Widget - Styles
 * Version: 1.0.0
 */

/* Import Jost font */
@import url("https://fonts.googleapis.com/css2?family=Jost:wght@400;600;700&display=swap");

/* Base styles */
.fm-search-widget {
  position: relative;
  width: 100%;
  font-family: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

/* Placeholder = texte automatique */
.ts-search-by-category input[name="s"]::placeholder {
    color: #999999!important; /* gris clair */
    opacity: 1; /* certains navigateurs réduisent l’opacité par défaut */
}

/* Texte tapé par l’utilisateur */
.ts-search-by-category input[name="s"] {
    color: #45293F!important; /* violet France Minéraux */
}


/* Conteneur des résultats */
.fm-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  max-height: 500px;
  overflow-y: auto;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.fm-search-results.fm-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Thème sombre */
.fm-search-results[data-theme="dark"] {
  background: #1f2937;
  color: white;
}

/* Header des résultats */
.fm-search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.fm-search-results[data-theme="dark"] .fm-search-results-header {
  background: #1f2937;
  border-bottom-color: #374151;
}

.fm-search-results-title {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.fm-search-results[data-theme="dark"] .fm-search-results-title {
  color: white;
}

.fm-search-results-count {
  font-size: 12px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 12px;
  border-radius: 12px;
}

.fm-search-results[data-theme="dark"] .fm-search-results-count {
  background: #374151;
  color: #9ca3af;
}

/* Loading state */
.fm-search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 16px;
  color: #6b7280;
}

.fm-search-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f4f6;
  border-top-color: #45293f;
  border-radius: 50%;
  animation: fm-spin 0.8s linear infinite;
}

@keyframes fm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* No results */
.fm-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  color: #6b7280;
}

.fm-no-results-icon {
  font-size: 48px;
  opacity: 0.5;
}

/* Product result */
.fm-product-result {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s;
}

.fm-product-result:hover {
  background-color: #f9fafb;
}

.fm-search-results[data-theme="dark"] .fm-product-result {
  border-bottom-color: #374151;
}

.fm-search-results[data-theme="dark"] .fm-product-result:hover {
  background-color: #374151;
}

.fm-product-result:last-child {
  border-bottom: none;
}

/* Product image */
.fm-product-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #f3f4f6;
}

/* Product info */
.fm-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fm-product-brand {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #45293f;
  letter-spacing: 0.5px;
}

/* Product rating */
.fm-product-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  white-space: nowrap;
  margin-top: 4px;
  margin-bottom: 4px;
}

.fm-stars {
  display: flex;
  align-items: center;
  gap: 2px;
}

.fm-star {
  display: inline-block;
}

.fm-star-filled path {
  fill: #45293f;
}

.fm-star-empty path {
  fill: #e5e7eb;
}

.fm-reviews-count {
  color: #6b7280;
  font-size: 11px;
}

.fm-product-name {
  font-size: 16px;
  font-weight: 600;
  color: #45293f;
  line-height: 22px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.fm-search-results[data-theme="dark"] .fm-product-name {
  color: white;
}

.fm-product-description {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fm-product-attribute {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Product footer */
.fm-product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.fm-product-price {
  display: inline;
  font-family: "Jost", sans-serif;
  font-size: 16px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: normal;
  line-height: 22px;
  color: rgb(215, 185, 132);
}

.fm-product-footer .fm-product-rating {
  margin: 0;
}

/* Score */
.fm-product-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #6b7280;
}

.fm-score-bar {
  width: 60px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.fm-search-results[data-theme="dark"] .fm-score-bar {
  background: #374151;
}

.fm-score-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .fm-search-results {
    max-height: 400px;
  }

  .fm-product-result {
    gap: 12px;
    padding: 12px 16px;
  }

  .fm-product-image {
    width: 60px;
    height: 60px;
  }

  .fm-product-name {
    font-size: 13px;
  }

  .fm-product-description {
    font-size: 11px;
  }

  .fm-product-price {
    font-size: 14px;
  }
}

/* Scrollbar personnalisé */
.fm-search-results::-webkit-scrollbar {
  width: 8px;
}

.fm-search-results::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 0 12px 12px 0;
}

.fm-search-results::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.fm-search-results::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.fm-search-results[data-theme="dark"]::-webkit-scrollbar-track {
  background: #374151;
}

.fm-search-results[data-theme="dark"]::-webkit-scrollbar-thumb {
  background: #4b5563;
}

.fm-search-results[data-theme="dark"]::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* Rate Limit Error */
.fm-rate-limit-error {
  padding: 24px;
  text-align: center;
}

.fm-rate-limit-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.fm-rate-limit-title {
  font-size: 18px;
  font-weight: 600;
  color: #45293f;
  margin-bottom: 12px;
}

.fm-rate-limit-message {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 12px;
  line-height: 1.5;
}

.fm-rate-limit-retry {
  font-size: 13px;
  color: #ef4444;
  font-weight: 600;
  margin-bottom: 16px;
}

.fm-rate-limit-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.fm-rate-limit-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.fm-rate-limit-label {
  color: #6b7280;
  font-weight: 500;
}

.fm-rate-limit-value {
  color: #45293f;
  font-weight: 600;
  font-family: "Courier New", monospace;
}

.fm-rate-limit-alternative {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.fm-rate-limit-alternative p {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.fm-rate-limit-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #45293f 0%, #2a1a28 100%);
  color: #ebd9ae;
  text-decoration: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(69, 41, 63, 0.2);
}

.fm-rate-limit-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(69, 41, 63, 0.3);
}

.fm-rate-limit-button svg {
  flex-shrink: 0;
}

/* Dark theme pour rate limit */
.fm-search-results[data-theme="dark"] .fm-rate-limit-title {
  color: #f3f4f6;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-message {
  color: #d1d5db;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-retry {
  color: #fca5a5;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-details {
  background: #374151;
  border-color: #4b5563;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-label {
  color: #d1d5db;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-value {
  color: #f3f4f6;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-alternative {
  border-top-color: #374151;
}

.fm-search-results[data-theme="dark"] .fm-rate-limit-alternative p {
  color: #d1d5db;
}