/* ============================================================
   DA2 Cross-Sell Popup — CSS Mobile-First v1.0.0
   2DA Informatique · Blue #024D99 · Red #CD2014
   ============================================================ */

:root {
  --da2-blue:     #024D99;
  --da2-red:      #CD2014;
  --da2-green:    #16a34a;
  --da2-bg:       #ffffff;
  --da2-surface:  #f8fafc;
  --da2-border:   #e2e8f0;
  --da2-text:     #0f172a;
  --da2-muted:    #64748b;
  --da2-radius:   20px;
  --da2-shadow:   0 -8px 40px rgba(0,0,0,.18);
  --da2-duration: 340ms;
  --da2-ease:     cubic-bezier(.32,.72,0,1);
}

/* ── Overlay ── */
.da2-crossell-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 99998;
  opacity: 0;
  transition: opacity var(--da2-duration) ease;
  will-change: opacity;
  /* caché par JS via display:none / display:block */
}
.da2-crossell-overlay.da2-visible { opacity: 1; }

/* ── Popup Bottom Sheet ── */
.da2-crossell-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  background: var(--da2-bg);
  border-radius: var(--da2-radius) var(--da2-radius) 0 0;
  box-shadow: var(--da2-shadow);
  transform: translateY(100%);
  transition: transform var(--da2-duration) var(--da2-ease);
  will-change: transform;
  max-height: 85vh;
  /* display géré par JS : none par défaut, flex quand ouvert */
  flex-direction: column;
  overflow: hidden;
  touch-action: pan-y;
}
.da2-crossell-popup.da2-visible { transform: translateY(0); }

/* ── Handle (poignée de swipe) ── */
.da2-popup-handle {
  display: flex;
  justify-content: center;
  padding: 12px 0 6px;
  flex-shrink: 0;
}
.da2-popup-handle span {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--da2-border);
}

/* ── Header ── */
.da2-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--da2-border);
}
.da2-popup-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.da2-popup-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--da2-blue), #0366d6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.da2-popup-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
.da2-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--da2-text);
  line-height: 1.2;
}
.da2-popup-subtitle {
  font-size: 12px;
  color: var(--da2-muted);
  margin-top: 2px;
}
.da2-popup-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--da2-surface);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
  -webkit-tap-highlight-color: transparent;
}
.da2-popup-close:active { background: var(--da2-border); }
.da2-popup-close svg {
  width: 16px;
  height: 16px;
  stroke: var(--da2-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Carousel produits ── */
.da2-popup-scroll-wrap {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.da2-products-track {
  display: flex;
  gap: 12px;
  padding: 16px 20px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.da2-products-track::-webkit-scrollbar { display: none; }

/* ── Carte produit ── */
.da2-product-card {
  flex: 0 0 148px;
  width: 148px;
  border-radius: 16px;
  background: #ffffff !important;
  border: 1.5px solid var(--da2-border);
  scroll-snap-align: start;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
}
.da2-product-card:active {
  transform: scale(.97);
}

/* Badge */
.da2-product-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.da2-badge-promo    { background: var(--da2-red);   color: #fff; }
.da2-badge-limited  { background: #f59e0b;           color: #fff; }
.da2-badge-low_stock{ background: #ef4444;           color: #fff; }
.da2-badge-popular  { background: var(--da2-blue);   color: #fff; }
.da2-badge-history  { background: #7c3aed;           color: #fff; }

/* Raison de la recommandation */
.da2-product-reason {
  font-size: 10px;
  color: #7c3aed;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.da2-product-reason::before { content: '✦'; font-size: 8px; }

/* Image */
.da2-product-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #fff !important;
}
.da2-product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  transition: transform .3s ease;
}

/* Infos produit */
.da2-product-info {
  padding: 10px 10px 0;
  flex: 1;
  background: #ffffff !important;
}
.da2-product-name {
  font-size: 12px;
  font-weight: 600;
  color: #0f172a !important;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.da2-product-price {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--da2-blue);
  line-height: 1;
}
.da2-product-price del {
  font-size: 10px;
  font-weight: 400;
  color: var(--da2-muted);
  text-decoration: line-through;
  margin-right: 3px;
}
.da2-product-price ins {
  color: var(--da2-red);
  text-decoration: none;
}

/* Bouton Ajouter */
.da2-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 16px);
  margin: 10px 8px 10px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--da2-blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.da2-add-btn:active  { transform: scale(.95); }
.da2-add-btn:disabled {
  background: var(--da2-green);
  cursor: default;
}
.da2-add-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Animation "ajout" ripple */
.da2-add-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.25);
  opacity: 0;
  transition: opacity .2s;
  border-radius: inherit;
}
.da2-add-btn.da2-adding::after { opacity: 1; }

/* Loader spinner */
.da2-btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: da2spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes da2spin {
  to { transform: rotate(360deg); }
}

/* ── Footer actions ── */
.da2-popup-footer {
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--da2-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--da2-bg);
}

.da2-btn-cart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border-radius: 14px;
  border: none;
  background: var(--da2-red);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .2px;
}
.da2-btn-cart:active { transform: scale(.98); }
.da2-btn-cart svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.da2-btn-continue {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  border: 1.5px solid var(--da2-border);
  background: transparent;
  color: var(--da2-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.da2-btn-continue:active {
  background: var(--da2-surface);
  color: var(--da2-text);
}

/* ── Skeleton loader ── */
.da2-skeleton-card {
  flex: 0 0 148px;
  width: 148px;
  border-radius: 16px;
  background: var(--da2-surface);
  border: 1.5px solid var(--da2-border);
  overflow: hidden;
}
.da2-skeleton-img {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(90deg,#e2e8f0 25%,#f1f5f9 50%,#e2e8f0 75%);
  background-size: 200% 100%;
  animation: da2shimmer 1.2s infinite;
}
.da2-skeleton-line {
  margin: 10px 10px 6px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,#e2e8f0 25%,#f1f5f9 50%,#e2e8f0 75%);
  background-size: 200% 100%;
  animation: da2shimmer 1.2s infinite;
}
.da2-skeleton-line.short { width: 55%; height: 14px; margin-top: 4px; }
.da2-skeleton-btn {
  margin: 10px 8px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(90deg,#e2e8f0 25%,#f1f5f9 50%,#e2e8f0 75%);
  background-size: 200% 100%;
  animation: da2shimmer 1.2s infinite;
}
@keyframes da2shimmer {
  to { background-position: -200% 0; }
}

/* ── Toast notification ── */
.da2-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 100000;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 30px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  transition: transform .3s var(--da2-ease), opacity .3s ease;
  opacity: 0;
  pointer-events: none;
}
.da2-toast.da2-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.da2-toast-icon {
  width: 20px;
  height: 20px;
  background: var(--da2-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.da2-toast-icon svg {
  width: 11px;
  height: 11px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Desktop overrides ── */
@media (min-width: 600px) {
  .da2-crossell-popup {
    max-width: 480px;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(100%);
    border-radius: var(--da2-radius) var(--da2-radius) 0 0;
  }
  .da2-crossell-popup.da2-visible {
    transform: translateX(-50%) translateY(0);
  }
  .da2-product-card { flex: 0 0 160px; width: 160px; }
}
