/**
 * Editor layout styles for Mail Doctor email templates.
 */

.wpmd-editor-grid {
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr);
	gap: 24px;
	align-items: flex-start;
	margin-top: 24px;
}

.wpmd-editor-grid__sidebar,
.wpmd-editor-grid__main {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.wpmd-email-templates-wrap {
	color: var(--md-color-text, #1d2327);
}

.wpmd-email-templates-wrap p,
.wpmd-email-templates-wrap .helper-text {
	color: var(--md-color-muted, #50575e);
}

.wpmd-card {
	background: var(--md-color-surface, #ffffff);
	border: 1px solid var(--md-color-border, #dcdcde);
	border-radius: 4px;
	padding: 28px 24px 24px;
	box-shadow: var(--md-shadow-sm, 0 12px 28px -20px rgba(28, 50, 83, 0.45));
	position: relative;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wpmd-card:hover,
.wpmd-card:focus-within {
	border-color: rgba(34, 113, 177, 0.25);
	box-shadow: var(--md-shadow-lg);
}

.wpmd-editor-grid__workspace {
	padding: 32px 32px 28px;
}

.wpmd-editor-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 16px;
	gap: 16px;
}

.wpmd-editor-header__titles h2 {
	margin: 0 0 4px;
	font-size: 20px;
	color: var(--md-color-text, #1d2327);
}

.wpmd-editor-meta {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
	padding: 12px 16px;
	border: 1px solid rgba(34, 113, 177, 0.18);
	border-radius: 8px;
	background: rgba(34, 113, 177, 0.06);
}

.wpmd-editor-meta__saved {
	font-size: 13px;
	color: var(--md-color-muted, #50575e);
}

.wpmd-editor-stage {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
}

.wpmd-editor-stage__left,
.wpmd-editor-stage__right {
	flex: 1 1 420px;
	min-width: 320px;
}

.wpmd-preview-header {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 18px;
}

.wpmd-preview-header h2 {
	margin: 0;
	font-size: 18px;
	color: var(--md-color-text, #1d2327);
}

.wpmd-preview-header p {
	margin: 0;
	font-size: 13px;
	color: var(--md-color-muted, #50575e);
}

.wpmd-editor-tabs {
	display: inline-flex;
	background: #edf2f7;
	border-radius: 12px;
	padding: 4px;
	margin-bottom: 18px;
	box-shadow: inset 0 0 0 1px rgba(34, 113, 177, 0.08);
}

.wpmd-editor-tab {
	border: 0;
	background: transparent;
	padding: 8px 18px;
	border-radius: 10px;
	font-weight: 600;
	color: var(--md-color-text, #1d2327);
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.wpmd-editor-tab.is-active {
	background: var(--md-color-accent, #2271b1);
	color: #fff;
	box-shadow: 0 10px 18px -12px rgba(9, 83, 146, 0.8);
}

.wpmd-field {
	margin-bottom: 16px;
}

.wpmd-field label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	color: var(--md-color-text, #1d2327);
}

.wpmd-field input[type="text"] {
	width: 100%;
}

.wpmd-editor-mode {
	display: none;
}

.wpmd-editor-mode.is-active {
	display: block;
}

.wpmd-editor-mode--visual textarea {
	width: 100%;
	min-height: 420px;
}

.wpmd-editor-mode--code textarea {
	width: 100%;
}

.wpmd-preview-controls {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
	margin-bottom: 16px;
	align-items: end;
}

.wpmd-editor-grid__merge-tags .wpmd-merge-tags-panel__body {
	max-height: 220px;
	overflow-y: auto;
}

.wpmd-editor-grid__help ul {
	margin: 0 0 16px;
	padding-left: 18px;
}

.wpmd-control label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
	color: var(--md-color-text, #1d2327);
}

.wpmd-preview-frame {
	position: relative;
	border: 1px solid #d0d0db;
	border-radius: 12px;
	overflow: hidden;
	min-height: 420px;
	background: linear-gradient(180deg, #f9fbff 0%, #ffffff 20%);
	box-shadow: 0 16px 30px -24px rgba(22, 42, 71, 0.7);
}

.wpmd-preview-frame iframe {
	width: 100%;
	min-height: 420px;
	border: 0;
	background: #fff;
}

.wpmd-preview-overlay {
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.85);
	display: none;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	color: var(--md-color-text, #1d2327);
	font-size: 15px;
	letter-spacing: 0.01em;
}

.wpmd-preview-frame.is-loading .wpmd-preview-overlay {
	display: flex;
}

.wpmd-preview-diagnostics {
	margin-top: 12px;
	font-size: 13px;
	color: var(--md-color-muted, #50575e);
}

.wpmd-preview-warnings {
	margin-top: 16px;
	padding: 12px 14px;
	border: 1px solid #dba617;
	background: #fff8e5;
	border-radius: 4px;
	display: none;
	font-size: 13px;
	color: #593d00;
}

.wpmd-preview-warnings.has-warnings {
	display: block;
}

.wpmd-preview-warnings__title {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
}

.wpmd-preview-warnings ul {
	margin: 0;
	padding-left: 18px;
}

.wpmd-preview-warnings li {
	margin-bottom: 4px;
}

.wpmd-editor-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	margin-top: 24px;
}

.wpmd-template-list__nav {
	display: block;
	margin-bottom: 18px;
}

.wpmd-template-list__description {
	margin-top: 18px;
	font-size: 13px;
	color: var(--md-color-muted, #50575e);
}

.wpmd-template-list__nav ul {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wpmd-template-list__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 16px;
	border-radius: 10px;
	border: 1px solid transparent;
	background: var(--md-color-neutral-soft, #f6f7f7);
	font-weight: 600;
	color: var(--md-color-text, #1d2327);
	text-decoration: none;
	transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.wpmd-template-list__label {
	flex: 1 1 auto;
}

.wpmd-template-list__item:hover,
.wpmd-template-list__item:focus {
	background: var(--md-color-accent-soft, #eef5ff);
	border-color: rgba(34, 113, 177, 0.35);
	color: var(--md-color-accent, #2271b1);
	box-shadow: 0 12px 22px -20px rgba(34, 113, 177, 0.65);
}

.wpmd-template-list__item.is-active {
	background: var(--md-color-accent, #2271b1);
	color: #fff;
	box-shadow: 0 16px 26px -18px rgba(17, 85, 143, 0.9);
}

.wpmd-template-list__item.is-active .wpmd-template-list__status {
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
}

.wpmd-template-list__status {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 2px 10px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	border-radius: 999px;
	background: rgba(34, 113, 177, 0.1);
	color: var(--md-color-accent, #2271b1);
}

.wpmd-merge-tags-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 16px;
	position: sticky;
	top: 0;
	background: var(--md-color-surface, #ffffff);
	padding-bottom: 6px;
	box-shadow: 0 1px 0 rgba(26, 36, 47, 0.06);
}

.wpmd-merge-tags-panel {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.wpmd-merge-tags-panel__header input[type="search"] {
	flex: 1 1 auto;
}

.wpmd-merge-tag-group h3 {
	font-size: 14px;
	margin: 16px 0 8px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--md-color-muted, #50575e);
}

.wpmd-merge-tag-group ul {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wpmd-merge-tags-panel__body {
	flex: 1 1 auto;
	overflow: auto;
	max-height: calc(100vh - 260px);
	scrollbar-width: thin;
	scrollbar-color: rgba(34, 113, 177, 0.3) transparent;
	padding-right: 4px;
}

.wpmd-merge-tags-panel__body::-webkit-scrollbar {
	width: 8px;
}

.wpmd-merge-tags-panel__body::-webkit-scrollbar-thumb {
	background: rgba(34, 113, 177, 0.35);
	border-radius: 999px;
}

.wpmd-merge-tags-panel__body::-webkit-scrollbar-track {
	background: transparent;
}

.wpmd-merge-tags-panel__body::after {
	content: '';
	display: block;
	height: 8px;
}

.wpmd-merge-tag {
	border: 1px solid #c3c4c7;
	background: #f6f7f7;
	padding: 6px 10px;
	border-radius: 4px;
	cursor: pointer;
	font-family: var(--wp--preset--font-family--monospace, Menlo, Consolas, monospace);
	font-size: 12px;
	color: var(--md-color-text, #1d2327);
}

.wpmd-merge-tag:focus,
.wpmd-merge-tag:hover {
	border-color: #2271b1;
	color: var(--md-color-accent, #2271b1);
	background: #f0f6fc;
}

.wpmd-help-card,
.wpmd-toggle-card,
.wpmd-template-list {
	margin-bottom: 24px;
}

.wpmd-toggle-card__header h2 {
	margin: 0 0 4px;
}

.wpmd-editor-grid__settings .toggle-control {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 12px 0 16px;
}

.wpmd-editor-grid__merge-tags .helper-text {
	margin-top: 16px;
	font-size: 13px;
	color: #50575e;
}

@media (max-width: 1100px) {
	.wpmd-editor-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 900px) {
	.wpmd-card {
		padding: 24px 20px;
	}

	.wpmd-editor-grid {
		gap: 18px;
	}

	.wpmd-template-list__nav {
		position: static;
	}
}

@media (max-width: 782px) {
	.wpmd-editor-grid__settings {
		padding-top: 24px;
	}

	.wpmd-template-list__nav ul {
		flex-direction: row;
		overflow-x: auto;
		gap: 12px;
		padding-bottom: 4px;
		scrollbar-width: thin;
	}

	.wpmd-template-list__nav li {
		flex: 0 0 auto;
	}

	.wpmd-template-list__item {
		min-width: 200px;
	}

	.wpmd-editor-meta {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.wpmd-card,
	.wpmd-card::before,
	.wpmd-template-list__item,
	.wpmd-editor-tab {
		transition: none;
	}
}
