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

$params: (
   "gap": global.$gap-width,
   "margin": 0 0 global.$spacer 0,

   "reset-all-color": global.$state-error,
   "reset-all-font-size": global.$font-size-base,
   "reset-all-font-weight": global.$font-weight-base,

   "reset-item-background": global.$body-bg-alt,
   "reset-item-color": global.$text-dark,
   "reset-item-font-size": global.$font-size-base,
   "reset-item-font-weight": global.$font-weight-base,
   "reset-item-padding": 6px 9px,
   "reset-item-border": 0,
   "reset-item-border-radius": global.$border-radius-base,
   "reset-item-hide-name": "true",

   "reset-item-background-hover": darken(global.$body-bg-alt, 5%),
   "reset-item-border-color-hover": darken(global.$border-color, 5%),

   "reset-item-close-color": global.$state-error,
   "reset-item-close-font-size": global.$font-size-smaller,
   //"reset-item-close-color": global.$state-error,
);

@if global-variable-exists(c-section-filter-reset, components) {
   $keys: map.keys(components.$c-section-filter-reset);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Section:Filter:Reset", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-section-filter-reset);
}

.#{component("Section:Filter:Reset", "class")} {
   display: flex;
   flex-wrap: wrap;
   gap: map.get($params, "gap");
   margin: map.get($params, "margin");

   .reset-all {
      @include global.btn-reset;
      @include global.underline-default;

      cursor: pointer;
      color: map.get($params, "reset-all-color");
      font-size: map.get($params, "reset-all-font-size");
      font-weight: map.get($params, "reset-all-font-weight");
   }

   .reset-item {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: map.get($params, "reset-item-padding");
      background: map.get($params, "reset-item-background");
      color: map.get($params, "reset-item-color");
      font-size: map.get($params, "reset-item-font-size");
      font-weight: map.get($params, "reset-item-font-weight");
      border: map.get($params, "reset-item-border");
      border-radius: map.get($params, "reset-item-border-radius");
      cursor: pointer;
      transition: background-color global.$transition-speed, border-color global.$transition-speed;

      @include global.haf {
         background: map.get($params, "reset-item-background-hover");
         border-color: map.get($params, "reset-item-border-color-hover");
      }

      .name {
         margin-right: 2px;

         @if (map.get($params, "reset-item-hide-name") == "true") {
            display: none;
         }
      }

      .c-icon {
         color: map.get($params, "reset-item-close-color");
         font-size: map.get($params, "reset-item-close-font-size");
         line-height: 1;
         margin-left: 10px;

         // todo remove
         svg {
            width: 1em;
            height: 1em;
         }
      }
   }
}
