@layer pages {
  #scan-issues-index {
    .issues-filter {
      margin-bottom: var(--space-8);
    }
  }

  /* Result tabs run full width and their rule is the top rule of the issue list */
  .issues > .section-header {
    display: block;
    margin-bottom: 0;

    .tabs__list {
      margin-bottom: 0;
    }
  }

  .issues > .section-header + .issues__list {
    border-top: 0;
  }

  #scan-issues-show {
    .page-header {
      margin-bottom: var(--space-4);
      padding-bottom: 0;
      border-bottom: 0;
    }

    .issue__info {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: var(--space-1) var(--space-4);
      padding-bottom: var(--space-6);
      border-bottom: 1px solid var(--color-border);
    }

    .issue-controls {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-3);
    }
  }

  /* ===========================================
     Issue Badges
     =========================================== */

  .issue-category,
  .issue-wcag {
    display: inline-flex;
    padding: 0.125rem var(--space-2);
    font-size: 0.8125rem;
    font-weight: var(--font-medium);
    color: var(--color-text);
    border: 1px solid var(--color-gray-400);
    border-radius: var(--radius-sm);
  }

  /* ===========================================
     Issue Details and Fix Sections
     =========================================== */

  .issue-details,
  .issue-fix {
    margin-bottom: var(--space-8);

    h2 {
      margin-bottom: var(--space-4);
      padding-bottom: var(--space-3);
      font-size: var(--text-xl);
      font-weight: var(--font-semibold);
      border-bottom: 1px solid var(--color-border);
    }
  }

  .issue-section {
    margin-bottom: var(--space-6);

    h3 {
      margin-bottom: var(--space-2);
      font-size: var(--text-base);
      font-weight: var(--font-semibold);
      color: var(--color-text-muted);
    }

    p {
      line-height: var(--leading-relaxed);
    }
  }

  /* ===========================================
     Suggested fix (from the checker)
     =========================================== */

  .suggestion-card {
    margin-bottom: var(--space-6);

    h3 {
      margin-bottom: var(--space-2);
      font-size: var(--text-base);
      font-weight: var(--font-semibold);
    }

    p {
      margin: 0;
      line-height: var(--leading-relaxed);
    }
  }

  /* ===========================================
     AI Suggestion Card
     =========================================== */

  .ai-suggestion-card {
    overflow: hidden;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .ai-suggestion-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border);

    h3 {
      margin: 0;
      font-size: var(--text-base);
      font-weight: var(--font-semibold);
    }
  }

  .ai-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.125rem var(--space-2);
    font-size: 0.8125rem;
    font-weight: var(--font-medium);
    color: var(--color-text);
    border: 1px solid var(--color-gray-400);
    border-radius: var(--radius-sm);
  }

  .ai-suggestion-card__content {
    padding: var(--space-5);

    p {
      margin-bottom: var(--space-4);
      line-height: var(--leading-relaxed);

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

    h3, h4, h5, h6 {
      margin-top: var(--space-6);
      margin-bottom: var(--space-3);

      &:first-child {
        margin-top: 0;
      }
    }

    ul, ol {
      margin-bottom: var(--space-4);
      padding-left: var(--space-6);
    }

    li {
      margin-bottom: var(--space-2);
      line-height: var(--leading-relaxed);
    }

    .code-sample {
      margin: var(--space-4) 0;
    }

    code:not(.code-sample code) {
      padding: 0.125em 0.375em;
      font-family: var(--font-mono);
      font-size: 0.9em;
      color: var(--color-text);
      background-color: var(--color-gray-100);
      border-radius: var(--radius-sm);
    }

    strong {
      font-weight: var(--font-semibold);
    }
  }

  /* ===========================================
     AI Suggestion Prompt (Generate Button)
     =========================================== */

  .ai-suggestion-prompt {
    p {
      margin-bottom: var(--space-3);
      color: var(--color-text-muted);

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

    a {
      color: var(--color-text);
      font-weight: var(--font-semibold);
    }
  }

  /* ===========================================
     WCAG Reference Section
     =========================================== */

  .wcag-reference {
    margin-bottom: var(--space-8);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);

    h2 {
      margin-bottom: var(--space-2);
      font-size: var(--text-lg);
      font-weight: var(--font-semibold);
    }

    p {
      margin-bottom: var(--space-2);

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

    a {
      color: var(--color-link);
      text-decoration: underline;
      text-underline-offset: 0.2em;
    }
  }

  /* ===========================================
     Issue Navigation
     =========================================== */

  .issue-nav {
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
  }

  /* ===========================================
     Site Issues Index (bulk actions)
     =========================================== */

  .issue-card--selectable {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .issue-card__checkbox {
    flex-shrink: 0;
    padding-top: 0.125rem;

    input[type="checkbox"] {
      width: 1.125rem;
      height: 1.125rem;
      cursor: pointer;
    }
  }

  .issue-card__content {
    flex: 1;
    min-width: 0;
  }

  .issue-card__page {
    margin-top: var(--space-1);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);

    a {
      color: var(--color-text);
      text-decoration: underline;
      text-underline-offset: 0.2em;
    }

    .inline-code {
      margin-left: var(--space-2);
    }
  }

  .issue-card__page-label {
    font-weight: var(--font-medium);
  }

  @media (max-width: 768px) {
    .ai-suggestion-card__header {
      flex-direction: column;
      align-items: flex-start;
    }

    .ai-suggestion-card__content {
      padding: var(--space-4);
    }

    .bulk-actions-bar {
      flex-wrap: wrap;
      gap: var(--space-3);
    }

    .bulk-actions-controls {
      width: 100%;
      margin-left: 0;
    }

    .bulk-select {
      flex: 1;
      min-width: 0;
    }
  }
}
