/**
 * Subscription Notes Panel Styles
 *
 * @package ArraySubs
 */

// Notes Panel Container
.arraysubs-notes-panel {
  background: #fff;
  border-radius: 4px;

  // Compact mode - no background when wrapped in detail-card
  &--compact {
    background: transparent;

    .arraysubs-notes-panel__body {
      padding: 0;
    }
  }

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #dcdcde;
    transition: background-color 0.15s ease;

    &:hover {
      background-color: #f6f7f7;
    }
  }

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

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

    svg {
      color: #2271b1;
    }
  }

  &__count {
    font-size: 13px;
    color: #646970;
    font-weight: normal;
  }

  &__toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #50575e;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
      color: #2271b1;
    }
  }

  &__body {
    padding: 16px;
  }

  &__error {
    background: #fcf0f1;
    border-left: 4px solid #d63638;
    padding: 12px;
    margin-bottom: 16px;
    color: #8a2424;
    font-size: 13px;
  }
}

// Notes List
.arraysubs-notes-list {
  max-height: 400px;
  overflow-y: auto;
  border-bottom: 2px solid #acacac;
  border-left: 0;
  border-top: 1px solid #acacac;
  border-right: 1px solid #acacac;
  margin-bottom: 16px;

  &--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    background: #f6f7f7;

    p {
      margin: 0;
      color: #646970;
      font-style: italic;
    }
  }

  &--loading {
    background: #f6f7f7;
  }

  &__skeleton {
    padding: 12px;
  }

  &__skeleton-item {
    padding: 12px 0;
    border-bottom: 1px solid #e2e4e7;

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

  .skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #e2e4e7 25%, #f0f0f0 50%, #e2e4e7 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite;
    border-radius: 2px;
    margin-bottom: 8px;

    &--long {
      width: 100%;
    }

    &--short {
      width: 40%;
    }
  }
}

@keyframes skeleton-pulse {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

// Single Note Item
.arraysubs-note-item {
  padding: 12px;
  border-bottom: 1px solid #e2e4e7;
  position: relative;

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

  &--system {
    background-color: #f0f6fc;
  }

  &--private {
    border-left: 3px solid #dba617;
  }

  &--customer {
    border-left: 3px solid #00a32a;
  }

  &__content {
    font-size: 13px;
    line-height: 1.6;
    color: #1d2327;
    margin-bottom: 8px;
    word-wrap: break-word;

    p {
      margin: 0 0 8px 0;

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

    a {
      color: #2271b1;
      text-decoration: underline;

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

    ul,
    ol {
      margin: 8px 0;
      padding-left: 20px;
    }
  }

  &__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
  }

  &__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  &__date {
    font-size: 11px;
    color: #646970;
  }

  &__author,
  &__author-name {
    font-size: 11px;
    color: #646970;
  }

  &__author-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;

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

    &--system {
      background: #d5e5fa;
      color: #1d4f91;
    }

    &--admin {
      background: #e8e2ff;
      color: #5b35b0;
    }

    &--customer {
      background: #d1f3d9;
      color: #006908;
    }

    &--gateway {
      background: #e7f3ff;
      color: #0a66c2;
    }
  }

  &__type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;

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

    &--system {
      background: #d5e5fa;
      color: #2271b1;
    }

    &--private {
      background: #fcf0c3;
      color: #826200;
    }

    &--customer {
      background: #d1f3d9;
      color: #006908;
    }
  }

  &__delete {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #646970;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
    transition: all 0.15s ease;

    &:hover {
      background: #fcf0f1;
      color: #d63638;
    }

    span {
      @media (max-width: 600px) {
        display: none;
      }
    }
  }

  &:hover &__delete {
    opacity: 1;
  }
}

// Add Note Form
.arraysubs-add-note-form {
  background: #f6f7f7;
  padding: 16px;
  border-radius: 4px;
  border: 1px solid #dcdcde;

  &__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

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

  &__help {
    color: #646970;
    cursor: help;
    display: flex;
    align-items: center;

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

  &__editor-wrapper {
    margin-bottom: 12px;

    // TinyMCE container styling
    .tox.tox-tinymce {
      border-radius: 4px;
      border-color: #8c8f94;
    }

    .tox .tox-toolbar__primary {
      background: #f6f7f7;
    }

    // Fallback textarea when TinyMCE not available
    textarea.arraysubs-add-note-form__editor {
      width: 100%;
      min-height: 100px;
      padding: 8px 12px;
      border: 1px solid #8c8f94;
      border-radius: 4px;
      font-size: 13px;
      font-family: inherit;
      resize: vertical;

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

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

  &__type {
    min-width: 150px;
    padding: 6px 8px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    font-size: 13px;
    background: #fff;

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

  .button {
    min-width: 80px;
  }
}
