/**
 * Members Access Styles
 *
 * Styles for the members access admin pages
 * NOTE: Tabs are auto-generated via DefaultPageLayout submenu links
 *
 * @package ArraySubs
 */

.arraysubs-members-access {
  // Section styles
  &__section {
    margin-bottom: 30px;

    &:last-child {
      margin-bottom: 0;
    }
  }
  .arraysubs-rule-builder__section-header {
    border-top-right-radius: 4px;
    border-top-left-radius: 4px;
  }
  .arraysubs-rule-builder__section-content {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
  }
  &__section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-top-right-radius: 4px;
    border-top-left-radius: 4px;
    border-bottom: 1px solid #e0e0e0;

    h3 {
      margin: 0 0 5px 0;
      font-size: 15px;
      font-weight: 600;
    }

    p {
      margin: 0;
      color: #666;
      font-size: 13px;
    }

    .button {
      display: flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
    }
  }

  &__section-info {
    flex: 1;
  }

  // Empty state
  &__empty-state {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 4px;

    p {
      margin: 0 0 15px 0;
      color: #666;
    }

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

  // Rules List
  &__rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  // Individual Rule
  &__rule {
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #fff;
    transition: box-shadow 0.2s ease;

    &:hover {
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    &--disabled {
      background: #f9f9f9;
      opacity: 0.7;

      .arraysubs-members-access__rule-name {
        color: #999;
      }
    }
  }

  // Rule Header
  &__rule-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f6f7f7;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s ease;

    &:hover {
      background: #f0f0f1;
    }
  }

  &__rule-drag {
    color: #999;
    cursor: grab;

    &:active {
      cursor: grabbing;
    }
  }

  &__rule-toggle {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;

    .text-success {
      color: #46b450;
    }

    .text-muted {
      color: #999;
    }
  }

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

  &__rule-name {
    font-weight: 500;
    color: #1d2327;
    font-size: 14px;
  }

  &__rule-summary {
    font-size: 12px;
    color: #666;

    code {
      font-size: 11px;
      background: #e0e0e0;
      padding: 1px 4px;
      border-radius: 2px;
    }
  }

  &__rule-actions {
    display: flex;
    align-items: center;
    gap: 8px;

    .button-small {
      padding: 4px 8px;
      min-height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .button-link-delete {
      color: #d63638;

      &:hover {
        color: #a00;
        background: #fee;
      }
    }
  }

  &__rule-priority {
    font-size: 11px;
    color: #888;
    padding: 2px 8px;
    background: #f0f0f1;
    border-radius: 3px;
  }

  // Rule Body (expanded content)
  &__rule-body {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  // Form Fields
  &__field {
    display: flex;
    flex-direction: column;
    gap: 5px;

    label {
      font-weight: 500;
      color: #1d2327;
      font-size: 13px;
    }

    input[type="text"],
    input[type="number"],
    input[type="url"],
    select,
    textarea {
      max-width: 500px;

      &.small-text {
        max-width: 80px;
      }

      &.regular-text {
        max-width: 350px;
      }

      &.large-text {
        max-width: 600px;
      }
    }

    .description {
      margin: 3px 0 0 0;
      font-size: 12px;
      color: #666;
      font-style: italic;
    }

    &--small {
      max-width: 150px;
    }

    &--wide {
      flex: 1;
    }
  }

  &__field-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
  }

  // Multi-select
  &__multi-select {
    min-height: 120px;
    max-width: 400px;
    width: 100%;

    option {
      padding: 5px 8px;
    }
  }

  // Conditions placeholder
  &__conditions-placeholder {
    padding: 15px;
    background: #f9f9f9;
    border: 1px dashed #ccc;
    border-radius: 4px;
    color: #666;
    font-style: italic;

    p {
      margin: 0;
    }
  }

  // Actions footer
  &__actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;

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

  // Info box — step-by-step explanatory panel
  &__info-box {
    background: #f0f6fc;
    border: 1px solid #c3d9ed;
    border-radius: 4px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #1d2327;

    h4 {
      margin: 0 0 10px 0;
      font-size: 14px;
      font-weight: 600;
    }

    ol {
      margin: 0 0 8px 18px;
      padding: 0;

      li {
        margin-bottom: 6px;
        line-height: 1.5;
      }
    }

    ul {
      margin: 0 0 8px 18px;
      padding: 0;
      list-style: disc;

      li {
        margin-bottom: 4px;
        line-height: 1.4;
      }
    }
  }

  &__info-note {
    margin: 8px 0 0 0;
    padding: 8px 12px;
    background: #fff8e5;
    border-left: 3px solid #dba617;
    border-radius: 2px;
    font-size: 12px;
    line-height: 1.5;
  }
}

// Responsive adjustments
@media (max-width: 782px) {
  .arraysubs-members-access {
    &__section-header {
      flex-direction: column;
      align-items: stretch;
    }

    &__rule-header {
      flex-wrap: wrap;
    }

    &__rule-title {
      order: 3;
      width: 100%;
      margin-top: 10px;
    }

    &__rule-actions {
      margin-left: auto;
    }

    &__field-row {
      flex-direction: column;
      gap: 15px;
    }

    &__field {
      input[type="text"],
      input[type="number"],
      input[type="url"],
      select,
      textarea {
        max-width: 100%;
      }
    }
  }
}

// Rule Field Styles (used in rule builder)
.arraysubs-rule-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;

  &__label {
    font-weight: 500;
    color: #1d2327;
    font-size: 13px;
  }

  &__input {
    padding: 6px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    max-width: 400px;

    &:focus {
      border-color: #2271b1;
      outline: none;
      box-shadow: 0 0 0 1px #2271b1;
    }

    &--small {
      max-width: 100px;
    }
  }

  &__select {
    padding: 6px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    max-width: 300px;
    background: #fff;
    cursor: pointer;

    &:focus {
      border-color: #2271b1;
      outline: none;
      box-shadow: 0 0 0 1px #2271b1;
    }
  }

  &__multi-select {
    min-height: 100px;
    max-width: 300px;
    width: 100%;
    padding: 4px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;

    option {
      padding: 4px 8px;
    }

    &:focus {
      border-color: #2271b1;
      outline: none;
    }
  }

  &__textarea {
    padding: 8px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    max-width: 500px;
    resize: vertical;
    font-family: inherit;

    &:focus {
      border-color: #2271b1;
      outline: none;
      box-shadow: 0 0 0 1px #2271b1;
    }
  }

  &__help {
    margin: 0;
    font-size: 12px;
    color: #666;
    font-style: italic;
  }

  &__toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;

    input {
      opacity: 0;
      width: 0;
      height: 0;

      &:checked + .arraysubs-rule-field__toggle-slider {
        background-color: #2271b1;

        &::before {
          transform: translateX(16px);
        }
      }

      &:disabled + .arraysubs-rule-field__toggle-slider {
        opacity: 0.5;
        cursor: not-allowed;
      }
    }
  }

  &__toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.2s;
    border-radius: 20px;

    &::before {
      position: absolute;
      content: "";
      height: 14px;
      width: 14px;
      left: 3px;
      bottom: 3px;
      background-color: white;
      transition: 0.2s;
      border-radius: 50%;
    }
  }

  &--inline {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;

    .arraysubs-rule-field__help {
      flex-basis: 100%;
      margin-left: 0;
    }
  }

  &--wide {
    .arraysubs-rule-field__input,
    .arraysubs-rule-field__select,
    .arraysubs-rule-field__textarea {
      max-width: none;
    }
  }

  &--small {
    max-width: 150px;
  }

  // Input group for prefix/suffix (currency symbol, percent sign)
  &__input-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    max-width: 200px;
    overflow: hidden;

    .arraysubs-rule-field__input {
      border: none;
      border-radius: 0;
      box-shadow: none;
      max-width: none;
      flex: 1;

      &:focus {
        box-shadow: none;
      }
    }
  }

  &__input-prefix,
  &__input-suffix {
    padding: 6px 10px;
    background: #f6f7f7;
    color: #666;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    border: none;
  }

  &__input-prefix {
    border-right: 1px solid #c3c4c7;
  }

  &__input-suffix {
    border-left: 1px solid #c3c4c7;
  }

  // Divider for sub-sections within a rule (e.g. "Exclusions")
  &__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 5px;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;

    &::before,
    &::after {
      content: "";
      flex: 1;
      height: 1px;
      background: #ddd;
    }
  }

  // Footnote — explanatory block within rule action section
  &__footnote {
    margin-top: 10px;
    padding: 12px 16px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
    color: #555;
    line-height: 1.5;

    strong {
      color: #1d2327;
      font-size: 12px;
    }

    ul {
      margin: 6px 0 0 16px;
      padding: 0;
      list-style: disc;

      li {
        margin-bottom: 4px;
      }
    }
  }
}

.arraysubs-rule-field-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

// Global Settings section (legacy - can be removed if not used elsewhere)
.arraysubs-members-access__global-settings {
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border: 1px solid #e2e4e7;
  border-radius: 6px;

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

  &-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
  }
}

// Info box
.arraysubs-members-access__info-box {
  margin-bottom: 20px;
  padding: 15px;
  background: #f0f6fc;
  border: 1px solid #c3c4c7;
  border-left: 4px solid #2271b1;
  border-radius: 4px;

  p {
    margin: 0;
    font-size: 13px;
    color: #1d2327;

    strong {
      color: #1d2327;
    }
  }
}

// Download Files UI
.arraysubs-download-files {
  max-width: 600px;
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;

    .arraysubs-rule-field__label {
      margin-bottom: 0;
    }

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

  &__empty {
    padding: 20px;
    text-align: center;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 4px;
    color: #666;
    font-size: 13px;
  }

  &__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  &__item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition:
      box-shadow 0.2s ease,
      border-color 0.2s ease;

    &--dragging {
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      border-color: #2271b1;
      background: #fff;
    }
  }

  &__item-drag {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    padding: 6px 0;
    color: #999;
    cursor: grab;

    &:hover {
      color: #666;
    }

    &:active {
      cursor: grabbing;
    }
  }

  &__item-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    border-radius: 4px;
    color: #666;
  }

  &__item-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;

    .arraysubs-rule-field__input {
      width: 100%;
    }
  }

  &__file-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  &__file-info {
    flex: 1;
    min-width: 0;
  }

  &__filename {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #e8f0fe;
    border-radius: 4px;
    font-size: 13px;
    color: #1a73e8;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    svg {
      flex-shrink: 0;
    }
  }

  &__no-file {
    color: #999;
    font-size: 13px;
    font-style: italic;
  }

  &__item-actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    align-items: flex-start;
  }

  &__item-action-btn {
    flex-shrink: 0;
    background: none;
    border: 1px solid #ddd;
    padding: 6px;
    cursor: pointer;
    color: #2271b1;
    border-radius: 4px;
    transition:
      background 0.15s ease,
      border-color 0.15s ease,
      color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;

    &:hover {
      background: #f0f6fc;
      border-color: #2271b1;
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      pointer-events: none;
    }

    &--delete {
      color: #a00;

      &:hover {
        background: #fee;
        border-color: #d63638;
        color: #d63638;
      }
    }
  }
}

// Download Action Info
.arraysubs-download-action-info {
  padding: 15px;
  background: #f0f6fc;
  border-radius: 4px;

  p {
    margin: 0;
    font-size: 13px;
    color: #1d2327;
  }
}
