@use "sass:map";
@use "global/acms-common" as acms;
@use "global/common" as global;

/* ------------------------------
　　フォーム
------------------------------ */

/* ステップ
------------------------------ */
.form-step {
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0 0 1.5rem;

  /* カウンターの設定 */
  counter-reset: mailStep;
}

.form-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0 0.5rem;
  font-size: map.get(global.$font-scales, body-s);
  font-weight: bold;
  color: global.$color-text;
  list-style: none;

  &::before {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0 0 0.5rem;
    font-size: 1em;
    font-weight: normal;
    line-height: global.$line-height-lg;
    color: global.$color-text;
    content: counter(mailStep);

    /* カウンターの設定 */
    counter-increment: mailStep;
    background: global.$color-gray10;
    border-radius: 50%;
  }

  &.is-current {
    &::before {
      color: global.$color-text-inverse;
      background: global.$color-primary;
    }
  }

  &:not(:last-child) {
    margin: 0 1.25rem 0 0;
  }
}

@include acms.media-breakpoint-up(md) {
  .form-step-item {
    flex-direction: row;
    justify-content: center;
    padding: 1rem 0;
    font-size: map.get(global.$font-scales, body-m);

    &::before {
      width: 2.5rem;
      height: 2.5rem;
      margin: 0 0.5rem 0 0;
      font-size: map.get(global.$font-scales, heading-ss);
    }

    &:not(:last-child) {
      margin: 0 2rem 0 0;
    }
  }
}

@include acms.media-breakpoint-down(md) {
  .form-step {
    justify-content: center;
  }
}

/* フォームレイアウト
------------------------------ */
.form-group-list {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding: 0;
  margin: 0;
  list-style: none;

  &.is-narrow {
    max-width: 34rem;
    margin: 0 auto;
  }

  /* 確認画面 */
  &.is-confirm {
    padding: 0;
    border-bottom: 1px solid global.$color-gray40;

    .form-group {
      padding: 1rem;
      margin-bottom: 0;
      border-top: 1px solid global.$color-gray40;
    }
  }

  .form-group:last-child {
    margin-bottom: 0;
  }
}

.form-group-inner {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding: 0;
  margin: 0;
}

.form-group {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 2rem;
  border: 0;
}

.form-sub-group {
  & + & {
    margin-top: 1rem;
  }
}

.form-label {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 0 0.5rem;
  font-weight: bold;
  text-align: left;
}

.form-sub-label {
  margin-bottom: 0.5rem;
}

.form-control {
  box-sizing: border-box;
  display: block;
  width: 100%;
  line-height: global.$line-height-lg;
}

.form-button-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 2rem 0 0;

  .button {
    margin: 0;
  }
}

@include acms.media-breakpoint-up(md) {
  .form-label {
    vertical-align: top;
  }

  .form-button-group {
    flex-direction: row;
    margin: 2.5rem 0 0;
  }

  .form-button:not(:last-child) {
    margin: 0 1.25rem 0 0;
  }
}

@include acms.media-breakpoint-down(md) {
  .form-button {
    width: 100%;
    margin: 0 0 1rem;

    .button {
      width: 100%;
    }
  }

  .form-button-return {
    order: 1;
  }
}

/* ラベル
------------------------------ */
.label-required {
  padding: 0.25rem 0.5rem;
  margin: 0 0 0 0.25rem;
  font-size: map.get(global.$font-scales, body-s);
  vertical-align: middle;
  color: #fff;
  background: global.$color-error;
  border-radius: global.$border-radius-sm;

  &:first-child {
    margin: 0 0.25rem 0 0;
  }
}

@include acms.media-breakpoint-up(md) {
  .label-required {
    margin: 0 0 0 0.5rem;

    &:first-child {
      margin: 0 0.5rem 0 0;
    }
  }
}

.label-optional {
  padding: 0.25rem 0.5rem;
  margin: 0 0 0 0.25rem;
  font-size: map.get(global.$font-scales, body-s);
  vertical-align: middle;
  color: global.$color-text;
  background: global.$color-gray40;
  border-radius: global.$border-radius-sm;

  &:first-child {
    margin: 0 0.25rem 0 0;
  }
}

@include acms.media-breakpoint-up(md) {
  .label-optional {
    margin: 0 0 0 0.5rem;

    &:first-child {
      margin: 0 0.5rem 0 0;
    }
  }
}

/* フォーム要素
------------------------------ */
.form-group {
  select {
    &[required]:required {
      border: global.$border-width-sm solid global.$color-error;
    }

    &.focused:invalid {
      border: global.$border-width-sm solid global.$color-error;
    }

    &[required]:valid {
      border: global.$border-width-sm solid global.$color-gray40;
    }
  }

  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  textarea,
  select {
    color: global.$color-text;
    border: 1px solid rgb(0 0 0 / 20%);

    &[required]:required {
      background-color: global.$color-gray10;
    }

    &.focused:invalid,
    &.invalid {
      background-color: global.$color-gray10;
      border-color: global.$color-error;
      box-shadow: global.$box-shadow-error, acms.$acms-form-box-shadow;
    }

    &[required]:valid {
      background-color: global.$color-gray10;
    }

    &:focus {
      background-color: global.$color-gray10;
      border-color: global.$color-focus;
      box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
    }
  }

  // 入力欄をスマホのサイズのままにする
  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"] {
    box-sizing: border-box;
    padding: 0.75rem;
    font-size: map.get(global.$font-scales, body-m);
    line-height: global.$line-height-base;
    border: global.$border-width-sm solid rgb(0 0 0 / 20%);
    border-radius: global.$border-radius-sm;
  }

  textarea {
    box-sizing: border-box;
    padding: 0.75rem;
    font-size: map.get(global.$font-scales, body-m);
    border-radius: global.$border-radius-sm;
  }

  select {
    box-sizing: border-box;
    min-height: 3rem;
    padding: 0.75rem  3rem 0.75rem 1rem;
    font-size: map.get(global.$font-scales, body-m);
    line-height: global.$line-height-base;
    vertical-align: top;
    background-color: global.$color-gray10;
    border-radius: global.$border-radius-sm;
  }
}

@include acms.media-breakpoint-up(md) {
  .form-group {
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"] {
      padding: 0.75rem;
    }

    textarea {
      padding: 0.75rem;
    }
  }
}

.form-checkbox-only {
  display: block;
  padding: 0.75rem 1rem;
  margin: 0;
  line-height: 1.5;
  background: global.$color-gray20;
  border: global.$border-width-sm solid rgb(0 0 0 / 10%);
  border-radius: global.$border-radius-sm;

  &:hover {
    background: global.$color-gray30;
  }

  &:focus-within {
    background-color: global.$color-gray10;
    border-color: global.$color-focus;
    box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
  }
}

.form-checkbox-only-label {
  vertical-align: middle;

  a:link,
  a:hover,
  a:visited,
  a:active,
  a:focus {
    color: global.$color-link;
    text-decoration: none;
    border-bottom: 1px dashed;
  }
}

.form-input-password {
  border-radius: 3px;

  input[type="text"],
  input[type="password"] {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
  }

  &.invalid {
    border-color: global.$color-error;
    box-shadow: 0 0 0 4px rgb(201 45 45 / 40%), inset 2px 2px 1px rgb(0 0 0 / 10%);

    input[type="text"],
    input[type="password"] {
      border-color: global.$color-error;
    }
  }
}

.form-toggle-password {
  padding: 0;
  margin-left: auto;
  text-decoration: underline;
  appearance: none;
  background: none;
  border: none;

  &:hover {
    text-decoration: none;
  }
}

/* 検索フォーム
------------------------------ */
.form-search {
  .form-search-action {
    display: flex;
    width: 100%;

    .button {
      margin-left: -1px;
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }
  }

  input.form-search-input {
    box-sizing: border-box;
    flex: 1 1 auto;
    height: 3rem;
    padding: 0.5rem;
    font-size: map.get(global.$font-scales, body-m);
    appearance: none;
    background: global.$color-gray10;
    border: global.$border-width-sm solid global.$color-gray40;
    border-radius: global.$border-radius-md;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    transition: background-color 0.25s ease;

    &:hover {
      background: global.$color-white;
      border-color: global.$color-gray50;
    }

    &:focus {
      outline: none;
      background: global.$color-white;
      border-color: acms.$acms-form-focus-border-color;
      box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
    }
  }

  .form-search-side-button {
    display: flex;
    white-space: nowrap;
  }

  .form-search-button {
    padding: 0.75rem 1rem;
  }

  @include acms.media-breakpoint-up(md) {
    input.form-search-input {
      height: 4rem;
      padding: 1rem 1.25rem;
      font-size: map.get(global.$font-scales, heading-ss);
    }

    .form-search-button {
      padding: 0.75rem 2rem;
    }
  }
}

/* ヘルパーテキスト
------------------------------ */
.form-helper-text {
  margin: 0.5rem 0;
  font-size: map.get(global.$font-scales, body-s);
  color: global.$color-text-side;
}

/* バリデーター
------------------------------ */
.form-group {
  .valid-mark {
    display: none;
  }

  .valid-mark.valid {
    float: right;
    display: inline;
    color: #5cb85c;
  }

  .invalid {
    border-color: global.$color-error;
    box-shadow: global.$box-shadow-error, acms.$acms-form-box-shadow;
  }
}

.form-error-text {
  margin: 0.5rem 0;
  font-size: map.get(global.$font-scales, body-s);
  color: global.$color-error;

  .form-helper-text + .validator-result-0 & {
    margin-top: 0;
  }
}

.transaction-notice-,
.v-result-,
.v-result-1,
.validator-result-,
.validator-result-1 {
  display: none;
}

/* メッセージ
------------------------------ */
.form-message {
  margin: 0 0 1.5rem;
  text-align: center;

  * + & {
    margin-top: 1.5rem;
  }

  &.is-bold {
    font-weight: bold;
  }

  &.is-error {
    color: global.$color-error;
  }

  .form-input + & {
    margin-top: 2rem;
  }

  &.-sp-left {
    text-align: left;
  }

  &.-left {
    text-align: left;
  }

  small {
    font-size: 0.8125em;
  }
}

.form-message-back {
  text-align: center;
}

@include acms.media-breakpoint-up(md) {
  .form-message {
    margin: 0 0 2rem;

    * + & {
      margin-top: 2rem;
    }

    &.-sp-left {
      text-align: center;
    }
  }
}

/* 入力項目 */

/* パスワードの表示/非表示ボタン */

/* ステップ */

/* ユーザーアイコン */
.form-user-icon {
  width: 8rem;
  height: 8rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
  border-radius: 50%;
}

/* 非公開情報 */
.form-private {
  display: flex;
  align-items: center;
  font-weight: bold;
  color: global.$color-secondary;
}
