@use '../../../common/scss/global.scss';
@use '~@kyndryl-design-system/shidoka-foundation/scss/mixins/typography.scss';

:host {
  display: inline-block;
}

dialog {
  padding: 32px;
  color: inherit;
  background: var(--kd-color-background-ui-default);
  border-radius: 8px;
  border: 1px solid var(--kd-color-border-light);
  box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.12);
  min-width: 288px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);

  &[open] {
    animation: dialog-in 400ms ease-out;
  }

  &::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
  }

  &.size--md {
    width: 384px;
  }

  &.size--lg {
    width: 711px;
  }
}

@supports (transition-behavior: allow-discrete) {
  dialog {
    transition: opacity 400ms ease-out, transform 400ms ease-out,
      overlay 400ms ease-out allow-discrete,
      display 400ms ease-out allow-discrete;
    opacity: 0;
    transform: scale(0);

    &::backdrop {
      background-color: rgba(0, 0, 0, 0);
      transition: display 400ms allow-discrete, overlay 400ms allow-discrete,
        background-color 400ms;
    }

    &[open] {
      animation: none;
      opacity: 1;
      transform: scale(1);

      &::backdrop {
        background-color: rgba(0, 0, 0, 0.4);
      }
    }
  }
}

@keyframes dialog-in {
  0% {
    opacity: 0;
    transform: scale(0);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

button {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  border-radius: 4px;
  outline: 2px solid transparent;
  transition: outline-color 150ms ease-out, color 150ms ease-out;

  &:focus {
    outline-color: var(--kd-color-border-focus);
  }

  &:hover {
    color: var(--kd-color-text-link-hover);
  }

  &:active {
    color: var(--kd-color-text-pressed);
  }
}

.anchor {
  display: inline-block;
  width: 100%;
}

header {
  margin-bottom: 32px;
  margin-right: 16px;
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;

  kd-icon {
    display: block;
  }
}

.label {
  @include typography.type-ui-03;
  color: var(--kd-color-text-placeholder);
}

h1 {
  @include typography.type-body-01;
  margin: 0;
  order: 1;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 32px;

  @media (max-width: 42rem) {
    kd-button {
      width: 100%;
      flex-grow: 1;
    }
  }
}

.custom-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
