/* =============================================
   Wizard Step Component Styles
   All values reference design tokens from site.css
   ============================================= */

/* ----- Question Card ----- */
.question-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-card + .question-card {
    margin-top: 1rem;
}

.question-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    line-height: 1.4;
}

.question-card p {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* ----- Radio Group ----- */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-subtle);
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--color-text);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
    position: relative;
}

.radio-group label:hover {
    background: var(--color-accent-soft);
    border-color: #bfdbfe;
}

/* Hide the native radio circle */
.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* Checkmark indicator — hidden by default */
.radio-group label::after {
    content: '\F26B'; /* Bootstrap Icons check-circle-fill */
    font-family: "bootstrap-icons";
    font-size: 1rem;
    color: var(--color-accent);
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.radio-group label:has(input:checked) {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-text);
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.radio-group label:has(input:checked)::after {
    opacity: 1;
}

.review-option-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

/* ----- Evidence Option (MRI/CT Evidence & Severity) ----- */
.evidence-option {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-subtle);
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--color-text);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

/* Override generic .radio-group label centering for evidence/severity cards */
.radio-group label.evidence-option {
    align-items: flex-start;
    text-align: left;
}

.evidence-option:hover {
    background: var(--color-accent-soft);
    border-color: #bfdbfe;
}

/* Hide the native radio circle */
.evidence-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.evidence-option:has(input:checked) {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    box-shadow: inset 3px 0 0 var(--color-accent);
}

/* Checkmark indicator — hidden by default */
.evidence-option::after {
    content: '\F26B'; /* Bootstrap Icons check-circle-fill */
    font-family: "bootstrap-icons";
    font-size: 1rem;
    color: var(--color-accent);
    position: absolute;
    top: 0.875rem;
    right: 1rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.evidence-option:has(input:checked)::after {
    opacity: 1;
}

.evidence-option span:first-of-type {
    font-weight: 600;
    color: var(--color-text);
}

.evidence-option span:last-of-type {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* ----- Procedure Entry ----- */
.procedure {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Validation error banner */
.proc-error-msg {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #991b1b;
    font-size: 0.875rem;
}

.proc-error-msg.is-hidden {
    display: none;
}

/* General validation error message, shown above the question it belongs to */
.validation-error {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #991b1b;
    font-size: 0.875rem;
}

.validation-error.is-hidden {
    display: none;
}

.review-section > .validation-error {
    margin-bottom: 1rem;
}

/* Shown with an inline display:block, so these cards lose the flex gap the others use */
#mult-comorbid-section > .validation-error,
#mri-ct-report-age-section > .validation-error {
    margin-bottom: 1rem;
}

.validation-error i {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Two-column layout */
.procedure-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

/* Panel shell (replaces .list) */
.proc-panel {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

/* Panel header bar */
.proc-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-subtle);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.proc-panel-header i {
    font-size: 1rem;
}

.right-panel .proc-panel-header {
    background: linear-gradient(to right, #eff6ff, var(--color-bg-subtle));
    color: var(--color-accent-strong);
    border-color: #bfdbfe;
}

/* Badge showing item count */
.proc-panel-count {
    margin-left: auto;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.4rem;
}

.right-panel .proc-panel-count {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border: 1px solid #bfdbfe;
}

/* Hint text under header */
.proc-panel-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin: 0;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    font-style: italic;
}

/* List of items inside a panel */
.proc-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
}

.proc-list:empty::after {
    content: attr(data-empty);
    display: block;
    padding: 1.25rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Empty-state fallback via pseudo if data-empty attr not set */
#available-procs:empty::after {
    content: "All procedures have been selected.";
}

#selected-procs:empty::after {
    content: "No procedures selected yet — add from the left.";
}

/* ── Available procedure add button ───────── */
.proc-add {
    width: 100%;
    text-align: left;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.625rem 0.5rem 0.875rem;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.proc-add:hover {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
}

.proc-add-label {
    flex: 1;
    line-height: 1.4;
}

.proc-add-icon {
    color: var(--color-accent);
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.proc-add:hover .proc-add-icon {
    opacity: 1;
}

/* ── Selected procedure card ──────────────── */
.selected-item {
    background: var(--color-bg-surface);
    border: 1px solid #bfdbfe;
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.selected-item:hover {
    box-shadow: var(--shadow-sm);
}

.selected-proc-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
}

.selected-proc-icon {
    color: var(--color-accent);
    font-size: 0.9375rem;
    flex-shrink: 0;
}

.proc-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.proc-remove-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.8125rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.proc-remove-btn:hover {
    color: var(--color-error);
    background: #fef2f2;
}

/* ── Timeline chip strip ──────────────────── */
.timeline-group {
    border: none;
    padding: 0.625rem 0.75rem;
    margin: 0;
    background: var(--color-bg-surface);
}

.timeline-group legend {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    float: none;
    width: 100%;
    padding: 0;
}

.timeline-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* Each chip: visually hides the radio, styles the label */
.timeline-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg-subtle);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    user-select: none;
    white-space: nowrap;
}

.timeline-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.timeline-chip i {
    font-size: 0.8125rem;
}

.timeline-chip:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
}

.timeline-chip.is-selected {
    background: var(--color-accent);
    border-color: var(--color-accent-strong);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    font-weight: 600;
}

.timeline-chip.is-selected i {
    color: rgba(255, 255, 255, 0.85);
}

/* Focus ring for keyboard accessibility */
.timeline-chip:has(input:focus-visible) {
    outline: 3px solid var(--color-accent-soft);
    outline-offset: 2px;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
    .procedure-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .timeline-chips {
        gap: 0.25rem;
    }

    .timeline-chip {
        font-size: 0.75rem;
        padding: 0.25rem 0.625rem;
    }
}

/* ----- Review Page ----- */
.review-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.review-section {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.2s;
    position: relative;
}

.review-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 1rem 0;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--color-border);
}

/* Sections that do not apply yet are hidden rather than greyed out. */
.review-section[hidden] {
    display: none;
}

.review-unanswered-text {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

@keyframes review-flash {
    0%   { box-shadow: 0 0 0 3px #fca5a5; }
    50%  { box-shadow: 0 0 0 5px #ef4444; }
    100% { box-shadow: 0 0 0 0px transparent; }
}

.review-section.is-highlighted {
    animation: review-flash 1.2s ease-out forwards;
}

/* ----- Results Page ----- */
.results-page-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.results-meta-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.results-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.results-meta-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.results-meta-value {
    font-size: 0.9375rem;
    color: var(--color-text);
    font-weight: 500;
    word-break: break-all;
}

.results-status-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
}

.results-status-card.is-pending {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.results-status-card.is-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.results-score-card {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-score-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.results-score-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.results-model-badge {
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    white-space: nowrap;
}

.results-score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.875rem;
}

.results-score-item {
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.results-score-item-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-score-item-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.results-score-item-value.is-null {
    color: var(--color-text-muted);
    font-weight: 400;
    font-size: 0.875rem;
    font-style: italic;
}

.results-procedure-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    align-items: start;
}

.results-procedure-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.results-procedure-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

.results-procedure-notes {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.results-probability-badge {
    font-size: 0.875rem;
    font-weight: 700;
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
}

.results-refresh-form {
    display: flex;
    justify-content: center;
    padding-top: 0.5rem;
}

/* =============================================
   Results — three-section redesign
   .results-panel / table / iPAS gauge / rank
   ============================================= */

.results-panel {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.results-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-bg-subtle);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-wrap: wrap;
}

.results-panel-header i {
    font-size: 1rem;
    flex-shrink: 0;
}

.results-panel-subhead {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: none;
    letter-spacing: 0;
    font-style: italic;
}

/* ---- Shared table ----------------------------- */
.results-table-wrap {
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table thead tr {
    background: var(--color-bg-subtle);
    border-bottom: 2px solid var(--color-border);
}

.results-table th {
    padding: 0.625rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    white-space: nowrap;
}

.results-th-center {
    text-align: center !important;
}

.results-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background 0.1s;
}

.results-table tbody tr:last-child {
    border-bottom: none;
}

.results-table tbody tr:hover {
    background: var(--color-bg-subtle);
}

.results-table td {
    padding: 0.75rem 1.25rem;
    color: var(--color-text);
    vertical-align: middle;
}

.results-td-name {
    font-weight: 500;
}

.results-td-codes {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-family: ui-monospace, "Cascadia Code", monospace;
}

.results-td-center {
    text-align: center;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* ---- iPAS gauge ------------------------------ */
.results-ipas-body {
    padding: 1.5rem 1.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-ipas-label-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.results-ipas-score {
    font-size: 3.25rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
    letter-spacing: -0.03em;
}

.results-ipas-pct {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    vertical-align: super;
}

.results-ipas-gauge-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.results-ipas-track {
    position: relative;
    height: 1.25rem;
    border-radius: 999px;
    background: linear-gradient(to right, #ef4444, #eab308, #22c55e);
    overflow: visible;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

/* Grey overlay from the score point to 100% to show "remaining" */
.results-ipas-fill {
    /* purely for the marker anchor; actual colour comes from the gradient track */
    height: 100%;
    border-radius: 999px 0 0 999px;
}

.results-ipas-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1rem;
    height: 1.625rem;
    background: #fff;
    border: 2.5px solid var(--color-text);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    pointer-events: none;
}

.results-ipas-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 0 0.125rem;
}

.results-ipas-notes {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ---- Rank badges ------------------------------ */
.results-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
    background: var(--color-bg-subtle);
    color: var(--color-text-secondary);
    border: 1.5px solid var(--color-border);
}

.results-rank-1 {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde047;
}

.results-rank-2 {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    border-color: #bfdbfe;
}

.results-rank-3 {
    background: #f0fdf4;
    color: #166534;
    border-color: #86efac;
}

/* ----- MRI CT Severity ----- */
.MRI_CT_Severity .question-card,
.MRI_CT_Evidence .question-card,
.MRI_CT_Report .question-card,
.comorbidity .question-card {
    /* inherits .question-card — just namespace these wrappers */
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .procedure-columns {
        grid-template-columns: 1fr;
    }

    .results-meta-card {
        grid-template-columns: 1fr 1fr;
    }

    .results-score-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .results-meta-card,
    .results-score-grid {
        grid-template-columns: 1fr;
    }

    .review-section {
        padding: 1rem;
    }

    .question-card {
        padding: 1rem;
    }
}
