/* ==========================================================================
   CrewShop Recommendations Widget — Stiluri carusel
   Versiune: 1.0.0
   Prefix clase: .csrec-
   Zero dependențe externe. Funcționează pe orice platformă.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variabile CSS — customizabile per proiect
   -------------------------------------------------------------------------- */
:root {
  /* Culori principale */
  --csrec-primary:        #2563eb;
  --csrec-primary-hover:  #1d4ed8;
  --csrec-text:           #111827;
  --csrec-text-muted:     #6b7280;
  --csrec-bg:             #ffffff;
  --csrec-bg-alt:         #f9fafb;
  --csrec-border:         #e5e7eb;

  /* Card */
  --csrec-card-radius:    10px;
  --csrec-card-shadow:    0 2px 8px rgba(0,0,0,.07);
  --csrec-card-shadow-hover: 0 6px 20px rgba(0,0,0,.12);
  --csrec-card-img-bg:    #f3f4f6;
  --csrec-card-img-height: 200px;

  /* Carusel */
  --csrec-gap:            16px;
  --csrec-cards-desktop:  5;    /* card-uri vizibile pe desktop */
  --csrec-cards-tablet:   3;    /* tablet */
  --csrec-cards-mobile:   2;    /* mobil */
  --csrec-scroll-padding: 8px;

  /* Badge-uri */
  --csrec-badge-sale-bg:     #ef4444;
  --csrec-badge-sale-color:  #ffffff;
  --csrec-badge-new-bg:      #10b981;
  --csrec-badge-new-color:   #ffffff;
  --csrec-badge-top-bg:      #f59e0b;
  --csrec-badge-top-color:   #ffffff;
  --csrec-badge-generic-bg:  #e5e7eb;
  --csrec-badge-generic-color: #374151;

  /* Rating */
  --csrec-star-filled:    #f59e0b;
  --csrec-star-empty:     #d1d5db;

  /* Butoane nav carusel */
  --csrec-nav-size:       40px;
  --csrec-nav-bg:         #ffffff;
  --csrec-nav-border:     #e5e7eb;
  --csrec-nav-color:      #374151;
  --csrec-nav-shadow:     0 2px 8px rgba(0,0,0,.12);

  /* Dots */
  --csrec-dot-size:       8px;
  --csrec-dot-active:     #2563eb;
  --csrec-dot-inactive:   #d1d5db;

  /* Tranziții */
  --csrec-transition:     .2s ease;

  /* Font (moștenește fontul site-ului dacă nu e specificat) */
  --csrec-font:           inherit;
}

/* --------------------------------------------------------------------------
   Container bloc recomandări
   -------------------------------------------------------------------------- */
.csrec-block {
  font-family: var(--csrec-font);
  color: var(--csrec-text);
  margin: 32px 0;
  box-sizing: border-box;
}

.csrec-block *,
.csrec-block *::before,
.csrec-block *::after {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Header bloc (titlu + link "Vezi toate")
   -------------------------------------------------------------------------- */
.csrec-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.csrec-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--csrec-text);
  line-height: 1.2;
  margin: 0;
}

.csrec-subtitle {
  font-size: 14px;
  color: var(--csrec-text-muted);
  margin: 4px 0 0;
  font-weight: 400;
}

.csrec-see-all {
  font-size: 13px;
  font-weight: 500;
  color: var(--csrec-primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.csrec-see-all:hover {
  color: var(--csrec-primary-hover);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Carusel wrapper
   -------------------------------------------------------------------------- */
.csrec-carousel {
  position: relative;
  overflow: hidden;          /* conține săgețile și peek-ul */
}

.csrec-track-wrapper {
  overflow: hidden;
  border-radius: var(--csrec-card-radius);
}

.csrec-track {
  display: flex;
  gap: var(--csrec-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: var(--csrec-scroll-padding) 0;
}

.csrec-track::-webkit-scrollbar {
  display: none;
}

/* --------------------------------------------------------------------------
   Card produs
   -------------------------------------------------------------------------- */
.csrec-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: calc(
    (100% - (var(--csrec-cards-desktop) - 1) * var(--csrec-gap))
    / var(--csrec-cards-desktop)
  );
  background: var(--csrec-bg);
  border-radius: var(--csrec-card-radius);
  border: 1px solid var(--csrec-border);
  box-shadow: var(--csrec-card-shadow);
  transition: box-shadow var(--csrec-transition), transform var(--csrec-transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.csrec-card:hover {
  box-shadow: var(--csrec-card-shadow-hover);
  transform: translateY(-2px);
}

/* Imagine */
.csrec-card-img-wrap {
  position: relative;
  background: var(--csrec-card-img-bg);
  height: var(--csrec-card-img-height);
  overflow: hidden;
  flex-shrink: 0;
}

.csrec-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  transition: transform var(--csrec-transition);
}

.csrec-card:hover .csrec-card-img {
  transform: scale(1.04);
}

.csrec-card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--csrec-border);
}

/* Badge produs (SALE, NOU, TOP etc.) */
.csrec-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: var(--csrec-badge-generic-bg);
  color: var(--csrec-badge-generic-color);
}

.csrec-badge[data-type="SALE"],
.csrec-badge[data-type="sale"],
.csrec-badge[data-type="promo"] {
  background: var(--csrec-badge-sale-bg);
  color: var(--csrec-badge-sale-color);
}

.csrec-badge[data-type="NOU"],
.csrec-badge[data-type="new"],
.csrec-badge[data-type="nou"] {
  background: var(--csrec-badge-new-bg);
  color: var(--csrec-badge-new-color);
}

.csrec-badge[data-type="TOP"],
.csrec-badge[data-type="top"],
.csrec-badge[data-type="bestseller"] {
  background: var(--csrec-badge-top-bg);
  color: var(--csrec-badge-top-color);
}

/* Wishlist */
.csrec-wishlist-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: #9ca3af;
  transition: color var(--csrec-transition), background var(--csrec-transition);
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.csrec-wishlist-btn:hover,
.csrec-wishlist-btn.active {
  color: #ef4444;
  background: #fff;
}

/* Discount overlay */
.csrec-discount-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--csrec-badge-sale-bg);
  color: var(--csrec-badge-sale-color);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Corp card */
.csrec-card-body {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.csrec-card-brand {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--csrec-text-muted);
}

.csrec-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--csrec-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Rating stele */
.csrec-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.csrec-stars {
  display: flex;
  gap: 1px;
}

.csrec-star {
  font-size: 12px;
  color: var(--csrec-star-empty);
}

.csrec-star.filled {
  color: var(--csrec-star-filled);
}

.csrec-star.half {
  /* Hack jumătate stea via gradient */
  background: linear-gradient(
    to right,
    var(--csrec-star-filled) 50%,
    var(--csrec-star-empty) 50%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.csrec-rating-count {
  font-size: 11px;
  color: var(--csrec-text-muted);
}

/* Prețuri */
.csrec-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.csrec-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--csrec-text);
}

.csrec-price.has-discount {
  color: var(--csrec-badge-sale-bg);
}

.csrec-price-original {
  font-size: 12px;
  color: var(--csrec-text-muted);
  text-decoration: line-through;
}

.csrec-currency {
  font-size: 12px;
  font-weight: 500;
  color: inherit;
}

/* Footer card — buton coș */
.csrec-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--csrec-border);
  background: var(--csrec-bg-alt);
}

.csrec-btn-cart {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: var(--csrec-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--csrec-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.csrec-btn-cart:hover {
  background: var(--csrec-primary-hover);
}

.csrec-btn-cart:disabled,
.csrec-btn-cart.out-of-stock {
  background: var(--csrec-border);
  color: var(--csrec-text-muted);
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Butoane navigare carusel (Prev / Next)
   -------------------------------------------------------------------------- */
.csrec-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: var(--csrec-nav-size);
  height: var(--csrec-nav-size);
  border-radius: 50%;
  background: var(--csrec-nav-bg);
  border: 1px solid var(--csrec-nav-border);
  box-shadow: var(--csrec-nav-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--csrec-nav-color);
  transition: background var(--csrec-transition), opacity var(--csrec-transition), box-shadow var(--csrec-transition);
  z-index: 10;
}

.csrec-nav:hover {
  background: var(--csrec-primary);
  color: #ffffff;
  border-color: var(--csrec-primary);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.csrec-nav:disabled,
.csrec-nav.hidden {
  opacity: 0;
  pointer-events: none;
}

.csrec-nav-prev {
  left: 8px;
}

.csrec-nav-next {
  right: 8px;
}

.csrec-nav svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Dots indicator
   -------------------------------------------------------------------------- */
.csrec-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.csrec-dot {
  width: var(--csrec-dot-size);
  height: var(--csrec-dot-size);
  border-radius: 50%;
  background: var(--csrec-dot-inactive);
  border: none;
  cursor: pointer;
  transition: background var(--csrec-transition), transform var(--csrec-transition);
  padding: 0;
}

.csrec-dot.active {
  background: var(--csrec-dot-active);
  transform: scale(1.3);
}

/* --------------------------------------------------------------------------
   Grid layout (alternativă la carousel)
   -------------------------------------------------------------------------- */
.csrec-grid .csrec-track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  overflow-x: unset;
  scroll-snap-type: unset;
  flex-wrap: wrap;
}

.csrec-grid .csrec-card {
  width: auto;
}

/* --------------------------------------------------------------------------
   State: loading
   -------------------------------------------------------------------------- */
.csrec-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  gap: 12px;
  color: var(--csrec-text-muted);
  font-size: 13px;
}

.csrec-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--csrec-border);
  border-top-color: var(--csrec-primary);
  border-radius: 50%;
  animation: csrec-spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes csrec-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   State: empty / error
   -------------------------------------------------------------------------- */
.csrec-empty,
.csrec-error {
  text-align: center;
  padding: 24px;
  color: var(--csrec-text-muted);
  font-size: 13px;
  font-style: italic;
}

.csrec-error {
  color: #ef4444;
}

/* --------------------------------------------------------------------------
   Out of stock overlay
   -------------------------------------------------------------------------- */
.csrec-oos-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--csrec-text-muted);
  letter-spacing: .08em;
}

/* --------------------------------------------------------------------------
   Responsive — Tablet
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .csrec-card {
    width: calc(
      (100% - (var(--csrec-cards-tablet) - 1) * var(--csrec-gap))
      / var(--csrec-cards-tablet)
    );
  }

  .csrec-nav-prev { left: -12px; }
  .csrec-nav-next { right: -12px; }
}

/* --------------------------------------------------------------------------
   Responsive — Mobil
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .csrec-title { font-size: 16px; }

  .csrec-card {
    width: calc(
      (100% - (var(--csrec-cards-mobile) - 1) * var(--csrec-gap))
      / var(--csrec-cards-mobile)
    );
    --csrec-card-img-height: 150px;
  }

  .csrec-nav {
    display: none; /* pe mobil, swipe touch nativ */
  }

  .csrec-card-name { font-size: 12px; }
  .csrec-price { font-size: 15px; }
}

/* --------------------------------------------------------------------------
   Tematizare rapidă — override cu o singură clasă pe container
   Exemplu: <div class="csrec-theme-dark">
   -------------------------------------------------------------------------- */
.csrec-theme-dark {
  --csrec-bg:         #1e293b;
  --csrec-bg-alt:     #0f172a;
  --csrec-text:       #f1f5f9;
  --csrec-text-muted: #94a3b8;
  --csrec-border:     #334155;
  --csrec-card-img-bg: #0f172a;
  --csrec-nav-bg:     #334155;
  --csrec-nav-border: #475569;
  --csrec-nav-color:  #e2e8f0;
}
