/* ============================================================================
   CSP Evaluator UI — shared between the public free tool and the dashboard
   modal. CSS variables use fallback values so this file works regardless of
   which `:root` variable set is loaded (public style.css OR dashboard.css).
   ============================================================================ */

.csp-result {
    margin-top: 24px;
    display: none;
}
.csp-result.is-visible { display: block; }

.csp-error {
    color: var(--danger, #f43f5e);
    padding: 12px 14px;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius, 10px);
}

/* Score header */
.csp-score-header {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 28px;
    align-items: center;
    padding: 22px;
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 16px);
    margin-bottom: 20px;
}
@media (max-width: 640px) {
    .csp-score-header { grid-template-columns: 1fr; text-align: center; }
}

.csp-grade-circle {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt, var(--bg-input, #0b0e17));
    border: 4px solid var(--border-s, var(--border, rgba(255,255,255,0.1)));
}
.csp-grade-letter {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}
.csp-grade-score {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    margin-top: 4px;
}

.csp-grade-circle.csp-grade--a { border-color: #2dd4bf; color: #2dd4bf; }
.csp-grade-circle.csp-grade--b { border-color: #4da6ff; color: #4da6ff; }
.csp-grade-circle.csp-grade--c { border-color: #f59e0b; color: #f59e0b; }
.csp-grade-circle.csp-grade--d { border-color: #f43f5e; color: #f43f5e; }
.csp-grade-circle.csp-grade--f { border-color: #dc2626; color: #dc2626; }

.csp-score-meta { display: flex; flex-direction: column; gap: 14px; }

.csp-subscores {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 640px) {
    .csp-subscores { grid-template-columns: 1fr; }
}
.csp-subscore {
    background: var(--bg-alt, var(--bg-input, #0b0e17));
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    padding: 10px 12px;
    border-radius: var(--radius, 10px);
}
.csp-subscore-label {
    color: var(--text-muted, #64748b);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.csp-subscore-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text, #e2e8f0);
}
.csp-subscore-bar {
    margin-top: 6px;
    height: 4px;
    background: var(--border, rgba(255,255,255,0.06));
    border-radius: 2px;
    overflow: hidden;
}
.csp-subscore-bar-fill {
    height: 100%;
    background: var(--accent, #2dd4bf);
    transition: width 0.4s ease;
}

/* Severity counters strip */
.csp-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.csp-counter {
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    padding: 8px 14px;
    border-radius: var(--radius, 10px);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}
.csp-counter-num {
    font-weight: 800;
    font-size: 1rem;
}
.csp-counter--critical .csp-counter-num { color: #f43f5e; }
.csp-counter--high     .csp-counter-num { color: #f59e0b; }
.csp-counter--medium   .csp-counter-num { color: #4da6ff; }
.csp-counter--low      .csp-counter-num { color: #94a3b8; }
.csp-counter--info     .csp-counter-num { color: #2dd4bf; }

/* Section heading */
.csp-section { margin-bottom: 24px; }
.csp-section-title {
    font-size: 0.95rem;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Findings list */
.csp-finding {
    padding: 14px 16px;
    border-radius: var(--radius, 10px);
    margin-bottom: 10px;
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-left: 4px solid var(--text-muted, #64748b);
}
.csp-finding--critical { border-left-color: #f43f5e; }
.csp-finding--high     { border-left-color: #f59e0b; }
.csp-finding--medium   { border-left-color: #4da6ff; }
.csp-finding--low      { border-left-color: var(--text-muted, #64748b); }
.csp-finding--info     { border-left-color: #2dd4bf; }

.csp-finding-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.csp-finding-sev {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
}
.csp-finding--critical .csp-finding-sev { background: rgba(244,63,94,0.15); color: #f43f5e; }
.csp-finding--high     .csp-finding-sev { background: rgba(245,158,11,0.15); color: #f59e0b; }
.csp-finding--medium   .csp-finding-sev { background: rgba(77,166,255,0.15); color: #4da6ff; }
.csp-finding--low      .csp-finding-sev { background: rgba(148,163,184,0.15); color: #94a3b8; }
.csp-finding--info     .csp-finding-sev { background: rgba(45,212,191,0.15); color: #2dd4bf; }
.csp-finding-id {
    font-family: var(--font-mono, var(--mono, monospace));
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
}
.csp-finding-dir {
    font-family: var(--font-mono, var(--mono, monospace));
    font-size: 0.72rem;
    color: var(--accent, #2dd4bf);
    background: var(--accent-glow, rgba(45, 212, 191, 0.1));
    padding: 2px 6px;
    border-radius: 3px;
}
.csp-finding-title {
    font-weight: 600;
    color: var(--text, #e2e8f0);
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.csp-finding-rationale {
    color: var(--text-sub, var(--text-sec, #94a3b8));
    font-size: 0.86rem;
    line-height: 1.55;
    margin-bottom: 10px;
}
.csp-finding-fix {
    background: var(--bg-alt, var(--bg-input, #0b0e17));
    border: 1px solid var(--border-s, var(--border, rgba(255,255,255,0.1)));
    border-radius: var(--radius, 10px);
    padding: 10px 12px;
    font-family: var(--font-mono, var(--mono, monospace));
    font-size: 0.78rem;
    margin-bottom: 8px;
}
.csp-fix-row { display: flex; gap: 8px; margin-bottom: 4px; }
.csp-fix-row:last-child { margin-bottom: 0; }
.csp-fix-tag { color: var(--text-muted, #64748b); min-width: 18px; }
.csp-fix-before { color: #f43f5e; }
.csp-fix-after  { color: #2dd4bf; }

.csp-finding-citations {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
}
.csp-citation {
    color: var(--accent, #2dd4bf);
    text-decoration: none;
    background: var(--accent-glow, rgba(45, 212, 191, 0.1));
    padding: 3px 8px;
    border-radius: 4px;
}
.csp-citation:hover { background: rgba(45,212,191,0.18); }

.csp-browser-support {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.74rem;
}
.csp-browser {
    background: var(--bg-alt, var(--bg-input, #0b0e17));
    border: 1px solid var(--border-s, var(--border, rgba(255,255,255,0.1)));
    padding: 3px 10px;
    border-radius: 4px;
    color: var(--text-sub, var(--text-sec, #94a3b8));
}
.csp-browser strong { color: var(--text, #e2e8f0); margin-right: 4px; }

/* Score breakdown */
.csp-breakdown {
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius, 10px);
    padding: 14px 16px;
    margin-bottom: 20px;
}
.csp-breakdown-toggle {
    background: none;
    border: none;
    color: var(--accent, #2dd4bf);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.csp-breakdown-body {
    margin-top: 12px;
    display: none;
    font-family: var(--font-mono, var(--mono, monospace));
    font-size: 0.82rem;
}
.csp-breakdown.is-open .csp-breakdown-body { display: block; }
.csp-breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    color: var(--text-sub, var(--text-sec, #94a3b8));
    border-bottom: 1px dashed var(--border, rgba(255,255,255,0.06));
}
.csp-breakdown-row:last-child { border-bottom: none; }
.csp-breakdown-row--total {
    font-weight: 700;
    color: var(--text, #e2e8f0);
    border-top: 1px solid var(--border-s, var(--border, rgba(255,255,255,0.1)));
    margin-top: 4px;
    padding-top: 8px;
}

/* Compliance section */
.csp-compliance {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.csp-compliance-card {
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius, 10px);
    padding: 14px 16px;
}
.csp-compliance-name {
    font-weight: 600;
    color: var(--text, #e2e8f0);
    margin-bottom: 4px;
}
.csp-compliance-stats {
    color: var(--text-muted, #64748b);
    font-size: 0.8rem;
    margin-bottom: 10px;
}
.csp-compliance-req {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.78rem;
    color: var(--text-sub, var(--text-sec, #94a3b8));
    border-bottom: 1px dashed var(--border, rgba(255,255,255,0.06));
}
.csp-compliance-req:last-child { border-bottom: none; }
.csp-compliance-icon { width: 16px; flex-shrink: 0; }
.csp-compliance-icon--pass    { color: #2dd4bf; }
.csp-compliance-icon--partial { color: #f59e0b; }
.csp-compliance-icon--fail    { color: #f43f5e; }

/* Directives summary */
.csp-directives-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .csp-directives-grid { grid-template-columns: 1fr; }
}
.csp-directives-col h4 {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.csp-directive-chip {
    display: inline-block;
    background: var(--bg-card, #0f1320);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    padding: 4px 10px;
    margin: 2px 4px 2px 0;
    border-radius: 4px;
    font-family: var(--font-mono, var(--mono, monospace));
    font-size: 0.78rem;
}
.csp-directive-chip--missing {
    background: rgba(244,63,94,0.08);
    border-color: rgba(244,63,94,0.25);
    color: #f87171;
}
.csp-directive-chip--present {
    background: var(--accent-glow, rgba(45, 212, 191, 0.1));
    border-color: rgba(45,212,191,0.25);
    color: #5eead4;
}

/* Dashboard-specific: wide modal for the evaluator report */
.modal--wide {
    max-width: 920px !important;
    width: 95% !important;
}

.csp-eval-history {
    margin-top: 24px;
}
.csp-eval-history-row {
    display: grid;
    grid-template-columns: auto auto auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border, rgba(255,255,255,0.06));
    font-size: 0.85rem;
}
.csp-eval-history-row:last-child { border-bottom: none; }
.csp-eval-grade {
    font-weight: 700;
    font-size: 1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--border, rgba(255,255,255,0.06));
}
.csp-eval-grade--a { color: #2dd4bf; border-color: #2dd4bf; }
.csp-eval-grade--b { color: #4da6ff; border-color: #4da6ff; }
.csp-eval-grade--c { color: #f59e0b; border-color: #f59e0b; }
.csp-eval-grade--d { color: #f43f5e; border-color: #f43f5e; }
.csp-eval-grade--f { color: #dc2626; border-color: #dc2626; }

/* Evaluator button in CSP settings */
.csp-evaluator-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}
.csp-evaluator-tools p { margin: 0; }
