@use "design";
@use "m";

// Rounded corner hacks go here
// --------------------------------

:global(.globalRoundedFieldsContainer) {
  .cardRowGroup:first-child > li:first-child > *,
  .cardContent:first-child {
    border-top-left-radius: design.$border-radius-inside-large;
    border-top-right-radius: design.$border-radius-inside-large;
  }

  .cardRowGroup:last-child > li:last-child > *:not(.isOpen),
  .cardContent:last-child {
    border-bottom-left-radius: design.$border-radius-inside-large;
    border-bottom-right-radius: design.$border-radius-inside-large;
    @include m.noCardRowBottomBorder;
  }

  .cardFullWidthImage:first-child > img {
    border-top-left-radius: design.$border-radius-inside-large;
    border-top-right-radius: design.$border-radius-inside-large;
  }

  .cardFullWidthImage:last-child > img {
    border-bottom-left-radius: design.$border-radius-inside-large;
    border-bottom-right-radius: design.$border-radius-inside-large;
  }
}

// --------------------------------

.cardRow {
  position: relative; // For the debug buttons

  &.highlight {
    box-shadow: 0 2px 15px 4px rgba(design.$color-brand-primary--rgb, 0.3);

    animation-name: removeBoxShadow;
    animation-delay: 5s;
    animation-duration: 5s;
    animation-fill-mode: forwards;
    animation-timing-function: ease;
  }

  &:not(.isOpen) .cardRowContent {
    @include m.cardRowBottomBorder;
  }
}

@keyframes removeBoxShadow {
  to {
    box-shadow: none;
  }
}

.cardRowContent {
  display: flex;
  align-items: center;
  position: relative;

  padding-left: design.$card-h-padding;
  padding-right: design.$card-h-padding;
  padding-top: design.$space-50;
  padding-bottom: design.$space-50;

  min-height: 46px;

  border-bottom: 1px solid transparent;

  width: 100%; // because buttons

  // font-size: 15px;
  line-height: 1.35em;

  .label {
    padding-right: 10px;
    margin-right: auto;

    display: flex;
    align-items: center;
    gap: 10px;

    .icon {
      flex-shrink: 0;

      svg {
        width: 20px;
        height: 20px;
      }
    }
  }

  .subLabel,
  .subValue {
    @include design.font-smallest;
    color: design.$color-on-surface-variant;
  }

  &.isToggled {
    input {
      opacity: 0.5;
    }
  }

  .value {
    text-align: right;

    &:not(.isUnstyled) {
      color: design.$neutral-40;
    }

    // Checkboxes and switches get extra space under them, so
    // hack them to be block to remove. I think this is safe?
    > input {
      display: block;
      transition: 500ms opacity;
    }

    > svg {
      max-height: 25px;
    }
  }
}

.debugButton {
  position: absolute;
  left: -6px;
  z-index: 10;
  top: 15px;
}

.toggledContent {
  @include m.cardRowBottomBorder;

  padding-top: 10px;
  padding-right: design.$card-h-padding;
  padding-bottom: calc(design.$card-h-padding + 5px);
  padding-left: design.$card-h-padding;
}

.isAction {
  @include m.shadeActive;
  cursor: pointer;

  &:focus-visible {
    z-index: 1;
    border-bottom-color: transparent;
  }
}

.chevronIcon {
  flex-shrink: 0;
  color: design.$neutral-60;
  padding-left: 10px;

  svg {
    transition: transform 100ms;
  }

  .isToggled & svg {
    transform: rotate(90deg);
  }
}

.redColor {
  .labelText {
    color: design.$red-40;
  }
}

.brandPrimaryColor {
  .labelText {
    color: design.$color-brand-primary;
  }
}

.accentPrimaryColor {
  .labelText {
    color: design.$color-primary;
  }
}

.textGreyColor {
  .labelText {
    color: design.$color-on-surface-variant;
  }
}

.cardContent {
  padding-left: design.$card-h-padding;
  padding-right: design.$card-h-padding;

  &.link {
    display: flex;
    align-items: center;

    .chevronIcon {
      margin-left: auto;
    }
  }

  &.borderBottom {
    @include m.cardRowBottomBorder;
  }

  &.minimalPadding {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  &.matchFieldsPadding {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  &.normalPadding {
    padding-top: design.$card-h-padding;
    padding-bottom: design.$card-h-padding;
  }
}

.cardContentReset {
  margin-left: calc(-1 * design.$card-h-padding);
  margin-right: calc(-1 * design.$card-h-padding);
}

.scrollingCardContent {
  padding: design.$card-h-padding;
  max-height: 200px; // Basically arbitrary;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.describedAmount {
  text-align: center;
  padding: 40px design.$card-h-padding;

  .number {
    padding-top: 8px; // Make horizontal alignment better visually
    margin-bottom: 18px;
    @include design.fontHugeNumber;
    color: design.$color-success;
    word-break: break-word;
  }

  .numberInvalid {
    color: design.$color-on-surface-variant;
  }

  .description,
  .above {
    color: design.$color-on-surface-variant;
    @include design.font-smaller;
  }

  .above {
    margin-bottom: 8px;
  }
}

.setupStep {
  &.isActive ~ .setupStep {
    opacity: 0.5;
  }

  .icon {
    flex-grow: 0;
    flex-shrink: 0;

    svg {
      width: 28px;
      height: 28px;

      &.complete {
        color: green;
      }
    }
  }

  .setupLabel {
    flex-grow: 1;

    // Hack, make sure buttons don't squish
    button {
      flex-shrink: 0;
    }
  }
}
