/* --- Quiz Manager Plugin Frontend Styles --- */

/* --- General Wrapper and Structure --- */
.qmp-quiz-wrapper {
	max-width: 800px;
	margin: 20px auto; /* Add space top/bottom */
	background: #ffffff;
	padding: 25px;
	border-radius: 12px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	border: 1px solid #e0e0e0;
	font-family: sans-serif; /* Define a base font */
}

.qmp-quiz-wrapper h1 {
	color: #1a73e8;
	text-align: center;
	margin-bottom: 30px;
	font-size: 1.8em;
}

.qmp-quiz-wrapper h2 {
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.qmp-step {
    margin-bottom: 25px; /* Spacing between steps */
}

/* --- Input Fields --- */
.qmp-input-group {
	margin-bottom: 15px;
}

.qmp-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.qmp-quiz-wrapper input[type="text"] {
	width: 100%; /* Full width */
	padding: 12px 15px; /* More padding */
	border: 1px solid #ccc; /* Subtle border */
	border-radius: 8px;
	font-size: 16px;
	box-sizing: border-box; /* Include padding in width */
    transition: border-color 0.3s ease;
}
.qmp-quiz-wrapper input[type="text"]:focus {
    border-color: #1a73e8;
    outline: none;
    box-shadow: 0 0 5px rgba(26, 115, 232, 0.3);
}

/* --- Buttons --- */
.qmp-btn {
	background: #1a73e8;
	color: white;
	padding: 12px 24px;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 16px;
	width: 100%;
	margin: 5px 0;
	transition: background 0.3s, box-shadow 0.3s;
    text-align: center;
    display: inline-block; /* Allows setting width/margins properly */
    box-sizing: border-box;
    font-weight: bold;
    line-height: 1.5; /* Ensure text vertical alignment */
}
.qmp-btn:hover {
	background: #1557b0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.qmp-btn:active {
    background: #10408e;
}

.qmp-action-btn {
    width: auto; /* Don't force full width */
    min-width: 150px;
    display: block; /* Center it */
    margin-left: auto;
    margin-right: auto;
    margin-top: 15px;
}

.qmp-back-btn {
    background-color: #6c757d; /* Gray color */
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
    margin-bottom: 15px; /* Space below back button */
}
.qmp-back-btn:hover {
    background-color: #5a6268;
}

/* --- Selection Areas (Categories, Subjects, Chapters, Order) --- */
.qmp-selection-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px; /* Space between buttons */
    margin-top: 15px;
}
.qmp-selection-area .qmp-btn {
    width: auto; /* Adjust width automatically */
    min-width: 120px; /* Minimum width */
    flex-grow: 1; /* Allow buttons to grow */
    max-width: 250px; /* Max width */
    background-color: #3498db; /* Different color for choice buttons */
}
.qmp-selection-area .qmp-btn:hover {
    background-color: #2980b9;
}

.qmp-selection-area p { /* Loading messages */
    width: 100%;
    text-align: center;
    color: #777;
    font-style: italic;
}

/* --- Quiz Container Specifics --- */
#qmp-quiz-container h2 {
    font-size: 1.2em;
    text-align: left;
    border-bottom: none;
    margin-bottom: 10px;
}

.qmp-status-bar {
	background: #e8f0fe;
	padding: 10px 15px;
	border-radius: 8px;
	margin-bottom: 20px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
	gap: 10px;
    font-size: 0.9em;
}
.qmp-status-item {
	text-align: center;
	padding: 8px;
	background: white;
	border-radius: 6px;
    border: 1px solid #d1d1d1;
    color: #333;
}
.qmp-status-item span {
    font-weight: bold;
    color: #1a73e8;
}

#qmp-question-container {
    font-size: 1.1em;
    margin-bottom: 15px;
    line-height: 1.5;
    color: #333;
}

/* --- Quiz Options Styling --- */
.qmp-options {
	list-style: none !important; /* Override theme styles */
	padding: 0;
    margin: 0 0 20px 0;
}

.qmp-options li {
	padding: 15px;
	margin: 10px 0;
	border: 2px solid #1a73e8;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.3s ease;
    background-color: #fff;
    color: #333;
    line-height: 1.4;
    position: relative; /* For potential future pseudo-elements */
}

.qmp-options li::before {
    content: none !important; /* Force remove theme list styles */
}

.qmp-options li:hover:not(.qmp-selected):not(.qmp-disabled) {
	background: #e8f0fe;
    border-color: #1557b0;
}

.qmp-options li.qmp-correct {
	background: #d4edda !important; /* Use important to override hover if needed */
	border-color: #28a745 !important;
	color: #155724 !important;
    font-weight: bold;
}
.qmp-options li.qmp-incorrect {
	background: #f8d7da !important;
	border-color: #dc3545 !important;
	color: #721c24 !important;
}

/* Style the selected incorrect answer */
.qmp-options li.qmp-selected.qmp-incorrect {
     text-decoration: line-through;
     opacity: 0.8;
}

.qmp-options li.qmp-disabled {
	cursor: not-allowed;
	opacity: 0.8; /* Slightly faded */
}
.qmp-options li.qmp-disabled:hover {
    background: #fff; /* Prevent hover effect on disabled correct/incorrect */
    border-color: #1a73e8; /* Keep border consistent or fade it */
}
.qmp-options li.qmp-correct.qmp-disabled:hover {
    background: #d4edda !important;
    border-color: #28a745 !important;
}
.qmp-options li.qmp-incorrect.qmp-disabled:hover {
     background: #f8d7da !important;
	 border-color: #dc3545 !important;
}


/* --- Messages (e.g., Already Answered) --- */
#qmp-message-container {
    margin-bottom: 15px;
}
.qmp-message {
	padding: 12px 15px;
	margin: 10px 0;
	border-radius: 8px;
	text-align: center;
    font-size: 0.95em;
    border-width: 1px;
    border-style: solid;
}
.qmp-message.qmp-warning {
	background: #fff3cd;
	color: #856404;
    border-color: #ffeeba;
}
.qmp-message.qmp-info {
	background: #d1ecf1;
	color: #0c5460;
    border-color: #bee5eb;
}
.qmp-message.qmp-correct {
	background: #d4edda;
	color: #155724;
    border-color: #c3e6cb;
}
.qmp-message.qmp-incorrect {
	background: #f8d7da;
	color: #721c24;
    border-color: #f5c6cb;
}


/* --- Navigation Buttons (Prev/Next/Finish) --- */
.qmp-navigation {
	display: flex;
    justify-content: space-between; /* Pushes buttons apart */
	gap: 15px;
	margin-top: 25px;
}
.qmp-navigation .qmp-btn {
    width: 48%; /* Approx half width each */
}
/* Adjust if only one button is visible */
.qmp-navigation .qmp-btn:only-child {
    width: 100%;
}
#qmp-next-btn {
    background-color: #28a745; /* Green for next/finish */
}
#qmp-next-btn:hover {
     background-color: #218838;
}
#qmp-prev-btn {
    background-color: #ffc107; /* Amber for previous */
    color: #333;
}
#qmp-prev-btn:hover {
     background-color: #e0a800;
}


/* --- Result and Review Container --- */
.qmp-result-container,
.qmp-review-container {
	background: #f8f9fa; /* Light gray background */
	padding: 25px;
	border-radius: 8px;
	margin-top: 20px;
    border: 1px solid #dee2e6;
}

.qmp-result-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 15px;
	margin: 25px 0;
}
.qmp-result-item {
	background: white;
	padding: 15px;
	border-radius: 6px;
	text-align: center;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    font-size: 0.95em;
}
.qmp-result-item strong {
    display: block; /* Put label on its own line */
    margin-bottom: 5px;
    color: #555;
    font-size: 0.9em;
}

.qmp-result-container .qmp-btn,
.qmp-review-container .qmp-btn {
    width: auto; /* Don't force full width */
    min-width: 150px;
    margin: 10px 5px 0 5px; /* Spacing for multiple buttons */
}
.qmp-result-container .qmp-btn:first-of-type,
.qmp-review-container .qmp-btn:first-of-type {
    margin-left: 0;
}


/* --- Review Section Specifics --- */
.qmp-review-question-block {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.07);
}
.qmp-review-question-block p {
    margin: 0 0 10px 0;
    line-height: 1.5;
}
.qmp-review-question-block p:last-child {
    margin-bottom: 0;
}
.qmp-review-question-block strong {
    color: #333;
}
.qmp-review-explanation {
    margin-top: 15px !important;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
    font-size: 0.9em;
    color: #555;
}
.qmp-review-explanation strong {
    color: #1a73e8;
}


/* --- Notification Element --- */
.qmp-notification {
	position: fixed;
	top: 20px;
	right: 20px;
	padding: 15px 25px;
	background-color: #4CAF50; /* Success Green */
	color: white;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	z-index: 10000; /* High z-index */
	opacity: 0;
	transform: translateY(-20px);
	transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 16px;
    text-align: center;
}
.qmp-notification.qmp-show {
	opacity: 1;
	transform: translateY(0);
}
.qmp-notification.qmp-error {
	background-color: #f44336; /* Error Red */
}


/* --- Result Image Generation Container (Hidden) --- */
/* Styles applied here affect the generated image */
#qmp-result-image-container {
	/* Positioned off-screen by JS */
	display: block; /* Needs to be block for html2canvas */
    width: 450px; /* Fixed width for consistent image size */
    background: white;
    padding: 25px;
    border: 3px solid #1a73e8;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.4;
    color: #333;
    text-align: center; /* Center header */
    box-sizing: border-box;
}
#qmp-result-image-container h2 {
    color: #1a73e8;
    margin: 0 0 20px 0;
    font-size: 1.3em;
    line-height: 1.3;
}
/* Style the score prominently */
#qmp-result-image-container h2 strong {
    display: inline-block;
    background-color: #ffc107; /* Yellow highlight */
    color: #333;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 1.1em;
}
.qmp-result-image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns */
    gap: 12px;
    margin-top: 15px;
    text-align: left; /* Align text within items left */
}
.qmp-result-image-item {
    background: #f0f8ff; /* Very light blue */
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #d4eaff;
    font-size: 0.9em; /* Slightly smaller font for image */
    overflow-wrap: break-word; /* Wrap long text */
}
.qmp-result-image-item strong {
    color: #1a73e8;
    /* display: block; */ /* Optional: label on own line */
    margin-right: 5px;
}

/* Make some items span full width if needed */
/* .qmp-result-image-item.full-width {
    grid-column: 1 / -1;
} */


/* --- Leaderboard Shortcode Styles --- */
.qmp-leaderboard-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
}
.qmp-quiz-leaderboard {
    width: 100%;
    border-collapse: collapse;
    margin: 0; /* Remove margin as wrapper has it */
    font-size: 0.9em;
    white-space: nowrap; /* Prevent wrapping */
}
.qmp-quiz-leaderboard th,
.qmp-quiz-leaderboard td {
    border: 1px solid #ddd;
    padding: 10px 12px; /* Increase padding */
    text-align: left;
    vertical-align: middle;
}
.qmp-quiz-leaderboard th {
    background-color: #57c6f9;
    color: white;
    font-weight: bold;
    position: sticky; /* Make header sticky on scroll */
    top: 0;
    z-index: 1;
}
.qmp-quiz-leaderboard tr:nth-child(even) {
    background-color: #f2f9fd; /* Lighter alternating color */
}
.qmp-quiz-leaderboard tr:hover {
    background-color: #e6f4fc;
}
/* Center specific columns */
.qmp-quiz-leaderboard td:nth-child(1), /* Rank */
.qmp-quiz-leaderboard td:nth-child(7), /* Score */
.qmp-quiz-leaderboard td:nth-child(8) { /* Time */
    text-align: center;
}


/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
	.qmp-quiz-wrapper {
		padding: 15px;
	}
	.qmp-btn {
		padding: 10px 15px;
        font-size: 15px;
	}
    .qmp-action-btn {
        min-width: 120px;
    }
	.qmp-status-bar {
		grid-template-columns: 1fr 1fr; /* Two columns on small screens */
        font-size: 0.85em;
	}
    .qmp-result-grid {
        grid-template-columns: 1fr; /* Single column */
    }
    .qmp-navigation {
        flex-direction: column; /* Stack nav buttons */
    }
    .qmp-navigation .qmp-btn {
        width: 100%; /* Full width when stacked */
    }
    .qmp-notification {
        width: 90%;
        right: 5%;
        top: 10px;
    }
    .qmp-quiz-leaderboard {
        font-size: 0.85em;
    }
    .qmp-quiz-leaderboard th,
    .qmp-quiz-leaderboard td {
        padding: 8px 10px;
    }
}