:root {
  --color-black: #000000;
  --color-gray-dark: #5c5c5c;
  --color-gray: #e5e5e5;
  --color-gray-light: #f2f2f2;
  --color-white: #ffffff;
  --color-accent: #5a8dcb;
  --color-green: #37ab46;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Gilroy", sans-serif;
  color: var(--color-black);
  background-color: var(--color-gray-light);
  height: 100svh;
  width: 100vw;
  display: flex;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 9rem;
  transform: rotate(-90deg);
  transform-origin: center;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 30px;
}

input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 30px;
}

input[type="range"]::-ms-fill-lower {
  background: var(--color-accent);
  border-radius: 30px;
}

input[type="range"]::-ms-fill-upper {
  background: var(--color-gray);
  border-radius: 30px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-accent)
    radial-gradient(circle at center, var(--color-white) 25.5%, transparent 25%);
  position: relative;
  z-index: 2;
}

input[type="range"]::-moz-range-thumb {
  border: none;
  background-color: var(--color-accent);
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

input[type="range"]:focus {
  outline: none;
}

@media not all and (min-resolution: 0.001dpcm) {
  @supports (-webkit-appearance: none) {
    input[type="range"] {
      background: var(--color-gray);
      border-radius: 30px;
      height: 5px;
    }

    input[type="range"]::-webkit-slider-runnable-track {
      background: none;
    }
  }
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.abs-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.main {
  position: relative;
  flex-grow: 1;
}

.input__wrapper {
  width: 100%;
  height: 100%;
}

.input__label {
  width: 100%;
  height: 100%;
  font-size: 2rem;
  text-align: center;
  color: var(--color-accent);
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.input__label-text {
  position: relative;

  &::after {
    position: absolute;
    content: "";
    top: calc(100% + 3px);
    left: 0;
    height: 2px;
    width: 0%;
    background-color: var(--color-accent);
    transition: width 0.3s ease-in-out;
  }
}

.input__label:hover {
  .input__label-text {
    &::after {
      width: 100%;
    }
  }
}

.input__label--hidden {
  display: none;
}

.input {
  display: none;
}

.image__container {
  display: none;
  z-index: 5;
  --offset: 20px;

  width: calc(100% - var(--offset) * 2);
  height: calc(100% - var(--offset) * 2);
  border-radius: 16px;

  canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
    overflow: hidden;
  }
}

.image__container--visible {
  display: flex;
  justify-content: center;
  align-items: center;
}

.toolbar {
  --offset: 20px;
  position: absolute;
  top: var(--offset);
  right: var(--offset);

  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 0.25rem;

  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  opacity: 0;
  transform: translateY(10%);
  z-index: -1;
}

.toolbar--visible {
  opacity: 1;
  transform: translateY(0);
  z-index: 10;
}

.toolbar__item {
  padding: 10px;
  background-color: var(--color-white);
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
}

.toolbar__btn {
  --size: 32px;

  position: relative;
  padding: 10px;
  overflow: hidden;
}

.toolbar__btn-placeholder {
  width: var(--size);
  height: var(--size);
}

.toolbar__btn-icon {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  border-radius: 10px;

  svg {
    width: var(--size);
    height: var(--size);
  }
}

.toolbar__btn-icon--active {
  background-color: var(--color-accent);
}

.toolbar__btn-icon--disabled {
  background-color: var(--color-white);
}

.toolbar__btn-icon--visible {
  opacity: 1;
  transform: translateY(0);
}

.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  --size: 2rem;
  width: var(--size);
  height: var(--size);
  border: 4px solid var(--color-gray-light);
  border-top: 4px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;

  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease-in-out;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loader--visible {
  z-index: 15;
  opacity: 1;
}

.strength-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: opacity 0.3s ease-in-out;
}

.strength-control--disabled {
  opacity: 0.4;
  pointer-events: none;
}

.range-container {
  background-color: var(--color-white);
  width: 55px;
  border-radius: 5px;
  padding: 15px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.range-slider {
  width: 10px;
  height: 150px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  outline: none;
  border-radius: 5px;
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
}

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
}

.strength-value {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.control-label {
  font-size: 1.1rem;
  font-weight: 500;
}

.toolbar__switcher-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding-inline: 0;
  padding-top: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 10px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 10px;
  background-color: var(--color-gray);
  transition: 0.4s;
  border-radius: 34px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 8px;
  width: 8px;
  left: 1px;
  bottom: 1px;
  background-color: var(--color-white);
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--color-green);
}

input:checked + .slider.round:before {
  transform: translateX(10px);
}

input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    var(--color-accent) var(--slider-percentage),
    var(--color-gray) var(--slider-percentage)
  );
}

.toolbar__mobile {
  display: none;
  --offset: 20px;
  position: absolute;
  bottom: var(--offset);
  left: var(--offset);
  right: var(--offset);
  z-index: 10;

  align-items: center;
  gap: 10px;

  background-color: var(--color-white);
  padding: 10px;
  border-radius: 5px;

  .range-container--mobile {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 20px;
  }

  .range-slider--mobile {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    outline: none;
    border-radius: 5px;
    transform: none !important;
  }

  .auto-enhance-checkbox {
    display: none;
  }

  .toolbar-label--mobile {
    cursor: pointer;
    color: var(--color-gray-dark);
  }

  .toolbar-switch--mobile:has(input:checked) {
    .toolbar-label--mobile {
      color: var(--color-accent);
    }
  }
}

@media (max-width: 768px) {
  .toolbar {
    display: none;
  }

  .toolbar__mobile {
    display: flex;
  }
}
