:root {
    --color-primary: #0056b3;
    --color-secondary: #2a6496;
    --color-success: #28a745;
    --color-error: #cc0000;
    --color-background: #f4f7f6;
    --color-white: #ffffff;
    --color-light-blue: #e6f7ff;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background-color: var(--color-background);
    margin: 0;
    padding: 20px;
}

/* --- Global Container and Headings --- */
.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--color-white);
    padding: 30px;
    border-radius: 10px; /* Slightly more rounded */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); /* Stronger shadow */
}

/* Specific style for the smaller tool/registration container */
.container.auth-page {
    max-width: 600px;
    margin: 100px auto;
    text-align: center;
}

h2 {
    color: var(--color-primary);
    border-bottom: 3px solid var(--color-primary); /* Thicker line */
    padding-bottom: 12px;
    margin-bottom: 25px;
}

h3 {
    color: var(--color-secondary);
    margin-top: 30px;
    margin-bottom: 15px;
}

/* --- Authentication/Registration Styles --- */
.auth-box {
    padding: 30px;
    border: 1px solid var(--color-primary); /* Solid border */
    background-color: var(--color-light-blue);
    border-radius: 8px;
}
.auth-box label,
.auth-box input,
.auth-box select {
    text-align: left;
}
.auth-box label {
    display: block;
    font-weight: bold;
    margin-top: 10px;
}

#registrationForm input[type="email"],
#registrationForm input[type="text"],
#registrationForm select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #aaa;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#registrationForm input:focus,
#registrationForm select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
    outline: none;
}

#auth-message {
    margin-top: 20px;
    font-size: 1em;
    font-weight: bold;
    display: block;
    text-align: left; /* Message should be left-aligned */
}

/* --- Assessment Page Styles --- */

/* Container for relative positioning of the loader */
#assessment-form-container {
    position: relative;
}

.scoring-key {
    background-color: var(--color-light-blue);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 5px solid var(--color-primary);
}

.scoring-key table {
    width: 100%;
    border-collapse: collapse;
}

.scoring-key th,
.scoring-key td {
    padding: 12px;
    text-align: left;
    border: 1px solid #ccc;
    font-size: 0.9em;
}

.scoring-key th {
    background-color: #eef7ff;
    color: var(--color-secondary);
}

/* --- Responsive Table Fix for Scoring Key (New Addition) --- */

@media (max-width: 600px) {
    /* Hide the table header on small screens */
    .scoring-key thead {
        display: none;
    }

    /* Treat rows as blocks */
    .scoring-key tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ccc;
        border-radius: 6px;
        overflow: hidden;
        background-color: var(--color-white);
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    /* Treat cells as blocks and align the content */
    .scoring-key td {
        display: block;
        text-align: right;
        border: none;
        padding: 10px 12px;
        position: relative;
    }

    /* Add a pseudo-element label for each cell's data */
    .scoring-key td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: var(--color-primary);
    }
    
    /* Special styling for the Level/Score cell */
    .scoring-key tr:first-child td:first-child,
    .scoring-key tr td:first-child {
        background-color: #f7f7f7;
        border-bottom: 1px solid #eee;
        font-size: 1.1em;
        font-weight: bold;
    }
}

/* --- End Responsive Table Fix --- */

.question-group {
    margin-bottom: 25px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fafafa;
}

.question-group label {
    font-weight: bold;
    font-size: 1.1em;
    color: #333;
    display: block;
}

.description {
    font-size: 0.9em;
    color: #555;
    margin-top: 8px;
    margin-bottom: 15px;
}

/* Radio Button Styles */
.radio-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.radio-options label {
    flex-grow: 1; 
    text-align: center;
    background-color: #f0f0f0;
    border: 2px solid #ccc;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s, border-color 0.2s;
    font-weight: bold;
    font-size: 1.1em;
}

.radio-options label:hover {
    background-color: #e5e5e5;
}

.radio-options input[type="radio"] {
    display: none;
}

/* Checked state */
.radio-options input[type="radio"]:checked + label {
    background-color: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
    box-shadow: 0 0 5px rgba(0, 86, 179, 0.5);
}

/* Accessibility Focus State */
.radio-options input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}


/* Score Description Area */
.score-description {
    /* Base styles are applied in JS, setting a default look here */
    padding: 0;
    margin-top: 10px;
    font-weight: normal;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    min-height: 20px; /* Prevents layout shift when content is added */
}
.score-description-1 {
    --score-color: #A80000; /* Red */
}
.score-description-2 {
    --score-color: #B76523; /* Orange */
}
.score-description-3 {
    --score-color: #0056b3; /* Primary Blue (Making Progress) */
}
.score-description-4 {
    --score-color: #087F8C; /* Dark Green/Cyan */
}

/* Apply consistent styling using the custom property */
.score-description[data-score] {
    border-left: 5px solid var(--score-color);
    padding: 10px 12px;
    margin-top: 15px;
    background-color: #fff;
}
.score-description[data-score] strong {
    color: var(--score-color);
}
/* Submit Button */
button[type="submit"] {
    background-color: var(--color-success);
    color: var(--color-white);
    padding: 18px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    display: block;
    width: 100%;
    margin-top: 40px;
    font-weight: bold;
}

button[type="submit"]:hover {
    background-color: #218838;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

/* Error Message */
.error-message {
    color: var(--color-error);
    background-color: #ffe0e0;
    border: 1px solid var(--color-error);
    padding: 8px 10px;
    border-radius: 4px;
    font-weight: bold;
    margin-top: 10px;
    font-size: 0.9em;
}

.error-message:empty {
    padding: 0;
    border: none;
    display: none;
}

/* Assessment Wrapper for JS control */
#assessment-wrapper {
    opacity: 0;
    transition: opacity 0.5s;
}

/* Instant Report Output Styling */
#resultsOutput {
    display: none;
}

.instant-report-summary {
    background-color: #f0f8ff;
    padding: 25px;
    border: 2px solid var(--color-primary);
    border-radius: 8px;
    margin-top: 30px;
    text-align: left;
}
.instant-report-summary h3 {
    color: var(--color-primary);
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}
.instant-report-summary p {
    margin: 10px 0;
}
.instant-report-summary strong {
    font-size: 1.1em;
}
.instant-report-summary .grade {
    font-size: 2em;
    color: var(--color-success);
    font-weight: bold;
    margin-bottom: 15px;
    display: block;
}

/* Loading Overlay Styles */
#loadingOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.85); /* Semi-transparent white */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 8px;
    transition: opacity 0.3s;
    pointer-events: none; /* Allows clicks to pass through by default */
    opacity: 0; /* Hidden by default */
}

#loadingOverlay.visible {
    opacity: 1;
    pointer-events: all; /* Blocks interaction when visible */
}

/* Spinner Animation */
.spinner {
    border: 6px solid #f3f3f3; /* Light grey */
    border-top: 6px solid var(--color-primary); /* Blue spinner */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingOverlay p {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-primary);
}
/* --- Mobile-Specific Assessment Layout Fixes --- */

@media (max-width: 500px) {
    /* Target the container for the 1, 2, 3, 4 radio buttons */
    .radio-options {
        /* Force items to wrap */
        flex-wrap: wrap; 
        /* Remove the fixed gap (since they stack) */
        gap: 0;
    }

    /* Force each score label to take up the full width */
    .radio-options label {
        flex-grow: 1;
        width: 100%; 
        box-sizing: border-box; /* Include padding/border in width calculation */
        margin-bottom: 8px; /* Add vertical spacing between the stacked buttons */
        /* Make the text centered, which is better for stacked buttons */
        text-align: center;
        font-size: 1.2em; /* Slightly larger text for easier reading/tapping */
    }
    
    /* Ensure the question description and error messages remain legible */
    .description, .error-message {
        font-size: 1em;
    }
    
    /* Make the main button slightly smaller to better fit mobile screens */
    button[type="submit"] {
        font-size: 1.1em;
        padding: 15px 20px;
    }
}