/* Ashbar Useful Tools - MD / Rich / HTML editor. Scoped, RTL-aware, theme-friendly.
 * Same visual language as the PDF-split tool: #2563eb accent, soft borders, 10px radii. */

.ashbar-mde-wrap {
	position: relative;
	direction: rtl;
	text-align: right;
	max-width: 900px;
	margin: 0 auto;
	padding: 24px;
	border: 1px solid #e2e2e2;
	border-radius: 10px;
	background: #fff;
	box-sizing: border-box;
}

.ashbar-mde-wrap * {
	box-sizing: border-box;
}

/* The explicit display values below (flex/block) would otherwise override
 * the browser's [hidden] { display: none } - so enforce it. */
.ashbar-mde-wrap [hidden] {
	display: none !important;
}

.ashbar-mde-title {
	margin: 0 0 8px;
}

.ashbar-mde-intro {
	margin: 0 0 20px;
	color: #555;
	font-size: 0.95em;
}

/* Top bar: tabs + direction */

.ashbar-mde-topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 10px;
}

.ashbar-mde-tabs {
	display: flex;
	gap: 4px;
}

.ashbar-mde-tab {
	padding: 8px 18px;
	border: 1px solid #d5d5d5;
	border-bottom: none;
	border-radius: 8px 8px 0 0;
	background: #f3f3f3;
	color: #444;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ashbar-mde-tab:hover {
	background: #e9efff;
}

.ashbar-mde-tab.is-active {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
}

.ashbar-mde-dir {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.9em;
	color: #555;
}

.ashbar-mde-dir-btn {
	padding: 5px 10px;
	border: 1px solid #d5d5d5;
	border-radius: 6px;
	background: #fff;
	font: inherit;
	font-size: 0.9em;
	cursor: pointer;
}

.ashbar-mde-dir-btn.is-active {
	background: #2563eb;
	border-color: #2563eb;
	color: #fff;
}

/* Toolbar */

.ashbar-mde-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	padding: 8px;
	border: 1px solid #e2e2e2;
	border-bottom: none;
	border-radius: 8px 8px 0 0;
	background: #fafafa;
}

.ashbar-mde-format {
	padding: 5px 8px;
	border: 1px solid #d5d5d5;
	border-radius: 6px;
	background: #fff;
	font: inherit;
	font-size: 0.9em;
	cursor: pointer;
}

.ashbar-mde-tbtn {
	min-width: 34px;
	padding: 5px 8px;
	border: 1px solid transparent;
	border-radius: 6px;
	background: transparent;
	font: inherit;
	font-size: 0.95em;
	line-height: 1.2;
	color: #333;
	cursor: pointer;
	transition: background-color 0.1s ease;
}

.ashbar-mde-tbtn:hover {
	background: #e9efff;
	border-color: #c9d8fb;
}

.ashbar-mde-tbtn-code {
	font-family: monospace;
	font-size: 0.85em;
}

.ashbar-mde-tsep {
	width: 1px;
	height: 22px;
	margin: 0 4px;
	background: #ddd;
}

/* Link / image bar */

.ashbar-mde-linkbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding: 8px;
	border: 1px solid #c9d8fb;
	border-radius: 0;
	background: #f0f5ff;
}

.ashbar-mde-linkbar input {
	flex: 1 1 220px;
	padding: 6px 10px;
	border: 1px solid #c4c4c4;
	border-radius: 6px;
	font: inherit;
	font-size: 0.9em;
}

/* Panes */

.ashbar-mde-rich,
.ashbar-mde-code {
	width: 100%;
	padding: 14px 16px;
	border: 1px solid #e2e2e2;
	border-radius: 0 0 8px 8px;
	background: #fff;
	font: inherit;
	line-height: 1.6;
	overflow: auto;
}

/* Alignment follows the chosen direction (MD has no alignment of its own). */
.ashbar-mde-rich[dir="rtl"],
.ashbar-mde-code[dir="rtl"] {
	text-align: right;
}

.ashbar-mde-rich[dir="ltr"],
.ashbar-mde-code[dir="ltr"] {
	text-align: left;
}

.ashbar-mde-rich:focus,
.ashbar-mde-code:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ashbar-mde-rich.is-empty::before {
	content: attr(data-placeholder);
	color: #999;
	pointer-events: none;
}

.ashbar-mde-code {
	display: block;
	resize: vertical;
	font-family: Consolas, Menlo, monospace;
	font-size: 0.9em;
	white-space: pre-wrap;
}

/* Rich-content element defaults (in case the theme resets them) */

.ashbar-mde-rich blockquote {
	margin: 0.6em 0;
	padding: 0.2em 1em;
	border-inline-start: 3px solid #c9d8fb;
	color: #555;
}

.ashbar-mde-rich pre {
	padding: 10px 12px;
	border-radius: 6px;
	background: #f5f5f5;
	font-family: Consolas, Menlo, monospace;
	font-size: 0.9em;
	direction: ltr;
	text-align: left;
	overflow: auto;
}

.ashbar-mde-rich code {
	padding: 1px 5px;
	border-radius: 4px;
	background: #f2f2f2;
	font-family: Consolas, Menlo, monospace;
	font-size: 0.9em;
}

.ashbar-mde-rich pre code {
	padding: 0;
	background: transparent;
}

.ashbar-mde-rich table {
	border-collapse: collapse;
	margin: 0.6em 0;
}

.ashbar-mde-rich th,
.ashbar-mde-rich td {
	border: 1px solid #ccc;
	padding: 6px 10px;
}

.ashbar-mde-rich img {
	max-width: 100%;
	height: auto;
}

.ashbar-mde-rich hr {
	border: none;
	border-top: 1px solid #ddd;
	margin: 1em 0;
}

/* Status */

.ashbar-mde-status {
	min-height: 1.4em;
	margin: 8px 0;
	font-size: 0.92em;
}

.ashbar-mde-status-ok {
	color: #15803d;
}

.ashbar-mde-status-error {
	color: #b91c1c;
}

/* Actions */

.ashbar-mde-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 28px;
	margin-top: 6px;
}

.ashbar-mde-action-group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.ashbar-mde-action-label {
	font-size: 0.9em;
	color: #555;
}

.ashbar-mde-button {
	padding: 8px 16px;
	border: 1px solid #2563eb;
	border-radius: 8px;
	background: #2563eb;
	color: #fff;
	font: inherit;
	font-size: 0.92em;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ashbar-mde-button:hover {
	background: #1e50c4;
}

.ashbar-mde-button-secondary {
	background: #fff;
	color: #2563eb;
}

.ashbar-mde-button-secondary:hover {
	background: #f0f5ff;
}

.ashbar-mde-button-small {
	padding: 6px 12px;
}

/* Drop overlay */

.ashbar-mde-drop-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px dashed #2563eb;
	border-radius: 10px;
	background: rgba(240, 245, 255, 0.92);
	color: #2563eb;
	font-size: 1.1em;
	font-weight: 600;
	z-index: 5;
	pointer-events: none;
}

/* Modal */

.ashbar-mde-modal {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(0, 0, 0, 0.45);
	z-index: 100000;
}

.ashbar-mde-modal-box {
	direction: rtl;
	text-align: right;
	max-width: 480px;
	width: 100%;
	max-height: 85vh;
	overflow: auto;
	padding: 22px 24px;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.ashbar-mde-modal-box h4 {
	margin: 0 0 10px;
	font-size: 1.1em;
}

.ashbar-mde-modal-box p {
	margin: 0 0 12px;
	color: #444;
}

.ashbar-mde-loss-list {
	margin: 0 0 16px;
	padding-inline-start: 20px;
	color: #444;
}

.ashbar-mde-loss-list li {
	margin-bottom: 4px;
}

.ashbar-mde-modal-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-start;
}

/* Responsive */

@media (max-width: 600px) {
	.ashbar-mde-wrap {
		padding: 14px;
	}

	.ashbar-mde-topbar {
		flex-direction: column;
		align-items: stretch;
	}

	.ashbar-mde-tabs {
		justify-content: stretch;
	}

	.ashbar-mde-tab {
		flex: 1;
	}
}
