/**
 * components/cart-sheet.css
 *
 * Bottom Sheet du panier : glisse depuis le bas (transform/opacity
 * uniquement), fond scrim, contenu scrollable, total + CTA fixes en bas.
 * Sur desktop, la sheet reste ancrée en bas mais se limite en largeur.
 */

.cart-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-bottom-sheet);
  visibility: hidden;
  transition: visibility 0s linear var(--duration-base);
}

.cart-sheet.is-open {
  visibility: visible;
  transition-delay: 0s;
}

/* Fond scrim */
.cart-sheet__overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.cart-sheet.is-open .cart-sheet__overlay {
  opacity: 1;
}

/* Panneau */
.cart-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 85svh;
  background-color: var(--color-bg-surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--duration-base) var(--ease-out-soft);
}

.cart-sheet.is-open .cart-sheet__panel {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .cart-sheet__panel {
    left: auto;
    right: var(--space-6);
    width: 420px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
}

/* Le fond de page ne défile pas sous la sheet ouverte */
body.cart-sheet-open {
  overflow: hidden;
}

/* --- Header --- */

.cart-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
}

.cart-sheet__title {
  font-size: var(--text-xl);
}

.cart-sheet__close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  transition: color var(--duration-fast) var(--ease-standard),
              background-color var(--duration-fast) var(--ease-standard);
}

.cart-sheet__close:hover {
  color: var(--color-text-primary);
  background-color: var(--color-bg-surface);
}

.cart-sheet__close svg {
  width: 20px;
  height: 20px;
}

/* --- Erreurs (rate limiting, rupture, etc.) --- */

.cart-sheet__error {
  margin: 0 var(--space-5) var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background-color: rgba(228, 87, 61, 0.12);
  color: var(--color-error);
  font-size: var(--text-sm);
}

/* --- Liste des articles --- */

.cart-sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-5) var(--space-4);
}

.cart-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: opacity var(--duration-fast) var(--ease-standard);
}

.cart-item.is-busy {
  opacity: 0.55;
}

.cart-item__img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  object-fit: contain;
}

.cart-item__info {
  flex: 1;
  min-width: 0;
}

.cart-item__name {
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: var(--text-sm);
}

.cart-item__variation {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.cart-item__price {
  font-family: var(--font-display);
  color: var(--color-accent-yellow);
  font-size: var(--text-base);
  margin-top: var(--space-1);
}

/* Quantités */
.cart-item__qty {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.cart-item__qty-btn {
  width: 36px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: var(--text-lg);
  transition: background-color var(--duration-fast) var(--ease-standard);
}

.cart-item__qty-btn:hover:not(:disabled) {
  background-color: var(--color-bg-primary);
}

.cart-item__qty-btn:disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.cart-item__count {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
}

/* Skeletons (chargement — jamais de spinner) */
.cart-item--skeleton {
  border-bottom-color: transparent;
}

.cart-item__skeleton-img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
}

.cart-item__skeleton-line {
  display: block;
  height: 14px;
  margin-block: var(--space-2);
  width: 80%;
}

.cart-item__skeleton-line--short {
  width: 45%;
}

/* --- Suggestions (upsell éthique, jamais pré-coché) --- */

.cart-suggest {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.cart-suggest__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.cart-suggest__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-2);
}

.cart-suggest__img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}

.cart-suggest__info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.cart-suggest__name {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.cart-suggest__price {
  font-size: var(--text-xs);
  color: var(--color-accent-yellow);
  font-family: var(--font-display);
}

.cart-suggest__add {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-visible);
  color: var(--color-text-primary);
  font-size: var(--text-lg);
  transition: background-color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}

.cart-suggest__add:hover:not(:disabled) {
  background-color: var(--color-accent-yellow);
  border-color: var(--color-accent-yellow);
  color: var(--color-text-on-accent);
}

/* --- État vide --- */

.cart-sheet__empty {
  text-align: center;
  padding-block: var(--space-7);
}

.cart-sheet__empty-text {
  margin-bottom: var(--space-5);
}

/* --- Total + CTA --- */

.cart-sheet__footer {
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
}

.cart-sheet__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.cart-sheet__total strong {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-accent-yellow);
}

.cart-sheet__checkout {
  width: 100%;
}

/* ===== Panier flottant ===== */

/*
 * Le bouton du header s'en va dès qu'on fait défiler la carte — or c'est en
 * la parcourant qu'on ajoute des plats. Ce bouton reste à portée de pouce.
 * Il n'apparaît QUE si le panier contient quelque chose : sur une page vide,
 * un panier flottant ne serait qu'un obstacle.
 */
.cart-fab {
  position: fixed;
  /*
   * À GAUCHE, volontairement : le chatbot occupe le coin bas-droit et les
   * deux se chevauchaient. Un panier qu'on doit viser entre deux bulles ne
   * sert à rien.
   */
  left: var(--space-4);
  /* Au-dessus de la zone de geste système sur iPhone. */
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 56px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-full, 999px);
  background-color: var(--color-accent-orange);
  color: var(--color-text-on-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* Le compteur porte l'attribut `hidden` quand le panier est vide : on s'en
   sert comme condition d'affichage, sans une ligne de JavaScript de plus. */
.cart-fab:has(.cart-fab__count:not([hidden])) {
  display: inline-flex;
}

.cart-fab__icon {
  font-size: var(--text-lg);
  line-height: 1;
}

.cart-fab__count {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 999px;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  line-height: 26px;
  text-align: center;
}

/* La Bottom Sheet ouverte, le bouton n'a plus lieu d'être. */
body.lgc-cart-open .cart-fab {
  display: none !important;
}

@media print {
  .cart-fab {
    display: none !important;
  }
}
