@use "sass:map";
@use "@twig/scss/_global" as global;
@use "@twig/scss/variables/_variables-components" as components;

$params: (
   "border": global.$border-width solid global.$border-color,
   "border-radius": global.$border-radius-base,
   "margin-bottom": global.$gap-width,
   "padding": 20px 20px,
   "gap": global.$gap-width,
   "img-size": 50px,

   "title-color": global.$text-dark,
   "title-font-size": global.$font-size-base,
   "title-font-weight": global.$font-weight-bold,

   "product-name-color": global.$text-dark,
   "product-name-font-size": global.$font-size-base,
   "product-name-font-weight": global.$font-weight-base,
   "product-name-line-height": global.$line-height-sm,

   "price-color": global.$text-dark,
   "price-font-size": global.$font-size-base,
   "price-font-weight": global.$font-weight-bold,

   "select-font-size": 14px,
);

@if global-variable-exists(c-product-sets-product, components) {
   $keys: map.keys(components.$c-product-sets-product);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Product:Sets:Product", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-product-sets-product);
}

.#{component("Product:Sets:Product", "class")} {
   container-type: inline-size;
   width: 100%;
   border: map.get($params, "border");
   border-radius: map.get($params, "border-radius");
   margin-bottom: map.get($params, "margin-bottom");
   padding: map.get($params, "padding");

   .inner-content {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: map.get($params, "gap");
   }

   .title {
      flex: 100%;
      white-space: nowrap;
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
   }

   .product {
      flex: 1;
      display: flex;
      align-items: center;
      gap: map.get($params, "gap");

      picture {
         max-width: map.get($params, "img-size");
      }
   }

   .product-name {
      white-space: normal;
      color: map.get($params, "product-name-color");
      font-size: map.get($params, "product-name-font-size");
      font-weight: map.get($params, "product-name-font-weight");
      line-height: map.get($params, "product-name-line-height");
   }

   .price {
      color: map.get($params, "price-color");
      font-size: map.get($params, "price-font-size");
      font-weight: map.get($params, "price-font-weight");
   }

   select {
      font-size: map.get($params, "select-font-size");
   }

   @container (inline-size > 360px) {
      @include global.container-query-selector(".inner-content") {
         flex-wrap: nowrap;
      }

      @include global.container-query-selector(".title") {
         flex: unset;
      }
   }

      @container (inline-size > 300px) {
         @include global.container-query-selector("select") {
            min-width: 40%;
            width: auto;
         }
   }
}
