/* Import Font */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap');

/* Global Resets and Body Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    background-color: #f8f9fa; /* Lighter background */
    color: #343a40; /* Darker text */
    line-height: 1.6;
    display: flex;
    flex-direction: column; /* Stack header, main, footer vertically */
    min-height: 100vh; /* Ensure footer stays at bottom */
}

main {
    flex-grow: 1; /* Allow main content to grow */
    width: 100%;
}

/* Header Styles (from original) */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky; /* Make header sticky */
    top: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0.5rem 2rem; /* Adjusted padding */
    z-index: 1000;
}

.logo img {
    display: block; /* Ensure image behaves like a block */
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
    padding: 5px 0; /* Add padding for better click area */
}

.nav-links a:hover,
.nav-links a.active { /* Style for active link */
    color: #007bff;
    border-bottom: 2px solid #007bff; /* Underline active link */
}


/* Course Layout: Sidebar + Content Area */
.course-layout {
    display: flex;
    width: 100%;
    max-width: 1400px; /* Max width for the course layout */
    margin: 20px auto; /* Center the layout */
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 5px;
    overflow: hidden; /* Contain children */
}

/* Sidebar Styles */
.sidebar {
    width: 250px; /* Fixed width */
    flex-shrink: 0; /* Prevent shrinking */
    background-color: #e9ecef; /* Slightly different background */
    padding: 20px;
    border-right: 1px solid #dee2e6;
    height: calc(100vh - 120px); /* Adjust height based on header/footer/controls */
    overflow-y: auto; /* Scroll if chapters overflow */
}

.sidebar h3 {
    margin-bottom: 15px;
    color: #495057;
    border-bottom: 1px solid #ced4da;
    padding-bottom: 10px;
}

.sidebar a {
    display: block;
    margin-bottom: 10px;
    padding: 8px 12px;
    color: #495057;
    text-decoration: none;
    font-weight: 500; /* Slightly bolder */
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    cursor: pointer;
    word-wrap: break-word; /* Wrap long chapter titles */
    position: relative; /* For lock icon */
}

.sidebar a:hover {
    background-color: #ced4da;
    color: #212529;
}

.sidebar a.active {
    background-color: #007bff;
    color: #ffffff;
}

/* Locked Chapter Link Styles */
.sidebar a.locked {
    color: #adb5bd; /* Greyed out */
    cursor: not-allowed; /* Indicate non-interactive */
    pointer-events: none; /* Disable clicks */
}

.sidebar a.locked::after {
    content: "\1F512"; /* Unicode lock symbol */
    font-size: 0.8em;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd; /* Match text color */
}

.sidebar a.locked:hover {
    background-color: transparent; /* No hover effect */
}


/* Content Area Styles */
.content-area {
    flex-grow: 1; /* Take remaining space */
    padding: 30px;
    height: calc(100vh - 120px); /* Match sidebar height */
    overflow-y: auto; /* Scroll if content overflows */
}

.content-area h2 {
    margin-bottom: 15px;
    color: #007bff;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Chapter Editor Styles */
.chapter-editor {
    border: 1px solid #e0e0e0;
    padding: 20px;
    border-radius: 5px;
    background-color: #fdfdfd;
}

.chapter-editor h2, .chapter-editor h4 {
    margin-bottom: 10px;
}

.chapter-editor input[type="text"],
.chapter-editor textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit; /* Use body font */
}
.chapter-editor textarea {
    resize: vertical; /* Allow vertical resize */
}

.chapter-editor label {
    margin-right: 15px;
    cursor: pointer;
}

.chapter-editor hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid #eee;
}

/* Quiz Editor Specific Styles */
.quiz-content-editor {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ccc;
}

.quiz-question-form {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f8f8;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
}
.quiz-question-form label {
    font-weight: 500;
    display: block;
    margin-bottom: 5px;
}

.quiz-choices-container {
    margin-top: 10px;
    margin-bottom: 10px;
    padding-left: 20px; /* Indent choices */
}

.quiz-choice-form {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.quiz-choice-form input[type="radio"] {
    margin-right: 10px;
    flex-shrink: 0; /* Prevent radio from shrinking */
}

.quiz-choice-form input[type="text"] {
     flex-grow: 1; /* Allow text input to grow */
     margin-bottom: 0; /* Remove default margin */
}

/* Buttons within editors */
.chapter-editor button {
    font-size: 0.9em;
    padding: 6px 12px;
    margin-right: 5px;
    margin-top: 5px; /* Add some top margin */
    background-color: #6c757d; /* Grey */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chapter-editor button:hover {
    background-color: #5a6268; /* Darker grey */
}
.chapter-editor button.add-quiz-question-btn,
.chapter-editor button.add-quiz-choice-btn {
    background-color: #28a745; /* Green */
}
.chapter-editor button.add-quiz-question-btn:hover,
.chapter-editor button.add-quiz-choice-btn:hover {
    background-color: #218838; /* Darker Green */
}

.chapter-editor button.remove-quiz-choice-btn,
.chapter-editor button.remove-quiz-question-btn {
    background-color: #dc3545; /* Red */
}
.chapter-editor button.remove-quiz-choice-btn:hover,
.chapter-editor button.remove-quiz-question-btn:hover {
    background-color: #c82333; /* Darker Red */
}

.chapter-editor button:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
}


/* Quiz Display Styles (for downloaded course) */
.quiz-display-container {
    background-color: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 20px;
}
.quiz-display-container h4 {
    margin-bottom: 15px;
}
.quiz-question-display {
    margin-bottom: 25px;
}
.quiz-question-display p { /* Question text */
    font-weight: 500;
    margin-bottom: 10px;
}
.quiz-question-display label {
    display: block;
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.quiz-question-display label:hover {
    background-color: #eee;
}
.quiz-question-display input[type="radio"] {
    margin-right: 10px;
}
.quiz-result {
    margin-top: 10px;
    font-weight: bold;
    padding: 5px;
    border-radius: 3px;
}
.quiz-result.correct {
    color: #155724; /* Dark green */
    background-color: #d4edda; /* Light green */
    border: 1px solid #c3e6cb;
}
.quiz-result.incorrect {
    color: #721c24; /* Dark red */
    background-color: #f8d7da; /* Light red */
    border: 1px solid #f5c6cb;
}

/* Score Display (for downloaded course) */
.chapter-score-display {
    margin-top: 20px;
    padding: 15px;
    background-color: #e2e3e5;
    border: 1px solid #d6d8db;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
}

/* Remove old slider styles */
/*
.container, .slider, .slide, .forwardDiv {
    display: none !important;
}
*/

/* Responsive Adjustments */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.5rem 1rem;
    }
    .nav-links {
        margin-top: 10px;
        width: 100%;
        justify-content: space-around; /* Space out links */
    }
    .nav-links li {
        margin-left: 0;
    }

    .course-layout {
        flex-direction: column;
        margin: 10px; /* Reduce margin */
        height: auto; /* Allow height to adjust */
    }
    .sidebar {
        width: 100%; /* Full width */
        height: auto; /* Auto height */
        max-height: 250px; /* Limit height */
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    .content-area {
        height: auto; /* Auto height */
        padding: 15px; /* Reduce padding */
    }
     .chapter-editor input[type="text"],
     .chapter-editor textarea {
         font-size: 1rem; /* Ensure readability on mobile */
     }
     .divFloat {
         width: 95%; /* More width for modal */
         padding: 15px;
     }
}
