/**
 * Admin styles for PressPrimer Quiz
 *
 * @package PressPrimer_Quiz
 * @since 1.0.0
 */

/*
 * Fix Ant Design radio/checkbox native inputs in WP admin.
 *
 * WordPress admin forms.css styles input[type="radio"] and input[type="checkbox"]
 * with explicit width, height, and positioning that override Ant Design v5's
 * CSS-in-JS styles. This makes the native <input> visible alongside the custom
 * styled <span class="ant-radio-inner"> / <span class="ant-checkbox-inner">,
 * causing duplicate radio buttons and checkboxes to appear.
 *
 * @since 2.2.0
 */
.ant-radio-input,
.ant-checkbox-input {
	position: absolute !important;
	inset: 0 !important;
	z-index: 1 !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	cursor: pointer !important;
	opacity: 0 !important;
}

/*
 * Fix Ant Design modal close button in WP admin.
 *
 * WordPress admin CSS applies styles to bare <button> elements that interfere
 * with the Ant Design v5 modal close button, making it unclickable even though
 * the X icon renders. Reset the button so the click target covers the icon.
 *
 * @since 2.2.2
 */
.ant-modal-close {
	cursor: pointer !important;
	pointer-events: auto !important;
}

/* Dashboard Layout */
.ppq-dashboard {
	margin-top: 20px;
}

.ppq-dashboard-welcome {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-left: 4px solid #2271b1;
	padding: 20px;
	margin-bottom: 20px;
}

.ppq-dashboard-welcome h2 {
	margin-top: 0;
}

.ppq-dashboard-stats,
.ppq-dashboard-actions {
	background: #fff;
	border: 1px solid #c3c4c7;
	padding: 20px;
	margin-bottom: 20px;
}

.ppq-dashboard-stats h3,
.ppq-dashboard-actions h3 {
	margin-top: 0;
	border-bottom: 1px solid #c3c4c7;
	padding-bottom: 10px;
	margin-bottom: 15px;
}

/* General Admin Styles */
.ppq-admin-container {
	max-width: 1200px;
	margin: 20px 0;
}

.ppq-admin-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.ppq-admin-actions {
	display: flex;
	gap: 10px;
}

/* Form Styles */
.ppq-form-table {
	width: 100%;
	max-width: 800px;
}

.ppq-form-table th {
	width: 200px;
	text-align: left;
	padding: 15px 10px 15px 0;
	vertical-align: top;
}

.ppq-form-table td {
	padding: 15px 10px;
}

.ppq-form-field {
	margin-bottom: 20px;
}

.ppq-form-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 5px;
}

.ppq-form-field input[type="text"],
.ppq-form-field input[type="number"],
.ppq-form-field textarea,
.ppq-form-field select {
	width: 100%;
	max-width: 400px;
}

.ppq-form-field textarea {
	height: 100px;
}

.ppq-form-field .description {
	font-size: 12px;
	color: #646970;
	margin-top: 5px;
}

/* Button Styles */
.ppq-button-group {
	display: flex;
	gap: 10px;
	align-items: center;
}

/* Table Styles */
.ppq-table {
	width: 100%;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.ppq-table th {
	background: #f6f7f7;
	font-weight: 600;
	padding: 10px;
	text-align: left;
	border-bottom: 1px solid #c3c4c7;
}

.ppq-table td {
	padding: 10px;
	border-bottom: 1px solid #dcdcde;
}

.ppq-table tr:hover {
	background: #f6f7f7;
}

/* Notice Styles */
.ppq-notice {
	padding: 12px;
	margin: 15px 0;
	border-left: 4px solid;
}

.ppq-notice.notice-info {
	border-left-color: #2271b1;
	background: #f0f6fc;
}

.ppq-notice.notice-success {
	border-left-color: #00a32a;
	background: #edfaef;
}

.ppq-notice.notice-warning {
	border-left-color: #dba617;
	background: #fcf9e8;
}

.ppq-notice.notice-error {
	border-left-color: #d63638;
	background: #fcf0f1;
}

/* Loading States */
.ppq-loading {
	opacity: 0.6;
	pointer-events: none;
}

.ppq-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid #f3f3f3;
	border-top: 2px solid #2271b1;
	border-radius: 50%;
	animation: ppq-spin 1s linear infinite;
	vertical-align: middle;
	margin-left: 5px;
}

@keyframes ppq-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* Responsive */

/* Tablet/Medium screens - force sidebar below content */
@media screen and (min-width: 783px) and (max-width: 1280px) {
	/* React Question Editor - Tablet Layout */
	.ant-layout {
		flex-direction: column !important;
	}

	.ant-layout-content {
		width: 100% !important;
		padding: 0 !important;
	}

	.ant-layout-sider {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 100% !important;
		flex: none !important;
		margin-top: 24px !important;
		position: static !important;
		height: auto !important;
	}

	/* Prevent Ant Design from trying to use columns */
	.ant-layout-has-sider {
		flex-direction: column !important;
	}

	/* Make cards use full width */
	.ant-card {
		width: 100% !important;
	}
}

/* Mobile screens */
@media screen and (max-width: 782px) {
	.ppq-admin-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.ppq-form-table th,
	.ppq-form-table td {
		display: block;
		width: 100%;
	}

	.ppq-form-table th {
		padding-bottom: 5px;
	}

	/* React Question Editor - Mobile Layout */
	.ppq-question-editor-container {
		padding: 12px !important;
	}

	.ppq-editor-header {
		padding: 16px !important;
		margin-bottom: 16px !important;
	}

	/* Force Ant Design layout to stack properly on mobile */
	.ant-layout {
		flex-direction: column !important;
	}

	.ant-layout-content {
		padding: 0 !important;
		width: 100% !important;
	}

	.ant-layout-sider {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 100% !important;
		flex: none !important;
		margin-top: 16px !important;
		position: static !important;
	}

	/* Make cards more compact */
	.ant-card {
		margin-bottom: 16px !important;
	}

	.ant-card-head {
		padding: 12px 16px !important;
	}

	.ant-card-body {
		padding: 16px !important;
	}

	/* Form fields */
	.ant-form-item {
		margin-bottom: 16px !important;
	}

	/* Buttons */
	.ant-btn-group {
		display: flex !important;
		flex-direction: column !important;
		gap: 8px !important;
	}

	.ant-btn-group .ant-btn {
		width: 100% !important;
	}

	/* Answer list items */
	.ant-list-item {
		padding: 12px !important;
	}

	/* Make inputs full width */
	.ant-input,
	.ant-select,
	.ant-input-number {
		width: 100% !important;
		max-width: 100% !important;
	}
}

/* Question Editor */
.ppq-question-editor .ppq-form-section {
	background: #fff;
	border: 1px solid #c3c4c7;
	padding: 20px;
	margin-bottom: 20px;
}

.ppq-question-editor .ppq-form-section h2 {
	margin-top: 0;
	margin-bottom: 15px;
	padding-bottom: 10px;
	border-bottom: 1px solid #c3c4c7;
}

/* Character Counters */
.ppq-char-counter {
	font-size: 12px;
	color: #646970;
	margin-top: 5px;
	text-align: right;
}

#stem-char-counter {
	padding: 5px 10px;
	background: #f0f0f1;
	border-radius: 3px;
	margin-top: 10px;
}

/* Type Selector */
.ppq-type-selector {
	display: flex;
	gap: 15px;
}

.ppq-type-option {
	display: flex;
	align-items: center;
	padding: 10px 15px;
	border: 2px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s;
}

.ppq-type-option:hover {
	border-color: #2271b1;
}

.ppq-type-option input[type="radio"] {
	margin-right: 8px;
}

.ppq-type-option input[type="radio"]:checked + span {
	font-weight: 600;
}

/* Answer Rows */
#ppq-answers-container {
	margin-bottom: 15px;
}

.ppq-answer-row {
	background: #f6f7f7;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 15px;
	margin-bottom: 10px;
}

.ppq-answer-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.ppq-drag-handle {
	cursor: move;
	color: #646970;
}

.ppq-correct-toggle {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 0;
	font-weight: 600;
}

.ppq-remove-answer {
	margin-left: auto;
	color: #d63638;
}

.ppq-remove-answer:disabled {
	color: #a7aaad;
	cursor: not-allowed;
}

.ppq-answer-content {
	margin-bottom: 10px;
}

.ppq-answer-text {
	width: 100%;
}

.ppq-answer-feedback {
	margin-top: 10px;
}

.ppq-feedback-toggle {
	display: flex;
	align-items: center;
	gap: 5px;
	cursor: pointer;
	color: #2271b1;
	font-size: 13px;
}

.ppq-feedback-toggle:hover {
	color: #135e96;
}

.ppq-feedback-content {
	margin-top: 10px;
}

#ppq-add-answer {
	margin-top: 10px;
}

/* Sortable Placeholder */
.ppq-answer-placeholder {
	background: #f0f6fc;
	border: 2px dashed #2271b1;
	border-radius: 4px;
	height: 100px;
	margin-bottom: 10px;
	visibility: visible !important;
}

/* Sortable Helper */
.ui-sortable-helper {
	opacity: 0.7;
	cursor: move;
}

/* Dragging State */
.ppq-answer-row.ui-sortable-helper {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Sidebar Styling */
.ppq-question-editor .postbox {
	margin-bottom: 15px;
}

.ppq-question-editor .postbox .inside {
	padding: 12px;
}

.ppq-form-field {
	margin-bottom: 15px;
}

.ppq-form-field:last-child {
	margin-bottom: 0;
}

.ppq-form-field label {
	display: block;
	margin-bottom: 5px;
}

.ppq-form-field .description {
	margin-top: 5px;
	font-size: 12px;
	color: #646970;
}

.ppq-taxonomy-list {
	max-height: 200px;
	overflow-y: auto;
	padding: 5px 0;
}

.ppq-checkbox-label {
	display: block;
	padding: 5px 0;
	margin: 0;
	font-weight: normal;
}

.ppq-checkbox-label input[type="checkbox"] {
	margin-right: 5px;
}

/* Utility Classes */
.ppq-text-muted {
	color: #646970;
}

.ppq-text-success {
	color: #00a32a;
}

.ppq-text-error {
	color: #d63638;
}

.ppq-text-warning {
	color: #dba617;
}

.ppq-mt-0 { margin-top: 0; }
.ppq-mb-0 { margin-bottom: 0; }
.ppq-mt-10 { margin-top: 10px; }
.ppq-mb-10 { margin-bottom: 10px; }
.ppq-mt-20 { margin-top: 20px; }
.ppq-mb-20 { margin-bottom: 20px; }

/* Banks Admin */
.ppq-form-section {
	background: #fff;
	border: 1px solid #c3c4c7;
	padding: 20px;
	margin-bottom: 20px;
}

.ppq-form-section h2 {
	margin-top: 0;
	margin-bottom: 15px;
	padding-bottom: 10px;
	border-bottom: 1px solid #c3c4c7;
}

.ppq-add-question-form {
	margin-bottom: 0;
}

#ppq-question-search-results {
	background: #f6f7f7;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
}

#ppq-question-search-results label {
	cursor: pointer;
	transition: background 0.2s;
}

#ppq-question-search-results label:hover {
	background: #fff;
}

.ppq-filter-form {
	margin-bottom: 15px;
}

.ppq-filter-form select {
	margin-right: 10px;
	vertical-align: middle;
}

/* Categories & Tags Admin */
#col-container {
	display: flex;
	gap: 20px;
}

#col-left {
	flex: 0 0 300px;
}

#col-right {
	flex: 1;
}

.form-field {
	margin-bottom: 20px;
}

.form-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 5px;
}

.form-field input[type="text"],
.form-field textarea,
.form-field select {
	width: 100%;
}

.form-field .description {
	font-size: 12px;
	color: #646970;
	margin-top: 5px;
	font-style: italic;
}

.form-field .required {
	color: #d63638;
}

@media screen and (max-width: 782px) {
	#col-container {
		flex-direction: column;
	}

	#col-left {
		flex: 1;
	}
}

/* Quiz List Table - Fix Preview Link Position */
.row-actions .preview {
	float: none !important;
}

/* Quiz List Table - ID Column Width */
.wp-list-table .column-id {
	width: 60px;
	text-align: center;
}

/* Bank Detail - Add Questions Tabs */
.ppq-bank-add-tabs {
	background: #fff;
	border: 1px solid #c3c4c7;
	margin-bottom: 20px;
}

.ppq-bank-tabs-nav {
	display: flex;
	gap: 0;
	background: #f6f7f7;
	border-bottom: 1px solid #c3c4c7;
}

.ppq-bank-tab {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 15px 25px;
	background: transparent;
	border: none;
	border-bottom: 3px solid transparent;
	margin-bottom: -1px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	color: #50575e;
	transition: all 0.2s;
}

.ppq-bank-tab:hover {
	background: #fff;
	color: #2271b1;
}

.ppq-bank-tab--active {
	background: #fff;
	color: #1d2327;
	border-bottom-color: #2271b1;
	font-weight: 600;
}

.ppq-bank-tab .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.ppq-bank-tab-content {
	display: none;
	padding: 20px;
}

.ppq-bank-tab-content--active {
	display: block;
}

.ppq-bank-tab-content h3 {
	margin-top: 0;
	margin-bottom: 15px;
	padding-bottom: 10px;
	border-bottom: 1px solid #dcdcde;
}

/* Modal Styles */
.ppq-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100100;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.ppq-modal-overlay--visible {
	opacity: 1;
}

.ppq-modal {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	max-width: 420px;
	width: 90%;
	max-height: 90vh;
	overflow: hidden;
	transform: scale(0.9);
	transition: transform 0.2s ease;
}

.ppq-modal-overlay--visible .ppq-modal {
	transform: scale(1);
}

.ppq-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #dcdcde;
	background: #f6f7f7;
}

.ppq-modal-title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: #1d2327;
}

.ppq-modal-close {
	background: none;
	border: none;
	cursor: pointer;
	color: #646970;
	padding: 4px;
	line-height: 1;
	border-radius: 4px;
	transition: all 0.15s ease;
}

.ppq-modal-close:hover {
	background: #dcdcde;
	color: #1d2327;
}

.ppq-modal-close .dashicons {
	font-size: 20px;
	width: 20px;
	height: 20px;
}

.ppq-modal-body {
	padding: 24px 20px;
	text-align: center;
}

.ppq-modal-icon {
	margin-bottom: 16px;
}

.ppq-modal-icon .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
}

.ppq-modal-icon--info .dashicons {
	color: #2271b1;
}

.ppq-modal-icon--warning .dashicons {
	color: #dba617;
}

.ppq-modal-icon--error .dashicons {
	color: #d63638;
}

.ppq-modal-icon--success .dashicons {
	color: #00a32a;
}

.ppq-modal-message {
	font-size: 14px;
	line-height: 1.6;
	color: #3c434a;
	white-space: pre-wrap;
}

.ppq-modal-footer {
	display: flex;
	justify-content: center;
	gap: 12px;
	padding: 16px 20px;
	background: #f6f7f7;
	border-top: 1px solid #dcdcde;
}

.ppq-modal-footer .button {
	min-width: 90px;
	justify-content: center;
}

/* Danger/destructive button style for confirms */
.ppq-modal-footer .ppq-modal-confirm {
	/* Keep primary styling by default */
}

/* Optional: Make cancel button more subtle */
.ppq-modal-footer .ppq-modal-cancel {
	background: #fff;
}

/* ==========================================================================
   RTL (Right-to-Left) Language Support
   ========================================================================== */

.rtl .ppq-admin-page {
	direction: rtl;
	text-align: right;
}

/* Forms */
.rtl .ppq-form-field label {
	text-align: right;
}

.rtl .ppq-form-description {
	text-align: right;
}

/* Tables */
.rtl .ppq-admin-table th,
.rtl .ppq-admin-table td {
	text-align: right;
}

/* Row actions */
.rtl .ppq-row-actions {
	direction: rtl;
}

/* Modal */
.rtl .ppq-modal-content {
	text-align: right;
}

.rtl .ppq-modal-footer {
	flex-direction: row-reverse;
}

/* List tables */
.rtl .column-actions {
	text-align: left;
}

/* Navigation */
.rtl .ppq-admin-nav {
	flex-direction: row-reverse;
}

/* Notices */
.rtl .ppq-notice {
	border-left: none;
	border-right: 4px solid;
}

.rtl .ppq-notice-success {
	border-right-color: #00a32a;
}

.rtl .ppq-notice-error {
	border-right-color: #d63638;
}

.rtl .ppq-notice-warning {
	border-right-color: #dba617;
}

.rtl .ppq-notice-info {
	border-right-color: #72aee6;
}

/* ==========================================================================
   Celebration Notice (100 Attempts Review Request)
   ========================================================================== */

.ppq-celebration-notice {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-left: 4px solid #0073aa;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	margin: 45px 20px 20px 0;
	padding: 16px 20px;
	position: relative;
}

.ppq-celebration-notice__content {
	display: flex;
	align-items: flex-start;
	gap: 16px;
}

.ppq-celebration-notice__icon {
	font-size: 32px;
	line-height: 1;
	flex-shrink: 0;
}

.ppq-celebration-notice__text {
	flex: 1;
}

.ppq-celebration-notice__title {
	font-size: 15px;
	font-weight: 600;
	color: #1d2327;
	margin: 0 0 8px;
}

.ppq-celebration-notice__message {
	font-size: 14px;
	color: #50575e;
	margin: 0 0 16px;
}

.ppq-celebration-notice__actions {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	align-items: center;
}

.ppq-celebration-notice__dismiss {
	position: absolute;
	top: 12px;
	right: 12px;
	background: none;
	border: none;
	color: #787c82;
	cursor: pointer;
	padding: 4px;
	font-size: 20px;
	line-height: 1;
}

.ppq-celebration-notice__dismiss:hover {
	color: #1d2327;
}

.ppq-celebration-notice__dismiss:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Button overrides for consistent styling */
.ppq-celebration-notice .button-primary {
	background: #0073aa;
	border-color: #0073aa;
	color: #fff;
}

.ppq-celebration-notice .button-primary:hover {
	background: #005a87;
	border-color: #005a87;
}

.ppq-celebration-notice .button-primary:focus {
	box-shadow: 0 0 0 1px #fff, 0 0 0 3px #0073aa;
}

.ppq-celebration-notice .button-secondary {
	background: #f6f7f7;
	border-color: #c3c4c7;
	color: #1d2327;
}

.ppq-celebration-notice .button-secondary:hover {
	background: #f0f0f1;
	border-color: #8c8f94;
}

.ppq-celebration-notice .button-link {
	color: #2271b1;
	text-decoration: none;
	padding: 0 10px;
}

.ppq-celebration-notice .button-link:hover {
	color: #135e96;
}

.ppq-celebration-notice .button-link:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* RTL support */
.rtl .ppq-celebration-notice {
	border-left: 1px solid #c3c4c7;
	border-right: 4px solid #0073aa;
	margin: 20px 0 20px 20px;
}

.rtl .ppq-celebration-notice__dismiss {
	right: auto;
	left: 12px;
}

/* Responsive */
@media screen and (max-width: 782px) {
	.ppq-celebration-notice__content {
		flex-direction: column;
		gap: 12px;
	}

	.ppq-celebration-notice__actions {
		flex-direction: column;
		align-items: flex-start;
	}

	.ppq-celebration-notice__actions .button {
		width: 100%;
		text-align: center;
	}

	.ppq-celebration-notice .button-link {
		padding: 8px 0;
	}
}
