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

$params: (
   "margin-bottom": global.$spacer,

   "price-color": global.$text-dark,
   "price-color-discounted": global.$discount-color,
   "price-font-size": 34px,
   "price-font-family": global.$font-family-base,
   "price-font-weight": global.$font-weight-bold,
   "price-line-height": 1.1,

   "price-novat-font-size": global.$font-size-h3,

   "price-novat-text-color": global.$text-muted,
   "price-novat-text-font-size": global.$font-size-smaller,

   "discountlabel-margin": 0 12px 0 0,

   "other-prices-color": global.$text-muted,
   "other-prices-font-size": global.$font-size-smaller,
   "other-prices-price-color": global.$text-dark,
   "other-prices-price-decoration": line-through,

   "other-prices-discount-color": global.$discount-color,

   "unit-price-color": global.$text-muted,
   "unit-price-font-size": global.$font-size-base,
);

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

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

.#{component("Product:Price", "class")} {
   margin-bottom: map.get($params, "margin-bottom");

   > div {
      display: flex;
      align-items: center;
      margin-bottom: 5px;

      &.has-discount {
         strong {
            color: map.get($params, "price-color-discounted");
         }
      }

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

      .#{component("Product:DiscountLabel", "class")}  {
         margin: map.get($params, "discountlabel-margin");
      }

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

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

   p {
      color: map.get($params, "other-prices-color");
      font-size: map.get($params, "other-prices-font-size");
      margin: 0;

      strong {
         color: map.get($params, "other-prices-price-color");
         text-decoration: map.get($params, "other-prices-price-decoration");
      }

      .discount {
         color: map.get($params, "other-prices-discount-color");
      }
   }

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