/* General body styling for a clean, modern look */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5; /* Light grey background */
    color: #333; /* Dark grey text for readability */
    margin: 0;
    padding: 20px; /* Padding for smaller screens */
    box-sizing: border-box;
}

/* The main container for the entire application */
#app-container {
    width: 100%;
    max-width: 800px; /* Set a fixed max-width for the container */
    margin: 0 auto;   /* Center the container horizontally */
}

.page {
    display: none;
    width: 100%;
}

.page.active {
    display: block;
}

/* Login Page Styles */
#login-page.active {
    display: flex; 
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 40px);
}

.login-container {
    width: 100%;
    max-width: 400px;
    background-color: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 30px 40px;
    text-align: center;
}

.login-container h1 {
    color: #1a1a1a;
    margin-top: 0;
    margin-bottom: 25px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
}

.login-form button {
    width: 100%;
    padding: 12px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-form button:hover {
    background-color: #555;
}

.remember-me-container {
    text-align: left;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #555;
}

#remember-me-checkbox {
    width: auto; 
    margin: 0;
}

#login-error {
    color: #cf1322;
    margin-top: 15px;
    font-size: 0.9em;
}

.hidden {
    display: none;
}


/* Homepage Styles */
#homepage {
    background-color: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 24px;
}

#homepage h1 {
    color: #1a1a1a;
    margin-top: 0;
    border-bottom: 2px solid #e8e8e8;
    padding-bottom: 16px;
    text-align: center;
}

#accuracy-display {
    background-color: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 10px 15px;
    margin: -10px 0 20px 0;
    font-size: 0.95em;
    color: #595959;
    text-align: center;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 30px;
}

.menu-category {
    text-align: left;
}

.category-title {
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
    font-size: 1.2em;
}

.category-items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 600px) {
    .category-items {
        grid-template-columns: 1fr 1fr;
    }
}

.menu-item {
    padding: 15px 20px;
    font-size: 1.0em;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    text-align: center;
}

.menu-item:hover {
    background-color: #555;
    transform: translateY(-2px);
}

/* --- MODIFICATION START: Styles for Personal Center buttons --- */
/* The #show-wrong-answers and #clear-wrong-answers buttons will now use the default .menu-item style */
/* Removing specific color styles for them */

#logout-btn {
    background-color: #8c8c8c; /* A neutral grey for logout */
}
#logout-btn:hover {
    background-color: #a6a6a6;
}
/* --- MODIFICATION END --- */


/* Main container for the quiz */
.quiz-container {
    background-color: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    padding: 24px;
    box-sizing: border-box;
    position: relative; 
}

.quiz-container h1 {
    text-align: center;
    color: #1a1a1a; 
    margin-top: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e8e8e8; 
    padding-bottom: 16px;
}

.question-block {
    display: none; 
    border-bottom: 1px solid #e8e8e8; 
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.question-block.active {
    display: block; 
}

.question-origin {
    font-size: 0.9em;
    font-style: italic;
    color: #888;
    margin-bottom: 16px;
    padding-left: 10px;
    border-left: 3px solid #e8e8e8;
}

.question-text {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 16px;
    line-height: 1.6; 
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option, .tf-option {
    display: block;
    width: 100%;
    padding: 12px 15px;
    background-color: #fafafa; 
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    text-align: left;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    box-sizing: border-box;
}

.option:hover, .tf-option:hover {
    background-color: #f0f0f0; 
    border-color: #bfbfbf;
}

.option.selected, .tf-option.selected {
    background-color: #e6f7ff; 
    border-color: #91d5ff;
}

.selected.correct, input.correct {
    background-color: #f6ffed !important; 
    border-color: #b7eb8f !important; 
    color: #389e0d !important; 
}

.selected.incorrect, input.incorrect {
    background-color: #fff1f0 !important; 
    border-color: #ffa39e !important; 
    color: #cf1322 !important; 
}

.fill-in-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fill-in-container input[type="text"] {
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
}

.check-btn {
    padding: 10px 15px;
    background-color: #333; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    align-self: flex-start;
    transition: background-color 0.3s;
    margin-top: 8px;
}
.check-btn:hover {
    background-color: #555; 
}
.check-btn:disabled {
    background-color: #bfbfbf;
    cursor: not-allowed;
}

.feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 4px;
    background-color: #f9f9f9;
    border: 1px solid #e8e8e8;
    display: none; 
}

.feedback .answer-label {
    font-weight: bold;
    color: #1a1a1a;
}

.feedback .correct-answer {
    color: #237804; 
    font-weight: bold;
}

.feedback .explanation {
    margin-top: 8px;
    color: #595959; 
    line-height: 1.6;
    white-space: pre-wrap; 
    font-size: 0.95em;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
}

.navigation button {
    padding: 10px 20px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

.navigation button:hover {
    background-color: #555;
}

.navigation button:disabled {
    background-color: #bfbfbf;
    cursor: not-allowed;
}

.progress-indicator {
    font-size: 1em;
    color: #595959;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.question-jumper {
    width: 55px;
    padding: 4px;
    text-align: center;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 1em;
    font-family: inherit;
    color: #333;
    -moz-appearance: textfield; 
}

.question-jumper:focus {
    outline: none;
    border-color: #91d5ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.question-jumper::-webkit-outer-spin-button,
.question-jumper::-webkit-inner-spin-button {
    -webkit-appearance: none; 
    margin: 0;
}

.back-to-home {
    margin-bottom: 16px;
    text-align: left;
}

.back-to-home button {
    background-color: #f0f2f5;
    color: #555;
    border: 1px solid #d9d9d9;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s, color 0.3s;
}
.back-to-home button:hover {
    background-color: #e8e8e8;
    color: #333;
}

.empty-quiz-message {
    text-align: center;
    padding: 40px;
    font-size: 1.1em;
    color: #888;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-content {
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
}

.modal-buttons button {
    padding: 12px 20px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #333;
    color: white;
    transition: background-color 0.2s;
}

.modal-buttons button:hover {
    background-color: #555;
}

#modal-close-btn {
    background-color: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    margin-top: 10px;
}

/* Mobile-specific optimizations */
@media (max-width: 480px) {
    body {
        padding: 10px; 
    }

    #app-container {
        display: flex;
        align-items: center; 
        min-height: calc(100vh - 20px); 
    }

    #homepage {
        padding: 15px; 
        width: 100%; 
    }

    .quiz-container {
        padding: 15px; 
    }

    .quiz-container h1 {
        font-size: 1.4em; 
    }

    .navigation {
        flex-direction: column; 
        gap: 15px;
    }

    .progress-indicator {
        order: -1; 
    }

    .navigation button {
        width: 100%; 
    }
}
