/* SpecterQA Dashboard — style.css
 * Clean, modern UI with violet primary, system fonts, WCAG 2.1 AA contrast.
 */

/* ── Reset & Base ──────────────────────────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #1e1e2e;
    background: #f8f8fc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #6d28d9;
    text-decoration: none;
}

a:hover,
a:focus {
    color: #5b21b6;
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
}

code,
.cell-mono {
    font-family: ui-monospace, "SF Mono", Menlo, "Cascadia Code", monospace;
    font-size: 0.875em;
}

img {
    max-width: 100%;
    height: auto;
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* ── Header ────────────────────────────────────────────────────────────── */

.site-header {
    background: #1e1e2e;
    border-bottom: 3px solid #6d28d9;
    padding: 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.logo:hover,
.logo:focus {
    color: #c4b5fd;
    text-decoration: none;
}

.logo-icon {
    font-size: 1.5rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-tagline {
    color: #a5a5c0;
    font-size: 0.875rem;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.site-footer {
    background: #1e1e2e;
    color: #a5a5c0;
    text-align: center;
    padding: 1rem 1.5rem;
    font-size: 0.8125rem;
    margin-top: auto;
}

/* ── Page Header ───────────────────────────────────────────────────────── */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e1e2e;
}

/* ── Stats Grid ────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}

.stat-card-pass {
    border-left: 4px solid #16a34a;
}

.stat-card-fail {
    border-left: 4px solid #dc2626;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e1e2e;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8125rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ── Filter Bar ────────────────────────────────────────────────────────── */

.filter-bar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-input {
    flex: 1;
    min-width: 240px;
    padding: 0.625rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: #fff;
    color: #1e1e2e;
    transition: border-color 0.15s;
}

.filter-input:focus {
    outline: none;
    border-color: #6d28d9;
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.filter-input::placeholder {
    color: #9ca3af;
}

.filter-counts {
    font-size: 0.8125rem;
    color: #64748b;
}

/* ── Table ─────────────────────────────────────────────────────────────── */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.runs-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    overflow: hidden;
}

.runs-table thead {
    background: #f3f0ff;
}

.runs-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4c1d95;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e5e5f0;
    white-space: nowrap;
}

.runs-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f5;
    font-size: 0.875rem;
    vertical-align: middle;
}

.runs-table tbody tr:hover {
    background: #faf8ff;
}

.runs-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-nowrap {
    white-space: nowrap;
}

/* ── Badges ────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-pass {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-fail {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.badge-mode {
    background: #f3f0ff;
    color: #6d28d9;
    border: 1px solid #c4b5fd;
    font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn-secondary {
    background: #fff;
    color: #6d28d9;
    border-color: #6d28d9;
}

.btn-secondary:hover {
    background: #f3f0ff;
    color: #5b21b6;
}

/* ── Breadcrumb ────────────────────────────────────────────────────────── */

.breadcrumb {
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: #6d28d9;
}

/* ── Run Header (Detail Page) ──────────────────────────────────────────── */

.run-header {
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.run-header-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.run-title {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    color: #1e1e2e;
}

.run-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.meta-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-size: 0.9375rem;
    color: #1e1e2e;
}

/* ── Actions Bar ───────────────────────────────────────────────────────── */

.actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* ── Sections ──────────────────────────────────────────────────────────── */

.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e1e2e;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e5f0;
}

/* ── Steps ─────────────────────────────────────────────────────────────── */

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-card {
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    overflow: hidden;
}

.step-card.step-pass {
    border-left: 4px solid #16a34a;
}

.step-card.step-fail {
    border-left: 4px solid #dc2626;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f5;
    flex-wrap: wrap;
}

.step-number {
    font-weight: 700;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    font-size: 0.8125rem;
    font-weight: 700;
}

.step-icon-pass {
    background: #dcfce7;
    color: #166534;
}

.step-icon-fail {
    background: #fee2e2;
    color: #991b1b;
}

.step-id {
    color: #64748b;
    font-size: 0.8125rem;
}

.step-body {
    padding: 1rem;
}

.step-description {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
}

.step-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: #991b1b;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.step-notes {
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.step-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8125rem;
    color: #64748b;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.step-ux-observations {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.step-ux-observations ul {
    margin: 0.25rem 0 0 1.25rem;
    padding: 0;
}

.step-ux-observations li {
    margin-bottom: 0.25rem;
}

.step-actions-detail {
    margin-bottom: 0.75rem;
}

.step-actions-detail summary {
    cursor: pointer;
    font-size: 0.8125rem;
    color: #6d28d9;
    font-weight: 600;
}

.step-actions-detail summary:hover {
    color: #5b21b6;
}

.actions-list {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    font-size: 0.8125rem;
    color: #475569;
}

.actions-list li {
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.step-findings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.finding-inline {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    border-left: 3px solid;
}

.finding-severity {
    font-weight: 700;
    margin-right: 0.25rem;
}

.finding-category {
    color: #64748b;
    margin-right: 0.5rem;
}

/* ── Screenshots ───────────────────────────────────────────────────────── */

.step-screenshots {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.screenshot-thumb {
    display: block;
    width: 240px;
    border: 1px solid #e5e5f0;
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.screenshot-thumb:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.screenshot-thumb img {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Findings Section ──────────────────────────────────────────────────── */

.findings-group {
    margin-bottom: 1.5rem;
}

.findings-severity-heading {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding: 0.25rem 0;
}

.findings-severity-heading.severity-block,
.findings-severity-heading.severity-critical {
    color: #991b1b;
}

.findings-severity-heading.severity-high {
    color: #c2410c;
}

.findings-severity-heading.severity-medium {
    color: #a16207;
}

.findings-severity-heading.severity-low {
    color: #4338ca;
}

.finding-card {
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid;
}

.finding-card.severity-block,
.finding-card.severity-critical {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.finding-card.severity-high {
    border-left-color: #ea580c;
    background: #fff7ed;
}

.finding-card.severity-medium {
    border-left-color: #ca8a04;
    background: #fefce8;
}

.finding-card.severity-low {
    border-left-color: #6d28d9;
    background: #faf8ff;
}

.finding-inline.severity-block,
.finding-inline.severity-critical {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.finding-inline.severity-high {
    border-left-color: #ea580c;
    background: #fff7ed;
}

.finding-inline.severity-medium {
    border-left-color: #ca8a04;
    background: #fefce8;
}

.finding-inline.severity-low {
    border-left-color: #6d28d9;
    background: #faf8ff;
}

.finding-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.finding-category-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f3f0ff;
    color: #6d28d9;
    border-radius: 3px;
    text-transform: lowercase;
}

.finding-step {
    font-size: 0.75rem;
    color: #64748b;
}

.finding-description {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.finding-evidence {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: #64748b;
}

/* ── Cost Table ────────────────────────────────────────────────────────── */

.cost-summary {
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
    padding: 1.25rem;
}

.cost-overview {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    font-size: 0.9375rem;
    margin-bottom: 1rem;
    color: #475569;
}

.cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.cost-table thead {
    background: #f3f0ff;
}

.cost-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4c1d95;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e5f0;
}

.cost-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f5;
}

.cost-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Empty State ───────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: #fff;
    border: 1px solid #e5e5f0;
    border-radius: 8px;
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.empty-state code {
    background: #f3f0ff;
    padding: 0.15em 0.5em;
    border-radius: 3px;
    color: #6d28d9;
}

.empty-state-inline {
    color: #64748b;
    font-style: italic;
}

/* ── Error Page ────────────────────────────────────────────────────────── */

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 2rem;
    color: #991b1b;
    margin-bottom: 0.75rem;
}

.error-page p {
    font-size: 1.125rem;
    color: #475569;
    margin-bottom: 1.5rem;
}

/* ── Lightbox ──────────────────────────────────────────────────────────── */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.lightbox-close:hover {
    color: #c4b5fd;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .run-meta-grid {
        grid-template-columns: 1fr;
    }

    .runs-table th,
    .runs-table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }

    .screenshot-thumb {
        width: 180px;
    }

    .cost-overview {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-tagline {
        display: none;
    }

    .step-stats {
        flex-direction: column;
        gap: 0.25rem;
    }
}
