/**
 * ValidationPanel Styles
 */

@import '~@capillarytech/cap-ui-library/styles/_variables.scss';

.validation-panel {
  border: 1px solid $CAP_COLOR_16;
  border-radius: $CAP_SPACE_06;
  background: $CAP_WHITE;

  &--loading {
    padding: $CAP_SPACE_16;
    text-align: center;
  }

  &--clean {
    padding: $CAP_SPACE_16;
    text-align: center;
    background: #f6ffed;
    border-color: #b7eb8f;
  }

  &__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: $CAP_SPACE_08;
    color: #666;
    font-size: 14px;
  }

  &__clean {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: $CAP_SPACE_08;
    color: #52c41a;
    font-size: 14px;
    font-weight: $FONT_WEIGHT_MEDIUM;
  }

  &__summary {
    display: flex;
    gap: $CAP_SPACE_16;
    padding: $CAP_SPACE_12 $CAP_SPACE_16;
    background: $CAP_G21;
    border-bottom: 1px solid $CAP_COLOR_16;
    border-radius: $CAP_SPACE_06 $CAP_SPACE_06 0 0;
  }

  &__summary-item {
    display: flex;
    align-items: center;
    gap: $CAP_SPACE_04;
    font-size: $CAP_SPACE_12;
    color: #666;

    &--security {
      color: #ff4d4f;
      font-weight: $FONT_WEIGHT_MEDIUM;
    }

    span:first-of-type {
      font-weight: 600;
      margin-left: $CAP_SPACE_02;
    }
  }

  &__collapse {
    .ant-collapse-item {
      border: none;

      &:last-child {
        border-radius: 0 0 $CAP_SPACE_06 $CAP_SPACE_06;
      }
    }

    .ant-collapse-header {
      padding: 12px 16px !important;
      align-items: center !important;
    }

    .ant-collapse-content {
      border-top: 1px solid #f0f0f0;
    }

    .ant-collapse-content-box {
      padding: 0;
    }
  }

  &__panel {
    &--error {
      .ant-collapse-header {
        background: #fff2f0;
        border-left: 3px solid #ff4d4f;
      }
    }

    &--warning {
      .ant-collapse-header {
        background: #fffbe6;
        border-left: 3px solid #faad14;
      }
    }

    &--info {
      .ant-collapse-header {
        background: #e6f7ff;
        border-left: 3px solid #1890ff;
      }
    }
  }

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  &__title {
    display: flex;
    align-items: center;
    gap: $CAP_SPACE_08;
    font-weight: $FONT_WEIGHT_MEDIUM;
  }

  &__issues {
    max-height: 300px;
    overflow-y: auto;
  }

  &__sanitization {
    border-top: 1px solid $CAP_COLOR_16;
    background: #f9f9f9;
  }

  &__sanitization-header {
    display: flex;
    align-items: center;
    gap: $CAP_SPACE_08;
    padding: $CAP_SPACE_12 $CAP_SPACE_16;
    font-weight: $FONT_WEIGHT_MEDIUM;
    color: #666;
    font-size: 13px;
  }

  &__sanitization-list {
    padding: 0 $CAP_SPACE_16 $CAP_SPACE_12;
  }

  &__sanitization-item {
    padding: $CAP_SPACE_04 0;
    font-size: $CAP_SPACE_12;
    color: #8c8c8c;
  }
}

.validation-issue {
  display: flex;
  gap: $CAP_SPACE_12;
  padding: $CAP_SPACE_12 $CAP_SPACE_16;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s;

  &:hover {
    background: $CAP_G21;
  }

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

  &--error {
    border-left: 2px solid #ff4d4f;
  }

  &--warning {
    border-left: 2px solid #faad14;
  }

  &--info {
    border-left: 2px solid #1890ff;
  }

  &__icon {
    flex-shrink: 0;
    margin-top: 2px;

    &--error {
      color: #ff4d4f;
    }

    &--info {
      color: #1890ff;
    }

    &--security {
      color: #ff4d4f;
    }
  }

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

  &__message {
    font-size: 13px;
    line-height: 1.4;
    color: #262626;
    margin-bottom: $CAP_SPACE_04;
    word-break: break-word;
  }

  &__meta {
    display: flex;
    flex-wrap: wrap;
    gap: $CAP_SPACE_08;
    font-size: 11px;
    color: #8c8c8c;
  }

  &__location {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
  }

  &__rule {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #e6f7ff;
    padding: 2px 6px;
    border-radius: 3px;
    color: #1890ff;
  }

  &__source {
    display: flex;
    align-items: center;
    gap: $CAP_SPACE_04;
    background: #f0f0f0;
    padding: $CAP_SPACE_02 $CAP_SPACE_06;
    border-radius: 3px;
  }
}

// Dark theme support for editor integration
.html-editor-content .validation-panel {
  border-color: #424242;
  background: #2d2d2d;
  color: #e0e0e0;

  &__summary {
    background: #3d3d3d;
    border-color: #424242;
  }

  .validation-issue {
    border-color: #424242;
    color: #e0e0e0;

    &:hover {
      background: #3d3d3d;
    }

    &__message {
      color: #e0e0e0;
    }

    &__location {
      background: #424242;
      color: #e0e0e0;
    }

    &__rule {
      background: #1f1f1f;
      color: #69c0ff;
    }

    &__source {
      background: #424242;
      color: #e0e0e0;
    }
  }

  .ant-collapse-header {
    background: #3d3d3d !important;
    color: #e0e0e0 !important;
  }

  .ant-collapse-content {
    background: #2d2d2d;
    border-color: #424242;
  }
}

// Responsive design
@media (max-width: 768px) {
  .validation-panel {
    &__summary {
      flex-direction: column;
      gap: 8px;
    }

    &__issues {
      max-height: 200px;
    }
  }

  .validation-issue {
    padding: 8px 12px;

    &__meta {
      flex-direction: column;
      gap: 4px;
    }
  }
}