@import './../icons/icon-animations.css';

@tailwind components;

@layer components {
  /* Many of these nested elements stem from formkit. Once Pro elements can be exported, we'd need to rethink that structure. */
  /* Related GH issue: https://github.com/formkit/formkit/issues/412 */
  .dropdown {
    & .dropdown-wrapper {
      @apply min-h-[90px] relative h-auto;

      & .dropdown-inner {
        /* Manually setting the height ensures consistent look&feel for all browsers. */
        @apply border border-blue-900 bg-white rounded p-10 text-base text-gray-900 transition-all ease-in-out duration-250 h-[46px];
        @apply hover:border-blue-500;
        @apply focus:outline-none focus:shadow-purple-600 focus:border-purple-600;
        @apply focus-within:outline-none focus-within:shadow-purple-600 focus-within:border-purple-600;

        @apply disabled:border-gray-300 disabled:bg-gray-300 disabled:text-gray-800 disabled:cursor-default;

        &::placeholder {
          @apply text-gray-500;
        }

        &:disabled::placeholder {
          @apply text-gray-800;
        }

        @apply h-auto p-0 absolute top-[27px] w-full my-10;

        & .dropdown-trigger {
          @apply p-10 w-full flex flex-row items-center justify-between h-[42px] text-left;

          & .placeholder {
            @apply text-gray-500;
          }

          &:after {
            @apply content-[""] w-20 h-20 block;
            @apply transition-all ease-in-out duration-250;
            @apply has-symbol-caret;
            @apply rotate-0;
          }
        }
      }

      & .dropdown-list-item {
        @apply p-10 text-blue-700 hover:text-blue-900;

        & .dropdown-option {
          @apply flex flex-row items-center relative gap-10;
        }
      }
    }

    &[data-disabled='true'] {
      & .dropdown-inner {
        @apply border-gray-300 bg-gray-300;

        & .placeholder {
          @apply text-gray-800;
        }
      }
    }

    &[data-multiple='true'] {
      & .dropdown-list-item .dropdown-option {
        &:before,
        &:after {
          @apply block content-[''] w-20 min-w-[20px] h-20 cursor-pointer transition-all ease-in-out duration-250;
        }

        &:after {
          @apply absolute top-0 left-0;
        }

        &:before {
          @apply border border-blue-900 rounded;
        }

        &:focus:before {
          @apply outline-none shadow-purple-600 border-purple-600;
        }

        &[data-checked='true']:before,
        &:checked:before {
          @apply bg-blue-900 border-blue-900;
        }

        &:after {
          @apply opacity-0 content-[""] bg-center bg-[length:12px_12px] bg-no-repeat;
          background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.7071 0.292893C12.0976 0.683417 12.0976 1.31658 11.7071 1.70711L4.70711 8.70711C4.51957 8.89464 4.26522 9 4 9C3.73478 9 3.48043 8.89464 3.29289 8.70711L0.292893 5.70711C-0.0976311 5.31658 -0.0976311 4.68342 0.292893 4.29289C0.683417 3.90237 1.31658 3.90237 1.70711 4.29289L4 6.58579L10.2929 0.292893C10.6834 -0.0976311 11.3166 -0.0976311 11.7071 0.292893Z' fill='#fff'/%3E%3C/svg%3E");
        }

        &[data-checked='true']:after,
        &:checked:after {
          @apply opacity-100;
        }

        &:hover:before {
          @apply border-blue-500 bg-blue-500;
        }

        &:disabled:before {
          @apply border-gray-500 bg-gray-500;
        }
      }
    }

    &[data-expanded='true'] {
      & .dropdown-inner {
        @apply z-10;

        & .dropdown-trigger:after {
          @apply rotate-180;
        }
      }
    }
  }
}
