/* ================================================================
   SRE Service Review UI — styles.css
   ================================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-error-bg: #fef2f2;
    --color-error-border: #fecaca;
    --color-low: #16a34a;
    --color-medium: #d97706;
    --color-high: #dc2626;
    --color-critical: #7c2d12;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Layout --- */
.header {
    background: var(--color-text);
    color: #fff;
    padding: 1.5rem 2rem;
    text-align: center;
}
.header h1 { font-size: 1.5rem; font-weight: 600; }
.subtitle { color: #9ca3af; font-size: 0.875rem; margin-top: 0.25rem; }

.container { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* --- Card --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.125rem; margin-bottom: 1rem; }

.card-error {
    background: var(--color-error-bg);
    border-color: var(--color-error-border);
}

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.15s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.input-row { display: flex; gap: 0.5rem; }
.input-row input { flex: 1; }

.error-text { color: var(--color-danger); font-size: 0.8rem; margin-top: 0.25rem; }
.status-text { font-size: 0.8rem; margin-top: 0.25rem; }
.muted-text { color: var(--color-text-muted); font-size: 0.8rem; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-secondary:hover:not(:disabled) { background: #d1d5db; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* --- Progress / Spinner --- */
.progress-container { text-align: center; padding: 2rem 0; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Score Gauge --- */
.summary-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.gauge-container { position: relative; width: 120px; height: 120px; }
.gauge { transform: rotate(-90deg); }
.gauge-bg { stroke: var(--color-border); }
.gauge-fill { stroke: var(--color-primary); transition: stroke-dashoffset 1s ease; }

.gauge-label {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1.3;
}
.gauge-label span { display: block; }
#score-text { font-size: 1.125rem; font-weight: 600; }

/* --- Risk Badge --- */
.risk-badge-container { text-align: center; }

.risk-badge {
    display: inline-block;
    padding: 0.375rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
    color: #fff;
}
.risk-low { background: var(--color-low); }
.risk-medium { background: var(--color-warning); }
.risk-high { background: var(--color-high); }
.risk-unknown { background: var(--color-text-muted); }

/* --- Category Grid --- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.category-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.category-card h3 {
    font-size: 0.875rem;
    text-transform: capitalize;
    margin-bottom: 0.5rem;
}
.category-score { font-size: 1.5rem; font-weight: 700; }
.category-risk { font-size: 0.75rem; margin-top: 0.25rem; font-weight: 500; }

/* --- Criteria Table --- */
.criteria-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.criteria-table th,
.criteria-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.criteria-table th {
    background: var(--color-bg);
    font-weight: 600;
    position: sticky;
    top: 0;
}
.criteria-table tr:hover td { background: #f9fafb; }

.status-pass { color: var(--color-success); font-weight: 600; }
.status-partial { color: var(--color-warning); font-weight: 600; }
.status-fail { color: var(--color-danger); font-weight: 600; }

/* --- Evidence toggle --- */
.evidence-toggle {
    cursor: pointer;
    color: var(--color-primary);
    font-size: 0.75rem;
    text-decoration: underline;
    border: none;
    background: none;
    padding: 0;
}
.evidence-row { display: none; }
.evidence-row.open { display: table-row; }
.evidence-cell {
    padding: 0.75rem 1rem;
    background: #f9fafb;
    font-size: 0.8rem;
    line-height: 1.5;
}
.evidence-cell ul { margin: 0.25rem 0 0 1rem; }

/* --- Report sections --- */
.report-header {
    margin-bottom: 1.5rem;
}
.report-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}
.report-header p {
    margin: 0.125rem 0;
    font-size: 0.875rem;
}
.report-header .score-line {
    font-weight: 600;
}

.report-section {
    margin-bottom: 1.5rem;
}
.report-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--color-border);
}

/* --- Report tables --- */
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}
.report-table th,
.report-table td {
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.report-table th {
    background: var(--color-bg);
    font-weight: 600;
}
.report-table tr:hover td {
    background: #f9fafb;
}
.report-table a {
    color: var(--color-primary);
    text-decoration: none;
}
.report-table a:hover {
    text-decoration: underline;
}

/* --- Evidence details blocks --- */
.report-section details {
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.report-section details summary {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8125rem;
}
.report-section details summary:hover {
    background: #eef0f3;
}
.report-section details[open] summary {
    border-bottom: 1px solid var(--color-border);
}
.evidence-content {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    line-height: 1.5;
}
.evidence-content h4 {
    font-size: 0.8125rem;
    margin: 0.5rem 0 0.25rem;
}
.evidence-content h4:first-child {
    margin-top: 0;
}
.evidence-content ul {
    margin: 0.25rem 0 0.5rem 1.25rem;
    padding: 0;
}
.evidence-content li {
    margin-bottom: 0.125rem;
}
.evidence-content a {
    color: var(--color-primary);
    text-decoration: none;
}
.evidence-content a:hover {
    text-decoration: underline;
}

/* --- Excluded note --- */
.report-excluded-note {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

/* --- References --- */
.report-references {
    margin-bottom: 1rem;
}
.report-references h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}
.report-references ul {
    list-style: disc;
    margin-left: 1.25rem;
    font-size: 0.8125rem;
}
.report-references a {
    color: var(--color-primary);
    text-decoration: none;
}
.report-references a:hover {
    text-decoration: underline;
}

/* --- Report footer --- */
.report-footer {
    text-align: center;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--color-text-muted);
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    margin-top: 1rem;
}

/* --- No-criteria message --- */
.report-empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container { padding: 0 0.5rem; }
    .summary-grid { flex-direction: column; }
    .category-grid { grid-template-columns: 1fr; }
    .report-table { font-size: 0.75rem; }
    .report-table th, .report-table td { padding: 0.3rem 0.4rem; }
}
