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

$params: (
   "gap": 10px,
   "margin": 39px 0 15px 0,
   "align-items": center,

   "title-color": global.$text-muted,
   "title-font-size": global.$font-size-base,
   "custom-control-font-weight": unset,

   "custom-control-padding": 12px 16px,
   "custom-control-border": 1px solid global.$border-color,
   "custom-control-border-bottom": unset,
   "custom-control-border-radius": global.$border-radius-base,
   "custom-control-checked-color": global.$text-dark,
   "custom-control-checked-border-bottom": 1px solid,

   "tooltip-icon-margin-left": 5px,
   "tooltip-icon-size": global.$font-size-base,
   "tooltip-icon-color": global.$text-dark,

   "tooltip-bottom": 100%,
   "tooltip-left": -10px,
   "tooltip-width": 250px,
   "tooltip-padding": 5px,
   "tooltip-color": global.$body-color,
   "tooltip-background": global.$body-bg,
   "tooltip-border": 1px solid global.$border-color,
   "tooltip-box-shadow": global.$box-shadow,
   "tooltip-font-size": global.$font-size-base,
   "tooltip-text-align": center,
);

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

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

.#{component("Section:Filter:Sorting:Row", "class")} {
   margin: map.get($params, "margin");
   display: flex;
   align-items: map.get($params, "align-items");
   gap: map.get($params, "gap");

   .title {
      margin-bottom: 0;
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
   }

   .custom-control {
      padding: map.get($params, "custom-control-padding");
      border: map.get($params, "custom-control-border");
      border-radius: map.get($params, "custom-control-border-radius");
      font-weight: map.get($params, "custom-control-font-weight");
      
      @if not (map.get($params, "custom-control-border-bottom") == unset) {
         border-bottom: map.get($params, "custom-control-border-bottom");
      }

      &:has(.custom-control-input:checked) {
         border-color: map.get($params, "custom-control-checked-color");
         border-bottom: map.get($params, "custom-control-checked-border-bottom");;
      }

      &:hover {
         border-color: map.get($params, "custom-control-checked-color");
      }
   }

   .tooltip {
      position: relative;
      cursor: help;
      margin-left: map.get($params, "tooltip-icon-margin-left");
      vertical-align: middle;

      .c-icon {
         color: map.get($params, "tooltip-icon-color");
         font-size: map.get($params, "tooltip-icon-size");
      }

      span {
         position: absolute;
         bottom: map.get($params, "tooltip-bottom");
         left: map.get($params, "tooltip-left");
         z-index: 1000;
         display: none;
         width: map.get($params, "tooltip-width");
         padding: map.get($params, "tooltip-padding");
         color: map.get($params, "tooltip-color");
         background: map.get($params, "tooltip-background");
         box-shadow: map.get($params, "tooltip-box-shadow");
         border: map.get($params, "tooltip-border");
         font-size: map.get($params, "tooltip-font-size");
         text-align: map.get($params, "tooltip-text-align");
         white-space: normal;
      }

      @include global.haf {
         span {
            display: block;
         }
      }
   }
}
