* {
  box-sizing: border-box;
}

.form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;

  .label {
    font-size: 10px;
    font-weight: 500;
    color: #000;
  }

  .phoneInput {
    border-radius: 29px;
    border: 2px solid var(--default-input-dark, rgba(255, 255, 255, 0));
    position: relative;

    .countrySelect {
      appearance: none;
      border: none;
      outline: none;

      .countryFlag {
        width: 32px;
        height: 24px;
        margin-right: 8px;
      }

      &Dialog {
        margin-top: 10px;
        border-radius: 8px;
        border: 1px solid #000;
      }
    }

    .numberInput {
      appearance: none;
      border: none;
      outline: none;
    }
  }
}

.styledForm {
  display: flex;
  gap: 8px;
  font-family: 'Work Sans', sans-serif;

  .phoneInput {
    display: flex;
    width: 300px;
    height: 60px;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--secondary-gray, #a2a2a2);
    background: #fff;

    &.invalid {
      border-bottom: 1px solid var(--secondary-red, #ff0000);
    }

    .countryIcon {
      display: flex;
      width: 20px;
      height: 20px;
      justify-content: center;
      align-items: center;
    }

    .countrySelect {
      display: flex;
      align-items: center;
      gap: 4px;
      cursor: pointer;

      &[data-open='true'] {
        .countryIcon {
          transform: rotate(180deg);
        }
      }

      &Search {
        display: flex;
        height: 48px;
        padding: 12px;
        align-items: center;
        gap: 8px;
        align-self: stretch;

        border-bottom: 1px solid var(--secondary-light-gray, #dedede);

        &Icon {
          display: flex;
          width: 24px;
          height: 24px;
          justify-content: center;
          align-items: center;
        }

        &Input {
          display: flex;
          align-items: center;
          gap: 8px;
          align-self: stretch;
          outline: none;
          border: none;

          color: var(--secondary-dark-gray, #7a7a7a);
          font-family: 'Work Sans';
          font-size: 20px;
          font-style: normal;
          font-weight: 500;
          line-height: normal;
        }
      }

      .countryFlag {
        width: 32px;
        height: 24px;
        object-fit: contain;
      }

      &Dialog {
        width: 100%;
      }

      &List {
        margin-block-start: 0;
        margin-block-end: 0;
        padding-inline-start: 0;
      }

      &Item {
        display: flex;
        min-height: 47px;
        padding: 12px;
        align-items: center;
        gap: 8px;
        align-self: stretch;
        cursor: pointer;

        color: var(--secondary-dark-gray, #7a7a7a);
        font-family: 'Work Sans';
        font-size: 20px;
        font-style: normal;
        font-weight: 500;
        line-height: normal;

        &:hover {
          color: var(--main-black, #414141);
          background: var(--hover-blue-15, rgba(180, 231, 239, 0.15));
        }

        &Flag {
          width: 30px;
          height: 24px;
          flex-shrink: 0;
          object-fit: contain;
        }
      }
    }

    .numberInput {
      color: var(--main-black, #414141);
      font-family: 'Work Sans';
      font-size: 20px;
      font-style: normal;
      font-weight: 500;
      line-height: normal;

      &::placeholder {
        color: var(--secondary-dark-gray, #7a7a7a);
        font-family: 'Work Sans';
        font-size: 20px;
        font-style: normal;
        font-weight: 500;
        line-height: normal;
      }

      &Wrapper {
        position: relative;

        .label {
          position: absolute;
          top: 0;
          left: 0;
          background: none;
          transition: all 0.3s ease;

          &.filled {
            top: -20px;
            color: var(--main-black, #414141);
          }

          &.focused {
            top: -20px;
            color: var(--main-black, #414141);
          }

          &Text {
            color: var(--secondary-dark-gray, #7a7a7a);
            font-family: 'Work Sans';
            font-size: 14px;
            font-style: normal;
            font-weight: 500;
            line-height: normal;
          }
        }
      }
    }
  }
}

.flags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  flex-wrap: wrap;
  gap: 8px;

  .flagGroup {
    display: flex;
    gap: 8px;

    .flag {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;

      .countryFlag {
        width: 32px;
        height: 24px;
      }
    }
  }
}

.styledTwoForm {
  display: flex;
  gap: 8px;
  font-family: 'Work Sans', sans-serif;

  .phoneInput {
    display: flex;
    width: 300px;
    height: 60px;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-radius: 29px;
    border: 2px solid var(--default-input-dark, rgba(255, 255, 255, 0));
    border-bottom: 2px solid rgba(0, 0, 0, 0.3);
    padding: 20px 36px 15px 36px;

    &.invalid {
      border-bottom: 2px solid var(--secondary-red, #ff0000);
    }

    .countryIcon {
      display: flex;
      width: 20px;
      height: 20px;
      justify-content: center;
      align-items: center;
    }

    .countrySelect {
      display: flex;
      align-items: center;
      gap: 4px;
      cursor: pointer;
      position: relative;

      &[data-open='true'] {
        .countryIcon {
          transform: rotate(180deg);
        }
      }

      &Search {
        position: sticky;
        top: 0;
        display: flex;
        padding: 8px 8px 8px 8px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        align-self: stretch;
        border-bottom: 1px solid rgba(31, 30, 88, 0.1);
        background: #fcfcfc;

        &Wrapper {
          display: flex;
          height: 44px;
          padding: 7px 16px;
          align-items: center;
          gap: 12px;
          align-self: stretch;

          border-radius: 21px;
          background: #f0f0f3;
        }

        &Icon {
          display: flex;
          width: 24px;
          height: 24px;
          justify-content: center;
          align-items: center;
        }

        &Input {
          display: flex;
          align-items: center;
          gap: 8px;
          align-self: stretch;
          outline: none;
          border: none;
          background: none;

          color: var(--text-Om, #1f1e58);
          font-family: Gantari;
          font-size: 16px;
          font-style: normal;
          font-weight: 400;
          line-height: 24px; /* 150% */

          &::placeholder {
            color: rgba(31, 30, 88, 0.5);
            font-family: Gantari;
            font-size: 16px;
            font-style: normal;
            font-weight: 400;
            line-height: 24px; /* 150% */
          }
        }
      }

      .countryFlag {
        width: 21px;
        height: 15px;
        object-fit: cover;
        border-radius: 4px;
      }

      &Dialog {
        width: 100%;
        display: flex;
        padding: 8px 0px;
        padding-top: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-top: 8px;
        border-radius: 29px;
        background: #fcfcfc;
        box-shadow: 0px 2px 16px 0px rgba(18, 18, 18, 0.1);
        overflow: hidden;
        transform: scale(0.9); /* Начальный масштаб */
        opacity: 0; /* Начальная прозрачность */
        transition:
          transform 0.3s ease,
          opacity 0.3s ease; /* Переход для масштаба и прозрачности */
        pointer-events: none;
      }

      &Dialog[aria-hidden='false'] {
        transform: scale(1); /* Конечный масштаб */
        opacity: 1; /* Конечная прозрачность */
        pointer-events: all;
      }

      &List {
        display: flex;
        padding: 8px 0px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-block-start: 0;
        margin-block-end: 0;
        padding-inline-start: 0;
        overflow: auto;
        width: 100%;
      }

      &Item {
        display: flex;
        min-height: 44px;
        padding: 6px 16px;
        align-items: center;
        gap: 16px;
        align-self: stretch;
        cursor: pointer;

        color: var(--text-Om, #1f1e58);
        font-family: Gantari;
        font-size: 16px;
        font-style: normal;
        font-weight: 400;
        line-height: normal;

        &:hover {
          color: var(--main-black, #414141);
          background: var(--hover-blue-15, rgba(180, 231, 239, 0.15));
        }

        &Flag {
          width: 24px;
          height: 18px;
          flex-shrink: 0;
          object-fit: cover;
          border-radius: 4px;
        }
      }
    }

    .numberInput {
      color: var(--text-Om, #1f1e58);
      font-family: Gantari;
      font-size: 18px;
      font-style: normal;
      font-weight: 500;
      line-height: normal;
      opacity: 0.7;

      &::placeholder {
        color: var(--text-Om, #1f1e58);
        font-family: Gantari;
        font-size: 18px;
        font-style: normal;
        font-weight: 500;
        line-height: normal;
        opacity: 0.7;
      }
    }
  }

  .label {
    position: relative;

    &Text {
      position: absolute;
      left: 36px;
      color: var(--text-Om, #1f1e58);
      text-align: center;
      font-family: Gantari;
      font-size: 18px;
      font-style: normal;
      font-weight: 500;
      line-height: normal;
      opacity: 0.7;
    }
  }
}

.countrySelectDialog {
  position: absolute;
  background-color: white;
  max-height: 200px;
  overflow: auto;

  &Open {
    display: flex;
    flex-direction: column;
  }
}

.formPhoneInput {
  .phoneInput {
    display: flex;
    gap: 8px;
  }

  .countrySelect {
    background: none;
    appearance: none;
    width: 32px;
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;

    & .countryFlag {
      width: 32px;
      height: 24px;
    }
  }

  .countryFlag {
    width: 32px;
    height: 24px;
    cursor: pointer;
  }
}
