:root {
    --primary-color: #0056b3;
    /* Strong accessible blue */
    --primary-hover: #004494;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --error-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout Utilities */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hidden {
    display: none !important;
}

/* Header */
.site-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.logo a:hover {
    color: var(--primary-hover);
}

/* Main Content */
#main-content {
    padding-top: 2rem;
    padding-bottom: 2rem;
    flex: 1;
    width: 100%;
}

.intro {
    text-align: center;
    margin-bottom: 2rem;
}

.intro h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.disclaimer-banner {
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--text-muted);
}

.privacy-note {
    font-size: 0.85rem;
    color: var(--success-color);
    font-weight: 500;
}

/* Form Styling */
#phq9-form {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.instruction-text {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.question-group {
    border: none;
    margin-bottom: 2rem;
    padding: 0;
}

fieldset.question-group {
    transition: background-color 0.3s;
    padding: 1rem;
    border-radius: var(--radius);
}

fieldset.question-group:hover {
    background-color: #fcfcfc;
}

/* Highlight error state */
fieldset.question-group.error {
    border: 1px solid var(--error-color);
    background-color: #fff8f8;
}

.question-text {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    display: block;
    width: 100%;
}

/* Option Grid - Responsive */
.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

@media (min-width: 600px) {
    .options-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.radio-label:hover {
    background-color: #f1f7ff;
    border-color: var(--primary-color);
}

.radio-label input[type="radio"] {
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
}

/* Custom Radio Visual */
.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.radio-custom::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition);
}

/* Checked State */
.radio-label input:checked+.radio-custom {
    border-color: var(--primary-color);
}

.radio-label input:checked+.radio-custom::after {
    opacity: 1;
    transform: scale(1);
}

.radio-label input:checked~.label-text {
    font-weight: 600;
    color: var(--primary-color);
}

/* Focus States for Accessibility */
.radio-label:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.label-text {
    font-size: 0.95rem;
    line-height: 1.3;
}

.score-hint {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-left: 4px;
}

.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    font-weight: 500;
    display: none;
}

.question-group.error .error-message {
    display: block;
}

/* Buttons */
.cta-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
    transition: var(--transition);
}

.cta-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.cta-button:focus {
    outline: 3px solid #80bdff;
    outline-offset: 2px;
}

/* Results Area */
.results-area {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 2rem;
    border-top: 5px solid var(--primary-color);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.action-btn:hover {
    background-color: #f0f0f0;
    border-color: var(--text-muted);
}

.score-display {
    text-align: center;
    background-color: #f1f8ff;
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.score-number {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.score-severity {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0.5rem;
}

.result-guidance {
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--radius);
}

.guidance-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}

.medical-disclaimer-box {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}



/* Footer */
.site-footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--text-muted);
    margin: 0 0.5rem;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* SEO Content Section Styling */
.seo-content {
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    padding-bottom: 2rem;
    /* Add padding at bottom */
}

.content-block {
    margin-bottom: 2.5rem;
}

.content-block h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.content-block h3 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.content-block p,
.content-block ul,
.content-block ol {
    margin-bottom: 1rem;
    color: #495057;
}

.content-block ul,
.content-block ol {
    padding-left: 1.5rem;
}

.content-block li {
    margin-bottom: 0.5rem;
}

/* Score Table */
.table-responsive {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 500px;
    /* Ensure readability on small screens */
}

.score-table th,
.score-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.score-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

.score-table tr:nth-child(even) {
    background-color: #fcfcfc;
}

/* Urgent Box */
.urgent-box {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.urgent-box h3 {
    margin-top: 0;
    color: #856404;
}

.urgent-box p {
    margin-bottom: 0;
    color: #856404;
}

/* FAQ Details */
.faq-section details {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background-color: #fff;
    transition: all 0.2s;
}

.faq-section summary {
    padding: 1rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    /* Hide default triangle */
    position: relative;
    padding-right: 2.5rem;
}

/* Custom indicator for details */
.faq-section summary::-webkit-details-marker {
    display: none;
}

.faq-section summary::after {
    content: '+';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.faq-section details[open] summary::after {
    content: '-';
}

.faq-section details[open] {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.faq-section details p {
    padding: 0 1rem 1rem 1rem;
    margin-bottom: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Intro Description */
.intro-description {
    max-width: 600px;
    margin: 0 auto 1.5rem auto;
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Print Styles */
@media print {
    body {
        background-color: #fff;
    }

    .site-header,
    .site-footer,
    .action-btn,
    .cta-button,
    .seo-content {
        display: none;
    }

    .container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    #phq9-form,
    .results-area {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .results-area {
        display: block !important;
        margin-top: 0;
        page-break-inside: avoid;
    }
}

/* References Section */
.reference-list {
    list-style: none;
    padding-left: 0;
}

.reference-list li {
    margin-bottom: 0.75rem;
}

.reference-list a {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.reference-list a:hover {
    text-decoration: underline;
}

.reference-list a::after {
    content: ' ↗';
    /* External link indicator */
    font-size: 0.85em;
    margin-left: 4px;
    color: var(--text-muted);
}

/* Infographics */
.infographic-container {
    margin: 2rem 0;
    text-align: center;
}

.infographic-container figure {
    margin: 0;
    display: inline-block;
    max-width: 100%;
}

.infographic-container img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.infographic-container figcaption {
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}