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

$params: (
   "trigger-size": 30px,
   "trigger-border-radius": global.$border-radius-base,
   "trigger-font-size": 16px,
   "trigger-color": global.$text-dark,
   "trigger-background": global.$body-bg-alt,
   "trigger-background-hover": darken(global.$body-bg-alt, 5%),
   "trigger-border": unset,
   "trigger-border-color-hover": unset,

   "menu-width": 220px,
   "menu-offset-top": 7px,
   "menu-offset-right": -10px,
   "menu-background": global.$body-bg,
   "menu-border": global.$border-width solid global.$border-color,
   "menu-border-radius": global.$border-radius-lg,
   "menu-padding": 0 20px,

   "menu-item-padding": 10px 0,
   "menu-item-border-bottom": global.$border-width solid global.$border-color,
   "menu-item-color": global.$text-dark,
   "menu-item-font-size": global.$font-size-base,
   "menu-item-weight-size": global.$font-weight-base,
);

@if global-variable-exists(c-preorders-userpreorderstable-preorder-moreactions, components) {
   $keys: map.keys(components.$c-preorders-userpreorderstable-preorder-moreactions);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("Preorders:UserPreordersTable:Preorder:MoreActions", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-preorders-userpreorderstable-preorder-moreactions);
}

.#{component("Preorders:UserPreordersTable:Preorder:MoreActions", "class")} {
   position: relative;

   .trigger {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: map.get($params, "trigger-size");
      height: map.get($params, "trigger-size");
      background-color: map.get($params, "trigger-background");
      border: map.get($params, "trigger-border");
      border-radius: map.get($params, "trigger-border-radius");
      font-size: map.get($params, "trigger-font-size");
      color: map.get($params, "trigger-color");
      transition: background-color global.$transition-speed, border-color global.$transition-speed;

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

   .menu {
      @include global.list-unstyled;

      display: none;
      position: absolute;
      top: calc(100% + #{map.get($params, "menu-offset-top")});
      right: map.get($params, "menu-offset-right");
      z-index: 1;
      width: map.get($params, "menu-width");
      background: map.get($params, "menu-background");
      border: map.get($params, "menu-border");
      border-radius: map.get($params, "menu-border-radius");
      padding: map.get($params, "menu-padding");

      li {
         text-align: left;
         padding: map.get($params, "menu-item-padding");
         border-bottom: map.get($params, "menu-item-border-bottom");

         &:last-child {
            border-bottom: 0;
         }
      }

      a {
         @include global.underline-hover;

         display: block;
         color: map.get($params, "menu-item-color");
         font-size: map.get($params, "menu-item-font-size");
         font-weight: map.get($params, "menu-item-font-weight");
      }

      &.is-open {
         display: block;
      }
   }
}
