/* ==========================================================================
   FM Editor — Frontend Memorial Editor
   ========================================================================== */

:root {
	--fm-color-main:    #0b3e66;
	--fm-color-accent:  #6cb34b;
	--fm-color-white:   #ffffff;
	--fm-color-bg:      #f8f9fa;
	--fm-color-border:  #dee2e6;
	--fm-color-text:    #212529;
	--fm-color-muted:   #6c757d;
	--fm-color-danger:  #c92a2a;
	--fm-color-success: #2b8a3e;
	--fm-color-warning: #e67700;
	--fm-radius:        8px;
	--fm-radius-sm:     4px;
	--fm-shadow:        0 1px 3px rgba(0, 0, 0, 0.08);
	--fm-shadow-lg:     0 4px 12px rgba(0, 0, 0, 0.1);
	--fm-transition:    0.2s ease;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.fm-editor {
	max-width: 860px;
	margin: 0 auto;
	padding: 24px 16px 80px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: var(--fm-color-text);
	line-height: 1.5;
}

/* ==========================================================================
   Header
   ========================================================================== */

.fm-editor__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 32px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--fm-color-border);
}

.fm-editor__header-left {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.fm-editor__header-right {
	display: flex;
	align-items: center;
	gap: 10px;
}

.fm-editor__title {
	font-size: 1.5rem;
	font-weight: 700;
	margin: 0;
	color: var(--fm-color-main);
}

/* ==========================================================================
   Status Indicator
   ========================================================================== */

.fm-editor__status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.8rem;
}

.fm-editor__status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	transition: background var(--fm-transition);
}

.fm-editor__status-dot--saved   { background: var(--fm-color-success); }
.fm-editor__status-dot--saving  { background: var(--fm-color-warning); animation: fm-pulse 1s infinite; }
.fm-editor__status-dot--unsaved { background: var(--fm-color-warning); }
.fm-editor__status-dot--error   { background: var(--fm-color-danger); }

@keyframes fm-pulse {
	0%, 100% { opacity: 1; }
	50%      { opacity: 0.4; }
}

.fm-editor__status-text {
	color: var(--fm-color-muted);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.fm-editor__toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--fm-color-text);
	color: var(--fm-color-white);
	padding: 12px 24px;
	border-radius: var(--fm-radius);
	font-size: 0.9rem;
	box-shadow: var(--fm-shadow-lg);
	z-index: 9999;
	transition: opacity 0.4s ease;
}

.fm-editor__toast--fade {
	opacity: 0;
}

/* ==========================================================================
   Sections
   ========================================================================== */

.fm-editor__section {
	background: var(--fm-color-white);
	border: 1px solid var(--fm-color-border);
	border-radius: var(--fm-radius);
	padding: 24px;
	margin-bottom: 20px;
	box-shadow: var(--fm-shadow);
}

.fm-editor__section-title {
	font-size: 1.1rem;
	font-weight: 600;
	margin: 0 0 4px;
	color: var(--fm-color-main);
}

.fm-editor__section-desc {
	font-size: 0.85rem;
	color: var(--fm-color-muted);
	margin: 0 0 16px;
}

/* ==========================================================================
   Form Fields
   ========================================================================== */

.fm-editor__row {
	margin-bottom: 16px;
}

.fm-editor__row--two {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

.fm-editor__field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 16px;
}

.fm-editor__field:last-child {
	margin-bottom: 0;
}

.fm-editor__label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--fm-color-text);
}

.fm-editor__required {
	color: var(--fm-color-danger);
}

.fm-editor__optional {
	color: var(--fm-color-muted);
	font-weight: 400;
}

.fm-editor__input,
.fm-editor__textarea {
	width: 100%;
	padding: 10px 12px;
	font-size: 0.95rem;
	border: 1px solid var(--fm-color-border);
	border-radius: var(--fm-radius-sm);
	background: var(--fm-color-white);
	color: var(--fm-color-text);
	transition: border-color var(--fm-transition), box-shadow var(--fm-transition);
	box-sizing: border-box;
	font-family: inherit;
}

.fm-editor__input:focus,
.fm-editor__textarea:focus {
	outline: none;
	border-color: var(--fm-color-main);
	box-shadow: 0 0 0 3px rgba(11, 62, 102, 0.12);
}

.fm-editor__textarea {
	resize: vertical;
	min-height: 120px;
}

/* ==========================================================================
   Slug
   ========================================================================== */

.fm-editor__slug-wrap {
	display: flex;
	align-items: center;
	gap: 0;
	flex-wrap: wrap;
}

.fm-editor__slug-base {
	padding: 10px 12px;
	font-size: 0.85rem;
	background: var(--fm-color-bg);
	border: 1px solid var(--fm-color-border);
	border-right: none;
	border-radius: var(--fm-radius-sm) 0 0 var(--fm-radius-sm);
	color: var(--fm-color-muted);
	white-space: nowrap;
}

.fm-editor__input--slug {
	border-radius: 0 var(--fm-radius-sm) var(--fm-radius-sm) 0;
	flex: 1;
	min-width: 150px;
}

.fm-editor__slug-status {
	display: block;
	font-size: 0.8rem;
	margin-top: 4px;
	width: 100%;
}

.fm-editor__slug-status--checking { color: var(--fm-color-muted); }
.fm-editor__slug-status--ok       { color: var(--fm-color-success); }
.fm-editor__slug-status--taken    { color: var(--fm-color-danger); }

/* ==========================================================================
   Main Photo
   ========================================================================== */

.fm-editor__section--photo {
	display: flex;
	justify-content: center;
}

.fm-editor__main-photo-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}

.fm-editor__main-photo {
	width: 200px;
	height: 200px;
	border-radius: 50%;
	overflow: hidden;
	border: 3px solid var(--fm-color-border);
	background: var(--fm-color-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color var(--fm-transition);
}

.fm-editor__main-photo:hover {
	border-color: var(--fm-color-main);
}

.fm-editor__main-photo-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.fm-editor__main-photo-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	color: var(--fm-color-muted);
	font-size: 0.85rem;
}

.fm-editor__main-photo-placeholder span:first-child {
	font-size: 2rem;
}

.fm-editor__main-photo-actions {
	display: flex;
	gap: 8px;
}

/* ==========================================================================
   Gallery
   ========================================================================== */

.fm-editor__gallery-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 16px;
	font-size: 0.85rem;
}

.fm-editor__gallery-count {
	font-weight: 600;
	color: var(--fm-color-text);
}

.fm-editor__gallery-limit {
	color: var(--fm-color-muted);
}

.fm-editor__gallery-unlimited {
	color: var(--fm-color-accent);
	font-weight: 600;
}

.fm-editor__gallery-upgrade {
	color: var(--fm-color-main);
	text-decoration: underline;
	margin-left: 4px;
}

.fm-editor__gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 12px;
	min-height: 80px;
	transition: background var(--fm-transition);
	border-radius: var(--fm-radius);
	padding: 4px;
}

.fm-editor__gallery-grid--dragover {
	background: rgba(108, 179, 75, 0.08);
	outline: 2px dashed var(--fm-color-accent);
	outline-offset: -2px;
}

.fm-editor__gallery-item {
	position: relative;
	aspect-ratio: 1;
	border-radius: var(--fm-radius-sm);
	overflow: hidden;
	border: 2px solid var(--fm-color-border);
	background: var(--fm-color-bg);
	transition: border-color var(--fm-transition), transform var(--fm-transition);
	cursor: default;
}

.fm-editor__gallery-item:hover {
	border-color: var(--fm-color-main);
}

.fm-editor__gallery-item--dragging {
	opacity: 0.4;
	transform: scale(0.95);
}

.fm-editor__gallery-item--over {
	border-color: var(--fm-color-accent);
	box-shadow: 0 0 0 2px rgba(108, 179, 75, 0.3);
}

.fm-editor__gallery-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.fm-editor__gallery-remove {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: var(--fm-color-white);
	border: none;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity var(--fm-transition);
}

.fm-editor__gallery-item:hover .fm-editor__gallery-remove {
	opacity: 1;
}

.fm-editor__gallery-remove:hover {
	background: var(--fm-color-danger);
}

.fm-editor__gallery-drag-handle {
	position: absolute;
	bottom: 4px;
	left: 4px;
	width: 24px;
	height: 24px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.5);
	color: var(--fm-color-white);
	font-size: 12px;
	line-height: 24px;
	text-align: center;
	cursor: grab;
	opacity: 0;
	transition: opacity var(--fm-transition);
	user-select: none;
}

.fm-editor__gallery-item:hover .fm-editor__gallery-drag-handle {
	opacity: 1;
}

.fm-editor__gallery-drag-handle:active {
	cursor: grabbing;
}

.fm-editor__gallery-add {
	aspect-ratio: 1;
	border: 2px dashed var(--fm-color-border);
	border-radius: var(--fm-radius-sm);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	color: var(--fm-color-muted);
	font-size: 0.8rem;
	cursor: pointer;
	transition: border-color var(--fm-transition), color var(--fm-transition), background var(--fm-transition);
}

.fm-editor__gallery-add:hover {
	border-color: var(--fm-color-accent);
	color: var(--fm-color-accent);
	background: rgba(108, 179, 75, 0.04);
}

.fm-editor__gallery-add-icon {
	font-size: 1.5rem;
	font-weight: 300;
}

/* Gallery progress */

.fm-editor__gallery-progress {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 12px;
	padding: 8px 0;
}

.fm-editor__gallery-progress-bar {
	flex: 1;
	height: 4px;
	background: var(--fm-color-bg);
	border-radius: 2px;
	overflow: hidden;
	position: relative;
}

.fm-editor__gallery-progress-bar::after {
	content: '';
	display: block;
	height: 100%;
	background: var(--fm-color-accent);
	border-radius: 2px;
	width: 0%;
	transition: width 0.3s ease;
}

.fm-editor__gallery-progress-text {
	font-size: 0.8rem;
	color: var(--fm-color-muted);
	white-space: nowrap;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.fm-editor__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.fm-editor__badge {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border: 2px solid var(--fm-color-border);
	border-radius: 999px;
	cursor: pointer;
	transition: border-color var(--fm-transition), background var(--fm-transition), color var(--fm-transition);
	user-select: none;
	font-size: 0.875rem;
}

.fm-editor__badge:hover {
	border-color: var(--fm-color-main);
	background: rgba(11, 62, 102, 0.04);
}

.fm-editor__badge--selected {
	border-color: var(--fm-color-main);
	background: var(--fm-color-main);
	color: var(--fm-color-white);
}

.fm-editor__badge-checkbox {
	display: none;
}

.fm-editor__badge-icon {
	font-size: 1rem;
	line-height: 1;
}

.fm-editor__badge-label {
	font-weight: 500;
}

/* ==========================================================================
   External Links
   ========================================================================== */

.fm-editor__links-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 12px;
}

.fm-editor__link-row {
	display: grid;
	grid-template-columns: 1fr 2fr auto;
	gap: 8px;
	align-items: center;
}

.fm-editor__input--link-label,
.fm-editor__input--link-url {
	margin: 0;
}

/* ==========================================================================
   Visibility
   ========================================================================== */

.fm-editor__visibility-wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.fm-editor__visibility-option {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 16px;
	border: 2px solid var(--fm-color-border);
	border-radius: var(--fm-radius);
	cursor: pointer;
	transition: border-color var(--fm-transition), background var(--fm-transition);
}

.fm-editor__visibility-option:hover {
	border-color: var(--fm-color-main);
	background: rgba(11, 62, 102, 0.02);
}

.fm-editor__visibility-option--selected {
	border-color: var(--fm-color-main);
	background: rgba(11, 62, 102, 0.04);
}

.fm-editor__visibility-radio {
	display: none;
}

.fm-editor__visibility-icon {
	font-size: 1.4rem;
	line-height: 1;
	margin-top: 2px;
	flex-shrink: 0;
}

.fm-editor__visibility-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.fm-editor__visibility-info strong {
	font-size: 0.95rem;
	color: var(--fm-color-text);
}

.fm-editor__visibility-info span {
	font-size: 0.82rem;
	color: var(--fm-color-muted);
}

/* ==========================================================================
   Footer Save Bar
   ========================================================================== */

.fm-editor__footer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: var(--fm-color-white);
	border-top: 1px solid var(--fm-color-border);
	padding: 14px 24px;
	display: flex;
	align-items: center;
	gap: 16px;
	z-index: 100;
	box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.fm-editor__footer-status {
	font-size: 0.82rem;
	color: var(--fm-color-muted);
}

/* ==========================================================================
   Gates (no purchase / no slots)
   ========================================================================== */

.fm-editor-gate {
	max-width: 480px;
	margin: 60px auto;
	text-align: center;
	padding: 48px 32px;
	background: var(--fm-color-white);
	border: 1px solid var(--fm-color-border);
	border-radius: var(--fm-radius);
	box-shadow: var(--fm-shadow);
}

.fm-editor-gate__icon {
	font-size: 3rem;
	margin-bottom: 16px;
}

.fm-editor-gate__title {
	font-size: 1.4rem;
	font-weight: 700;
	color: var(--fm-color-main);
	margin: 0 0 12px;
}

.fm-editor-gate__text {
	font-size: 0.95rem;
	color: var(--fm-color-muted);
	margin: 0 0 24px;
	line-height: 1.6;
}

.fm-editor-gate__cta {
	display: inline-block;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.fm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 18px;
	font-size: 0.9rem;
	font-weight: 600;
	border-radius: var(--fm-radius-sm);
	border: 2px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: background var(--fm-transition), color var(--fm-transition), border-color var(--fm-transition), opacity var(--fm-transition);
	white-space: nowrap;
	font-family: inherit;
	line-height: 1;
}

.fm-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.fm-btn--primary {
	background: var(--fm-color-main);
	color: var(--fm-color-white);
	border-color: var(--fm-color-main);
}

.fm-btn--primary:hover:not(:disabled) {
	background: #0a3357;
	border-color: #0a3357;
}

.fm-btn--secondary {
	background: var(--fm-color-bg);
	color: var(--fm-color-text);
	border-color: var(--fm-color-border);
}

.fm-btn--secondary:hover:not(:disabled) {
	background: #e9ecef;
	border-color: #adb5bd;
}

.fm-btn--ghost {
	background: transparent;
	color: var(--fm-color-muted);
	border-color: var(--fm-color-border);
}

.fm-btn--ghost:hover:not(:disabled) {
	background: var(--fm-color-bg);
	color: var(--fm-color-text);
}

.fm-btn--danger {
	color: var(--fm-color-danger);
	border-color: var(--fm-color-danger);
}

.fm-btn--danger:hover:not(:disabled) {
	background: var(--fm-color-danger);
	color: var(--fm-color-white);
}

.fm-btn--lg {
	padding: 12px 28px;
	font-size: 1rem;
}

/* ==========================================================================
   Notices
   ========================================================================== */

.fm-notice {
	padding: 14px 18px;
	border-radius: var(--fm-radius-sm);
	font-size: 0.9rem;
	margin-bottom: 16px;
	border: 1px solid transparent;
}

.fm-notice--info {
	background: #e7f5ff;
	border-color: #74c0fc;
	color: #1864ab;
}

.fm-notice--error {
	background: #fff5f5;
	border-color: #ffa8a8;
	color: var(--fm-color-danger);
}

.fm-notice--success {
	background: #ebfbee;
	border-color: #8ce99a;
	color: var(--fm-color-success);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media ( max-width: 640px ) {
	.fm-editor {
		padding: 16px 12px 100px;
	}

	.fm-editor__header {
		flex-direction: column;
		align-items: flex-start;
	}

	.fm-editor__header-right {
		width: 100%;
		justify-content: flex-end;
	}

	.fm-editor__row--two {
		grid-template-columns: 1fr;
	}

	.fm-editor__link-row {
		grid-template-columns: 1fr;
	}

	.fm-editor__slug-wrap {
		flex-direction: column;
		align-items: stretch;
	}

	.fm-editor__slug-base {
		border-right: 1px solid var(--fm-color-border);
		border-bottom: none;
		border-radius: var(--fm-radius-sm) var(--fm-radius-sm) 0 0;
	}

	.fm-editor__input--slug {
		border-radius: 0 0 var(--fm-radius-sm) var(--fm-radius-sm);
	}

	.fm-editor__main-photo {
		width: 160px;
		height: 160px;
	}

	.fm-editor__gallery-grid {
		grid-template-columns: repeat( auto-fill, minmax( 90px, 1fr ) );
	}

	.fm-editor__footer {
		padding: 12px 16px;
	}

	.fm-editor__visibility-option {
		padding: 12px;
	}

	.fm-editor-gate {
		margin: 32px auto;
		padding: 32px 20px;
	}
}
