/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.2;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #1976D2;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: #388E3C;
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: #F57C00;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-button:hover {
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary);
  transform: scale(1.1);
}

.icon-button:active {
  transform: scale(0.95);
}

.icon-button .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== FAVORIS AMÉLIORÉS ===== */
.no-favorites {
  text-align: center;
  padding: var(--spacing-xl);
  color: #666;
}

.no-favorites-icon {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.no-favorites h4 {
  margin-bottom: var(--spacing-sm);
  color: var(--text);
}

.favorites-tips {
  margin-top: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.tip {
  background: rgba(33, 150, 243, 0.1);
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  text-align: left;
}

.favorites-header-section {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm);
  background: #f8f9fa;
  border-radius: var(--border-radius);
}

.favorites-search-container {
  flex: 1;
  position: relative;
}

.favorites-search-container .search-icon {
  position: absolute;
  left: var(--spacing-sm);
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

#favorites-search {
  width: 100%;
  padding: var(--spacing-xs) var(--spacing-sm) var(--spacing-xs) 30px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: var(--font-size-sm);
  transition: all var(--transition);
}

#favorites-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.favorites-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.btn-clear-all,
.btn-export-fav {
  width: 32px;
  height: 32px;
  border: 1px solid #e0e0e0;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: var(--font-size-sm);
}

.btn-clear-all:hover {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.btn-export-fav:hover {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.favorites-stats {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-sm);
  background: rgba(33, 150, 243, 0.05);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--primary);
}

.stats-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--primary);
  font-weight: 500;
}

.favorites-section {
  margin-bottom: var(--spacing-lg);
}

.favorites-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid var(--primary);
}

.favorites-section-header h5 {
  margin: 0;
  color: var(--primary);
  font-size: var(--font-size-md);
}

.section-count {
  background: var(--primary);
  color: white;
  padding: 2px var(--spacing-xs);
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.favorites-section-tools {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.favorite-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm);
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: var(--border-radius);
  transition: all var(--transition);
  border-left: 4px solid transparent;
}

.favorite-item:hover {
  border-color: var(--primary);
  border-left-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateX(2px);
}

.favorite-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  flex: 1;
}

.favorite-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  flex-shrink: 0;
}

.favorite-info {
  flex: 1;
  min-width: 0;
}

.favorite-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-description {
  color: #666;
  font-size: var(--font-size-xs);
  line-height: 1.3;
  margin-bottom: var(--spacing-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-tags {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.mini-tag {
  padding: 1px 4px;
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.favorite-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.btn-remove-fav {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-fav:hover {
  background: var(--error);
  color: white;
  transform: scale(1.1);
}

.no-search-results {
  text-align: center;
  padding: var(--spacing-xl);
  color: #666;
}

.no-search-results i {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: var(--spacing-lg);
  transition: all var(--transition);
  border: 1px solid rgba(0,0,0,0.05);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  color: white;
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
}

.card-description {
  color: #666;
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-md);
}

/* ===== TAGS ===== */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.tag {
  padding: 2px var(--spacing-xs);
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary);
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  border: 1px solid rgba(33, 150, 243, 0.2);
  transition: all var(--transition);
}

.tag:hover {
  background: rgba(33, 150, 243, 0.2);
  transform: scale(1.05);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(0px);
}

.modal.active {
  opacity: 1;
  visibility: visible;
  animation: modalFadeIn 0.3s ease;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 1200px;
  max-height: 95vh;
  overflow: hidden;
  transform: scale(0.95) translateY(20px);
  transition: transform 0.2s ease;
  will-change: transform;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-xl);
  border-bottom: 1px solid #eee;
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-body {
  padding: var(--spacing-xl);
  max-height: 75vh;
  overflow-y: auto;
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  contain: layout style paint;
  transform: translateZ(0);
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

#modal-title {
  font-size: var(--font-size-xl);
  margin: 0;
  color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.modal-actions .icon-button {
  width: 44px;
  height: 44px;
}

/* Loading dans modal */
.modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

.modal-loading .loading-spinner {
  color: var(--primary);
}

.modal-loading i {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  color: var(--primary);
}

.modal-loading p {
  color: #666;
  font-style: italic;
}

/* Erreur de chargement */
.error-content {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--error);
}

.error-content i {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-hover);
  padding: var(--spacing-md);
  border-left: 4px solid var(--success);
  transform: translateX(100%);
  transition: transform var(--transition);
  min-width: 300px;
  max-width: 400px;
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast.info {
  border-left-color: var(--primary);
}

.toast-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.toast-content button {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: 50%;
  transition: all var(--transition);
}

.toast-content button:hover {
  background: rgba(0,0,0,0.1);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--text);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid #e0e0e0;
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: var(--font-size-sm);
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-input:invalid {
  border-color: var(--error);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--spacing-xs);
  background: var(--primary);
  color: white;
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  min-width: 18px;
  justify-content: center;
}

.badge.success { background: var(--success); }
.badge.warning { background: var(--warning); }
.badge.error { background: var(--error); }
.badge.secondary { background: var(--secondary); }

/* ===== RESPONSIVE FAVORIS ===== */
@media (max-width: 767px) {
  .favorites-header-section {
    flex-direction: column;
  }
  
  .favorites-stats {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
  
  .favorite-item {
    padding: var(--spacing-xs);
  }
  
  .favorite-content {
    gap: var(--spacing-xs);
  }
  
  .favorite-icon {
    width: 28px;
    height: 28px;
    font-size: var(--font-size-sm);
  }
  
  .favorite-description {
    display: none;
  }
  
  .mini-tag {
    display: none;
  }
}

@media (max-width: 360px) {
  .favorites-actions {
    flex-direction: column;
  }
  
  .btn-clear-all,
  .btn-export-fav {
    width: 100%;
    border-radius: var(--border-radius);
    height: 36px;
  }
}

/* Ajout à la fin du fichier components.css */

/* ===== FAVORIS NON TROUVÉS ===== */
.favorites-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

.favorites-loading .loading-spinner {
  color: var(--primary);
}

.favorites-loading i {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  color: var(--accent);
}

.favorites-error {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--error);
}

.favorites-error i {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
}

.not-found-section {
  background: rgba(244, 67, 54, 0.05);
  border: 1px solid rgba(244, 67, 54, 0.2);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
}

.not-found-explanation {
  background: rgba(244, 67, 54, 0.1);
  padding: var(--spacing-sm);
  border-radius: 4px;
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--error);
}

.favorite-item.not-found {
  background: rgba(244, 67, 54, 0.05);
  border-color: rgba(244, 67, 54, 0.2);
}

.favorite-icon.error {
  background: var(--error);
}

.section-count.error {
  background: var(--error);
}

.stats-item.error {
  color: var(--error);
}

.btn-remove-fav:hover {
  background: var(--error);
  color: white;
  transform: scale(1.1);
}

/* ===== RECHERCHE FAVORIS AMÉLIORÉE ===== */
.favorites-search-container {
  flex: 1;
  position: relative;
}

.favorites-search-container .search-icon {
  position: absolute;
  left: var(--spacing-sm);
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  z-index: 1;
}

#favorites-search {
  width: 100%;
  padding: var(--spacing-xs) var(--spacing-sm) var(--spacing-xs) 30px;
  padding-right: 35px; /* Espace pour bouton clear */
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: var(--font-size-sm);
  transition: all var(--transition);
}

#favorites-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.favorites-search-clear {
  position: absolute;
  right: var(--spacing-xs);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition);
  z-index: 2;
}

.favorites-search-clear:hover {
  background: rgba(244, 67, 54, 0.1);
  color: var(--error);
}

/* Message "aucun résultat" en overlay */
.no-search-results-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--border-radius);
}

.no-search-results {
  text-align: center;
  padding: var(--spacing-xl);
  color: #666;
}

.no-search-results i {
  font-size: 2rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
  color: var(--primary);
}

.no-search-results p {
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-md);
}

.no-search-results .btn {
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-md);
}

/* Animation d'apparition du message */
.no-search-results-overlay {
  animation: fadeInMessage 0.2s ease;
}

@keyframes fadeInMessage {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* États de recherche */
.favorites-section[style*="none"] {
  display: none !important;
}

.favorite-item[style*="none"] {
  display: none !important;
}

/* Responsive recherche favoris */
@media (max-width: 767px) {
  .favorites-search-container {
    margin-bottom: var(--spacing-sm);
  }
  
  .no-search-results-overlay {
    position: relative;
    background: rgba(255, 255, 255, 1);
    padding: var(--spacing-md);
  }
  
  .no-search-results {
    padding: var(--spacing-md);
  }
}


/* ===== FAVORIS AMÉLIORÉS - CORRECTION DÉBORDEMENT ===== */
.favorites-section-tools {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.favorite-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm);
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: var(--border-radius);
  transition: all var(--transition);
  border-left: 4px solid transparent;
  /* CORRECTION: Éviter débordement */
  min-width: 0;
  overflow: hidden;
}

.favorite-item:hover {
  border-color: var(--primary);
  border-left-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateX(2px);
}

.favorite-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  flex: 1;
  /* CORRECTION: Permettre shrinking */
  min-width: 0;
  overflow: hidden;
}

.favorite-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  /* CORRECTION: Taille fixe */
  flex-shrink: 0;
}

.favorite-info {
  flex: 1;
  /* CORRECTION: Contrôler débordement */
  min-width: 0;
  overflow: hidden;
}

.favorite-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: 2px;
  /* CORRECTION: Gérer texte long */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.favorite-description {
  color: #666;
  font-size: var(--font-size-xs);
  line-height: 1.3;
  margin-bottom: var(--spacing-xs);
  /* CORRECTION: Limiter à 2 lignes */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em; /* ~2 lignes */
}

.favorite-tags {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  /* CORRECTION: Limiter hauteur tags */
  max-height: 1.5em;
  overflow: hidden;
}

.mini-tag {
  padding: 1px 4px;
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  /* CORRECTION: Pas de wrap des tags */
  white-space: nowrap;
  flex-shrink: 0;
}

.favorite-actions {
  display: flex;
  gap: var(--spacing-xs);
  /* CORRECTION: Toujours visible */
  flex-shrink: 0;
  margin-left: var(--spacing-xs);
}

.btn-remove-fav {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  /* CORRECTION: Taille fixe */
  flex-shrink: 0;
}

.btn-remove-fav:hover {
  background: var(--error);
  color: white;
  transform: scale(1.1);
}

/* Responsive favoris amélioré */
@media (max-width: 767px) {
  .favorite-item {
    padding: var(--spacing-xs);
  }
  
  .favorite-content {
    gap: var(--spacing-xs);
  }
  
  .favorite-icon {
    width: 28px;
    height: 28px;
    font-size: var(--font-size-sm);
  }
  
  .favorite-title {
    font-size: var(--font-size-xs);
  }
  
  .favorite-description {
    font-size: 10px;
    /* Mobile: 1 ligne seulement */
    -webkit-line-clamp: 1;
    max-height: 1.3em;
  }
  
  .mini-tag {
    font-size: 8px;
    padding: 1px 3px;
  }
  
  /* Masquer tags sur très petit écran */
  .favorite-tags {
    display: none;
  }
}

@media (max-width: 360px) {
  .favorite-description {
    display: none;
  }
  
  .favorite-info {
    display: flex;
    align-items: center;
  }
}