/* ==========================================================================
   PSA Quality of Care Assessment — Modern Compact Design
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-hover: #1c2129;
    --border: #30363d;
    --accent: #1a7aab;
    --accent-hover: #2196c9;
    --accent-glow: rgba(26, 122, 171, 0.18);
    --text: #e6edf3;
    --text-dim: #8b949e;
    --text-faint: #484f58;
    --green: #3fb950;
    --amber: #d29922;
    --red: #f85149;
    --r: 8px;
}

/* ---- Reset for WP themes ---- */
.psa-tool *,
.psa-tool *::before,
.psa-tool *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Container ---- */
.psa-tool {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    max-width: 720px;
    margin: 2rem auto;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Intro ---- */
.psa-intro {
    margin-bottom: 1.5rem;
}

.psa-intro h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
    text-transform: none;
    letter-spacing: -0.02em;
}

.psa-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
}

/* ---- Org Info Card ---- */
.psa-org-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.psa-org-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.psa-input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

.psa-input-group input,
.psa-input-group select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.psa-input-group input::placeholder {
    color: var(--text-faint);
}

.psa-input-group input:focus,
.psa-input-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.psa-input-group select option {
    background: var(--surface);
    color: var(--text);
}

/* ---- Domain Accordion ---- */
.psa-domain {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 0.5rem;
    overflow: hidden;
    transition: border-color 0.2s;
}

.psa-domain:hover {
    border-color: #3d444d;
}

.psa-domain-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.65rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    gap: 0.75rem;
}

.psa-domain-toggle:hover {
    background: var(--surface-hover);
}

.psa-domain-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
}

.psa-badge {
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid rgba(26, 122, 171, 0.25);
}

.psa-domain-name {
    font-weight: 600;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.psa-domain-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.psa-score-pill {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.psa-score-pill .current-domain-score {
    color: var(--text);
    font-weight: 700;
}

.psa-chevron {
    font-size: 0.75rem;
    color: var(--text-faint);
    transition: transform 0.2s ease;
}

.psa-domain-toggle[aria-expanded="true"] .psa-chevron {
    transform: rotate(180deg);
}

/* ---- Domain Body ---- */
.psa-domain-body {
    padding: 0 1rem 0.75rem;
    border-top: 1px solid var(--border);
}

.psa-domain-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    padding: 0.5rem 0 0.35rem;
    line-height: 1.4;
}

/* ---- Score Rows ---- */
.psa-checklist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 0.35rem;
}

.psa-score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    transition: background 0.12s;
}

.psa-score-row:hover {
    background: var(--surface-hover);
}

.psa-row-info {
    flex: 1;
    min-width: 0;
}

.psa-check-text {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.4;
}

/* ---- Score Selector (Radio Buttons as Numbered Buttons) ---- */
.psa-score-selector {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.psa-score-option {
    cursor: pointer;
    margin: 0 !important;
}

.psa-score-option input[type="radio"] {
    display: none;
}

.psa-score-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-faint);
    background: var(--bg);
    border: 1px solid var(--border);
    transition: all 0.12s ease;
    font-family: inherit;
}

.psa-score-btn:hover {
    border-color: var(--accent);
    color: var(--text-dim);
}

/* Selected state */
.psa-score-option input:checked+.psa-score-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* When score > 0 is selected, highlight the row */
.psa-score-row.scored {
    background: rgba(26, 122, 171, 0.06);
}

.psa-score-row.scored .psa-check-text {
    color: var(--text);
}

/* ---- Sticky Score Bar ---- */
.psa-score-bar {
    position: sticky;
    bottom: 0;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 0.65rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    z-index: 100;
}

.psa-score-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dim);
}

.psa-score-label strong {
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 700;
}

.psa-score-max {
    font-size: 0.8rem;
    color: var(--text-faint);
}

/* ---- Submit Button ---- */
.psa-submit {
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.psa-submit:hover {
    background: var(--accent-hover);
}

.psa-submit:active {
    transform: scale(0.97);
}

.psa-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Success Card ---- */
.psa-success-card {
    background: var(--surface);
    padding: 2.5rem 1.5rem;
    border-radius: var(--r);
    text-align: center;
    border: 1px solid var(--border);
    border-top: 3px solid var(--green);
}

.psa-success-card h3 {
    color: var(--green);
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.psa-success-card p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

#psa-message {
    margin-top: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .psa-tool {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 1rem;
    }

    .psa-org-grid {
        grid-template-columns: 1fr;
    }

    .psa-score-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        border-radius: 0;
    }

    .psa-submit {
        width: 100%;
    }

    .psa-domain-toggle {
        flex-wrap: wrap;
    }

    .psa-domain-name {
        white-space: normal;
    }

    .psa-score-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .psa-score-selector {
        align-self: flex-end;
    }
}