/**
 * Cancel Modal Styles
 *
 * @package ArraySubs
 */

// Modal open state - prevent body scroll
body.arraysubs-modal-open {
  overflow: hidden;
}

// Modal container
.arraysubs-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  // Backdrop
  &__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
  }

  // Modal container
  &__container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    margin: 20px;
    display: flex;
    flex-direction: column;
    animation: arraysubs-modal-in 0.2s ease-out;
  }

  // Modal content
  &__content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: inherit;
    overflow: hidden;
  }

  // Body - scrollable
  &__body {
    overflow-y: auto;
  }

  // Close button
  &__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #666;
    border-radius: 4px;
    transition:
      background-color 0.15s ease,
      color 0.15s ease;

    &:hover {
      background: #f0f0f0;
      color: #333;
    }

    &:focus {
      outline: 2px solid var(--arraysubs-fb-primary-color, #0073aa);
      outline-offset: 2px;
    }
  }

  // Header
  &__header {
    padding: 20px 24px 0;
  }

  &__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
  }

  // Body
  &__body {
    padding: 20px 24px;
  }

  &__message {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #50575e;
  }

  // Form elements
  &__form {
    margin-top: 16px;
  }

  &__label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1d2327;
  }

  &__select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background-color: #fff;
    color: #1d2327;
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;

    &:focus {
      border-color: var(--arraysubs-fb-primary-color, #0073aa);
      box-shadow: 0 0 0 1px var(--arraysubs-fb-primary-color, #0073aa);
      outline: none;
    }
  }

  // Other reason textarea
  &__other-reason {
    margin-top: 16px;
  }

  &__textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background-color: #fff;
    color: #1d2327;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;

    &:focus {
      border-color: var(--arraysubs-fb-primary-color, #0073aa);
      box-shadow: 0 0 0 1px var(--arraysubs-fb-primary-color, #0073aa);
      outline: none;
    }

    &::placeholder {
      color: #8c8f94;
    }
  }

  // Footer
  &__footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 20px;
    border-top: 1px solid #e0e0e0;
  }

  // Buttons
  &__cancel-btn,
  &__confirm-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease;
    line-height: 1.4;

    &:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }
  }

  &__cancel-btn {
    background: #f0f0f0 !important;
    border: 1px solid #8c8f94 !important;
    color: #1d2327 !important;

    &:hover:not(:disabled) {
      background: #e0e0e0 !important;
      border-color: #646970 !important;
    }

    &:focus {
      outline: 2px solid var(--arraysubs-fb-primary-color, #0073aa);
      outline-offset: 2px;
    }
  }

  &__confirm-btn {
    background: var(--arraysubs-fb-primary-color, #0073aa) !important;
    border: 1px solid var(--arraysubs-fb-primary-color, #0073aa) !important;
    color: #fff !important;

    &:hover:not(:disabled) {
      background: var(--arraysubs-fb-primary-hover, #005a87) !important;
      border-color: var(--arraysubs-fb-primary-hover, #005a87) !important;
    }

    &:focus {
      outline: 2px solid var(--arraysubs-fb-primary-color, #0073aa);
      outline-offset: 2px;
    }
  }
}

// Modal animation
@keyframes arraysubs-modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

// Responsive styles
@media (max-width: 480px) {
  .arraysubs-modal {
    &__container {
      margin: 16px;
    }

    &__header {
      padding: 16px 16px 0;
    }

    &__body {
      padding: 16px;
    }

    &__footer {
      padding: 16px;
      flex-direction: column-reverse;
      gap: 8px;
    }

    &__cancel-btn,
    &__confirm-btn {
      width: 100%;
      text-align: center;
    }
  }
}

// Wide modal variant (for plan switching, retention offers)
.arraysubs-modal__container--wide {
  max-width: 640px;
}

// Input field styles (for shipping address modal etc.)
.arraysubs-modal__input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid #8c8f94;
  border-radius: 4px;
  background-color: #fff;
  color: #1d2327;
  font-family: inherit;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;

  &:focus {
    border-color: var(--arraysubs-fb-primary-color, #0073aa);
    box-shadow: 0 0 0 1px var(--arraysubs-fb-primary-color, #0073aa);
    outline: none;
  }

  &::placeholder {
    color: #8c8f94;
  }
}

// =====================================================
// Shipping Address Form Layout
// =====================================================
.arraysubs-shipping-form {
  &__row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    min-width: 0;

    &:last-child {
      margin-bottom: 0;
    }
  }

  &__field {
    flex: 1;
    min-width: 0;

    &--full {
      flex: 0 0 100%;
    }

    .required {
      color: #d63638;
    }
  }

  @media (max-width: 600px) {
    &__row {
      flex-direction: column;
      gap: 8px;
    }
  }
}

// =====================================================
// Plan Switch Modal Styles
// =====================================================

.arraysubs-switch-loading,
.arraysubs-switch-empty,
.arraysubs-switch-error {
  text-align: center;
  padding: 20px;
  color: #666;
}

.arraysubs-switch-error {
  color: #d63638;
}

.arraysubs-switch-options__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.arraysubs-switch-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;

  &:hover {
    border-color: var(--arraysubs-fb-primary-color, #0073aa);
    background-color: #f9f9f9;
  }

  &--selected {
    border-color: var(--arraysubs-fb-primary-color, #0073aa);
    background-color: #f0f7fc;
  }

  &__info {
    flex: 1;
  }

  &__name {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
  }

  &__link {
    display: inline-block;
    font-size: 12px;
    color: var(--arraysubs-fb-primary-color, #0073aa);
    text-decoration: none;
    margin-bottom: 4px;

    &:hover {
      text-decoration: underline;
      color: var(--arraysubs-fb-primary-hover, #005a87);
    }
  }

  &__price {
    margin: 0;
    font-size: 14px;
    color: #50575e;
  }

  &__action {
    display: flex;
    align-items: center;
    gap: 12px;

    .button {
      background: var(--arraysubs-fb-primary-color, #0073aa) !important;
      border: 1px solid var(--arraysubs-fb-primary-color, #0073aa) !important;
      color: #fff !important;
      padding: 8px 16px;
      font-size: 13px;
      font-weight: 500;
      border-radius: 4px;
      cursor: pointer;
      transition: background-color 0.15s ease;
      line-height: 1.4;

      &:hover {
        background: var(--arraysubs-fb-primary-hover, #005a87) !important;
        border-color: var(--arraysubs-fb-primary-hover, #005a87) !important;
      }
    }
  }

  &__type {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    text-transform: uppercase;

    &--upgrade {
      background: #d4edda;
      color: #155724;
    }

    &--downgrade {
      background: #fff3cd;
      color: #856404;
    }

    &--crossgrade {
      background: #e2e3e5;
      color: #383d41;
    }
  }
}

.arraysubs-switch-preview {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;

  h4 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
  }

  &__table {
    width: 100%;
    border-collapse: collapse;

    td {
      padding: 8px 0;
      font-size: 14px;
    }

    td:last-child {
      text-align: right;
    }
  }

  &__total {
    border-top: 1px solid #e0e0e0;

    td {
      padding-top: 12px;
    }
  }

  &__refund {
    margin-top: 12px;
    padding: 12px;
    background: #d4edda;
    border-radius: 4px;
    font-size: 14px;
    color: #155724;
  }
}

// =====================================================
// Retention Offers Modal Styles
// =====================================================

.arraysubs-retention-loading {
  text-align: center;
  padding: 20px;
  color: #666;
}

.arraysubs-retention__intro {
  margin: 0 0 20px;
  font-size: 15px;
  color: #50575e;
}

.arraysubs-retention-offers__list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.arraysubs-retention-offer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  padding: 20px;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;

  &:hover {
    border-color: var(--arraysubs-fb-primary-color, #0073aa);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
  }

  &__content {
    flex: 1 1 220px;
    min-width: 0;
  }

  &__title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
  }

  &__description {
    margin: 0;
    font-size: 14px;
    color: #50575e;
    line-height: 1.5;
  }

  // Wraps under the content when a plan picker makes it too wide, and
  // never grows past the card.
  &__action {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
  }

  &__choice-label {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    font-size: 13px;
    color: #50575e;
  }

  &__target-product {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 50px;
    box-sizing: border-box;
    text-overflow: ellipsis;
  }

  &__accept-btn,
  &__contact-btn {
    padding: 10px 20px;
    font-weight: 500;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border-radius: 4px;
    border: 1px solid #46b450 !important;
    background: #46b450 !important;
    color: #fff !important;
    text-decoration: none !important;
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease,
      color 0.15s ease;

    &:hover,
    &:focus {
      background: #389e49 !important;
      border-color: #389e49 !important;
      color: #fff !important;
      text-decoration: none !important;
    }
  }
}

// No offers confirmation styling
.arraysubs-retention-no-offers {
  text-align: center;
  padding: 30px 20px;

  &__message {
    font-size: 16px;
    color: #50575e;
    margin: 0;
    line-height: 1.5;
  }
}

.arraysubs-retention__skip-btn,
.arraysubs-retention__confirm-cancel-btn {
  background: transparent !important;
  border: none !important;
  color: #666 !important;
  text-decoration: underline !important;
  cursor: pointer;
  margin-left: auto;
  margin-right: 0;
  padding: 8px 0;

  &:hover,
  &:focus {
    color: #333 !important;
    background: transparent !important;
    border: none !important;
  }
}
.arraysubs-retention__confirm-cancel-btn {
  order: -1;
  margin-right: auto;
  margin-left: 0;
}

.arraysubs-retention__keep-btn {
  margin-right: 10px;
  min-height: 42px;
  padding: 10px 20px;
  border-radius: 4px;
  border: 1px solid #2271b1 !important;
  background: #2271b1 !important;
  color: #fff !important;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;

  &:hover,
  &:focus {
    background: #135e96 !important;
    border-color: #135e96 !important;
    color: #fff !important;
  }
}

#arraysubs-cancel-modal {
  .arraysubs-modal__cancel-btn {
    background: #2271b1 !important;
    border: 1px solid #2271b1 !important;
    color: #fff !important;

    &:hover:not(:disabled) {
      background: #135e96 !important;
      border-color: #135e96 !important;
    }
  }

  .arraysubs-modal__confirm-btn {
    background: transparent !important;
    border: none !important;
    color: #666 !important;
    text-decoration: underline;
    order: -1;
    margin-right: auto;
    padding: 8px 0;

    &:hover:not(:disabled) {
      background: transparent !important;
      border: none !important;
      color: #333 !important;
    }
  }
}

#arraysubs-retention-modal {
  .arraysubs-retention__keep-btn {
    margin-right: 10px;
  }
}

// Responsive for plan switch and retention modals
@media (max-width: 640px) {
  .arraysubs-switch-option,
  .arraysubs-retention-offer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;

    &__action {
      margin-top: 12px;
      justify-content: center;
    }

    &__content {
      padding-right: 0;
    }
  }

  // Stacked: the card's gap already spaces the action, and the content's
  // row-layout basis must not become a fixed height.
  .arraysubs-retention-offer {
    &__content {
      flex-basis: auto;
    }

    &__action {
      margin-top: 0;
    }
  }
}

// Tabs Styles
.arraysubs-tabs {
  margin-top: 10px;

  &__header {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
  }

  &__nav {
    padding: 10px 15px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;

    &:hover {
      color: #333;
    }

    &.active {
      color: var(--arraysubs-fb-primary-color, #0073aa); // Primary color
      border-bottom-color: var(--arraysubs-fb-primary-color, #0073aa);
      font-weight: 600;
    }

    &:focus {
      outline: none;
    }
  }

  &__content {
    position: relative;
  }

  &__pane {
    display: none;
    animation: fadeIn 0.3s ease;

    &.active {
      display: block;
    }
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
