/* ==========================================================================
   Composants transverses : boutons, badges, pastilles, champs, notifications.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Boutons
   Un seul socle (.btn) + modificateurs. Toutes les variantes partagent la meme
   geometrie, ce qui garantit un alignement parfait quand elles sont cote a cote.
   -------------------------------------------------------------------------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text-100);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-5);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.45;
  pointer-events: none;
}

.btn__icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* Variante principale : noir plein, reservee a l'action de conversion. */
.btn--primary {
  --btn-bg: var(--ink);
  --btn-fg: var(--on-ink);
  --btn-border: var(--ink);
}

.btn--primary:hover {
  --btn-bg: #26282c;
  --btn-border: #26282c;
}

/* Variante secondaire : contour, pour les actions de second rang. */
.btn--ghost {
  --btn-bg: var(--surface-0);
  --btn-border: var(--line-strong);
}

.btn--ghost:hover {
  --btn-bg: var(--surface-100);
  --btn-border: var(--ink);
}

/* Variante WhatsApp : identite verte officielle, contact immediat. */
.btn--whatsapp {
  --btn-bg: #ffffff;
  --btn-border: rgba(18, 140, 68, 0.4);
  --btn-fg: #0f7a3d;
}

.btn--whatsapp:hover {
  --btn-bg: #f1faf4;
  --btn-border: #0f7a3d;
}

.btn--solid-dark {
  --btn-bg: var(--surface-100);
  --btn-border: var(--line);
}

.btn--solid-dark:hover {
  --btn-bg: var(--surface-200);
  --btn-border: var(--line-strong);
}

.btn--sm {
  min-height: 38px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-xs);
}

.btn--lg {
  min-height: 52px;
  padding: 0 var(--sp-8);
  font-size: var(--fs-base);
}

.btn--block {
  width: 100%;
}

/* Bouton icone (fermeture de modale, actions compactes). */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-0);
  color: var(--text-100);
  transition:
    background-color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.icon-btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

/* --------------------------------------------------------------------------
   Badges et pastilles
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  background: var(--surface-0);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-200);
}

/* Badge pose sur une photo : fond blanc opaque, lisible sur tout visuel. */
.badge--glass {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(11, 11, 12, 0.08);
  box-shadow: var(--shadow-sm);
}

.badge--new {
  color: var(--gold-700);
  border-color: var(--gold-400);
  background: var(--gold-100);
}

.badge--certified {
  color: #14603c;
  border-color: rgba(31, 125, 79, 0.35);
  background: var(--emerald-soft);
}

.badge--sold {
  background: var(--ruby-soft);
  border-color: rgba(179, 64, 44, 0.4);
  color: #933423;
}

.badge--reserved {
  background: var(--amber-soft);
  border-color: rgba(169, 112, 26, 0.4);
  color: #86590f;
}

/* Pastille d'etat : point colore + libelle. */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-300);
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--text-400));
}

.status-dot--disponible {
  --dot: var(--emerald);
}
.status-dot--reserve {
  --dot: var(--amber);
}
.status-dot--vendu {
  --dot: var(--ruby);
}

/* --------------------------------------------------------------------------
   Champs de formulaire
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-200);
}

.field__label .req {
  color: var(--ruby);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-400);
}

.field__error {
  min-height: 0;
  font-size: var(--fs-xs);
  color: #a53a26;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text-100);
  font-size: var(--fs-base);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.textarea {
  min-height: 112px;
  padding-top: var(--sp-3);
  resize: vertical;
  line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-500);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-400);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11, 11, 12, 0.08);
}

.input[aria-invalid='true'],
.select[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--ruby);
  box-shadow: 0 0 0 3px rgba(179, 64, 44, 0.12);
}

/* Fleche personnalisee, harmonisee avec le reste des champs. */
.select {
  appearance: none;
  padding-right: var(--sp-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23565b62' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  background-size: 15px;
  cursor: pointer;
}

.input[type='date'],
.input[type='time'] {
  cursor: pointer;
}

/* Piege a robots : invisible pour l'humain, present dans le DOM. */
.honeypot {
  position: absolute !important;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* Case a cocher stylisee (consentement). */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-300);
  cursor: pointer;
}

.checkbox input {
  appearance: none;
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  background: var(--surface-0);
  transition: all var(--dur-fast) var(--ease-out);
}

.checkbox input:checked {
  background: var(--ink)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
    center / 12px no-repeat;
  border-color: var(--ink);
}

/* --------------------------------------------------------------------------
   Structures de formulaire
   Utilisees par le back-office (tiroir d'edition) et par la fiche technique.
   -------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.form__fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  border: 0;
  padding: 0;
  margin: 0;
}

/* Intitule de groupe : petites capitales suivies d'un filet qui occupe
   la largeur restante. Sert aussi de sous-titre dans la fiche technique. */
.form__legend {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 0;
  margin-bottom: var(--sp-1);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-400);
}

.form__legend::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.form__row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}

@media (max-width: 620px) {
  .form__row {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Notifications ephemeres
   -------------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(360px, calc(100vw - 2 * var(--sp-5)));
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--r-md);
  background: var(--surface-0);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  color: var(--text-100);
  pointer-events: auto;
  animation: toast-in var(--dur-base) var(--ease-out) both;
}

.toast--success {
  border-left-color: var(--emerald);
}
.toast--error {
  border-left-color: var(--ruby);
}

.toast.is-leaving {
  animation: toast-out var(--dur-base) var(--ease-in-out) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(18px);
  }
}

@media (max-width: 560px) {
  .toast-stack {
    right: var(--sp-4);
    left: var(--sp-4);
    bottom: var(--sp-4);
  }
  .toast {
    max-width: none;
  }
}

/* --------------------------------------------------------------------------
   Indicateurs de chargement
   -------------------------------------------------------------------------- */

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* Squelette de chargement : evite le saut de mise en page du catalogue. */
.skeleton {
  background: var(--surface-100);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
