@import "../../scss/renewal-price-pro-badge";

.arraysubs-quick-product {
  width: min(820px, 100%);
  height: 100%;
  max-height: 100%;

  > .arraysubs-modal__content {
    padding: 0;
    min-height: 0;
    overflow: clip;
    display: flex;
    flex-direction: column;
    flex: 1;
  }

  &__progress {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 28px;
    background: #f8fafb;
    border-bottom: 1px solid #e2e5e9;
    color: #50575e;
    flex-shrink: 0;
    font-size: 13px;
    progress {
      flex: 1;
      min-width: 40px;
      height: 6px;
      accent-color: var(--wp-admin-theme-color);
    }
  }

  &__body {
    padding: 24px 28px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    > h2 {
      margin: 0 0 24px;
      font-size: 22px;
    }
    h2:focus {
      outline: none;
    }
    .field-warper {
      margin-bottom: 22px;
    }
    .field-item-label {
      display: block;
      margin-bottom: 8px;
      font-weight: 600;
    }
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea {
      width: 100%;
    }
    .field-item-help {
      margin-top: 6px;
      color: #646970;
      font-size: 13px;
    }
    .arraysubs-box-section {
      border-radius: 8px;
    }
    .arraysubs-fb-select-dropdown {
      z-index: 5;
    }
  }

  &__types {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  &__type {
    --type-padding: 20px;
    --type-gap: 12px;
    --type-radio-size: 20px;
    --type-icon-size: 24px;
    --type-copy-inset: calc(
      var(--type-padding) + var(--type-radio-size) + var(--type-icon-size) +
        var(--type-gap) + var(--type-gap)
    );
    position: relative;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    cursor: pointer;
    background: #fff;
    &:not(.is-disabled):hover {
      border-color: var(--wp-admin-theme-color);
    }
    &.is-selected {
      border-color: var(--wp-admin-theme-color);
      background: color-mix(in srgb, var(--wp-admin-theme-color) 6%, white);
      box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
    }
    &:focus-within {
      outline: 2px solid var(--wp-admin-theme-color);
      outline-offset: 3px;
    }
    &.is-disabled {
      background: #f8fafb;
      cursor: not-allowed;
    }
    &.is-disabled &-main {
      cursor: not-allowed;
      padding-bottom: 12px;
    }
    &-main {
      display: grid;
      grid-template-columns: var(--type-radio-size) var(--type-icon-size) minmax(
          0,
          1fr
        );
      align-items: center;
      gap: var(--type-gap);
      padding: var(--type-padding);
      cursor: pointer;
    }
    &-main > input[type="radio"] {
      position: relative;
      width: var(--type-radio-size);
      height: var(--type-radio-size);
      min-width: var(--type-radio-size);
      min-height: var(--type-radio-size);
      margin: 0;

      // Avoid WordPress's size-dependent margins shifting the selected dot.
      &:checked::before {
        position: absolute;
        top: 50%;
        left: 50%;
        float: none;
        margin: 0;
        transform: translate(-50%, -50%);
      }
    }
    &-main > svg {
      width: var(--type-icon-size);
      height: var(--type-icon-size);
      color: var(--wp-admin-theme-color);
    }
    &.is-disabled &-main > svg {
      color: #787c82;
    }
    &-copy {
      display: grid;
      gap: 4px;
      min-width: 0;
    }
    &-heading {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px 10px;

      > strong {
        color: #2c3338;
        font-size: 16px;
        line-height: 1.4;
      }
    }
    &-description {
      color: #646970;
      line-height: 1.5;
      font-size: 13px;
    }
    &-status {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px 7px;
      border: 1px solid #dcdcde;
      border-radius: 4px;
      color: #50575e;
      background: #fff;
      font-size: 11px;
      font-weight: 500;
      line-height: 1.4;
      white-space: nowrap;
    }
    &-highlight {
      position: absolute;
      inset: -1px;
      border-radius: inherit;
      pointer-events: none;
      animation: arraysubs-quick-product-highlight 800ms ease-in-out 2;
    }
  }

  &__requirements {
    // Use the same column dimensions as the label, including at mobile sizes.
    margin-inline: var(--type-copy-inset) var(--type-padding);
    padding: 0 0 var(--type-padding);
    color: #50575e;
    cursor: default;
    font-size: 13px;
    line-height: 1.6;

    ul {
      display: grid;
      gap: 12px;
      margin: 0;
      padding: 0;
      list-style: none;
    }
    li {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      gap: 2px 8px;
      margin: 0;
    }
    p {
      margin: 8px 0 0;
      color: #646970;
      font-size: 12px;
    }
    a,
    .button-link {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      max-width: 100%;
      padding: 0;
      color: var(--wp-admin-theme-color);
      font: inherit;
      font-weight: 600;
      text-decoration: none;
      text-align: start;
      white-space: normal;
      cursor: pointer;

      > svg {
        flex-shrink: 0;
      }

      &:hover > span {
        text-decoration: underline;
      }
    }
  }

  &__guide {
    &-intro {
      margin: -10px 0 24px;
      color: #646970;
      font-size: 14px;
      line-height: 1.6;
    }
    &-steps {
      margin: 0 0 24px;
      padding: 0;
      list-style: none;

      > li {
        position: relative;
        display: grid;
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 16px;
        margin: 0;
        padding-bottom: 24px;

        &:not(:last-child)::before {
          content: "";
          position: absolute;
          inset-inline-start: 15px;
          top: 36px;
          bottom: 4px;
          width: 2px;
          background: color-mix(
            in srgb,
            var(--wp-admin-theme-color) 18%,
            white
          );
        }
        &:last-child {
          padding-bottom: 0;
        }
      }
      h3 {
        margin: 4px 0 6px;
        color: #2c3338;
        font-size: 15px;
        line-height: 1.5;
      }
      p {
        margin: 0;
        color: #646970;
        font-size: 13px;
        line-height: 1.6;
      }
    }
    &-number {
      display: grid;
      place-items: center;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: color-mix(in srgb, var(--wp-admin-theme-color) 8%, white);
      color: var(--wp-admin-theme-color);
      font-size: 14px;
      font-weight: 600;
    }
    &-link {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      color: var(--wp-admin-theme-color);
      font-weight: 600;
      line-height: 1.6;

      svg {
        flex-shrink: 0;
      }
    }
  }

  &__notice {
    padding: 16px;
    border-left: 3px solid var(--wp-admin-theme-color);
    background: color-mix(in srgb, var(--wp-admin-theme-color) 6%, white);
    line-height: 1.7;
  }
  &__error {
    color: #b32d2e;
    background: #fcf0f1;
    padding: 12px 16px;
    border-radius: 6px;
  }
  &__footer {
    padding: 16px 28px;
    border-top: 1px solid #dcdcde;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    background: #fff;
    .button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }
  }

  &__review {
    section {
      border-bottom: 1px solid #e2e5e9;
      padding-bottom: 18px;
      margin-bottom: 20px;
    }
    h3 {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      font-size: 16px;
    }
    dl {
      display: grid;
      grid-template-columns: minmax(140px, 1fr) 1.5fr;
      gap: 12px 24px;
      margin: 0;
    }
    dt {
      color: #646970;
    }
    dd {
      margin: 0;
      overflow-wrap: anywhere;
      white-space: pre-wrap;
    }
  }
  &__success {
    text-align: center;
    margin-top: -10px;
    > svg {
      color: #008a20;
    }
    h2 {
      margin: 0;
      line-height: 1.4;
    }
  }
  &__created-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
    overflow-wrap: anywhere;
  }
  &__links {
    display: grid;
    gap: 14px;
    max-width: 380px;
    margin: 30px auto;

    &:has(.arraysubs-quick-product__link-card--trial) {
      max-width: 520px;

      > .arraysubs-quick-product__link-card:not(
          .arraysubs-quick-product__link-card--trial
        ) {
        max-width: 380px;
        justify-self: center;
      }
    }

    .arraysubs-quick-product__link-card.button {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      width: 100%;
      min-height: 88px;
      height: auto;
      padding: 14px 18px;
      white-space: normal;
      text-align: center;
      line-height: 1.4;

      > strong {
        display: block;
        font-size: 16px;
        line-height: 1.4;
      }

      > span {
        display: block;
        max-width: 290px;
        color: #646970;
        font-size: 13px;
        font-weight: 400;
        line-height: 1.5;
      }

      &.button-primary > span {
        color: inherit;
      }

      &.arraysubs-quick-product__link-card--trial {
        gap: 10px;

        &,
        &:hover,
        &:focus,
        &:active {
          background: var(--wp-admin-theme-color);
          border-color: var(--wp-admin-theme-color);
          color: #fff;
        }

        > strong {
          font-size: 22px;
        }

        > span {
          max-width: 420px;
          font-size: 15px;
        }

        > .arraysubs-quick-product__trial-action {
          font-size: 16px;
          font-weight: 600;
          text-decoration: underline;
        }
      }
    }
  }

  @media (max-width: 600px) {
    &__body {
      padding: 20px 16px;
    }
    &__progress,
    &__footer {
      padding: 14px 16px;
    }
    &__type {
      --type-padding: 16px;
      --type-gap: 10px;
      --type-icon-size: 22px;
    }
    &__review dl {
      grid-template-columns: 1fr;
      gap: 6px;
      dd {
        margin-bottom: 10px;
      }
    }
  }
}

@keyframes arraysubs-quick-product-highlight {
  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
  50% {
    box-shadow: 0 0 0 4px
      color-mix(in srgb, var(--wp-admin-theme-color) 65%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .arraysubs-quick-product__type-highlight {
    animation: none;
  }
}

// Reuse FormBuilder radios while matching the modal's selected cards.
.arraysubs-quick-product {
  &__step-description {
    color: #646970;
    line-height: 1.6;
    margin: -8px 0 24px;
  }

  .arraysubs-fb-radio-group:has(input[name="_arraysubs_subscription_mode"]) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;

    .arraysubs-fb-radio-item {
      position: relative;
      display: flex;
      align-items: center;
      gap: 8px;
      border: 1px solid #dcdcde;
      border-radius: 6px;
      margin: 0;

      &:has(input:checked) {
        border-color: var(--wp-admin-theme-color);
        background: color-mix(in srgb, var(--wp-admin-theme-color) 6%, white);
      }
      &:has(input:focus-visible) {
        outline: 2px solid var(--wp-admin-theme-color);
        outline-offset: 2px;
      }
      &:has(input:disabled) {
        color: #787c82;
      }
      label {
        margin: 0;
        cursor: pointer;
      }
      input:disabled + label {
        cursor: not-allowed;
      }
      input[type="radio"] {
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
        box-sizing: border-box;
        border-radius: 50%;
        margin: 0;
        flex-shrink: 0;

        &:checked {
          border-color: var(--wp-admin-theme-color);
          // Draw both circles together, independent of WordPress's mobile dot size.
          background: radial-gradient(
            circle at center,
            #fff 0 4px,
            var(--wp-admin-theme-color) 4px
          );
        }

        &:checked::before {
          content: none;
        }
      }
    }
  }
}

// WordPress enlarges its checkmark on mobile; FormBuilder keeps a 16px control.
.arraysubs-quick-product .arraysubs-fb-checkbox-item > input[type="checkbox"] {
  position: relative;

  &:checked::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    float: none;
    margin: 0;
    transform: translate(-50%, -50%);
  }
}

.arraysubs-quick-product
  .arraysubs-fb-radio-group:has(input[name="_arraysubs_subscription_mode"])
  .arraysubs-fb-radio-item {
  padding-left: 8px;
  label {
    padding: 3px 8px !important;
  }
}
