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

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

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

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

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

  &::before {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 2rem;
    height: 2rem;
    margin: 0 0 0.5rem;
    color: global.$color-text;
    font-weight: normal;
    font-size: 1em;
    line-height: global.$line-height-lg;
    background: global.$color-gray10;
    border-radius: 50%;

    /* カウンターの設定 */
    counter-increment: mailStep;
    content: counter(mailStep);
  }

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

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

@media screen and (min-width: acms.$breakpoint-md-min) {
  .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;
    }
  }
}

@media screen and (max-width: acms.$breakpoint-md-max) {
  .form-step {
    justify-content: center;
  }
}

/* フォームレイアウト
------------------------------ */
.form-group-list {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin: 0;
  padding: 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 {
      margin-bottom: 0;
      padding: 1rem;
      border-top: 1px solid global.$color-gray40;
    }
  }

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

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

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

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

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

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

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

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

  .button {
    margin: 0;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .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;
  }
}

@media screen and (max-width: acms.$breakpoint-md-max) {
  .form-button {
    width: 100%;
    margin: 0 0 1rem;

    .button {
      width: 100%;
    }
  }

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

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

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

@media screen and (min-width: acms.$breakpoint-md-min) {
  .label-required {
    margin: 0 0 0 0.5rem;

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

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

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

@media screen and (min-width: acms.$breakpoint-md-min) {
  .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;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .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;
  margin: 0;
  padding: 0.75rem 1rem;
  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 {
  margin-left: auto;
  padding: 0;
  text-decoration: underline;
  background: none;
  border: none;
  appearance: 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 {
    flex: 1 1 auto;
    box-sizing: border-box;
    height: 3rem;
    padding: 0.5rem;
    font-size: map.get(global.$font-scales, body-m);
    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;
    appearance: none;

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

    &:focus {
      background: global.$color-white;
      border-color: acms.$acms-form-focus-border-color;
      outline: none;
      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;
  }

  @media screen and (min-width: acms.$breakpoint-md-min) {
    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;
  color: global.$color-text-side;
  font-size: map.get(global.$font-scales, body-s);
}

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

  .valid-mark.valid {
    display: inline;
    float: right;
    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;
  color: global.$color-error;
  font-size: map.get(global.$font-scales, body-s);

  .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;
}

@media (min-width: acms.$breakpoint-md-min) {
  .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;
  color: global.$color-secondary;
  font-weight: bold;
}
