/* quiz.css */

.quiz-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 30px;
    word-wrap: break-word;
    hyphens: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

#quiz-app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

#user-info, #quiz-container, #results {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 2rem;
    margin-bottom: 2rem;
    width: 100%;
}

.wrong-answer {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: rgba(255, 0, 0, 0.1);
}

.wrong-answer .feedback {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
    max-width: 900px;
}

#username, #attempts {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    background-color: var(--input-bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

#username:focus, #attempts:focus,
#username:not(:placeholder-shown), #attempts:not(:placeholder-shown) {
    background-color: var(--background-color);
    border-color: var(--primary-color);
}

.input-help-text {
    display: none;
    position: absolute;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    font-size: 14px;
    color: var(--text-color);
    left: 0;
    right: auto;
    top: 0;
    transform: translateY(100%);
    width: max-content;
    max-width: 200px;
    min-width: 200px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
    white-space: normal;
    word-wrap: break-word;
}

/* Ensure the tooltip stays within the viewport */
.input-group:last-child .input-help-text {
    top: auto;
    bottom: 0;
}

.input-group:hover .input-help-text {
    display: block;
}

.input-group:hover .input-help-text::after {
    content: "";
    position: absolute;
    top: 0;
    left: 10px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--background-color);
    transform: translateY(-100%);
}

#start-button, #next-button, #submit-text-answer, #retry-quiz, #reset-progress, #download-results {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 20px auto 0;
}

#options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#options button {
    width: 100%;
    text-align: left;
    padding: 15px;
}

#options button.selected {
    background-color: var(--quiz-title-color);
    color: white;
    font-weight: bold;
}

#text-answer {
    width: 100%;
    margin-top: 10px;
    min-height: 100px;
    resize: vertical;
}

.reset-button {
    background-color: var(--warning-color);
}

.reset-button:hover {
    background-color: var(--warning-color-dark);
}

.final-results {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
}

.final-results h1, .final-results h2, .final-results h3 {
    color: #333;
    margin-top: 20px;
}

.user-info {
    background-color: #f0f0f0;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.attempt {
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.attempt-summary {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.attempt-summary th, .attempt-summary td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.attempt-summary th {
    background-color: #f0f0f0;
}

.question-feedback {
    background-color: #f9f9f9;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.feedback {
    background-color: #e6f3ff;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

.download-pdf {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
}

.download-pdf:hover {
    background-color: #45a049;
}

/* Dark theme styles */
body.dark-theme .final-results {
    background-color: #222;
    color: #fff;
}

body.dark-theme .final-results h1, 
body.dark-theme .final-results h2, 
body.dark-theme .final-results h3 {
    color: #fff;
}

body.dark-theme .user-info,
body.dark-theme .attempt-summary th,
body.dark-theme .question-feedback {
    background-color: #333;
}

body.dark-theme .attempt {
    border-color: #444;
}

body.dark-theme .attempt-summary th, 
body.dark-theme .attempt-summary td {
    border-color: #444;
}

body.dark-theme .feedback {
    background-color: #2a4d69;
}

body.dark-theme .download-pdf {
    background-color: #45a049;
}

body.dark-theme .download-pdf:hover {
    background-color: #4CAF50;
}

/* Adjust styles for mobile devices */
@media screen and (max-width: 768px) {
    #quiz-app {
        width: 100%;
        padding: 1rem;
        margin-top: 60px; /* Adjust based on your header height */
    }

    .quiz-title {
        font-size: 1.8rem;
        white-space: normal;
        margin-bottom: 20px;
    }

    #user-info, #quiz-container, #results {
        padding: 1rem;
    }

    .input-group {
        margin-bottom: 15px;
    }

    #username, #attempts {
        font-size: 14px;
    }

    .input-help-text {
        position: static;
        width: 100%;
        max-width: 100%;
        margin-top: 5px;
        box-shadow: none;
        border: none;
        background-color: transparent;
        padding: 5px 0;
        font-size: 12px;
    }

    #start-button, #next-button, #submit-text-answer, #retry-quiz, #reset-progress, #download-results {
        max-width: 100%;
        margin: 15px auto 0;
        font-size: 14px;
    }

    #options button {
        padding: 10px;
        font-size: 14px;
    }
}


@media screen and (max-width: 480px) {
    #user-info, #quiz-container, #results {
        padding: 0.8rem;
    }

    .quiz-title {
        font-size: 1.5rem;
    }

    #username, #attempts, .input-group, #start-button, #next-button, #submit-text-answer, #retry-quiz, #reset-progress, #download-results {
        max-width: 100%;
    }
}