/* ============================================
   COMPOSANTS UI - Boutons, cartes, inputs, etc.
   Nos Recettes V3 - Mobile First
   ============================================ */

/* === BOUTONS === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--orange-500);
  color: white;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
  min-height: 44px;
}

.btn-primary:hover {
  background: var(--orange-600);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: transparent;
  color: var(--orange-600);
  border: 1px solid var(--orange-200);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  min-height: 44px;
}

.btn-secondary:hover {
  background: var(--orange-50);
  border-color: var(--orange-300);
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--orange-600);
  font-size: var(--text-lg);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-icon:hover {
  background: var(--orange-100);
  transform: scale(1.05);
}

.btn-icon.active {
  background: var(--orange-500);
  color: white;
}

.btn-label {
  display: none;
}

@media (min-width: 1024px) {
  .btn-icon {
    width: 40px;
    height: 40px;
  }

  .btn-icon:has(.btn-label) {
    width: auto;
    padding: 0 var(--space-3);
    gap: var(--space-1);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
  }

  .btn-label {
    display: inline;
    font-weight: 500;
  }
}

/* === CARTES RECETTE === */
.recipe-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.recipe-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.recipe-card-image-container {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--orange-50);
}

.recipe-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-card-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--orange-50);
  color: var(--orange-300);
}

.recipe-card-favorite {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  transition: transform var(--transition-fast);
  z-index: 2;
}

.recipe-card-favorite:hover {
  transform: scale(1.15);
}

.recipe-card-favorite.active {
  color: var(--error);
}

.recipe-card-body {
  padding: var(--space-4);
}

.recipe-card-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--gray-800);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.recipe-card-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--orange-50);
  color: var(--orange-700);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-2);
}

.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.recipe-card-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* === CHIPS / FILTRES === */
.filter-chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  white-space: nowrap;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--gray-600);
  background: var(--bg-card);
  transition: all var(--transition-fast);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.filter-chip:hover {
  border-color: var(--orange-300);
  color: var(--orange-600);
}

.filter-chip.active {
  background: var(--orange-500);
  color: white;
  border-color: var(--orange-500);
}

/* === PORTIONS CONTROL === */
.portions-control {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.portions-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.portions-btn:hover {
  background: var(--orange-100);
}

.portions-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.portions-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  min-width: 2ch;
  text-align: center;
}

.portions-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* === TOASTS === */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border-left: 4px solid var(--info);
  position: relative;
  overflow: hidden;
  animation: toast-in 300ms ease forwards;
  cursor: pointer;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--error); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info    { border-left-color: var(--info); }

.toast-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--leading-normal);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--info);
  animation: toast-progress var(--toast-duration) linear forwards;
}

.toast.toast-success .toast-progress { background: var(--success); }
.toast.toast-error .toast-progress   { background: var(--error); }
.toast.toast-warning .toast-progress { background: var(--warning); }

.toast.removing {
  animation: toast-out 200ms ease forwards;
}

/* === TAGS === */
.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: var(--text-xs);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* === SCROLL HORIZONTAL === */
.scroll-horizontal-container {
  position: relative;
}

.scroll-horizontal-container::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--bg-page));
  pointer-events: none;
  z-index: 1;
}

.scroll-horizontal-container.scrolled-end::after {
  opacity: 0;
}

/* === BOTTOM TOOLBAR MOBILE === */
.recipe-toolbar-mobile {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: center;
}

.recipe-toolbar-mobile::-webkit-scrollbar {
  display: none;
}

@media (min-width: 1024px) {
  .recipe-toolbar-mobile {
    display: none;
  }

  .toast-container {
    top: var(--space-6);
    right: var(--space-6);
  }
}

/* Mobile: toasts centrees en haut */
@media (max-width: 639px) {
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }
}

/* === CAROUSEL LIGHTBOX === */
.carousel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 250;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal);
}

.carousel-overlay.active {
  opacity: 1;
  visibility: visible;
}

.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.carousel-counter {
  font-weight: var(--font-medium);
}

.carousel-close {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.carousel-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.carousel-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  padding: 0 var(--space-4);
}

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: var(--text-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  z-index: 2;
  backdrop-filter: blur(4px);
}

.carousel-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.carousel-nav:disabled {
  opacity: 0.2;
  cursor: default;
}

.carousel-nav.prev {
  left: var(--space-4);
}

.carousel-nav.next {
  right: var(--space-4);
}

.carousel-image {
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: var(--radius-md);
  user-select: none;
}

.carousel-footer {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-6);
  text-align: center;
  min-height: 60px;
}

.carousel-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  max-width: 640px;
  margin: 0 auto;
}

.carousel-caption-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: white;
}

.carousel-caption-subtitle {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.carousel-caption-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--orange-500);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  letter-spacing: 0.02em;
}

.carousel-caption-text {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.8);
  line-height: var(--leading-relaxed);
  text-align: center;
}

/* Dots indicateur */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.3);
  transition: all var(--transition-fast);
}

.carousel-dot.active {
  background: var(--orange-400);
  width: 24px;
}

/* Mobile */
@media (max-width: 639px) {
  .carousel-nav {
    width: 36px;
    height: 36px;
    font-size: var(--text-lg);
  }

  .carousel-nav.prev {
    left: var(--space-2);
  }

  .carousel-nav.next {
    right: var(--space-2);
  }

  .carousel-image {
    max-width: calc(100vw - 80px);
    max-height: calc(100vh - 200px);
  }

  .carousel-footer {
    padding: var(--space-3) var(--space-4);
  }
}

/* === SKELETON LOADER === */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-card {
  height: 280px;
  border-radius: var(--radius-lg);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-text.short {
  width: 60%;
}
