/* ============================================================
   Rental Dashboard — Inline Content Editor
   Loaded on the frontend only for users with edit_posts cap.
   ============================================================ */

/* ── Hover outline on editable elements ──────────────────── */
[data-td-key] {
	position: relative;
	transition: outline 0.15s ease;
}

[data-td-key].td-hovered {
	outline: 2px dashed #2563eb;
	outline-offset: 4px;
	border-radius: 2px;
}

/* Gallery must not inherit text-edit hover from a parent data-td-key */
.rnt-gallery.td-hovered,
[data-rnt-gallery].td-hovered {
	outline: 2px dashed #7c3aed;
	outline-offset: 6px;
	border-radius: 4px;
}

.rnt-gallery [data-td-key].td-hovered,
[data-rnt-gallery] [data-td-key].td-hovered {
	outline: none;
}

/* ── Floating edit button ──────────────────────────────────── */
.rd-ie-float-btn {
	position: absolute;
	z-index: 999998;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 10px 5px 8px;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 6px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 12px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
	transform: translateY(0);
	box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
	white-space: nowrap;
}

.rd-ie-float-btn:hover {
	background: #1d4ed8;
}

.rd-ie-float-btn svg {
	flex-shrink: 0;
}

/* ── Modal backdrop ────────────────────────────────────────── */
.rd-ie-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 999999;
	align-items: center;
	justify-content: center;
}

.rd-ie-modal.open {
	display: flex;
}

.rd-ie-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(2px);
	animation: rd-ie-fadein 0.2s ease;
}

@keyframes rd-ie-fadein {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* ── Dialog ────────────────────────────────────────────────── */
.rd-ie-dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: min(740px, calc(100vw - 32px));
	max-height: calc(100vh - 48px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
	overflow: hidden;
	animation: rd-ie-slidein 0.2s ease;
}

@keyframes rd-ie-slidein {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────────── */
.rd-ie-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 20px;
	border-bottom: 1px solid #e5e7eb;
	background: #f8fafc;
}

.rd-ie-header-left {
	display: flex;
	align-items: center;
	gap: 8px;
	color: #2563eb;
	flex-shrink: 0;
}

.rd-ie-header-left svg {
	flex-shrink: 0;
}

.rd-ie-header h3 {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 15px;
	font-weight: 600;
	color: #0f172a;
	line-height: 1.3;
}

.rd-ie-header-right {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* ── Mode tabs (Visual / HTML) ─────────────────────────────── */
.rd-ie-mode-tabs {
	display: flex;
	align-items: center;
	background: #e2e8f0;
	border-radius: 7px;
	padding: 3px;
	gap: 2px;
}

.rd-ie-tab {
	padding: 4px 12px;
	border: none;
	border-radius: 5px;
	background: transparent;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 12px;
	font-weight: 500;
	color: #64748b;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	line-height: 1.5;
}

.rd-ie-tab:hover {
	color: #0f172a;
}

.rd-ie-tab.active {
	background: #fff;
	color: #0f172a;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.rd-ie-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 6px;
	color: #64748b;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.rd-ie-close:hover {
	background: #f1f5f9;
	color: #0f172a;
}

/* ── Toolbar ───────────────────────────────────────────────── */
.rd-ie-toolbar--disabled {
	opacity: 0.4;
	pointer-events: none;
}

.rd-ie-toolbar {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 8px 12px;
	border-bottom: 1px solid #e5e7eb;
	background: #f8fafc;
}

.rd-ie-toolbar button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 30px;
	height: 30px;
	padding: 0 6px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 5px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	color: #374151;
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.rd-ie-toolbar button:hover {
	background: #e2e8f0;
	color: #0f172a;
}

.rd-ie-toolbar button.active {
	background: #dbeafe;
	border-color: #93c5fd;
	color: #1d4ed8;
}

.rd-ie-toolbar button strong,
.rd-ie-toolbar button em {
	line-height: 1;
	pointer-events: none;
}

.rd-ie-sep {
	display: block;
	width: 1px;
	height: 20px;
	background: #d1d5db;
	margin: 0 4px;
	flex-shrink: 0;
}

/* ── Contenteditable editor area ───────────────────────────── */
.rd-ie-editor {
	flex: 1;
	overflow-y: auto;
	padding: 20px 24px;
	min-height: 160px;
	max-height: 420px;
	outline: none;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 15px;
	line-height: 1.7;
	color: #1e293b;
	caret-color: #2563eb;
}

.rd-ie-editor:focus {
	box-shadow: inset 0 0 0 2px #dbeafe;
}

/* Preserve basic formatting in the editor */
.rd-ie-editor p      { margin: 0 0 0.75em; }
.rd-ie-editor p:last-child { margin-bottom: 0; }
.rd-ie-editor strong { font-weight: 700; }
.rd-ie-editor em     { font-style: italic; }
.rd-ie-editor a      { color: #2563eb; text-decoration: underline; }
.rd-ie-editor ul,
.rd-ie-editor ol     { margin: 0.5em 0; padding-left: 1.5em; }
.rd-ie-editor li     { margin-bottom: 0.25em; }

/* ── HTML source textarea ──────────────────────────────────── */
.rd-ie-html {
	display: none;
	flex: 1;
	width: 100%;
	min-height: 160px;
	max-height: 420px;
	padding: 16px 20px;
	border: none;
	outline: none;
	resize: none;
	box-sizing: border-box;
	font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', Consolas, 'Courier New', monospace;
	font-size: 13px;
	line-height: 1.7;
	color: #1e293b;
	background: #f8fafc;
	caret-color: #2563eb;
	tab-size: 2;
}

.rd-ie-html:focus {
	box-shadow: inset 0 0 0 2px #dbeafe;
}

/* ── Footer ────────────────────────────────────────────────── */
.rd-ie-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 20px;
	border-top: 1px solid #e5e7eb;
	background: #f8fafc;
}

.rd-ie-hint {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 11px;
	color: #94a3b8;
	white-space: nowrap;
}

.rd-ie-footer-btns {
	display: flex;
	gap: 8px;
}

.rd-ie-cancel {
	padding: 8px 16px;
	background: transparent;
	border: 1px solid #d1d5db;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.rd-ie-cancel:hover {
	background: #f1f5f9;
	border-color: #9ca3af;
}

.rd-ie-save {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	background: #2563eb;
	border: none;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	transition: background 0.15s, opacity 0.15s;
}

.rd-ie-save:hover:not(:disabled) {
	background: #1d4ed8;
}

.rd-ie-save:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

/* Spinner — hidden by default, shown while saving */
.rd-ie-spinner {
	display: none;
	flex-shrink: 0;
}

.rd-ie-save.loading .rd-ie-save-label {
	opacity: 0.7;
}

.rd-ie-save.loading .rd-ie-spinner {
	display: block;
	animation: rd-ie-spin 0.75s linear infinite;
}

@keyframes rd-ie-spin {
	to { transform: rotate(360deg); }
}

/* ── Image variant of the float button ─────────────────────── */
.rd-ie-float-btn--image {
	background: #059669;
	box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}

.rd-ie-float-btn--image:hover {
	background: #047857;
}

/* ═══════════════════════════════════════════════════════════════
   MEDIA LIBRARY MODAL
   ═══════════════════════════════════════════════════════════════ */

/* ── Backdrop + dialog ─────────────────────────────────────── */
.rd-ml-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 999999;
	align-items: center;
	justify-content: center;
}

.rd-ml-modal.open {
	display: flex;
}

.rd-ml-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(2px);
	animation: rd-ie-fadein 0.2s ease;
}

.rd-ml-dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: min(920px, calc(100vw - 32px));
	max-height: calc(100vh - 48px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
	overflow: hidden;
	animation: rd-ie-slidein 0.2s ease;
}

/* ── Header ────────────────────────────────────────────────── */
.rd-ml-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e5e7eb;
	background: #f8fafc;
	flex-shrink: 0;
}

.rd-ml-header-left {
	display: flex;
	align-items: center;
	gap: 8px;
	color: #059669;
}

.rd-ml-header h3 {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 15px;
	font-weight: 600;
	color: #0f172a;
}

.rd-ml-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 6px;
	color: #64748b;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.rd-ml-close:hover {
	background: #f1f5f9;
	color: #0f172a;
}

/* ── Toolbar (search + upload) ─────────────────────────────── */
.rd-ml-toolbar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border-bottom: 1px solid #e5e7eb;
	background: #f8fafc;
	flex-shrink: 0;
}

.rd-ml-search-wrap {
	display: flex;
	align-items: center;
	flex: 1;
	gap: 8px;
	padding: 0 10px;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 7px;
	color: #9ca3af;
	transition: border-color 0.15s;
}

.rd-ml-search-wrap:focus-within {
	border-color: #2563eb;
	color: #2563eb;
}

.rd-ml-search {
	flex: 1;
	height: 34px;
	border: none;
	outline: none;
	background: transparent;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	color: #1e293b;
}

.rd-ml-search::placeholder {
	color: #94a3b8;
}

/* Upload button */
.rd-ml-upload-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
	white-space: nowrap;
	flex-shrink: 0;
}

.rd-ml-upload-label:hover {
	background: #f1f5f9;
	border-color: #9ca3af;
}

.rd-ml-upload-label.uploading {
	opacity: 0.85;
	pointer-events: none;
}

.rd-ml-upload-label .rd-ml-upload-spinner {
	display: none;
}

.rd-ml-upload-label.uploading .rd-ml-upload-icon {
	display: none;
}

.rd-ml-upload-label.uploading .rd-ml-upload-spinner {
	display: block;
}

.rd-ml-file-input {
	display: none;
}

/* ── Image grid ────────────────────────────────────────────── */
.rd-ml-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
}

.rd-ml-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 130px, 1fr ) );
	gap: 8px;
}

.rd-ml-item {
	position: relative;
	aspect-ratio: 1;
	overflow: hidden;
	border: 2px solid transparent;
	border-radius: 8px;
	background: #f1f5f9;
	padding: 0;
	cursor: pointer;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.rd-ml-item:hover {
	border-color: #93c5fd;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.rd-ml-item.selected {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.rd-ml-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

/* Checkmark overlay */
.rd-ml-item-check {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	background: #2563eb;
	border-radius: 50%;
	color: #fff;
	opacity: 0;
	transform: scale(0.7);
	transition: opacity 0.15s, transform 0.15s;
}

.rd-ml-item.selected .rd-ml-item-check {
	opacity: 1;
	transform: scale(1);
}

/* ── Status area (loading / empty / load more) ─────────────── */
.rd-ml-status {
	margin-top: 12px;
	text-align: center;
}

.rd-ml-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 24px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	color: #64748b;
}

.rd-ml-uploading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 14px 16px;
	margin-bottom: 8px;
	border-radius: 10px;
	background: color-mix(in srgb, var(--rd-site-accent, #2563eb) 8%, #fff);
	border: 1px solid color-mix(in srgb, var(--rd-site-accent, #2563eb) 22%, #e2e8f0);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #334155;
}

.rd-ml-item--uploading {
	border: 2px dashed #93c5fd;
	background: #f8fafc;
	pointer-events: none;
}

.rd-ml-item-uploading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	height: 100%;
	padding: 10px;
	box-sizing: border-box;
	text-align: center;
	color: #64748b;
}

.rd-ml-item-uploading-label {
	font-size: 12px;
	font-weight: 600;
	color: #475569;
}

.rd-ml-item-uploading-name {
	font-size: 11px;
	line-height: 1.35;
	color: #94a3b8;
	word-break: break-word;
	max-width: 100%;
}

.rd-ml-grid.is-uploading {
	opacity: 0.92;
}

.rd-ml-spin {
	animation: rd-ie-spin 0.75s linear infinite;
	flex-shrink: 0;
}

.rd-ml-empty {
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 32px 16px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	color: #94a3b8;
}

.rd-ml-empty p {
	margin: 0;
}

.rd-ml-load-more {
	margin-top: 12px;
	padding: 8px 20px;
	background: transparent;
	border: 1px solid #d1d5db;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
	cursor: pointer;
	transition: background 0.15s;
}

.rd-ml-load-more:hover {
	background: #f1f5f9;
}

/* ── Footer ────────────────────────────────────────────────── */
.rd-ml-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 20px;
	border-top: 1px solid #e5e7eb;
	background: #f8fafc;
	flex-shrink: 0;
}

.rd-ml-selection-info {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 12px;
	color: #64748b;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rd-ml-footer-btns {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.rd-ml-cancel {
	padding: 8px 16px;
	background: transparent;
	border: 1px solid #d1d5db;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #374151;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.rd-ml-cancel:hover {
	background: #f1f5f9;
	border-color: #9ca3af;
}

.rd-ml-confirm {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	background: #059669;
	border: none;
	border-radius: 7px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	transition: background 0.15s, opacity 0.15s;
}

.rd-ml-confirm:hover:not(:disabled) {
	background: #047857;
}

.rd-ml-confirm:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.rd-ml-confirm.loading .rd-ml-confirm-label {
	opacity: 0.7;
}

.rd-ml-confirm.loading .rd-ie-spinner {
	display: block;
	animation: rd-ie-spin 0.75s linear infinite;
}
