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

$params: (
   "breakpoint": 290px,

   "form-flex": 1,
   "form-max-width": 480px,
   "form-margin": unset,
   "gap": 0,
   "form-border-bottom": unset,

   "input-height": 100%,
   "input-background": transparent,
   "input-color": global.$text-muted,
   "input-border": global.$border-width solid global.$border-color-dark,
   "input-border-radius": 50px 0 0 50px,
   "input-border-radius-resp": global.$border-radius-base,
   "input-font-size": 16px,

   "button-flex": 0 0 auto,
   "button-width": auto,
   "button-height": auto,
   "button-padding": global.$btn-padding-y global.$btn-padding-x,
   "button-background": global.$body-bg-dark,
   "button-color": global.$white,
   "button-border-color": global.$border-color-dark,
   "button-border-width": global.$border-width,
   "button-border-radius": 0 50px 50px 0,
   "button-border-radius-resp": global.$border-radius-base,
   "button-font-size": global.$font-size-base,
   "button-text-transform": none,
   "button-text": "true",
   "button-icon": "false",

   "policy-margin": global.$gap-width 0 0,
   "policy-font-size": global.$font-size-base,
);

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

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

.#{component("Footer:NewsletterSubscribe:Form", "class")} {
   container-type: inline-size;
   flex: map.get($params, "form-flex");
   max-width: map.get($params, "form-max-width");
   width: 100%;
   margin: map.get($params, "form-margin");
   border-bottom: map.get($params, "form-border-bottom");

   form {
      display: flex;
      flex-direction: column;
      gap: map.get($params, "gap");
      width: 100%;

      > div {
         flex: 1;
      }
   }

   .form-control {
      height: map.get($params, "input-height");
      background: map.get($params, "input-background");
      color: map.get($params, "input-color");
      border: map.get($params, "input-border");
      border-radius: map.get($params, "input-border-radius-resp");
      font-size: map.get($params, "input-font-size");

      @include global.placeholder {
         color: map.get($params, "input-color");
      }
   }

   .btn {
      @include global.button-variant(
            map.get($params, "button-color"),
            map.get($params, "button-background"),
            map.get($params, "button-border-color")
      );

      flex: map.get($params, "button-flex");
      width: map.get($params, "button-width");
      height: map.get($params, "button-height");
      padding: map.get($params, "button-padding");
      border-radius: map.get($params, "button-border-radius-resp");
      border-width: map.get($params, "button-border-width");
      font-size: map.get($params, "button-font-size");
      text-transform: map.get($params, "button-text-transform");

      @if not (map.get($params, "button-text") == "true") {
         .text {
            display: none;
         }
      }

      @if not (map.get($params, "button-icon") == "true") {
         .c-icon {
            display: none;
         }
      }
   }

   .policy {
      p {
         margin: map.get($params, "policy-margin");
         font-size: map.get($params, "policy-font-size");
      }
   }

   @container (inline-size > #{map.get($params, "breakpoint")}) {
      @include global.container-query-selector("form") {
         flex-direction: row;

         > div {
            margin-right: -1px;
         }

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

         .btn {
            border-radius: map.get($params, "button-border-radius");
         }
      }
   }
}
