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

$params: (
   "gap": 10px,
   "margin": 0 0 global.$spacer 0,
   "line-height": global.$line-height-sm,
   "flex-wrap": wrap,

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

   "tooltip-icon-size": global.$font-size-smaller,
   "tooltip-icon-color": global.$text-muted,

   "select-color": global.$text-dark,
   "select-font-weight": global.$font-weight-base,
   "select-border": global.$border-width solid global.$border-color,
   "select-text-decoration": unset,
   "select-min-width": 170px,
);

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

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

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

   .title {
      display: flex;
      align-items: center;
      color: map.get($params, "title-color");
      font-size: map.get($params, "title-font-size");
      font-weight: map.get($params, "title-font-weight");
   }

   p {
      margin: 0;
   }

   .tooltip {
      position: relative;
      cursor: help;
      margin-left: 5px;

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

      span {
         display: none;
         background: global.$body-bg;
         border: 1px solid  global.$border-color;
         color: global.$body-color;
         padding: 5px;
         font-size: global.$font-size-base;
         box-shadow: global.$box-shadow;
         position: absolute;
         text-align: center;
         z-index: 1000;
         white-space: normal;
         bottom: 100%;
         left: -10px;
         width: 250px;
      }

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

   .form-control {
      border: map.get($params, "select-border");
      text-decoration: map.get($params, "select-text-decoration");
      color: map.get($params, "select-color");
      font-weight: map.get($params, "select-font-weight");
      min-width: map.get($params, "select-min-width");
   }

   @media screen and (max-width: global.$sm - 1) {
      flex-wrap: wrap;
      justify-content: center;
   }
}
