/**
 * Product Tabs Section - قسم علامات تبويب المنتجات
 * Matches design: main/sub title, tab navigation, product slider
 */

.products-tabs-section {
  --products-tabs-title-color: #222;
  --products-tabs-subtitle-color: #6b6b6b;
  --products-tabs-active-text: #222;
  --products-tabs-active-border: #222;
  --products-tabs-inactive-text: #757575;
  --products-tabs-inactive-border: transparent;
}

.products-tabs-container {
  overflow: hidden;
}

/* Top row: titles (right) + tabs (left) on same line */
.products-tabs-top-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

[dir="rtl"] .products-tabs-top-row {
  flex-direction: row;
}

/* Header: title + subtitle (right side in RTL) */
.products-tabs-header {
  flex-shrink: 0;
}

.products-tabs-header--right {
  text-align: right;
}

.products-tabs-header--center {
  text-align: center;
}

.products-tabs-header--left {
  text-align: left;
}

.products-tabs-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--products-tabs-title-color);
  margin: 0 0 6px;
  line-height: 1.25;
}

.products-tabs-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--products-tabs-subtitle-color);
  margin: 0;
  line-height: 1.4;
}

/* Tabs nav (left side in RTL) */
.products-tabs-nav {
  flex: 0 1 auto;
  min-width: 0;
}

.products-tabs-tabs-wrap {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 8px 0;
}

.products-tabs-tabs-wrap::-webkit-scrollbar {
  height: 6px;
}

.products-tabs-tabs-wrap::-webkit-scrollbar-thumb {
  background: #e0e0e0;
  border-radius: 3px;
}

.products-tabs-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--products-tabs-inactive-text);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--products-tabs-inactive-border);
  padding: 10px 4px 12px;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease;
  white-space: nowrap;
  font-family: inherit;
}

.products-tabs-tab:hover {
  color: var(--products-tabs-active-text);
}

.products-tabs-tab:focus {
  outline: 2px solid var(--primary-color, #333);
  outline-offset: 2px;
}

.products-tabs-tab--active {
  color: var(--products-tabs-active-text);
  border-bottom-color: var(--products-tabs-active-border);
  font-weight: 600;
}

.products-tabs-tab-label {
  line-height: 1.2;
}

/* Panels */
.products-tabs-panels {
  position: relative;
  min-height: 320px;
}

.products-tabs-panel {
  position: relative;
  z-index: 1;
  min-height: 300px;
}

.products-tabs-panel[hidden] {
  display: none !important;
}

.products-tabs-panel:not([hidden]) .products-tabs-slider-wrap {
  width: 100%;
}

.products-tabs-slider-wrap {
  position: relative;
  min-height: 280px;
}

.products-tabs-slider {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding: 4px 0;
}

.products-tabs-slider .prod-col {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-width: 0;
}

/* Desktop: 5–6 products visible, use slick if initialized */
.products-tabs-section .products-tabs-slider.slick-initialized {
  display: block;
  overflow: visible;
}

.products-tabs-section .products-tabs-slider.slick-initialized .slick-list {
  overflow: visible;
}

.products-tabs-section .products-tabs-slider .prod-col {
  padding: 0 6px;
}

/* Skeleton loader */
.products-tabs-loading {
  width: 100%;
  min-height: 280px;
}

.products-tabs-skeleton {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow: hidden;
  padding: 4px 0;
}

.products-tabs-skeleton-card {
  flex: 0 0 200px;
  min-width: 180px;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.products-tabs-skeleton-img {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: products-tabs-skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
  margin-bottom: 12px;
}

.products-tabs-skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: products-tabs-skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}

.products-tabs-skeleton-line.short {
  width: 60%;
}

.products-tabs-skeleton-line.price {
  width: 40%;
  margin-top: 8px;
}

@keyframes products-tabs-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state */
.products-tabs-empty {
  padding: 48px 24px;
  text-align: center;
}

.products-tabs-empty-text {
  margin: 0;
  font-size: 1rem;
  color: var(--products-tabs-inactive-text, #757575);
}

/* Fade transition for dynamic content */
.products-tabs-content--fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.products-tabs-content--fade.is-visible {
  opacity: 1;
}

/* Product cards inside section */
.products-tabs-section .outlit-product-card {
  height: 100%;
}

/* Mobile: stack title and tabs, center titles, tabs overflow horizontal */
@media (max-width: 767px) {
  .products-tabs-top-row {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .products-tabs-header,
  .products-tabs-header--right,
  .products-tabs-header--left {
    text-align: center;
  }

  .products-tabs-title {
    font-size: 1.5rem;
  }

  .products-tabs-subtitle {
    font-size: 0.9375rem;
  }

  .products-tabs-nav {
    min-width: 0;
  }

  .products-tabs-tabs-wrap {
    justify-content: flex-start;
    gap: 16px;
    padding-left: 4px;
    padding-right: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .products-tabs-tab {
    font-size: 0.9375rem;
    padding: 8px 2px 10px;
  }

  .products-tabs-panels,
  .products-tabs-panel,
  .products-tabs-slider-wrap {
    min-height: 260px;
  }

  .products-tabs-panel:not([hidden]) .products-tabs-slider-wrap,
  .products-tabs-panel:not([hidden]) .products-tabs-slider {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Fallback when slick not yet initialized (e.g. before first paint) */
  .products-tabs-slider:not(.slick-initialized) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .products-tabs-slider:not(.slick-initialized) .prod-col {
    min-width: 0;
  }

  .products-tabs-skeleton {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .products-tabs-skeleton-card {
    flex: none;
    min-width: 0;
  }
}
