.edit-mode-warning {
    position: fixed;
    top: 10px;
    left: 10px;
    background-color: #c0392b;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    z-index: 10000;
    font-size: 1em;
    font-weight: bold;
    display: none; /* Hidden by default */
}

body.edit-mode-enabled .edit-mode-warning {
    display: block; /* Show only in edit mode */
}

.edit-mode-warning p {
    margin: 0;
}

.edit-mode-warning a {
    color: white;
    text-decoration: underline;
}

/* --- EDITING MODE --- */

#loading-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 5px solid var(--primary-color);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.status-icon {
    margin-left: 10px;
    font-size: 1.2em;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.status-icon.success {
    color: #2ecc71;
}

.status-icon.error {
    color: #e74c3c;
}

.editable-list li {
    position: relative;
}

.edit-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    opacity: 0; /* Hidden by default */
    pointer-events: none; /* Not interactive by default */
    transition: opacity 0.2s ease-in-out;
}

.flashcard .edit-controls {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    justify-content: center;
    padding-bottom: 10px;
    margin-top: auto;
}

.article-part .edit-controls {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    justify-content: flex-end;
    padding-top: 10px;
}

/* Only show controls when edit mode is enabled AND the user hovers over the item */
body.edit-mode-enabled li:hover > .edit-controls,
body.edit-mode-enabled .article-part:hover > .edit-controls,
body.edit-mode-enabled .question:hover > .edit-controls {
    opacity: 1;
    pointer-events: auto;
}

body.edit-mode-enabled .flashcard:hover > .edit-controls {
    opacity: 1;
    pointer-events: auto;
}

.add-item-container {
    display: none; /* Hide the add button container by default */
}

/* Only show the add button container when edit mode is enabled */
body.edit-mode-enabled .add-item-container {
    display: block;
}

.edit-btn, .delete-btn {
    background: rgba(0,0,0,0.3);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
    z-index: 5;
}

.edit-btn:hover {
    background-color: #27ae60;
    transform: scale(1.1);
}

.delete-btn:hover {
    background-color: #c0392b;
    transform: scale(1.1);
}

li.editing {
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.2);
}

.tf-question.editing .tf-btn {
    cursor: pointer !important;
    opacity: 0.6;
    pointer-events: auto !important;
}

.tf-question.editing .tf-btn.selected {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--primary-color);
}

.add-item-container {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #333;
}

body.light-mode .add-item-container {
    border-top-color: #eee;
}

.add-btn {
    background-color: var(--primary-color); /* Changed from green to red */
}

.add-btn:hover {
    background-color: var(--primary-hover);
}

.item-counter {
    display: block;
    margin-top: 15px;
    font-size: 1em;
    font-weight: bold;
    color: #888;
}

/* --- VOCAB EDIT MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--container-bg-dark);
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-dark);
    width: 90%;
    max-width: 500px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal-content {
    transform: scale(1);
}

body.light-mode .modal-content {
    background-color: var(--container-bg-light);
    box-shadow: var(--shadow-light);
}

.modal-content h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
}

.modal-form-group {
    margin-bottom: 20px;
}

.modal-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #aaa;
}

body.light-mode .modal-form-group label {
    color: #555;
}

.modal-form-group input,
.modal-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #444;
    background-color: #111;
    color: #fff;
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-mode .modal-form-group input,
body.light-mode .modal-form-group textarea {
    background-color: #f0f0f0;
    border-color: #ccc;
    color: #111;
}

.modal-form-group input:focus,
.modal-form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.5);
}

.modal-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
}

.modal-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.modal-btn:hover {
    transform: translateY(-2px);
}

.modal-btn.save {
    background-color: var(--primary-color);
    color: white;
}
.modal-btn.save:hover {
    background-color: var(--primary-hover);
}

.modal-btn.cancel {
    background-color: #555;
    color: white;
}
.modal-btn.cancel:hover {
    background-color: #666;
}

.modal-btn.remove {
    background-color: #c0392b;
    color: white;
    margin-right: auto;
}

.modal-btn.remove:hover {
    background-color: #e74c3c;
}
.mcq-option {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mcq-option input[type="text"] {
    flex-grow: 1;
}

.mcq-option input[type="radio"] {
    display: none;
}

.mcq-option label {
    position: relative;
    cursor: pointer;
    padding-left: 30px;
    font-weight: normal !important;
    color: #888 !important;
    transition: color 0.2s;
}

.mcq-option label:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #555;
    border-radius: 50%;
    background-color: #222;
    transition: all 0.2s;
}

.mcq-option label:after {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
    transition: transform 0.2s var(--bounce);
}

.mcq-option input[type="radio"]:checked + label {
    color: var(--primary-color) !important;
    font-weight: bold !important;
}

.mcq-option input[type="radio"]:checked + label:before {
    border-color: var(--primary-color);
}

.mcq-option input[type="radio"]:checked + label:after {
    transform: translateY(-50%) scale(1);
}

body.light-mode .mcq-option label:before {
    background-color: #eee;
    border-color: #ccc;
}

/* --- TF EDIT MODAL --- */
.tf-options-modal {
    display: flex;
    gap: 20px;
    align-items: center;
}

.tf-options-modal input[type="radio"] {
    display: none;
}

.tf-options-modal label {
    position: relative;
    cursor: pointer;
    padding-left: 30px;
    font-weight: normal !important;
    color: #888 !important;
    transition: color 0.2s;
}

.tf-options-modal label:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #555;
    border-radius: 50%;
    background-color: #222;
    transition: all 0.2s;
}

.tf-options-modal label:after {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
    transition: transform 0.2s var(--bounce);
}

.tf-options-modal input[type="radio"]:checked + label {
    color: var(--primary-color) !important;
    font-weight: bold !important;
}

.tf-options-modal input[type="radio"]:checked + label:before {
    border-color: var(--primary-color);
}

.tf-options-modal input[type="radio"]:checked + label:after {
    transform: translateY(-50%) scale(1);
}

body.edit-mode-enabled .options li {
    pointer-events: none;
}

li.correct-answer {
    background-color: var(--correct-answer-bg);
    color: var(--correct-answer-text);
    border-color: var(--correct-answer-bg);
}

.tf-btn.correct-answer {
    background-color: var(--correct-answer-bg);
    color: var(--correct-answer-text);
    border-color: var(--correct-answer-bg);
    opacity: 1;
}

.edit-banner-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 10;
}

.change-image-btn {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 10;
}

.tab-image-container .change-image-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.tab-header .change-image-btn {
    position: relative;
    font-size: 0.5em;
    padding: 4px 8px;
}

.edit-banner-btn:hover, .change-image-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* --- IMAGE BANNER MODAL --- */
#banner-image-modal .modal-content {
    max-width: 800px;
}

.image-modal-tabs {
    display: flex;
    border-bottom: 2px solid #333;
    margin-bottom: 20px;
}

body.light-mode .image-modal-tabs {
    border-bottom-color: #ddd;
}

.image-modal-tabs .tab-link {
    background: none;
    border: none;
    color: #888;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: color 0.2s, border-bottom 0.2s;
    border-bottom: 3px solid transparent;
}

body.light-mode .image-modal-tabs .tab-link {
    color: #666;
}

.image-modal-tabs .tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.image-tab-content {
    display: none;
}

.image-tab-content.active {
    display: block;
}

.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-container input {
    flex-grow: 1;
    padding: 12px;
    border: 2px solid #444;
    background-color: #111;
    color: #fff;
    border-radius: 8px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-mode .search-container input {
    background-color: #f0f0f0;
    border-color: #ccc;
    color: #111;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.5);
}

.search-container .modal-btn {
    background-color: var(--primary-color);
    color: white;
}

.search-container .modal-btn:hover {
    background-color: var(--primary-hover);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px; /* for scrollbar */
}

.image-grid img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-grid img:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.upload-container {
    text-align: center;
    padding: 40px 20px;
    border: 2px dashed #444;
    border-radius: 10px;
}

body.light-mode .upload-container {
    border-color: #ccc;
}

.upload-container input[type="file"] {
    display: none;
}

.upload-container label {
    display: inline-block;
    margin-bottom: 20px;
}

.upload-container p {
    font-size: 0.9em;
    color: #888;
}

@media (min-width: 768px) {
    #warmup .tab-image-container,
    #discussion .tab-image-container {
        height: 320px;
        background-position: center;
    }
}

#warmup .tab-image-container,
#discussion .tab-image-container {
    height: 320px;
    background-position: center;
    background-size: cover;
    margin-bottom: 20px;
    border-radius: 15px;
}

.tab-image-container .change-image-btn {
    position: relative;
}

.view-exercise-container {
    text-align: center;
    margin: 20px 0;
}

.view-exercise-container .action-btn {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

#edit-expired-modal .modal-content {
    text-align: center;
}

#edit-expired-modal .modal-actions {
    justify-content: center;
}

#edit-expired-modal .modal-btn {
    text-decoration: none;
}
