/* ========================================
   STAREL ARCHIVE TOOLBAR
   Product category / shop archive controls
======================================== */


/* ========================================
   1. Archive Toolbar Layout
   Grid-based toolbar with measured subnav overflow
======================================== */

.starel-archive-toolbar {
  display: grid !important;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "filter sorting subnav count";
  align-items: center !important;
  width: 100%;
  gap: 20px 28px;
}

/* Row item placement.
   Filter button currently has no custom class, so it is treated as the first direct widget. */
.starel-archive-toolbar > .elementor-element:first-child {
  grid-area: filter;
  justify-self: start;
  align-self: center;
  min-width: 0;
}

.starel-archive-toolbar > .starel-archive-sorting {
  grid-area: sorting;
  justify-self: start;
  align-self: center;
  min-width: 0;
}

.starel-archive-toolbar > .starel-category-subnav {
  grid-area: subnav;
  justify-self: start;
  align-self: center;
  width: 100%;
  min-width: 0;
}

.starel-archive-toolbar > .starel-archive-count {
  grid-area: count;
  justify-self: end;
  align-self: center;
  min-width: max-content;
  margin-left: 0 !important;
}

/* When JS detects the subnav cannot fit in row 1,
   keep Filter + Sorting left and Product Count right,
   then place the subnav full-width on row 2. */
.starel-archive-toolbar.is-subnav-overflowing {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "filter sorting . count"
    "subnav subnav subnav subnav";
  row-gap: 22px;
}

.starel-archive-toolbar.is-subnav-overflowing > .starel-category-subnav {
  width: 100%;
  max-width: 100%;
}

/* Clean result count widget wrapper */
.starel-archive-count .elementor-widget-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ========================================
   2. Archive Sorting
   Native WooCommerce select, visually simplified
======================================== */

.starel-archive-sorting {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: auto !important;
  max-width: max-content;
  flex: 0 0 auto;
}

.starel-archive-sorting .woocommerce-ordering {
  --sorting-label-width: 64px;
  --sorting-arrow-size: 8px;
  --sorting-gap: 12px;
  --sorting-x-padding: 24px;

  position: relative;
  display: inline-flex;
  align-items: center;
  width: auto !important;
  max-width: max-content;
  margin: 0;
  flex: 0 0 auto;
}

/* Visual label */
.starel-archive-sorting .woocommerce-ordering::before {
  content: "Sorting";
  position: absolute;
  left: var(--sorting-x-padding);
  top: 50%;
  transform: translateY(-50%);
  color: var(--e-global-color-text);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Arrow */
.starel-archive-sorting .woocommerce-ordering::after {
  content: "";
  position: absolute;
  left: calc(var(--sorting-x-padding) + var(--sorting-label-width) + var(--sorting-gap));
  top: 50%;
  width: var(--sorting-arrow-size);
  height: var(--sorting-arrow-size);
  border-right: 1px solid var(--e-global-color-text);
  border-bottom: 1px solid var(--e-global-color-text);
  transform: translateY(-85%) rotate(45deg);
  pointer-events: none;
  z-index: 2;
}

/* Native select remains functional */
.starel-archive-sorting .woocommerce-ordering select.orderby {
  appearance: none;
  -webkit-appearance: none;
  width: calc(
    var(--sorting-x-padding) +
    var(--sorting-label-width) +
    var(--sorting-gap) +
    var(--sorting-arrow-size) +
    var(--sorting-x-padding)
  ) !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0;
  padding: 13px var(--sorting-x-padding);
  border: 1px solid var(--e-global-color-text);
  border-radius: 8px;
  background: transparent;
  color: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  outline: none;
}

/* Dropdown options remain readable */
.starel-archive-sorting .woocommerce-ordering select.orderby option {
  color: var(--e-global-color-text);
  background: #ffffff;
}

/* Focus state */
.starel-archive-sorting .woocommerce-ordering select.orderby:focus {
  border-color: var(--e-global-color-352f719);
  box-shadow: none;
  outline: none;
}

/* Archive Sorting Select Optical Alignment */
.starel-archive-sorting .woocommerce-ordering {
  margin: 0 !important;
  line-height: 0;
}

.starel-archive-sorting select.orderby {
  display: block;
  min-height: 38px;
  margin: 0 !important;
  padding: 11px 36px 9px 14px;
  line-height: 1;
}


/* ========================================
   3. Category Archive Subnav
   Plain text style
======================================== */

.starel-category-subnav {
  width: auto;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.starel-archive-toolbar > .starel-category-subnav {
  overflow: hidden;
}

.starel-category-subnav__list {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* Measuring class applied by JS so natural single-row width is calculated reliably. */
.starel-archive-toolbar.is-measuring-subnav .starel-category-subnav__list {
  flex-wrap: nowrap !important;
}

/* Long subnav becomes a second row and can wrap naturally. */
.starel-archive-toolbar.is-subnav-overflowing .starel-category-subnav__list {
  flex-wrap: wrap;
  gap: 18px 34px;
  width: 100%;
  max-width: 100%;
}

.starel-category-subnav__item {
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.starel-category-subnav__link {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--e-global-color-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s ease;
}

.starel-category-subnav__link:hover {
  color: var(--e-global-color-352f719);
}

.starel-category-subnav__name {
  color: inherit;
}

.starel-category-subnav__count {
  color: inherit;
  opacity: .55;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}

.starel-category-subnav__link:hover .starel-category-subnav__count {
  opacity: 1;
}

/* ========================================
   4. Archive Result Count
======================================== */

.starel-result-count {
  margin: 0;
  color: var(--e-global-color-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: right;
}


/* ========================================
   5. Floating Archive Filter Button
   Shows after archive toolbar leaves view
   Hides before archive boundary ends
======================================== */

.starel-floating-filter {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: 28px;
  z-index: 999;
  transform: translateX(-50%) !important;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity .22s ease,
    visibility .22s ease;
}

/* Visible state controlled by JS */
body.starel-show-floating-filter .starel-floating-filter {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) !important;
}

/* Button styling */
.starel-floating-filter .elementor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 28px;
  border-radius: 8px;
  background: #000000;
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

/* Keep SVG icon white */
.starel-floating-filter .elementor-button svg,
.starel-floating-filter .elementor-button svg path {
  fill: currentColor;
}

/* Prevent Elementor sticky/motion remnants causing alignment jumps */
.starel-floating-filter.elementor-sticky,
.starel-floating-filter.elementor-sticky--active {
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
}


/* ========================================
   6. Responsive Archive Toolbar
======================================== */

@media (max-width: 1024px) {
  .starel-archive-toolbar {
    gap: 16px 20px;
  }

  .starel-archive-toolbar.is-subnav-overflowing .starel-category-subnav__list {
    gap: 16px 24px;
  }
}

@media (max-width: 767px) {
  .starel-archive-toolbar,
  .starel-archive-toolbar.is-subnav-overflowing {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "filter sorting"
      "subnav subnav"
      "count count";
    gap: 16px;
  }

  .starel-archive-toolbar > .elementor-element:first-child {
    justify-self: start;
  }

  .starel-archive-toolbar > .starel-archive-sorting {
    justify-self: start;
  }

  .starel-archive-toolbar > .starel-category-subnav {
    width: 100%;
    overflow: hidden;
  }

  .starel-archive-toolbar > .starel-archive-count {
    justify-self: start;
    margin-left: 0 !important;
  }

  .starel-archive-count .elementor-widget-container {
    justify-content: flex-start;
  }

  .starel-result-count {
    text-align: left;
  }

  .starel-category-subnav__list,
  .starel-archive-toolbar.is-subnav-overflowing .starel-category-subnav__list {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 20px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .starel-category-subnav__link {
    white-space: nowrap;
  }

  .starel-floating-filter {
    bottom: 16px;
  }

  .starel-floating-filter .elementor-button {
    padding: 14px 28px;
  }
}

/* ========================================
   7. Archive Toolbar V3
   Three-control toolbar support for attribute archives
======================================== */

/* Attribute/product taxonomy archives do not always use the category subnav.
   Keep Filter + Sorting on the left and Product Count on the right. */
.starel-archive-toolbar.has-no-subnav {
  grid-template-columns: auto auto minmax(0, 1fr) auto !important;
  grid-template-areas: "filter sorting . count" !important;
}

@supports selector(:has(*)) {
  .starel-archive-toolbar:not(:has(> .starel-category-subnav)) {
    grid-template-columns: auto auto minmax(0, 1fr) auto !important;
    grid-template-areas: "filter sorting . count" !important;
  }
}

@media (max-width: 767px) {
  /* Mobile toolbar V4: group Filter + Sorting left with no reserved
     grid-switcher space. Product count stays below. */
  .starel-archive-toolbar,
  .starel-archive-toolbar.has-no-subnav,
  .starel-archive-toolbar.has-subnav,
  .starel-archive-toolbar.is-subnav-overflowing {
    grid-template-columns: auto auto !important;
    grid-template-areas:
      "filter sorting"
      "count count" !important;
    column-gap: 10px !important;
    row-gap: 16px !important;
    justify-content: start !important;
    justify-items: start !important;
    align-items: center !important;
    width: 100% !important;
  }

  .starel-archive-toolbar.has-subnav,
  .starel-archive-toolbar.is-subnav-overflowing.has-subnav {
    grid-template-areas:
      "filter sorting"
      "subnav subnav"
      "count count" !important;
  }

  @supports selector(:has(*)) {
    .starel-archive-toolbar:has(> .starel-category-subnav) {
      grid-template-areas:
        "filter sorting"
        "subnav subnav"
        "count count" !important;
    }

    .starel-archive-toolbar:not(:has(> .starel-category-subnav)) {
      grid-template-areas:
        "filter sorting"
        "count count" !important;
    }
  }

  .starel-archive-toolbar > .elementor-element:first-child,
  .starel-archive-toolbar > .starel-archive-sorting {
    justify-self: start !important;
    align-self: center !important;
  }

  .starel-archive-toolbar > .starel-archive-sorting {
    margin-left: 0 !important;
  }

  .starel-archive-toolbar > .starel-archive-count {
    justify-self: start !important;
    align-self: center !important;
    margin-left: 0 !important;
  }

  .starel-archive-count .elementor-widget-container {
    justify-content: flex-start !important;
  }

  .starel-result-count {
    text-align: left !important;
  }
}
