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

$params: (
   "max-width": unset,
   "form-max-width": 850px,
   "box-shadow": unset,
   "show-form-labels": "true",
   "background": transparent,
   "border-radius": 0,
   "padding": 0 0 30px 0,
   "margin": 0,
   "flex-wrap": wrap,
   "align-items": center,
   "justify-content": flex-start,

   "form-wrapper-flex": 1,

   "form-gap": global.$gap-width,

   "input-background-color": global.$input-bg,
   "input-border-color": global.$input-border-color,

   "title-width": 100%,
   "title-font-size": global.$font-size-h3,
   "title-margin-resp": 0 0 global.$spacer 0,
   "title-margin": 0 40px 0 0,
   "title-max-width": unset,

   "link-pass-bottom": 15px,
   "link-pass-right": 15px,

   "submit-btn-style": "btn-primary",
   "submit-btn-height": global.$input-height,
   "submit-btn-max-width": 200px,

   "resp-breakpoint-form": 650px,
   "resp-breakpoint-with-title": 900px,
);

@if global-variable-exists(c-userlogininline-form, components) {
   $keys: map.keys(components.$c-userlogininline-form);
   @each $name in $keys {
      @if not map.get($params, $name) {
         @warn "Neexistující proměnná '#{$name}' v komponentě '$#{component("UserLoginInline:Form", "class")}'.";
      }
   }

   $params: map.merge($params, components.$c-userlogininline-form);
}

.#{component("UserLoginInline:Form", "class")} {
   container-type: inline-size;
   display: flex;
   flex-wrap: map.get($params, "flex-wrap");
   align-items: map.get($params, "align-items");
   justify-content: map.get($params, "justify-content");
   padding: map.get($params, "padding");
   margin: map.get($params, "margin");
   width: 100%;
   background: map.get($params, "background");
   border-radius: map.get($params, "border-radius");
   max-width: map.get($params, "max-width");
   box-shadow: map.get($params, "box-shadow");

   .form-wrapper {
      flex: map.get($params, "form-wrapper-flex");
   }

   .title {
      font-size: map.get($params, "title-font-size");
      margin: map.get($params, "title-margin-resp");
      width: map.get($params, "title-width");
   }

   form {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      max-width: map.get($params, "form-max-width");
      gap: map.get($params, "form-gap");

      > div {
         width: 100%;
         margin-bottom: 0;
      }
   }

   .form-control {
      background-color: map.get($params, "input-background-color");
      border-color: map.get($params, "input-border-color");
   }

   .btn {
      @include global.set-btn-style(map.get($params, "submit-btn-style"));
      max-height: map.get($params, "submit-btn-height");
   }

   @if not map.get($params, "show-form-labels") {
      .form-group {
         label {
            display: none;
         }
      }
   }

   .link-pass {
      position: absolute;
      right: map.get($params, "link-pass-right");
      bottom: map.get($params, "link-pass-bottom");
   }

   @container (inline-size > #{map.get($params, "resp-breakpoint-form")}) {
      form {
         flex-wrap: nowrap;

         > div {
            flex: 1;
         }

         .btn {
            max-width: map.get($params, "submit-btn-max-width");
         }
      }
   }

   @container (inline-size > #{map.get($params, "resp-breakpoint-with-title")}) {
      .title {
         max-width: map.get($params, "title-max-width");
         margin: map.get($params, "title-margin");
      }
   }
}
