/* General Styles */
body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #333;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
}

main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 1rem;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff;
}

h1, h2, h3 {
    color: #333;
    margin-bottom: 1rem;
}

h2 {
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

/* Instructions Section */
.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 0.5rem;
}

.controls-explanation ul {
    list-style: none;
    padding-left: 0;
}

.controls-explanation li {
    margin-bottom: 0.3rem;
}

/* Exercise Container */
.exercise-container {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Text area takes 2/3, word bank 1/3 */
    gap: 1.5rem;
}

.text-container {
    grid-column: 1 / 2;
}

.word-bank-container {
    grid-column: 2 / 3;
    grid-row: 1 / 3; /* Span across text and controls rows */
    border-left: 1px solid #ddd;
    padding-left: 1.5rem;
}

.reading-text p {
    margin-bottom: 1em;
}

.reading-text span.word {
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.reading-text span.word.selected {
    background-color: yellow;
}

.reading-text span.gap {
    display: inline-block;
    width: 60px; /* Adjust as needed */
    height: 1.2em;
    border-bottom: 1px solid #999;
    margin: 0 2px;
    background-color: #eee;
    vertical-align: bottom;
    border-radius: 3px;
}

/* Controls */
.controls {
    grid-column: 1 / 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.primary-btn {
    background-color: #007bff;
    color: white;
}

.primary-btn:hover {
    background-color: #0056b3;
}

.secondary-btn {
    background-color: #6c757d;
    color: white;
}

.secondary-btn:hover {
    background-color: #5a6268;
}

/* Word Bank */
.word-bank {
    min-height: 100px;
    border: 1px dashed #ccc;
    padding: 1rem;
    background-color: #f9f9f9;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-content: flex-start;
}

.word-bank span.word-item {
    background-color: #e9ecef;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: grab;
    border: 1px solid #ced4da;
}

.word-bank span.word-item:active {
    cursor: grabbing;
}

/* Vocabulary Section */
.vocabulary-list {
    margin-top: 1rem;
}

.vocabulary-item {
    margin-bottom: 1rem;
    padding: 0.8rem;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.vocab-term {
    font-weight: bold;
    cursor: pointer;
    color: #0056b3;
}

.vocab-definition {
    display: none; /* Hidden by default */
    margin-top: 0.5rem;
    padding-left: 1rem;
    border-left: 3px solid #007bff;
    font-size: 0.9em;
    color: #555;
}

.vocab-definition p {
    margin: 0.3rem 0;
}

/* Feedback Section */
.feedback-display {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #ccc;
    background-color: #e9f7ef;
    border-radius: 4px;
}

.feedback-display p {
    margin: 0;
}

.feedback-display .correct {
    color: green;
}

.feedback-display .incorrect {
    color: red;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem;
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 0.9em;
}

footer p {
    margin: 0.3rem 0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .exercise-container {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
    }

    .text-container,
    .controls,
    .word-bank-container {
        grid-column: 1 / -1; /* Make elements span full width */
    }

    .word-bank-container {
        grid-row: auto; /* Reset row span */
        border-left: none;
        padding-left: 0;
        margin-top: 1.5rem;
        border-top: 1px solid #ddd;
        padding-top: 1.5rem;
    }
}



/* Teacher Controls Section */
.teacher-controls {
    background-color: #fff8e1; /* Light yellow background */
    border-color: #ffecb3;
}

.text-editor {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fdfdfd;
}

#text-input-area {
    width: 98%; /* Slightly less than 100% to account for padding/border */
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

.text-editor button {
    margin-right: 0.5rem;
}

/* Hiding Text/Words via CSS */
.text-content-hidden .word {
    visibility: hidden;
    /* Keep space */
    position: relative;
}
.text-content-hidden .word::after {
    content: ''; /* Placeholder to maintain spacing, adjust as needed */
    visibility: visible;
    display: inline-block;
    width: 100%; /* Match word width */
    height: 1em;
}

.selected-words-hidden .word.selected {
    background-color: transparent !important; /* Override yellow */
    color: transparent;
    text-shadow: 0 0 5px rgba(0,0,0,0.5); /* Optional: blur effect */
}

/* Gap Styling for Check Answers */
.gap.correct-gap {
    border-color: green;
    background-color: #e9f7ef;
}

.gap.incorrect-gap {
    border-color: red;
    background-color: #fce8e6;
}




/* --- Styles for UI Modifications (Apr 29 2025) --- */

/* Small Replace Text Button */
.text-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem; /* Adjust as needed */
}

.small-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    background-color: #6c757d; /* Match secondary button */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.small-btn:hover {
    background-color: #5a6268;
}

/* Send to Bottom Button */
#send-to-bottom-btn {
    display: block; /* Make it block level */
    width: 100%; /* Full width of the container */
    margin-top: 1rem; /* Space above the button */
}

/* Persistent Bottom Word Lists Section */
.bottom-word-lists {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ddd;
}

.persistent-word-lists {
    margin-top: 1rem;
}

.persistent-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background-color: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 4px;
}

.persistent-list-item span {
    flex-grow: 1;
    margin-right: 1rem;
    word-break: break-word; /* Prevent long lists from overflowing */
}

.delete-list-btn {
    padding: 0.2rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.delete-list-btn:hover {
    opacity: 1;
}

/* CSS for Hiding Text/Words (Corrected Apr 29 2025) */

/* Hide non-selected words when text-hidden is active */
body.text-hidden #reading-text .word:not(.selected) {
    color: transparent;
    /* Rely on parent maintaining height, or add placeholder if needed */
}

/* Ensure selected words remain visible when text-hidden is active */
body.text-hidden #reading-text .word.selected {
    color: initial; /* Use browser default text color */
    /* Yellow background is applied by default .selected rule, so they remain highlighted */
}

/* Optional: Add subtle background to indicate hidden text area */
body.text-hidden #reading-text::before {
    content: "(Text Hidden - Selected words remain visible)";
    position: absolute;
    top: 10px;
    left: 10px;
    color: #ccc;
    font-style: italic;
    font-size: 0.9em;
    z-index: 1; /* Ensure it's above transparent text */
}

/* Hide selected words when selected-hidden is active */
body.selected-hidden #reading-text .word.selected {
    background-color: transparent !important; /* Override yellow */
    color: transparent !important; /* Ensure transparency */
    border: 1px dashed #ccc;
    margin: -1px; /* Adjust for border */
}

/* Ensure frame size is maintained when text hidden */
#reading-text {
    min-height: 100px; /* Set a minimum height or ensure parent maintains size */
    transition: color 0.3s ease; /* Smooth transition for hiding */
}


