// Activity Audits Page
.arraysubs-audit-filters {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #ccd0d4;
  border-radius: 4px;

  &__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;

    button {
      line-height: 1 !important;
      min-height: 30px !important;
    }
  }

  &__select {
    min-width: 140px;
    max-width: 180px;
  }

  &__date {
    max-width: 150px;
  }

  &__search {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 160px;
    max-width: 280px;
    padding: 0 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;

    svg {
      color: #8c8f94;
      flex-shrink: 0;
    }

    input {
      flex: 1;
      border: none;
      outline: none;
      padding: 4px 0;
      background: transparent;
      font-size: 13px;
      line-height: 1.5;
    }
  }
}

.arraysubs-audit-table-wrap {
  background: #fff;
  border: 1px solid #ccd0d4;
  border-radius: 4px;
  overflow-x: auto;

  table{
    border: 0!important;
  }
}

.arraysubs-loading{
  padding: 5px;
}
.arraysubs-audit-table {
  margin: 0;

  &__col--date {
    width: 160px;
    white-space: nowrap;
  }

  &__col--author {
    width: 150px;
  }

  &__col--entity {
    width: 110px;
  }

  &__col--visibility {
    width: 110px;
  }

  &__col--sub {
    width: 260px;
  }

  &__col--desc {
    min-width: 200px;
  }

  tbody tr:hover .arraysubs-audit-activity__changes-link,
  tbody tr:focus-within .arraysubs-audit-activity__changes-link {
    opacity: 1;
    pointer-events: auto;
  }
}

.arraysubs-audit-activity {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

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

  &__changes-link {
    flex-shrink: 0;
    margin-top: 2px;
    color: #2271b1;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;

    &:hover,
    &:focus {
      color: #135e96;
      text-decoration: underline;
    }
  }
}

.arraysubs-audit-empty {
  padding: 40px 20px;
  text-align: center;
  color: #646970;
}

// Author badges
.arraysubs-audit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;

  &--system {
    background: #f0f0f1;
    color: #50575e;
  }

  &--admin {
    background: #e7f5fe;
    color: #0a4b78;
  }

  &--customer {
    background: #edf8ee;
    color: #1e4620;
  }

  &--gateway {
    background: #fef8ee;
    color: #6e3b00;
  }
}

// Entity badges
.arraysubs-audit-entity {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;

  &--subscription {
    background: #e7f5fe;
    color: #0a4b78;
  }

  &--product {
    background: #f3e8ff;
    color: #5b21b6;
  }

  &--member {
    background: #ecfdf3;
    color: #166534;
  }

  &--order {
    background: #fef2f2;
    color: #9f1239;
  }

  &--payment {
    background: #edf8ee;
    color: #1e4620;
  }

  &--renewal {
    background: #fef8ee;
    color: #6e3b00;
  }

  &--cancellation {
    background: #fde8e8;
    color: #991b1b;
  }

  &--other {
    background: #f0f0f1;
    color: #50575e;
  }

  &--coupon {
    background: #fef3c7;
    color: #92400e;
  }

  &--email {
    background: #ede9fe;
    color: #5b21b6;
  }

  &--settings {
    background: #e0f2fe;
    color: #075985;
  }
}

.arraysubs-audit-sub-link {
  font-weight: 500;
  text-decoration: none;
  color: #2271b1;

  &:hover {
    color: #135e96;
  }
}

.arraysubs-audit-ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.arraysubs-audit-ref-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid #dcdcde;
  border-radius: 999px;
  background: #f6f7f7;
  color: #1d2327;
  font-size: 12px;
  line-height: 1.3;
  text-decoration: none;
}

.arraysubs-audit-changes-modal {
  &__summary {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #f6f7f7;
    color: #1d2327;
    line-height: 1.5;
  }

  &__empty {
    margin: 0;
    color: #646970;
  }

  &__table-wrap {
    overflow-x: auto;
  }
}

.arraysubs-audit-changes-table {
  width: 100%;
  border-collapse: collapse;

  th,
  td {
    padding: 12px;
    border: 1px solid #dcdcde;
    text-align: left;
    vertical-align: top;
  }

  th {
    background: #f6f7f7;
    font-weight: 600;
  }

  td:first-child {
    width: 28%;
    font-weight: 600;
  }

  td:nth-child(2),
  td:nth-child(3) {
    width: 36%;
    white-space: pre-wrap;
    word-break: break-word;
  }
}

// Visibility badges
.arraysubs-audit-visibility {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;

  &--private {
    background: #f5f0ff;
    color: #6b21a8;
  }

  &--customer {
    background: #edf8ee;
    color: #1e4620;
  }
}

// Pagination
.arraysubs-audit-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;

  &__info {
    font-size: 13px;
    color: #50575e;
  }

  &__total {
    margin-left: 4px;
    color: #8c8f94;
  }

  .button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
}

// Logging Settings Popover
.arraysubs-audit-logging-settings {
  position: relative;

  &__popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 100;
    width: 320px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  }

  &__header {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f1;
    font-size: 13px;
  }

  &__loading {
    padding: 16px;
    margin: 0;
    color: #646970;
    font-size: 13px;
    text-align: center;
  }

  &__list {
    margin: 0;
    padding: 4px 0;
    list-style: none;
  }

  &__item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #f0f0f1;

    &:last-child {
      border-bottom: none;
    }
  }

  &__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;

    &:hover {
      background: #f6f7f7;
    }
  }

  &__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }

  &__name {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
  }

  &__help {
    font-size: 12px;
    color: #646970;
    line-height: 1.4;
  }

  &__toggle {
    flex-shrink: 0;
  }
}

// Pro-only message
.arraysubs-pro-only-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;

  &__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: #f0f0f1;
    color: #8c8f94;
  }

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

  &__description {
    max-width: 460px;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #646970;
  }
}

// Spin animation (shared)
.arraysubs-spin {
  animation: arraysubs-spin 1s linear infinite;
}

@keyframes arraysubs-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

// Scheduled-Job Logs
.arraysubs-job-filter-label {
  font-size: 13px;
  font-weight: 500;
  color: #50575e;
}

.arraysubs-job-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;

  &--success {
    background: #edf8ee;
    color: #1e4620;
  }

  &--failed {
    background: #fde8e8;
    color: #991b1b;
  }
}

.arraysubs-job-table {
  &__col--status {
    width: 100px;
  }

  &__col--hook {
    width: 200px;
  }

  &__col--detail {
    min-width: 240px;
    line-height: 1.5;
  }
}

.arraysubs-job-hook-label {
  display: block;
  font-weight: 500;
  color: #1d2327;
}

.arraysubs-job-sub-link {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
}

.arraysubs-job-row--failed {
  background-color: #fef2f2 !important;
}

// Responsive
@media (max-width: 782px) {
  .arraysubs-audit-filters__row {
    flex-direction: column;
    align-items: stretch;
  }

  .arraysubs-audit-filters__select,
  .arraysubs-audit-filters__date,
  .arraysubs-audit-filters__search {
    max-width: 100%;
  }

  .arraysubs-job-table__col--hook {
    width: auto;
    min-width: 140px;
  }
}
