@import '../../mixins.scss';

[data-payment-page-component="form"] {
  --payment-page-text-title-color : #000000;

  padding-top: 6px;

  [data-payment-page-component-form-section="repeater_form_item"] {
    &[data-payment-page-interaction-state="none"] {
      > [data-payment-page-component-form-section="repeater_form_item_content"] {
        display: none;
      }
    }
  }

  tr[data-payment-page-component-form-section="repeater_form_item"] {
    input,
    select {
      width : 100%;
      min-width : auto;
      max-width : 100%;
    }
  }

  [data-payment-page-component-form-section="header"] {
    padding : var( --payment-page-spacing-sm ) 0;

    > h3 {
      font-family : var( --payment-page-font-family );
      font-size: 16px;
      line-height: 1.5em;
      font-style  : var( --payment-page-text-title-font-style );
      font-weight : var( --payment-page-text-title-font-weight );
      color       : var( --payment-page-text-title-color );

      text-transform  : none;
      text-decoration : none;

      padding : 0;
      margin  : 0;
    }

    &[data-payment-page-separator="before"] {
      margin : var( --payment-page-spacing-sm ) 0 0 0;
      border-top: 1px solid var(--payment-page-layout-primary-border-color);
    }

    &[data-payment-page-separator="after"] {
      margin : 0 0 var( --payment-page-spacing-sm ) 0;
      border-bottom: 1px solid var(--payment-page-layout-primary-border-color);
    }
  }

  [data-payment-page-component-form-section="fields_map_form_wrapper"] {
    display : flex;
    flex-direction : column;

    > [data-payment-page-component-form-section="fields_map_form_container"] {


      > [data-payment-page-component-form-section="field_container"] {
        display: flex;
        flex-direction : row;
        margin-bottom: 1em;

        > [data-payment-page-component-form-section="field_container_draggable_container"] {
          width : 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          padding: 0 10px 0 0;

          [data-payment-page-component-form-trigger="fields_map_form_item_order"] {
            cursor : pointer;

            > svg {
              width : 24px;
              height : 24px;
              cursor : pointer;
            }
          }
        }

        > [data-payment-page-component-form-section="field_container_information_container"] {
          display: grid;
          gap: 10px 10px;
          grid-template-columns: repeat(2,1fr);
          grid-auto-flow : row;

          width: calc( 100% - 50px );
          padding: 1em;
          border: 1px solid #64666a;

          > [data-setting-container] {
            display : block;
            width   : 100%;
            grid-column: span 2;

            select, input[type="text"] {
              width : 100%;
            }

            label {
              > span {
                display : block;
                margin  : 0 0 5px 0;
              }
            }
          }

          > [data-setting-container="size"],
          > [data-setting-container="size_mobile"] {
            grid-column: span 1;
          }
        }
      }
    }
  }

  [data-payment-page-component-form-section^="field_wrapper_"] {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var( --payment-page-spacing-sm );

    &:not(:last-child) {
      margin: 0 0 var( --payment-page-spacing-sm );
    }
    > label {
      width: 100%;
      max-width: 150px;
      font-size : 15px;
      line-height : 1.5em;
    }
    > [data-payment-page-component-form-section^="field_container_"] {
      &[data-payment-page-has-label="1"] {
        width: calc(100% - 162px);
      }

      &[data-payment-page-has-label="0"] {
        width: 100%;
      }

      input[type="color"], input[type="date"], input[type="datetime-local"], input[type="datetime"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="tel"],
      input[type="text"], input[type="time"], input[type="url"], input[type="week"], select, textarea {
        border: 1px solid var( --payment-page-layout-secondary-border-color );
      }

      > input, > textarea {
        width: 65%;
      }
      > textarea {
        min-height: 100px !important;
        max-height: 400px !important;
      }
      > select {
        width: 100%;
      }
      > .select2-container {
        width: 100% !important;
      }
    }

    [data-payment-page-component-form-section="field_container_color"],
    [data-payment-page-component-form-section="field_container_css_style_border_color"],
    [data-payment-page-component-form-section="field_container_css_style_background_color"] {
      display: flex;
      align-items: center;
      align-content: center;
      border: 1px solid var( --payment-page-layout-secondary-border-color );

      &[data-payment-page-has-label="1"] {
        width: calc(100% - 166px);
      }

      > input {
        border : none !important;
      }
    }

    [data-payment-page-component-form-section="field_container_css_style_unit"] {
      display: flex;
      flex-direction: row;
      max-width : 150px;

      > select {
        width: 60px;
      }
    }

    [data-payment-page-component-form-section="field_container_css_style_unit_dimensions"] {
      display : flex;
      flex-direction : row;

      > ul {
        display : flex;
        flex-direction : row;
        margin : 0;
        padding : 0;
        gap : var( --payment-page-spacing-xs );

        > li {
          display : flex;
          flex-direction : column;
          gap : var( --payment-page-spacing-xs );
          margin : 0;
          padding : 0;
          text-align : center;

          > input[type="number"] {
            width : 60px;
            min-width : 40px;
          }
        }
      }

      > select {
        width : 60px;
        margin : 0 0 auto 0;
      }
    }

    [data-payment-page-component-form-section="field_container_true_false"],
    [data-payment-page-component-form-section="field_container_toggle"] {
      > label {
        position:relative;
        display:inline-block;
        vertical-align:top;
        height:20px;
        background:#4c4f56;
        border-radius:18px;
        cursor:pointer;

        > input[type="checkbox"] {
          display:none
        }

        > [data-payment-page-scope="label"] {
          position:relative;
          display:block;
          height:inherit;
          font-size:10px;
          width : 54px;
          background:#4c4f56;
          border-radius:inherit;
          transition:.15s ease-out;
          transition-property:opacity,background;

          &:after,
          &:before {
            position:absolute;
            top:0;
            width:50%;
            text-align:center;
            line-height:20px;
            transition:inherit;
          }

          &:before {
            content:attr(data-off);
            right:5px;
            color:#ffffff;
          }

          &:after {
            content:attr(data-on);
            left:5px;
            color:#ffffff;
            opacity:0;
          }
        }

        > [data-payment-page-scope="handle"] {
          position:absolute;
          top:1px;
          left:1px;
          width:18px;
          height:18px;
          background:#ffffff;
          border-radius:10px;
          transition:left .15s ease-out;
        }

        > input[type="checkbox"]:checked~[data-payment-page-scope="label"] {
          background:var( --payment-page-primary-color );

          &:before {
            opacity:0;
          }

          &:after {
            opacity:1;
          }
        }

        > input[type="checkbox"]:checked~[data-payment-page-scope="handle"] {
          left:auto;
          right:1px;
        }

        > input[type="checkbox"][disabled="disabled"]~[data-payment-page-scope="label"],
        > input[type="checkbox"][disabled="disabled"]~[data-payment-page-scope="handle"] {
          opacity : 0.6;
          cursor : not-allowed;
        }
      }
    }

    [data-payment-page-component-form-section="field_container_message_builder"] {
      > [data-payment-page-scope="field_list"] {
        margin : 0;
        padding : 0;
        gap : var( --payment-page-spacing-xs );
        display : flex;
        flex-direction: column;

        > li {
          display: flex;
          flex-direction: column;
          margin : 0;
          padding : 0;
          gap: var( --payment-page-spacing-xs );

          &[data-payment-page-scope="field_true_false"] {
            flex-direction: row;
            gap: var( --payment-page-spacing-sm );

            align-items: center;
            align-content: center;

            > label {
              width : 160px;
            }
          }

          > label {
            font-size : 15px;
            line-height : 1.5em;
          }
        }
      }

      > textarea {
        display : none !important;
      }

      > [data-payment-page-scope="field_order"] {
        border: 1px solid #7d7e82;
        outline: 0;
        margin: 0;
        position: relative;
        vertical-align: middle;
        background-color: #34383c;
        border-radius: 3px;
        box-sizing: border-box;
        cursor: pointer;
        min-height: 32px;
        width: 90.6%;
        display: inline-block;
        padding-bottom: 0.5em;

        > li {
          float: left;
          margin-left: 5px;
          margin-top: 5px;
          padding: 0 5px;
          background-color: #4c4f56;
          line-height: 1.5;
          font-size: 0.9em;
          border: none;
          color: #e0e1e3;
        }
      }
    }

    > [data-payment-page-component-form-section="description"] {
      width: 100%;
      margin: 0 0 0 162px;

      @include payment-page-font-medium();
    }

    &[data-payment-page-component-form-section="field_wrapper_toggle"] {
      flex-direction: row !important;
      flex-wrap: nowrap !important;
    }

    &[data-payment-page-component-form-section="field_wrapper_repeater"] {
      > label {
        margin-bottom: auto;
        margin-top: var( --payment-page-spacing-sm );
      }
      > [data-payment-page-component-form-section^="field_container_"] {
        > [data-payment-page-component-form-section="repeater_form_wrapper"] {
          > [data-payment-page-component-form-section="repeater_form_item_container"] {
            > [data-payment-page-component-form-section="repeater_form_item"] {
              border: 1px solid var( --payment-page-layout-primary-border-color );
              @include border-radius( var( --payment-page-general-border-radius ) );
              padding: var( --payment-page-spacing-sm );
              margin-bottom: var( --payment-page-spacing-sm );
              background-color: rgba( var( --payment-page-layout-primary-border-color-rgb ), 0.4 );

              > [data-payment-page-component-form-section="repeater_form_item_header"] {
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: var( --payment-page-spacing-sm );

                > h4 {
                  cursor: pointer;
                  display: flex;
                  align-items: center;
                  gap: var( --payment-page-spacing-sm );
                  margin: 0;
                  width: 100%;

                  > [data-payment-page-component-form-trigger="order"] {
                    cursor: grab;

                    > svg {
                      @include payment-page-icon-primary();
                    }
                  }

                  > i {
                    display        : flex;
                    align-items    : center;
                    justify-content: center;
                    @include fix-size( 12px );
                    @include transition( 0.3s ease );
                  }
                }
              }
              > [data-payment-page-component-form-section="repeater_form_item_content"] {
                margin-top: var( --payment-page-spacing-sm );
              }
              > [data-payment-page-component-form-section="repeater_form_item_footer"] {
                margin-top: var( --payment-page-spacing-sm );

                > [data-payment-page-button] {
                  margin-left : auto;
                }
              }
              &[data-payment-page-interaction-state="none"] {
                > [data-payment-page-component-form-section="repeater_form_item_header"] {
                  > h4 {
                    > i {
                      transform: rotate( 180deg );
                    }
                  }
                }
              }
            }
          }

          > footer {
            display: flex;
            flex-direction: row;
            margin : var( --payment-page-spacing-block-element ) 0 0 0;
          }

          &[data-payment-page-layout="basic"] {
            > [data-payment-page-component-form-section="repeater_form_item_container"] {
              > [data-payment-page-component-form-section="repeater_form_item"] {
                > [data-payment-page-component-form-section="repeater_form_item_content"] {
                  margin-top: 0;

                  > [data-payment-page-component-form-section="field_wrapper_true_false"] {
                    flex-direction:row-reverse !important;
                    align-items: center !important;
                    align-content: center !important;

                    > label {
                      width : calc( 100% - var(--payment-page-spacing-sm) - var(--payment-page-spacing-sm) - 60px );
                      margin-right : auto;
                    }

                    > [data-payment-page-component-form-section="field_container_true_false"] {
                      width : 60px;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  &:not( [data-payment-page-media-query-breakpoints~="large"] ) {
    [data-payment-page-component-form-section^="field_wrapper_"] {
      > [data-payment-page-component-form-section^="field_container_"] {
        > input, > textarea {
          width: 100%;
        }
      }
    }
  }
  &:not( [data-payment-page-media-query-breakpoints~="med_small"] ) {
    [data-payment-page-component-form-section^="field_wrapper_"] {
      flex-direction: column;
      align-items: flex-start;

      > label {
        width : 100%;
        max-width : 100%;
      }

      > [data-payment-page-component-form-section^="field_container_"] {
        width: 100%;
      }
      > [data-payment-page-component-form-section="description"] {
        margin: 0;
      }
    }
  }
}