<div
  {{ block.shopify_attributes }}
  style="--margin-top: {{ block.settings.margin_top | divided_by: 10.0 }}rem;--margin-bottom: {{ block.settings.margin_bottom | divided_by: 10.0 }}rem;"
>
  <div class="custom-product-card {{ block.settings.visibility }}">
    <!-- Title and Stock Indicator (on same line) -->
    <div class="custom-title-stock-wrap">
      <h1 class="custom-product-title">{{ product.title }}</h1>

      {% if block.settings.enable_lowstock2 %}
        <!-- Show stock indicator -->
        <div
          class="custom-stock-indicator"
          style="
            color: {{ block.settings.stock_text_color }};
            background-color: {{ block.settings.stock_bg_color }};
            font-size: {{ block.settings.stock_font_size }}px;
            border-radius: {{ block.settings.stock_border_radius }}px;
          "
        >
          <span
            class="stock-dot"
            style="background-color: {{ block.settings.stock_dot_color }};"
          ></span>
          <span class="stock-text">{{ block.settings.stock_text }}</span>
        </div>
      {% endif %}
    </div>

    <!-- Price and Rating Row -->
    <div class="custom-price-rating-wrap">
      {% if block.settings.price_rating_layout == 'price_first' %}
        <!-- Price First -->
        <div class="custom-price">
          {%- render 'ascendify-price',
            product: product,
            block: block,
            use_variant: true,
            show_badges: true,
            hide_sale_badge: block.settings.hide_sale_badge,
            price_class: 'price--large',
            price_second: price_second,
            main_price: true
          -%}
        </div>

        <!-- Rating Stars -->
        {% if block.settings.enable_ratingstars %}
          <div class="custom-rating-wrap">
            {% render 'rating-stars-block', block: block %}
          </div>
        {% endif %}
      {% else %}
        <!-- Rating First -->
        {% if block.settings.enable_ratingstars %}
          <div class="custom-rating-wrap">
            {% render 'rating-stars-block', block: block %}
          </div>
        {% endif %}

        <!-- Price Second -->
        <div class="custom-price">
          {%- render 'ascendify-price',
            product: product,
            block: block,
            use_variant: true,
            show_badges: true,
            hide_sale_badge: block.settings.hide_sale_badge,
            price_class: 'price--large',
            price_second: price_second,
            main_price: true
          -%}
        </div>
      {% endif %}
    </div>
  </div>
</div>

<style>
  .custom-title-stock-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
  }

  .custom-product-title {
    font-size: {{ block.settings.customproducttitlesize }}rem;
    font-weight: bold;
    margin: 0;
    flex: 1 1 auto;
  }

  .custom-stock-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    white-space: nowrap;
  }

  .stock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
  }

  .custom-price-rating-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .custom-rating-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
  }

  .custom-price {
    font-size: 1.25rem;
    font-weight: bold;
  }

  /* Price order control */
  .price__sale--price-second {
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    align-items: center;
  }

  .price__sale--price-second .price__compare-price {
    order: -1;
  }

  .price__regular {
    display: none;
  }

  .price--on-sale .price__regular {
    display: none;
  }

  .price--on-sale .price__sale {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  /* Responsive adjustments */
  @media (max-width: 768px) {
    .custom-title-stock-wrap,
    .custom-price-rating-wrap {
      gap: 8px;
    }
  }
</style>

{% if block.settings.custompricecolors %}
  <style>
    .price .main-price {
      color: {{ block.settings.main-pricecolor }};
    }
    .price .main-comapre-price {
      color: {{ block.settings.maincomapre-pricecolor }};
    }
  </style>
{% endif %}