/* ==========================================================================
   Base & General Styles
   ========================================================================== */

   body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff; /* Slightly softer grey background */
    color: #333; /* Default text color */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align items to the top for long content */
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

/* Main container for the PBQ page */
.pbq-container {
    background-color: #ffffff; /* White background for the content box */
    padding: 30px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); /* Slightly softer shadow */
    max-width: 850px; /* Appropriate width for passages */
    width: 100%;
    margin: 20px auto; /* Center the container with vertical margin */
}

h1 {
    text-align: center;
    color: #006064; /* Dark cyan heading */
    margin-bottom: 25px;
    font-size: 1.6em;
}

/* General Controls area styling (used for submit buttons) */
.controls {
    text-align: center; /* Default alignment, can be overridden */
    margin-top: 15px;
}

/* Utility class to hide elements */
.hidden {
    display: none !important;
}


/* ==========================================================================
   Progress Bar Styles
   ========================================================================== */
.progress-bar-container {
    width: 100%;
    height: 10px; /* Slightly thicker bar */
    background-color: #e9ecef; /* Lighter grey background */
    border-radius: 5px;
    margin-bottom: 1.8rem; /* Increased space below bar */
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); /* Subtle inset shadow */
}

.progress-bar {
    height: 100%;
    width: 0%; /* Start at 0% */
    background: linear-gradient(to right, #28a745, #218838); /* Green gradient */
    border-radius: 5px;
    transition: width 0.5s ease-in-out; /* Smooth transition */
    box-shadow: 0 0 5px rgba(40, 167, 69, 0.5); /* Glow effect */
}

/* ==========================================================================
   PBQ Page Specific Styles
   ========================================================================== */

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    font-size: 1.2em;
    color: #555;
    padding: 40px 0;
}

/* Error Message Box */
.error-message {
    color: #D8000C; /* Red text */
    background-color: #FFD2D2; /* Light red background */
    border: 1px solid #D8000C;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

/* Passage Area */
.passage-area {
    margin-bottom: 25px; /* Add some space below passage */
    padding-bottom: 0; /* Removed extra bottom padding */
}
.passage-area h2 {
    color: #006064; /* Dark cyan heading */
    margin-bottom: 15px;
    font-size: 1.4em;
    display: none; /* Hide the generic h2 if using separate topic */
}
/* Style for the explicitly added passage topic */
#passageTopic {
    text-align: center;
    font-weight: bold;
    margin-bottom: 1.5em; /* More space below topic */
    font-size: 1.2em;
    color: #222222;
    line-height: 1.4;
}
.passage-text {
    background-color: #f8f9fa; /* Light grey background for passage */
    padding: 20px 25px; /* More padding */
    border-left: 5px solid #76c7c0; /* Teal left border */
    line-height: 1.75; /* Improve readability */
    color: #222222; /* Dark grey text */
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Subtle shadow */
}
.passage-text br { /* Add spacing for line breaks */
    content: "";
    display: block;
    margin-bottom: 0.6em;
}


/* Visual Aid Container */
.visual-aid-container {
    margin-top: 30px; /* Space above visual aid */
    margin-bottom: 30px;
    text-align: center; /* Center the image */
    padding: 20px;
    background-color: #ffffff; /* Consistent light background */
    border-radius: 5px;
}

.visual-aid-container img {
    max-width: 100%; /* Ensure image is responsive */
    height: auto;
    border-radius: 5px;
}

/* Questions List Area */
.questions-list {
    margin-top: 20px;
}
/* Heading for the "Questions" section */
.pbq-container > #passageContent > h2 { /* Targeting the H2 directly under passageContent */
    color: #006064;
    margin-bottom: 20px;
    margin-top: 30px; /* More space above Questions heading */
    font-size: 1.4em;
    padding-bottom: 10px;
    border-bottom: 2px solid #76c7c0; /* Teal underline */
}


/* Individual Question Block */
.question-block {
    margin-bottom: 35px; /* Space between each question */
    padding: 25px;
    border: 1px solid #e0e0e0; /* Light border around question */
    border-radius: 8px;
    background-color: #fff; /* White background for clarity */
    box-shadow: 0 2px 6px rgba(0,0,0,0.06); /* Slightly more pronounced shadow */
    transition: box-shadow 0.3s ease;
}
.question-block:hover {
     /* box-shadow: 0 4px 10px rgba(0,0,0,0.08); */ /* Optional hover effect */
}
.question-block:last-child {
     margin-bottom: 20px; /* Less space after the last question */
}

/* Question Text (within a block) */
.question-text {
    font-weight: 600; /* Bold question text */
    font-size: 1.1em;
    margin-bottom: 20px;
    color: #34495e; /* Dark blue/grey text */
    line-height: 1.5;
}
.question-text > span { /* Style for the actual question content, not the number */
     font-weight: normal;
}


/* Choices List (within a block) */
.question-block .choices {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0; /* Space below choices before submit button */
}
.question-block .choice-item {
    margin-bottom: 10px;
}

/* Choice Button (within a block) */
.question-block .choice-button {
    display: flex;
    align-items: baseline;
    width: 100%;
    padding: 12px 15px;
    font-size: 1em;
    text-align: left;
    background-color: #fdfdfd; /* Very light grey background */
    border: 2px solid #dce4ec; /* Default light border */
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    color: #333;
    font-family: inherit;
}
.question-block .choice-button:hover:not(:disabled) { /* Only apply hover if not disabled */
    background-color: #e7f3ff; /* Light blue hover */
    border-color: #b8d4ff; /* Blue border on hover */
}
.question-block .choice-button:active:not(:disabled) { /* Only apply active if not disabled */
     transform: scale(0.99); /* Slight shrink on click */
}
.question-block .choice-button .choice-letter {
    font-weight: bold;
    margin-right: 10px;
    color: #007bff; /* Blue choice letter (A, B, C...) */
    flex-shrink: 0; /* Prevent letter from shrinking */
    min-width: 20px; /* Ensure alignment */
}

/* Selected choice *before* submitting */
.question-block .choice-button.selected {
    border-color: #007bff; /* Blue border for selected */
    background-color: #e7f3ff; /* Light blue background for selected */
    border-width: 2px; /* Keep consistent thickness */
}

/* Submit button area for individual questions */
.controls.question-submit-controls {
    text-align: right; /* Align submit button to the right */
    margin-top: 15px;
    margin-bottom: 15px; /* Space before feedback appears */
}
.submit-question-btn { /* Button to submit a single question */
     padding: 10px 25px;
     font-size: 0.95em;
     font-weight: 500;
     border-radius: 20px; /* Rounded corners */
     border: none;
     cursor: pointer;
     transition: background-color 0.2s ease, opacity 0.2s ease;
     background-color: #28a745; /* Green */
     color: white;
}
.submit-question-btn:hover:not(:disabled) {
    background-color: #218838; /* Darker green on hover */
}
.submit-question-btn:disabled {
    background-color: #bdc3c7; /* Grey when disabled */
    cursor: not-allowed;
    opacity: 0.7;
}

/* Feedback and Explanation (within a Question Block) */
.question-block .feedback-area,
.question-block .explanation-area {
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 6px;
    text-align: left; /* Left align text */
    transition: opacity 0.5s ease, max-height 0.5s ease; /* Smooth appearance */
    opacity: 0; /* Hidden by default */
    max-height: 0; /* Hidden by default */
    overflow: hidden; /* Needed for max-height transition */
    font-size: 0.95em;
}
/* Make feedback/explanation visible when needed */
.question-block .feedback-area.visible,
.question-block .explanation-area.visible {
    opacity: 1;
    max-height: 500px; /* Allow space to expand */
}

/* Feedback specific styles */
.question-block .feedback-area {
    font-weight: 600;
}
.question-block .feedback-area.correct {
    background-color: #d4edda; /* Light green for correct */
    color: #155724; /* Dark green text */
    border: 1px solid #c3e6cb;
}
.question-block .feedback-area.incorrect {
    background-color: #f8d7da; /* Light red for incorrect */
    color: #721c24; /* Dark red text */
    border: 1px solid #f5c6cb;
}

/* Explanation specific styles */
.question-block .explanation-area {
    background-color: #e9ecef; /* Light grey background */
    color: #495057; /* Dark grey text */
    border: 1px solid #dee2e6;
    margin-top: 10px; /* Space below feedback */
    line-height: 1.6;
}
.question-block .explanation-area strong {
    color: #34495e; /* Darker explanation title */
}

/* Styles for choices AFTER submission (within a Question Block) */
.question-block .choice-button.correct-final {
    background-color: #d4edda !important; /* Light green, override hover */
    border-color: #28a745 !important; /* Green border */
    color: #155724 !important; /* Dark green text */
    cursor: default; /* Not clickable */
    opacity: 1 !important; /* Fully opaque */
    font-weight: bold;
}
.question-block .choice-button.correct-final .choice-letter {
    color: #155724 !important;
}

.question-block .choice-button.incorrect-final {
    background-color: #f8d7da !important; /* Light red, override hover */
    border-color: #dc3545 !important; /* Red border */
    color: #721c24 !important; /* Dark red text */
    cursor: default; /* Not clickable */
    opacity: 0.8 !important; /* Slightly faded incorrect choice */
}
.question-block .choice-button.incorrect-final .choice-letter {
    color: #721c24 !important;
}

/* Style for non-selected, disabled choices after submit */
.question-block .choice-button:disabled:not(.correct-final):not(.incorrect-final),
.question-block .choice-button.disabled-unanswered { /* Class added by JS */
    opacity: 0.6; /* Fade out unselected options */
    cursor: default;
    background-color: #f8f9fa !important; /* Very light grey */
    border-color: #e9ecef !important; /* Light border */
    color: #6c757d !important; /* Grey text */
}
.question-block .choice-button:disabled:not(.correct-final):not(.incorrect-final) .choice-letter,
.question-block .choice-button.disabled-unanswered .choice-letter {
     color: #6c757d !important; /* Grey letter */
}


/* Final Controls Area (Rating + Next Passage Button) */
.controls.final-passage-controls { /* Specific class for the bottom controls */
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: flex-end; /* Push rating left, button right */
    align-items: center; /* Vertically align items */
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0; /* Separator line above */
}

/* Next Passage Button */
#nextPassageBtn { /* Specific ID for the final button */
    padding: 12px 30px;
    font-size: 1.05em;
    font-weight: 500;
    border-radius: 25px; /* Pill shape */
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    background-color: #007bff; /* Blue */
    color: white;
    min-width: 160px; /* Ensure minimum width */
}
#nextPassageBtn:hover:not(:disabled) {
    background-color: #0056b3; /* Darker blue on hover */
}
#nextPassageBtn:disabled {
    background-color: #bdc3c7; /* Grey when disabled */
    cursor: not-allowed;
    opacity: 0.7;
}

/* ==========================================================================
   Completion Screen Styles
   ========================================================================== */

.completion-screen {
    text-align: center;
    padding: 40px 30px;
    background-color: #e0f2f1; /* Light teal background */
    border-radius: 8px;
    margin-top: 30px; /* Space above */
    border: 1px solid #b2dfdb; /* Teal border */
}
.completion-screen h2 {
    color: #004d40; /* Darkest teal */
    border-bottom: none; /* Remove any potential inherited borders */
    margin-bottom: 15px;
    font-size: 1.8em;
}
.completion-screen p {
    font-size: 1.15em;
    color: #00695c; /* Medium teal */
    margin-bottom: 35px; /* More space before buttons */
}
.completion-controls button {
    background-color: #00796b; /* Teal */
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px; /* Slightly rounded corners */
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    margin: 8px 10px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    min-width: 180px; /* Ensure buttons have reasonable width */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.completion-controls button:hover:not(:disabled) {
    background-color: #004d40; /* Darkest teal */
    transform: translateY(-2px); /* Slight lift on hover */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
.completion-controls button:disabled {
     background-color: #999;
     cursor: not-allowed;
     opacity: 0.7;
     box-shadow: none;
     transform: none;
}


/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 650px) {
    .pbq-container {
        padding: 20px 15px; /* Less horizontal padding */
    }
    h1 {
        font-size: 1.4em;
    }
    .passage-text {
        padding: 15px;
        line-height: 1.65;
    }
    .visual-aid-container {
        padding: 15px;
    }
    .question-block {
        padding: 20px 15px;
    }
    .controls.final-passage-controls {
        flex-direction: column; /* Stack rating and button */
        align-items: center; /* Center items when stacked */
        gap: 15px; /* Space between rating and button when stacked */
    }
    #nextPassageBtn {
        width: 90%; /* More width */
        padding: 12px 20px; /* Adjust padding */
    }
    .rating-area {
         justify-content: center; /* Center stars when stacked */
         width: 100%; /* Take full width */
         margin-bottom: 0; /* Remove default bottom margin */
    }
    .completion-controls button {
         width: 90%;
         margin: 8px auto; /* Center buttons */
         display: block; /* Ensure they stack */
    }
    .progress-bar-container {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 450px) {
     body {
        padding: 10px;
     }
    .pbq-container {
        padding: 15px 10px;
    }
    h1 {
        font-size: 1.3em;
    }
    .question-text {
        font-size: 1em;
    }
    .question-block .choice-button {
        font-size: 0.95em;
        padding: 10px 12px;
    }
    .submit-question-btn {
        padding: 8px 20px;
    }
     #nextPassageBtn {
        font-size: 1em;
    }
     .completion-screen h2 {
         font-size: 1.6em;
     }
     .completion-screen p {
         font-size: 1.1em;
     }
     .completion-controls button {
         font-size: 0.95em;
         padding: 10px 20px;
     }
     .star {
        font-size: 1.6em;
     }
}