/* =========================================================
   JONCORP MARKET — Composants
   ========================================================= */

/* ---------- Carte produit ---------- */
.product-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.product-media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--c-surface-alt);
  overflow: hidden;
  display: block;
}
.product-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.product-card:hover .product-media img { transform: scale(1.05); }

/* ---------- Badges ---------- */
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--c-danger);
  color: #fff;
  line-height: 1.4;
  pointer-events: none;
}
.badge.new        { background: var(--c-success); left: auto; right: 10px; }
.badge.bestseller { background: var(--c-accent); color: #7c2d12; }

/* ---------- Bouton wishlist ---------- */
.wish-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--c-text-muted);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color var(--transition), transform var(--transition), background var(--transition);
}
.wish-btn:hover { color: var(--c-danger); transform: scale(1.08); }
.wish-btn.active { color: var(--c-danger); }
.wish-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* ---------- Corps de carte produit ---------- */
.product-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
}
.product-seller {
  font-size: 11px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.35;
  min-height: 38px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}
.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--c-text-muted);
}
.stars {
  display: inline-flex;
  gap: 1px;
  color: var(--c-accent);
  align-items: center;
}
.product-price {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: auto;
}
.product-price .now {
  font-weight: 800;
  font-size: var(--fs-lg);
  color: var(--c-text);
}
.product-price .old {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  text-decoration: line-through;
}
.product-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.product-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  font-size: var(--fs-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--c-border);
}
.skeleton-card .skeleton.img {
  aspect-ratio: 4 / 5;
  border-radius: 0;
}
.skeleton-card .skeleton.txt {
  height: 12px;
  margin: 12px 12px 0;
}
.skeleton-card .skeleton.txt.lg {
  height: 16px;
  width: 70%;
  margin-top: 12px;
}
.skeleton-card .skeleton.txt.sm {
  width: 50%;
  margin-bottom: 14px;
}
@keyframes sk {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  min-width: 240px;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  animation: slideIn .25s ease;
  word-break: break-word;
}
.toast .t-icon { display: inline-flex; flex-shrink: 0; }
.toast.success { background: var(--c-success); }
.toast.error   { background: var(--c-danger); }
.toast.info    { background: var(--c-primary); }
.toast.warning { background: var(--c-warning); }
.toast .close {
  margin-left: auto;
  opacity: .8;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
}
.toast .close:hover { opacity: 1; }
@keyframes slideIn  { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { to   { opacity: 0; transform: translateX(30px); } }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: var(--sp-4);
  animation: fadeIn .2s ease;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  animation: pop .22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop    { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Formulaires ---------- */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text);
  font-size: var(--fs-sm);
  font-family: inherit;
  line-height: 1.4;
  transition: border var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--c-danger);
}
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--c-surface-alt);
  color: var(--c-text-muted);
  cursor: not-allowed;
}
.form-input::placeholder,
.form-textarea::placeholder { color: #94a3b8; }

.form-textarea {
  resize: vertical;
  min-height: 84px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  cursor: pointer;
}

.form-input[type="number"]::-webkit-outer-spin-button,
.form-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.form-input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.form-hint {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-top: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.form-error {
  font-size: var(--fs-xs);
  color: var(--c-danger);
  margin-top: 4px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

/* ---------- Card générique ---------- */
.card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-6);
}
.card-title {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-4);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-4);
  color: var(--c-text-muted);
}
.empty svg {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  opacity: .35;
  margin: 0 auto var(--sp-4);
  display: block;
}

/* ---------- Onglets ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 12px 18px;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--c-text); }
.tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* ---------- Fil d'Ariane ---------- */
.crumbs {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  padding: var(--sp-4) 0;
  overflow-wrap: anywhere;
}
.crumbs a { transition: color var(--transition); }
.crumbs a:hover { color: var(--c-primary); }

/* ---------- Pastille de statut ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.status.received   { background: #dbeafe; color: #1e40af; }
.status.paid       { background: #dcfce7; color: #166534; }
.status.preparing  { background: #fef3c7; color: #92400e; }
.status.shipped    { background: #e0e7ff; color: #3730a3; }
.status.delivering { background: #ffedd5; color: #9a3412; }
.status.delivered  { background: #d1fae5; color: #065f46; }
.status.cancelled  { background: #fee2e2; color: #991b1b; }

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 30px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--c-border);
}
.timeline-item {
  position: relative;
  padding-bottom: var(--sp-6);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -30px;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--c-border);
  display: grid;
  place-items: center;
}
.timeline-item.done .timeline-dot {
  background: var(--c-primary);
  border-color: var(--c-primary);
}
.timeline-item.done .timeline-dot::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
}
.timeline-item .t-title { font-weight: 600; }
.timeline-item .t-date  { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* ---------- Alertes ---------- */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  align-items: flex-start;
  line-height: 1.5;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert code {
  background: rgba(0, 0, 0, .06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
}
.alert-info    { background: var(--c-primary-light); color: var(--c-primary-dark); }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* ---------- Accessibilité : focus visible ---------- */
.btn:focus-visible,
.tab:focus-visible,
.jm-icon-btn:focus-visible,
.wish-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* ---------- Impression ---------- */
@media print {
  .toast-stack,
  .modal-backdrop,
  .wish-btn,
  .product-actions,
  .jm-header,
  .jm-footer { display: none !important; }
}