"use client";

import {
  Crown,
  Gift,
  Percent,
} from "lucide-react";

import { useLanguage } from "@/lib/i18n";
import { promos } from "@/lib/data";

export function Loyalty() {
  const { t } = useLanguage();

  const loyaltyIcons = [
    {
      icon: Gift,
      label: "Avantages",
    },
    {
      icon: Percent,
      label: "Réductions",
    },
    {
      icon: Crown,
      label: "Privilèges",
    },
  ];

  return (
    <section className="mx-auto max-w-7xl px-4 py-20 md:px-8 md:py-24">
      <div className="overflow-hidden rounded-2xl border border-primary/30 bg-gradient-to-br from-card to-background p-8 md:p-12">
        <div className="grid gap-10 md:grid-cols-2">
          {/* PRÉSENTATION */}
          <div>
            <span className="text-xs font-semibold uppercase tracking-[0.3em] text-primary">
              {t("loyalty.tag")}
            </span>

            <h2 className="mt-3 text-balance font-serif text-3xl font-semibold leading-tight text-foreground md:text-4xl">
              {t("loyalty.title")}
            </h2>

            <p className="mt-4 leading-relaxed text-muted-foreground">
              {t("loyalty.body")}
            </p>

            {/* ICÔNES DES AVANTAGES */}
            <div className="mt-6 flex flex-wrap gap-4">
              {loyaltyIcons.map(({ icon: Icon, label }) => (
                <div
                  key={label}
                  className="flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary"
                  aria-label={label}
                  title={label}
                >
                  <Icon
                    className="h-5 w-5"
                    aria-hidden="true"
                  />
                </div>
              ))}
            </div>
          </div>

          {/* PROMOTIONS */}
          <div className="space-y-3">
            {promos.map((promo) => (
              <div
                key={promo.id}
                className="flex items-center justify-between gap-4 rounded-xl border border-border bg-card p-4"
              >
                <div>
                  <h3 className="font-semibold text-foreground">
                    {promo.title}
                  </h3>

                  <p className="text-sm text-muted-foreground">
                    {promo.description}
                  </p>
                </div>

                <span className="whitespace-nowrap rounded-full border border-dashed border-primary px-3 py-1.5 text-sm font-bold text-primary">
                  {promo.code}
                </span>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}