/* ==========================================================================
   ClearPath Scanner — Login + Dashboard pages
   Reuses design tokens + form styles from scan.css; adds layout for the
   auth card and dashboard sections.
   ========================================================================== */

/* ----------------------------------------------------------------------------
   Auth (login) page
   ---------------------------------------------------------------------------- */
.auth-page {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 80px 16px 0;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.auth-container {
    width: 100%;
    max-width: 460px;
    padding: 48px 24px 96px;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .auth-page {
        padding: 72px 12px 0;
    }
    .auth-container {
        padding: 32px 12px 48px;
    }
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: var(--shadow-card);
}

.auth-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-submit {
    margin-top: 4px;
}

.auth-footer-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: 24px;
}
.auth-footer-link a {
    color: var(--accent-cyan);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* URL-param error banner (e.g., invalid/expired link redirected here) */
.auth-url-error {
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid var(--status-error);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    color: var(--status-error);
    line-height: 1.5;
}

/* "Check your email" success state */
.auth-sent {
    text-align: center;
    padding: 12px 0;
}
.auth-sent-icon {
    font-size: 36px;
    color: var(--accent-cyan);
    margin-bottom: 12px;
}
.auth-sent-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.auth-sent-detail {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 16px;
}
.auth-sent-fineprint {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}
.auth-sent-fineprint a {
    color: var(--accent-cyan);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Inline error state */
.auth-error {
    text-align: center;
    padding: 8px 0;
}
.auth-error p {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--status-error);
    margin-bottom: 16px;
}

/* ----------------------------------------------------------------------------
   Dashboard page
   Layered padding so content NEVER reads flush against the viewport edge:
     - .dashboard-page wrapper has its own horizontal padding as a safety net
     - .dashboard-container applies its own padding inside max-width
     - box-sizing: border-box on both so max-width includes padding
   Generous on desktop, scales down on mobile. The title is bold/large enough
   that anything under ~32px feels cramped against the viewport edge.
   ---------------------------------------------------------------------------- */
.dashboard-page {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 80px 24px 0;        /* top: room for fixed site-header; sides: safety net */
    box-sizing: border-box;
}

.dashboard-container {
    max-width: 880px;
    width: 100%;
    margin: 0 auto;
    padding: 56px 32px 96px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .dashboard-page {
        padding: 80px 16px 0;
    }
    .dashboard-container {
        padding: 40px 16px 64px;
    }
}

@media (max-width: 480px) {
    .dashboard-page {
        padding: 72px 12px 0;
    }
    .dashboard-container {
        padding: 24px 12px 48px;
    }
}

.dashboard-content {
    width: 100%;
    box-sizing: border-box;
}

.dashboard-loading {
    text-align: center;
    padding: 96px 0;
}
.dashboard-loading p {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    margin-top: 16px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

/* Arcade Gamer for the page title — retro accent matching the site's "Sign Up"
   button styling on the homepage. CLAUDE.md mandates uppercase + letter-spacing
   when using Arcade Gamer to force the correct 'I' glyph (lowercase 'i' renders
   with a dot in this font, which is wrong).
   The @font-face is declared inline in scan-dashboard.html / scan-repo.html so
   this rule will pick it up there. Falls back to monospace on other pages. */
.dashboard-title {
    font-family: 'Arcade Gamer', monospace;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.dashboard-greeting {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.dashboard-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}

.dashboard-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}

.dashboard-card-body {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.dashboard-card-body:last-child { margin-bottom: 0; }

.dashboard-empty {
    color: var(--text-tertiary);
    font-style: italic;
}

/* Subscription state styles */
.subscription-state {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.subscription-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid;
}
.subscription-badge.active {
    background: rgba(124, 179, 66, 0.12);
    color: var(--status-complete);
    border-color: var(--status-complete);
}
.subscription-badge.none {
    background: rgba(107, 107, 107, 0.12);
    color: var(--text-tertiary);
    border-color: var(--border-hover);
}
.subscription-badge.past-due,
.subscription-badge.canceled {
    background: rgba(217, 119, 6, 0.12);
    color: var(--status-warning, var(--status-in-progress));
    border-color: var(--status-warning, var(--status-in-progress));
}

.scans-remaining {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.scans-remaining strong {
    font-size: 1.125rem;
}

.subscription-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* ----------------------------------------------------------------------------
   Recent scans list on the dashboard
   ---------------------------------------------------------------------------- */
.recent-scans-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-scan-item {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-elevated, var(--bg-surface));
    border: 1px solid var(--border-default);
    border-radius: 8px;
}

.recent-scan-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid;
    white-space: nowrap;
    text-align: center;
}

.recent-scan-badge.status-completed {
    background: rgba(124, 179, 66, 0.12);
    color: var(--status-complete);
    border-color: var(--status-complete);
}

.recent-scan-badge.status-queued {
    background: rgba(217, 119, 6, 0.12);
    color: var(--status-warning, var(--status-in-progress));
    border-color: var(--status-warning, var(--status-in-progress));
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Inline spinner inside the "Running" badge — small, color-matched to the
   amber warning state, spins continuously to signal active processing. */
.recent-scan-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: recent-scan-spin 0.7s linear infinite;
}

@keyframes recent-scan-spin {
    to { transform: rotate(360deg); }
}

.recent-scan-badge.status-failed {
    background: rgba(220, 38, 38, 0.12);
    color: var(--status-error);
    border-color: var(--status-error);
    /* Slightly bolder than other badges — failure should read as decisive,
       not just another status. */
    font-weight: 700;
}

/* Failed-row treatment — subtle red left-border + tinted background so
   failures are visually scannable without reading the badge. Kept very
   light so it doesn't dominate the list when most scans succeeded. */
.recent-scan-item.is-failed {
    background: rgba(220, 38, 38, 0.04);
    border-color: rgba(220, 38, 38, 0.35);
    border-left: 3px solid var(--status-error);
    /* Compensate the 3px left border so content doesn't shift */
    padding-left: 11px;
}

.recent-scan-body {
    min-width: 0;
}

.recent-scan-repo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-scan-meta {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

/* Failed-scan inline error — monospace + boxed so the actual error message
   reads as quoted system output, not body copy. Wraps cleanly on mobile. */
.recent-scan-error {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: var(--status-error);
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 4px;
    padding: 6px 8px;
    margin-top: 6px;
    line-height: 1.4;
    word-break: break-word;
}

/* Refund acknowledgement — green so users immediately see the good news
   sitting alongside the failure. Small + understated, since the user is
   already taking on the failure. */
.recent-scan-refunded {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    color: var(--status-complete);
    margin-top: 6px;
    font-weight: 500;
}

/* ----- Mobile breakpoints -----
   At 480px and below, the badge column collapses so the row stacks vertically.
   Failed rows keep their accent border, but we drop the chevron column on
   completed-expandable rows since the click target IS the whole row. */
@media (max-width: 480px) {
    .recent-scan-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .recent-scan-badge {
        justify-self: start;
    }
    /* Expandable rows on mobile: badge + body stack vertically, chevron
       moves up next to the badge so the click affordance stays visible. */
    .recent-scan-item.is-expandable {
        grid-template-columns: 1fr auto;
        grid-template-areas: "badge chevron" "body body";
        align-items: start;
    }
    .recent-scan-item.is-expandable > .recent-scan-badge { grid-area: badge; }
    .recent-scan-item.is-expandable > .recent-scan-body { grid-area: body; }
    .recent-scan-item.is-expandable > .recent-scan-chevron { grid-area: chevron; }
    .recent-scan-item.is-expanded {
        grid-template-areas: "badge chevron" "body body" "detail detail";
        grid-template-columns: 1fr auto;
    }
    .recent-scan-item.is-expanded > .recent-scan-detail { grid-area: detail; }
    /* Failed row on mobile keeps its accent — adjust padding for the 3px border */
    .recent-scan-item.is-failed {
        padding-left: 11px;
    }
}

/* Very narrow viewports (older small phones) — push the meta line down to
   its own line so the timestamp doesn't crowd the repo name. */
@media (max-width: 360px) {
    .recent-scan-repo {
        font-size: 0.875rem;
    }
    .recent-scan-error {
        font-size: 0.6875rem;
    }
}

/* Expandable detail — chevron, click affordance, expanded panel */
.recent-scan-item.is-expandable {
    cursor: pointer;
    grid-template-columns: 110px 1fr auto;
    transition: border-color 0.15s ease;
}
.recent-scan-item.is-expandable:hover {
    border-color: var(--border-hover);
}
.recent-scan-item.is-expanded {
    grid-template-areas: "badge body chevron" "detail detail detail";
    grid-template-columns: 110px 1fr auto;
}
.recent-scan-item.is-expanded > .recent-scan-badge { grid-area: badge; }
.recent-scan-item.is-expanded > .recent-scan-body { grid-area: body; }
.recent-scan-item.is-expanded > .recent-scan-chevron { grid-area: chevron; }
.recent-scan-item.is-expanded > .recent-scan-detail { grid-area: detail; }

.recent-scan-chevron {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    align-self: center;
    transition: transform 0.15s ease;
}

.recent-scan-detail {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-default);
}
.recent-scan-detail-loading {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    color: var(--text-tertiary);
    padding: 8px 0;
}
.recent-scan-detail-head {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}
.recent-scan-detail-section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin: 18px 0 10px;
}
.recent-scan-detail-section-title:first-child { margin-top: 0; }

.recent-scan-detail-sections {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.recent-scan-detail-section {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 6px;
}
.recent-scan-detail-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid;
    white-space: nowrap;
    text-align: center;
}
.recent-scan-detail-badge.status-pass {
    background: rgba(124, 179, 66, 0.12);
    color: var(--status-complete);
    border-color: var(--status-complete);
}
.recent-scan-detail-badge.status-issues {
    background: rgba(220, 38, 38, 0.12);
    color: var(--status-error);
    border-color: var(--status-error);
}
.recent-scan-detail-badge.status-info {
    background: rgba(79, 166, 157, 0.12);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}
.recent-scan-detail-badge.status-pending {
    background: rgba(107, 107, 107, 0.12);
    color: var(--text-tertiary);
    border-color: var(--border-hover);
}
.recent-scan-detail-section-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.recent-scan-detail-section-summary {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.recent-scan-detail-findings {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.recent-scan-detail-finding {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 6px;
}
.recent-scan-detail-sev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 9999px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid;
}
.recent-scan-detail-sev.severity-high {
    background: rgba(220, 38, 38, 0.12);
    color: var(--status-error);
    border-color: var(--status-error);
}
.recent-scan-detail-sev.severity-medium,
.recent-scan-detail-sev.severity-low {
    background: rgba(217, 119, 6, 0.12);
    color: var(--status-warning, var(--status-in-progress));
    border-color: var(--status-warning, var(--status-in-progress));
}
.recent-scan-detail-sev.severity-info {
    background: rgba(79, 166, 157, 0.12);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}
.recent-scan-detail-sev.severity-pass {
    background: rgba(124, 179, 66, 0.12);
    color: var(--status-complete);
    border-color: var(--status-complete);
}
.recent-scan-detail-finding-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.recent-scan-detail-finding-file {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.recent-scan-detail-finding-detail {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* "Copy for AI co-pilot" actions row — sits below the findings list.
   Border-top separates it from the findings without adding a heavy box. */
.recent-scan-detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-default);
}

/* Confirmed state — same green tint as the free-scan version so the
   feedback feels uniform across surfaces. */
.recent-scan-detail-actions .scan-copy-ai-btn.is-copied {
    background: var(--status-complete);
    color: var(--bg-primary);
}

.recent-scan-detail-actions .scan-copy-ai-hint {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ----- Detail panel — mobile breakpoints -----
   The detail panel uses two grid layouts:
     - .recent-scan-detail-section: 90px badge col + 1fr body
     - .recent-scan-detail-finding:  70px sev col   + 1fr body
   Below 480px the fixed first column eats too much horizontal space
   (the body wraps to 2-3 chars per line in extreme cases). Stack the
   badge above the body instead. */
@media (max-width: 480px) {
    .recent-scan-detail-section {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px 12px;
    }
    .recent-scan-detail-section > .recent-scan-detail-badge {
        justify-self: start;
    }
    .recent-scan-detail-finding {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px 12px;
    }
    .recent-scan-detail-finding > .recent-scan-detail-sev {
        justify-self: start;
    }
    /* Tighten section title spacing — at narrow widths the default 18px top
       margin combined with the stacked layout reads too sparse. */
    .recent-scan-detail-section-title {
        margin: 14px 0 8px;
    }
    /* Detail panel padding-top tightens too — the 16px above feels like a
       gap between unrelated content on small screens. */
    .recent-scan-detail {
        margin-top: 12px;
        padding-top: 12px;
    }
}
