/* static/css/quiz.css */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    flex-direction: column; /* Align items vertically */
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #2c3e50;
    color: #333;
    padding: 10px; /* Reduced padding for mobile first */
    box-sizing: border-box;
    font-size: 16px; /* Base font size for mobile */
}

.quiz-page-container {
    width: 100%;
    max-width: 800px; /* Max width for content */
    box-sizing: border-box; /* Ensure padding/border don't expand beyond 100% */
    margin-left: auto; /* Center the container if max-width is hit */
    margin-right: auto; /* Center the container if max-width is hit */
}

.quiz-header {
    display: flex;
    flex-direction: column; /* Stack on small screens */
    align-items: center;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box; /* Ensure padding/border don't expand beyond 100% */
}

.quiz-header h1 {
    color: #ffffff; /* Dark blue for heading */
    font-size: 1.8em; /* Adjusted for mobile */
    margin-bottom: 10px; /* Space when stacked */
}

.admin-btn {
    padding: 12px 18px; /* Slightly larger for touch */
    background-color: #457b9d; /* A different blue for admin button */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em; /* Adjusted */
    transition: background-color 0.3s ease;
    width: auto; /* Fit content */
    display: inline-block;
}

.admin-btn:hover {
    background-color: #1d3557;
}

.quiz-card, .admin-card {
    background-color: #ffffff;
    padding: 20px; /* Adjusted padding */
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
    position: relative; /* For timer positioning */
    box-sizing: border-box; /* Ensure padding/border don't expand beyond 100% */
}

#timer-display {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1em;
    font-weight: bold;
    color: #457b9d; /* Changed from #e63946 to a calmer blue */
}

.quiz-intro-text {
    margin-bottom: 25px;
    text-align: center;
    color: #555; /* Slightly lighter text for description */
}

.quiz-intro-text h2 {
    color: #1d3557; /* Consistent with other h2 */
    font-size: 1.5em;
    margin-bottom: 10px;
}

.quiz-intro-text p {
    font-size: 1em;
    line-height: 1.6;
}

.quiz-card h2 {
    color: #1d3557;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4em;
    padding-right: 45px; /* Added padding to prevent overlap with timer on mobile */
    box-sizing: border-box; /* Ensure padding is included in width calculation */
    text-align: left; /* Align question text to left for better readability */
}

#options-container button {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 15px; /* Good touch target size */
    background-color: #f1faee; /* Light background for options */
    color: #1d3557;
    border: 1px solid #a8dadc; /* Light blue border */
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 1em;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#options-container button:hover {
    background-color: #a8dadc;
    border-color: #457b9d;
}

#options-container button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

#options-container button.correct {
    background-color: #2a9d8f !important; /* Teal for correct */
    color: white !important;
    border-color: #2a9d8f !important;
}

#options-container button.incorrect {
    background-color: #e63946 !important; /* Red for incorrect */
    color: white !important;
    border-color: #e63946 !important;
}

.quiz-btn {
    padding: 15px 25px; /* Good touch target size */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 15px;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.1s ease;
    width: 100%; /* Make buttons full width on mobile */
    box-sizing: border-box;
}

.quiz-btn.primary-btn {
    background-color: #e63946; /* Accent color */
}

.quiz-btn.primary-btn:hover {
    background-color: #d62828; /* Darker accent */
}

#next-btn, #restart-btn {
    background-color: #457b9d; /* Medium blue */
}

#next-btn:hover, #restart-btn:hover {
    background-color: #1d3557; /* Darker blue */
}

.quiz-btn:active {
    transform: translateY(1px);
}

/* Admin Panel Styles */
.admin-card {
    text-align: left;
}

.admin-card h2, .admin-card h3 {
    color: #1d3557;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.5em;
}
.admin-card h3 {
    font-size: 1.3em;
}

/* Styles for the new manage-question-form */
#manage-question-form div {
    margin-bottom: 15px;
}

#manage-question-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #457b9d;
    font-size: 0.95em;
}

#manage-question-form input[type="text"],
#manage-question-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1em;
}

#manage-question-form textarea {
    resize: vertical;
    min-height: 80px;
}

#admin-options-container .admin-option-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

#admin-options-container .admin-option-item input[type="text"] {
    flex-grow: 1;
    margin-right: 8px;
}

.option-controls {
    margin-top: 10px;
    display: flex;
    flex-direction: column; /* Stack buttons on mobile */
    gap: 10px;
}

.admin-action-btn {
    padding: 10px 15px;
    font-size: 0.9em;
    background-color: #6c757d;
    width: 100%; /* Full width for stacked buttons */
}
.admin-action-btn.danger-btn {
    background-color: #dc3545;
}
.admin-action-btn:hover {
    opacity: 0.9;
}

#admin-correct-answer-container .correct-answer-option {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 4px;
    background-color: #f8f9fa;
    font-size: 0.95em;
}

#admin-correct-answer-container input[type="radio"] {
    margin-right: 10px;
    width: auto;
    transform: scale(1.2); /* Slightly larger radio buttons */
}

#admin-correct-answer-container label {
    font-weight: normal;
    color: #333;
    margin-bottom: 0;
}

.no-options-message {
    color: #6c757d;
    font-style: italic;
    font-size: 0.9em;
}

.form-actions {
    margin-top: 25px;
    display: flex;
    flex-direction: column; /* Stack action buttons */
    gap: 10px;
}

/* Existing Questions List (minor adjustments if needed) */
#existing-questions-list .question-item {
    background-color: #f8f9fa;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    position: relative; /* For potential absolute positioning of buttons if design changes */
}

#existing-questions-list .question-item p {
    margin: 0 0 8px 0;
    font-size: 0.95em;
}

#existing-questions-list .question-item strong {
    color: #1d3557;
}

#existing-questions-list .question-item .options {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 8px;
    word-break: break-word; /* Prevent overflow */
}

#existing-questions-list .question-item .actions {
    margin-top: 10px;
    text-align: left; /* Align to left for stacked buttons */
    display: flex;
    flex-direction: column; /* Stack buttons */
    gap: 8px;
}

#existing-questions-list .question-item .actions button {
    margin-left: 0; /* Remove left margin for stacked buttons */
    padding: 10px 15px;
    font-size: 0.9em;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%; /* Full width for stacked buttons */
}

#existing-questions-list .question-item .actions button.delete-btn {
    background-color: #e63946;
}

#existing-questions-list .question-item .actions button:hover {
    opacity: 0.8;
}

/* Medium screens and up (tablets, desktops) */
@media (min-width: 600px) {
    body {
        padding: 20px;
        font-size: 16px; /* Reset base font for larger screens if changed for mobile */
    }

    .quiz-header {
        flex-direction: row; /* Side-by-side again */
        justify-content: space-between; /* Added for proper spacing */
        align-items: center; /* Added for vertical alignment */
        text-align: left;
    }
    .quiz-header h1 {
        font-size: 2em;
        margin-bottom: 0;
    }

    .quiz-card, .admin-card {
        padding: 30px;
    }

    .quiz-card h2 {
        font-size: 1.5em;
        padding-right: 0; /* Reset padding-right for timer on larger screens */
        /* text-align: center; */ /* Re-center if preferred on desktop, or keep left */
    }

    .quiz-btn {
        width: auto; /* Auto width for buttons on larger screens */
        display: inline-block; /* Allow side-by-side */
    }
    
    .option-controls {
        flex-direction: row; /* Side-by-side buttons */
    }
    .admin-action-btn {
        width: auto; 
    }

    .form-actions {
        flex-direction: row; /* Side-by-side action buttons */
        justify-content: flex-end;
    }
    #existing-questions-list .question-item .actions {
        flex-direction: row; /* Side-by-side buttons */
        justify-content: flex-end;
        text-align: right;
    }
    #existing-questions-list .question-item .actions button {
        width: auto; /* Auto width for buttons */
        margin-left: 10px;
    }
    #existing-questions-list .question-item .actions button:first-child {
        margin-left: 0;
    }

    .quiz-intro-text h2 {
        font-size: 1.6em;
    }

    .quiz-intro-text p {
        font-size: 1.1em;
    }

    #question-counter {
        font-size: 1em;
    }

    #progress-bar-container {
        height: 10px; /* Slightly thicker on desktop */
    }

    .quiz-card h2 {
        font-size: 1.5em;
        padding-right: 0; /* Reset padding-right for timer on larger screens */
        /* text-align: center; */ /* Re-center if preferred on desktop, or keep left */
    }
}

/* Larger screens (desktops) - further refinements if needed */
@media (min-width: 992px) {
    .quiz-header h1 {
        font-size: 2.2em;
    }
    /* Add any specific larger screen adjustments here */
}

/* New styles for question counter and header info */
#question-header-info {
    display: flex;
    justify-content: space-between; /* Pushes counter to one side, timer to other (due to timer's absolute pos) */
    align-items: center;
    margin-bottom: 10px;
    min-height: 20px; /* Ensure space even if counter/timer are small */
}

#question-counter {
    font-size: 0.9em;
    color: #555;
    text-align: left; /* Align counter to the left */
}

/* New styles for progress bar */
#progress-bar-container {
    width: 100%;
    background-color: #e9ecef; /* Light grey track */
    border-radius: 4px;
    height: 8px; /* Slimmer bar */
    margin-top: 20px;
    overflow: hidden; /* Ensures inner bar stays within rounded corners */
}

#progress-bar {
    height: 100%;
    width: 0%; /* Initial state */
    background-color: #2a9d8f; /* Teal color for progress */
    border-radius: 4px; /* Match container */
    transition: width 0.3s ease-in-out; /* Smooth animation */
}

/* Celebration Animations have been removed as balloons-js is now used. */ 

/* Very small screens (e.g., small mobile phones) */
@media (max-width: 420px) {
    body {
        padding: 5px; /* Further reduce body padding */
        font-size: 14px; /* Slightly reduce base font size */
    }

    .quiz-header h1 {
        font-size: 1.5em; /* Reduce main title size */
    }

    .quiz-intro-text h2 {
        font-size: 1.3em; /* Reduce intro heading size */
    }

    .quiz-intro-text p {
        font-size: 0.9em; /* Reduce intro paragraph size */
        line-height: 1.5;
    }

    .quiz-card, .admin-card {
        padding: 10px; /* Reduce card padding */
    }

    .quiz-card h2 {
        font-size: 1.2em; /* Reduce question text size */
        padding-right: 35px; /* Adjust padding for timer */
        word-wrap: break-word; /* Help break long words */
        overflow-wrap: break-word; /* Ensure wrapping */
    }

    #options-container button {
        padding: 12px; /* Adjust option button padding */
        font-size: 0.9em; /* Adjust option button font size */
    }

    .quiz-btn {
        padding: 12px 20px; /* Adjust general button padding */
        font-size: 0.95em; /* Adjust general button font size */
    }

    /* Admin panel specific adjustments for very small screens */
    #manage-question-form label {
        font-size: 0.9em;
    }

    #manage-question-form input[type="text"],
    #manage-question-form textarea {
        padding: 10px;
        font-size: 0.95em;
    }

    .admin-action-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    #existing-questions-list .question-item p {
        font-size: 0.9em;
    }
    #existing-questions-list .question-item .options {
        font-size: 0.85em;
    }
    #existing-questions-list .question-item .actions button {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    #question-counter {
        font-size: 0.85em;
    }

    #timer-display {
        font-size: 0.9em; /* Adjust timer size */
        top: 5px;
        right: 5px;
    }
}

/* Scoreboard Styles */
.scoreboard {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.all-scores-container {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #457b9d #f1faee;
}

.all-scores-container::-webkit-scrollbar {
    width: 8px;
    display: block !important;
}

.all-scores-container::-webkit-scrollbar-track {
    background: #f1faee;
    border-radius: 4px;
    margin: 4px 0;
}

.all-scores-container::-webkit-scrollbar-thumb {
    background: #457b9d;
    border-radius: 4px;
    min-height: 40px;
}

.all-scores-container::-webkit-scrollbar-thumb:hover {
    background: #1d3557;
}

.scoreboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    transition: all 0.3s ease;
    align-items: center;
}

.scoreboard-entry:first-child {
    margin-top: 10px;
}

/* Medal styles */
.scoreboard-entry.gold-medal {
    background: linear-gradient(to right, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border-left: 4px solid #FFD700;
    padding-left: 8px;
}

.scoreboard-entry.silver-medal {
    background: linear-gradient(to right, rgba(192, 192, 192, 0.2), rgba(192, 192, 192, 0.05));
    border-left: 4px solid #C0C0C0;
    padding-left: 8px;
}

.scoreboard-entry.bronze-medal {
    background: linear-gradient(to right, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.05));
    border-left: 4px solid #CD7F32;
    padding-left: 8px;
}

.scoreboard-entry .rank {
    font-weight: bold;
    width: 120px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding-left: 8px;
}

.scoreboard-entry .initials {
    flex: 1;
    text-align: center;
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1;
}

.scoreboard-entry .time {
    width: 80px;
    text-align: right;
    flex-shrink: 0;
    line-height: 1;
}

.medal-text {
    display: inline;
    font-size: 0.8em;
    font-weight: normal;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gold-medal .medal-text {
    color: #FFD700;
    text-shadow: 0 0 2px rgba(255, 215, 0, 0.3);
}

.silver-medal .medal-text {
    color: #C0C0C0;
    text-shadow: 0 0 2px rgba(192, 192, 192, 0.3);
}

.bronze-medal .medal-text {
    color: #CD7F32;
    text-shadow: 0 0 2px rgba(205, 127, 50, 0.3);
}

.gold-medal .rank {
    color: #FFD700;
}

.silver-medal .rank {
    color: #C0C0C0;
}

.bronze-medal .rank {
    color: #CD7F32;
}

/* Hover effects for medal entries */
.scoreboard-entry.gold-medal:hover {
    background: linear-gradient(to right, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
}

.scoreboard-entry.silver-medal:hover {
    background: linear-gradient(to right, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
}

.scoreboard-entry.bronze-medal:hover {
    background: linear-gradient(to right, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
}

#perfect-score-input {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
}

#perfect-score-input h3 {
    color: #2a9d8f;
    margin-top: 0;
    margin-bottom: 10px;
}

#perfect-score-input input[type="text"] {
    padding: 8px;
    font-size: 1.2em;
    width: 80px;
    text-align: center;
    text-transform: uppercase;
    margin: 10px 0;
    border: 2px solid #457b9d;
    border-radius: 4px;
}

#perfect-score-input input[type="text"]:focus {
    outline: none;
    border-color: #2a9d8f;
}

/* Media Queries for Scoreboard */
@media (max-width: 420px) {
    .scoreboard {
        padding: 15px;
    }

    .scoreboard h3 {
        font-size: 1.2em;
    }

    .scoreboard-entry {
        font-size: 0.9em;
        padding: 8px;
    }

    .scoreboard-entry .time {
        font-size: 1em;
    }

    #perfect-score-input {
        padding: 10px;
    }

    #perfect-score-input input[type="text"] {
        font-size: 1.1em;
        width: 70px;
    }
}

/* Timer bar styles */
#timer-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 4px;
    height: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    display: none;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background-color: #e63946;
    border-radius: 4px;
    transition: width 1s linear;
}

#timer-bar-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 4px;
    height: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    display: none;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background-color: #e63946;
    border-radius: 4px;
    transition: width 1s linear;
}

.scoreboard-divider {
    text-align: center;
    margin: 10px 0;
    position: relative;
}

.scoreboard-divider span {
    background: #fff;
    padding: 0 10px;
    color: #666;
    font-size: 0.9em;
    position: relative;
    z-index: 1;
}

.scoreboard-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
    z-index: 0;
}

.remaining-scores-container {
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 5px;
    max-height: 200px;
    overflow-y: scroll !important; /* Force scroll */
    scrollbar-width: thin;
    scrollbar-color: #457b9d #f1faee;
    position: relative; /* Add position relative */
    box-sizing: border-box;
    width: 100%;
}

/* Webkit scrollbar styles */
.remaining-scores-container::-webkit-scrollbar {
    width: 8px;
    display: block !important; /* Force display */
}

.remaining-scores-container::-webkit-scrollbar-track {
    background: #f1faee;
    border-radius: 4px;
    margin: 4px 0;
}

.remaining-scores-container::-webkit-scrollbar-thumb {
    background: #457b9d;
    border-radius: 4px;
    min-height: 40px; /* Ensure thumb is visible */
}

.remaining-scores-container::-webkit-scrollbar-thumb:hover {
    background: #1d3557;
}

.top-five-container {
    margin-bottom: 10px;
}

/* Ensure scoreboard entries don't overflow */
.scoreboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
    min-width: 0; /* Prevent flex items from overflowing */
}

.scoreboard-entry .rank {
    font-weight: bold;
    width: 30px;
    flex-shrink: 0; /* Prevent rank from shrinking */
}

.scoreboard-entry .initials {
    flex: 1;
    text-align: center;
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scoreboard-entry .time {
    width: 80px;
    text-align: right;
    flex-shrink: 0; /* Prevent time from shrinking */
} 