/* =========================================================
   Softadastra Categories & Products — Alibaba-like Styles
   ========================================================= */

/* ---------- Variables ---------- */
:root {
  --topbar-h: 56px;

  /* container */
  --container-max: 1280px;
  --container-pad-desktop: 24px;
  --container-pad-mobile: 14px;

  /* sidebar */
  --sidebar-w-desktop: 240px;
  --sidebar-w-mobile: 108px;
  /* proche Alibaba */
  --sidebar-bg: #fff;
  --sidebar-line: #eee;

  /* circles */
  --circle-size-desktop: 110px;
  --circle-size-mobile: 72px;
  --circle-bg: #fff;
  --circle-line: #eee;

  /* products */
  --card-bg: #fff;
  --card-line: #eee;
  --card-radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 22px rgba(0, 0, 0, 0.1);

  /* brand */
  --brand: #ff6a00;
  /* proche d’Alibaba */
  --brand-soft: #fff7ed;
  /* fond léger orangé */
  --text: #222;
  --muted: #666;
}

/* ---------- Container global (centré, non collé bords) ---------- */
.soft-cats {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad-desktop);
  display: flex;
  align-items: stretch;
  gap: 16px;
  min-height: calc(100dvh - var(--topbar-h));
}

@media (max-width: 768px) {
  .soft-cats {
    padding: 0 var(--container-pad-mobile);
    gap: 12px;
  }
}

/* ---------- Sidebar sticky & scroll ---------- */
.soft-cats__sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  align-self: flex-start;

  flex: 0 0 var(--sidebar-w-desktop);
  width: var(--sidebar-w-desktop);
  max-width: var(--sidebar-w-desktop);

  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;

  border: 1px solid var(--sidebar-line);
  border-radius: 12px;
  background: var(--sidebar-bg);
  padding: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  z-index: 3;
}

@media (max-width: 1024px) {
  .soft-cats__sidebar {
    flex: 0 0 var(--sidebar-w-mobile);
    width: var(--sidebar-w-mobile);
    max-width: var(--sidebar-w-mobile);
    padding: 6px;
  }
}

@media (max-width: 480px) {
  .soft-cats__sidebar {
    flex: 0 0 96px;
    width: 96px;
    max-width: 96px;
  }
}

/* scrollbar esthétique */
.soft-cats__sidebar::-webkit-scrollbar {
  width: 8px;
}

.soft-cats__sidebar::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 8px;
}

.soft-cats__sidebar {
  scrollbar-width: thin;
  scrollbar-color: #e5e7eb transparent;
}

/* ---------- Sidebar items (Alibaba-like) ---------- */
.soft-cats__wrap {
  display: block;
}

.soft-cats__item {
  display: grid;
  grid-template-columns: 28px 1fr 12px;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}

.soft-cats__item:hover {
  background: #fafafa;
}

.soft-cats__item[aria-current="true"] {
  background: var(--brand-soft);
  outline: 1px solid #ffedd5;
}

.soft-cats__icon {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
}

.soft-cats__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soft-cats__chev {
  color: #bbb;
}

@media (max-width: 1024px) {
  .soft-cats__item {
    grid-template-columns: 24px 1fr 10px;
    gap: 8px;
    padding: 9px 6px;
  }

  .soft-cats__icon {
    width: 24px;
    height: 24px;
  }

  .soft-cats__name {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .soft-cats__item {
    grid-template-columns: 22px 1fr 8px;
    gap: 6px;
    padding: 8px 6px;
  }

  .soft-cats__icon {
    width: 22px;
    height: 22px;
  }

  .soft-cats__name {
    font-size: 12px;
  }
}

/* ---------- Panel (droite) ---------- */
.soft-cats__panel {
  flex: 1 1 auto;
  min-width: 0;
}

.soft-panel__inner {
  background: transparent;
}

.soft-panel__header {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 6px;
  column-gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.soft-panel__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.soft-panel__breadcrumb {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soft-panel__actions .soft-btn {
  padding: 8px 10px;
  border: 1px solid #eee;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.soft-panel__actions .soft-btn:hover {
  background: #fafafa;
}

/* ---------- Grilles ---------- */
/* Vue catégories (cercles) */
.soft-panel__grid.is-circles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 24px;
  justify-items: center;
  margin: 14px 0 18px;
}

/* Mobile: 4 colonnes fixes. Très petits: 3 colonnes */
@media (max-width: 768px) {
  .soft-panel__grid.is-circles {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .soft-panel__grid.is-circles {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px;
  }
}

/* Vue produits (cartes) */
.soft-panel__grid.is-products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1280px) {
  .soft-panel__grid.is-products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .soft-panel__grid.is-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .soft-panel__grid.is-products {
    grid-template-columns: 1fr;
  }
}

/* ---------- Cercles catégories 100% ---------- */
.soft-circle {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.soft-circle.is-in {
  animation: softFade 0.35s ease both;
}

@keyframes softFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.soft-circle__link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Wrapper parfaitement circulaire */
.soft-circle__imgwrap {
  width: var(--circle-size-desktop);
  height: var(--circle-size-desktop);
  border-radius: 50%;
  /* border: 1px solid var(--circle-line); */
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.18s ease, transform 0.18s ease,
    border-color 0.18s ease;
}

.soft-circle:hover .soft-circle__imgwrap {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  border-color: #e8e8e8;
}

/* Image interne aussi en cercle (100%) */
.soft-circle__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  /* optionnel: léger fond pour SVG/PNG transparents */
  background: #fff;
}

.soft-circle__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  max-width: var(--circle-size-desktop);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cercles sur mobile */
@media (max-width: 768px) {
  .soft-circle__imgwrap {
    width: var(--circle-size-mobile);
    height: var(--circle-size-mobile);
  }

  .soft-circle__name {
    font-size: 12px;
    max-width: var(--circle-size-mobile);
  }
}

/* Skeleton cercles */
.soft-circle.sk .soft-circle__imgwrap,
.soft-circle.sk .soft-circle__name {
  background: linear-gradient(90deg, #f3f3f3 25%, #ececec 37%, #f3f3f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

.soft-circle.sk .soft-circle__name {
  width: 60%;
  height: 14px;
  border-radius: 6px;
}

@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }

  100% {
    background-position: 400px 0;
  }
}

/* ---------- Cartes produits robustes ---------- */
.soft-prod {
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.soft-prod:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #e8e8e8;
}

.soft-prod__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* Image wrap (ratio carré) */
.soft-prod__imgwrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.soft-prod__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Bouton favori */
.soft-like.sa-card__fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.soft-like.sa-card__fav-btn svg {
  width: 18px;
  height: 18px;
  fill: #ff5a5f;
}

/* Badge promo */
.soft-badge.soft-badge--sale {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 4px 8px;
  background: #ffefea;
  color: #d84a05;
  border: 1px solid #ffd7c8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* Corps de carte */
.soft-prod__body {
  padding: 10px 12px 12px;
}

.soft-prod__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  max-height: 2.7em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
}

/* Ligne de prix */
.soft-priceRow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sa-card__pricebox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sa-card__price {
  font-size: 15px;
  font-weight: 800;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sa-card__usd {
  font-size: 12px;
  color: #999;
}

.soft-price--compare {
  font-size: 12px;
  color: #999;
  text-decoration: line-through;
}

/* Pills */
.soft-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.8;
  border: 1px solid #eee;
  background: #fff;
}

.soft-pill--sale {
  color: #d84a05;
  border-color: #ffd7c8;
  background: #ffefea;
}

.soft-pill--moq {
  color: #155e75;
  border-color: #bfdbfe;
  background: #eff6ff;
}

/* Skeleton produits */
.soft-prod.sk .soft-prod__imgwrap,
.soft-prod.sk .soft-prod__title,
.soft-prod.sk .soft-prod__body .soft-prod__meta {
  background: linear-gradient(90deg, #f3f3f3 25%, #ececec 37%, #f3f3f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

.soft-prod.sk .soft-prod__imgwrap {
  aspect-ratio: 1/1;
}

.soft-prod.sk .soft-prod__title {
  height: 18px;
  border-radius: 8px;
  margin: 10px 12px;
}

.soft-prod.sk .soft-prod__meta {
  height: 14px;
  border-radius: 7px;
  margin: 8px 12px 12px;
}

/* ---------- Spinner & Empty state ---------- */
.soft-spinner {
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 14px 0;
  color: #666;
}

.soft-spinner.is-visible {
  display: flex;
}

.soft-spinner__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  animation: dotPulse 0.9s infinite ease-in-out;
}

@keyframes dotPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }

  50% {
    transform: scale(1.35);
    opacity: 1;
  }
}

.soft-spinner__text {
  font-size: 13px;
}

/* Empty state */
.soft-emptystate {
  display: grid;
  place-items: center;
  padding: 40px 0;
}

.soft-emptystate__inner {
  text-align: center;
  color: #555;
}

.soft-emptystate__icon svg {
  width: 40px;
  height: 40px;
}

.soft-emptystate__title {
  font-weight: 700;
  margin-top: 8px;
}

.soft-emptystate__hint {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

/* ---------- Accessibilité & Motion ---------- */
.soft-cats__item:focus-visible,
.soft-circle__link:focus-visible,
.soft-prod__link:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
  border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Catégories (cercles) --- */
.soft-circle__imgwrap {
  position: relative;
  /* pour l'overlay */
  background: transparent !important;
  /* pas de fond blanc */
}

/* overlay skeleton pendant le chargement */
.soft-circle__imgwrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(90deg, #f3f3f3 25%, #ececec 37%, #f3f3f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  transition: opacity 0.2s ease;
}

/* l’image ne “flash” pas : fade-in quand chargée */
.soft-circle__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  background: transparent !important;
  /* enlève tout fond blanc */
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* quand l'image est chargée */
.soft-circle.is-loaded .soft-circle__img {
  opacity: 1;
}

.soft-circle.is-loaded .soft-circle__imgwrap::before {
  opacity: 0;
}

/* --- Produits --- */
.soft-prod__imgwrap {
  position: relative;
  background: transparent !important;
  /* pas de fond blanc forcé */
}

.soft-prod__imgwrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f3f3f3 25%, #ececec 37%, #f3f3f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
  transition: opacity 0.2s ease;
}

.soft-prod__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* fade-in */
  transition: opacity 0.25s ease;
}

.soft-prod.is-loaded .soft-prod__img {
  opacity: 1;
}

.soft-prod.is-loaded .soft-prod__imgwrap::before {
  opacity: 0;
}

@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }

  100% {
    background-position: 400px 0;
  }
}

/* Conteneur item : style par défaut (desktop/tablette) */
.soft-cats__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  background: #fff;
}

.soft-cats__item[aria-current="true"] {
  background: #fff7eb;
  box-shadow: inset 0 0 0 1px #ffb455;
}

.soft-cats__content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  /* truncate propre du nom */
}

.soft-cats__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: #f2f2f2;
}

.soft-cats__name {
  font-size: 14px;
  font-weight: 500;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soft-cats__chev {
  margin-left: auto;
  /* pousse à droite en layout flex */
  font-size: 18px;
  line-height: 1;
  color: #999;
}

/* —— Mobile : image + nom en bloc (empilés), chevron à droite —— */
@media (max-width: 1024px) {
  .soft-cats__item {
    display: grid;
    grid-template-columns: 1fr auto;
    /* contenu à gauche, chevron à droite */
    align-items: center;
    gap: 8px 12px;
  }

  .soft-cats__content {
    display: block;
    /* “block” pour empiler */
  }

  .soft-cats__icon {
    width: 36px;
    height: 36px;
    margin: 0 0 6px 0;
    /* espace sous l’image */
    display: block;
  }

  .soft-cats__name {
    display: block;
    /* sous l’image */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .soft-cats__chev {
    justify-self: end;
    /* bien collé à droite */
  }
}

/* Déjà OK en desktop; on renforce le cas mobile */
.soft-cats__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 640px) {
  .soft-cats__item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 12px;
  }

  .soft-cats__content {
    display: block;
    min-width: 0;
    /* 🔑 permet l’ellipsis du nom */
  }

  .soft-cats__name {
    display: block;
    white-space: nowrap;
    /* une seule ligne + “…” */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .soft-cats__chev {
    justify-self: end;
  }
}

@media (max-width: 640px) {
  .soft-cats__name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    /* 2 lignes max */
    overflow: hidden;
    white-space: normal;
    /* important pour le clamp */
    text-overflow: ellipsis;
    /* pour certains navigateurs */
  }
}

.soft-circle__name {
  font-weight: 500;
}

@media (max-width: 768px) {
  .soft-circle__name {
    font-size: 0.7rem;
    max-width: var(--circle-size-mobile);
  }
}

.soft-cats {
  margin-bottom: 50px !important;
}

@media (max-width: 768px) {
  .soft-cats {
    padding: 0 !important;
  }
}

@media (max-width: 900px) {
  .soft-panel__grid.is-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .soft-panel__grid.is-products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .sa-card__usd {
    display: none;
  }
}

.soft-panel__empty {
  margin: 14px 10px;
}
