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

$params: (
   "wrapper-padding": 20px,
   "wrapper-border-radius": global.$border-radius-base,
   "wrapper-background-color": global.$body-bg-alt,
   "wrapper-gap": 5px,

   "heading-font-weight": global.$font-weight-bold,

   "item-gap": 20px,
   "item-padding": 0,
   "item-border-top": none,

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

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

@if global-variable-exists(c-account-orderdetail-discounts, components) {
   $keys: map.keys(components.$c-account-orderdetail-discounts);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Account:OrderDetail:Discounts", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-account-orderdetail-discounts);
}

.#{component("Account:OrderDetail:Discounts", "class")} {
   container-type: inline-size;

   .discounts-wrapper {
      padding: map.get($params, "wrapper-padding");
      border-radius: map.get($params, "wrapper-border-radius");
      background-color: map.get($params, "wrapper-background-color");
      display: grid;
      grid-template-columns: 1fr;
      gap: map.get($params, "wrapper-gap");
   }

   .heading {
      font-weight: map.get($params, "heading-font-weight");
      margin-bottom: 0;
   }

   .item {
      display: flex;
      align-items: center;
      gap: map.get($params, "item-gap");
      padding: map.get($params, "item-padding");
      border-top: map.get($params, "item-border-top");
      line-height: global.$line-height-sm;
   }

   .title {
      flex: 1;
      color: map.get($params, "item-title-color");
      font-size: map.get($params, "item-title-font-size");
      font-weight: map.get($params, "item-title-font-weight");
   }

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