/**
 * SiteFeedback Frontend Styles — Widget button, modal, form.
 */

/* ─── Reset / Base ──────────────────────────────────────────────────── */
#sf-trigger-btn,
.sf-modal,
.sf-modal *,
.sf-modal *::before,
.sf-modal *::after {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Floating Button ───────────────────────────────────────────────── */
#sf-trigger-btn {
	position: fixed;
	z-index: 999999;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	padding: 0;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sf-trigger-btn:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

/* ─── Modal ─────────────────────────────────────────────────────────── */
.sf-modal {
	display: none;
	position: fixed;
	z-index: 1000000;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.sf-modal.sf-active {
	display: flex;
	align-items: center;
	justify-content: center;
}

.sf-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.5);
	backdrop-filter: blur(2px);
}

.sf-modal-container {
	position: relative;
	z-index: 1;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	width: 90%;
	max-width: 520px;
	max-height: 90vh;
	overflow-y: auto;
	animation: sf-slide-up 0.3s ease;
}

@keyframes sf-slide-up {
	from { transform: translateY(20px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

/* ─── Modal Header ──────────────────────────────────────────────────── */
.sf-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e5e7eb;
}

.sf-modal-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: #111827;
}

.sf-modal-close {
	background: none;
	border: none;
	font-size: 24px;
	cursor: pointer;
	color: #9ca3af;
	padding: 0 4px;
	line-height: 1;
}

.sf-modal-close:hover {
	color: #374151;
}

/* ─── Modal Body ────────────────────────────────────────────────────── */
.sf-modal-body {
	padding: 20px;
}

/* ─── Success Message ───────────────────────────────────────────────── */
.sf-success-msg {
	text-align: center;
	padding: 24px 0;
}

.sf-success-msg svg {
	margin-bottom: 12px;
}

.sf-success-msg p {
	font-size: 16px;
	color: #16a34a;
	font-weight: 500;
}

/* ─── Form ──────────────────────────────────────────────────────────── */
.sf-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.sf-form-row {
	display: flex;
	gap: 12px;
}

.sf-form-row .sf-form-group {
	flex: 1;
}

.sf-form-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.sf-form-group label {
	font-size: 13px;
	font-weight: 500;
	color: #374151;
}

.sf-required {
	color: #ef4444;
}

.sf-form-group input[type="text"],
.sf-form-group input[type="email"],
.sf-form-group select,
.sf-form-group textarea {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	transition: border-color 0.2s;
	background: #fff;
	color: #111827;
}

.sf-form-group input:focus,
.sf-form-group select:focus,
.sf-form-group textarea:focus {
	outline: none;
	border-color: #6366f1;
	box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.sf-form-group textarea {
	resize: vertical;
	min-height: 80px;
}

/* ─── Screenshot Area ───────────────────────────────────────────────── */
.sf-screenshot-area {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#sf-screenshot-preview-wrap {
	max-width: 100%;
	overflow: hidden;
	border-radius: 6px;
	border: 1px solid #e5e7eb;
}

#sf-screenshot-preview {
	max-width: 100%;
	height: auto;
	display: block;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */
.sf-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	border: none;
	transition: background 0.2s, transform 0.1s;
}

.sf-btn:active {
	transform: scale(0.98);
}

.sf-btn-primary {
	background: #6366f1;
	color: #fff;
}

.sf-btn-primary:hover {
	background: #4f46e5;
}

.sf-btn-primary:disabled {
	background: #a5b4fc;
	cursor: not-allowed;
}

.sf-btn-secondary {
	background: #f3f4f6;
	color: #374151;
}

.sf-btn-secondary:hover {
	background: #e5e7eb;
}

.sf-btn-ghost {
	background: transparent;
	color: #6b7280;
}

.sf-btn-ghost:hover {
	background: #f3f4f6;
	color: #374151;
}

.sf-form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding-top: 8px;
}

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 540px) {
	.sf-modal-container {
		width: 95%;
		max-height: 95vh;
	}

	.sf-form-row {
		flex-direction: column;
		gap: 14px;
	}

	.sf-modal-body {
		padding: 16px;
	}
}

/* ─── Screenshot Editor Overlay ─────────────────────────────────────── */
#sf-editor-overlay {
	position: absolute; /* cover the whole document */
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: transparent; /* transparent to see live DOM */
	z-index: 1000001; /* Above modal */
	pointer-events: none; /* let clicks through unless on children */
}

.sf-editor-toolbar {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 60px;
	background: #1f2937;
	border-bottom: 1px solid #374151;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px;
	z-index: 1000002;
	pointer-events: auto;
}

.sf-editor-tools, .sf-editor-actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

/* Tool icons: dark icon over a light chip so they stay readable even when
   the theme paints its own button background (e.g. Elementor kit yellow).
   The icon color carries !important because theme button/button:hover rules
   otherwise leave a light icon over a light background (invisible). */
.sf-editor-tools .sf-btn-ghost {
	background: #e5e7eb;
	color: #111827 !important;
}

.sf-editor-tools .sf-btn-ghost:hover {
	background: #d1d5db;
	color: #111827 !important;
}

.sf-editor-tools .sf-btn-ghost.active,
.sf-editor-tools .sf-btn-ghost.active:hover,
.sf-editor-tools .sf-btn-ghost.active:focus {
	background: #4f46e5 !important;
	color: #fff !important;
}

.sf-tool-separator {
	width: 1px;
	height: 24px;
	background: #4b5563;
	margin: 0 4px;
}

.sf-editor-canvas-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	cursor: crosshair;
	pointer-events: auto; /* catch all drawing */
}

.sf-editor-canvas-container.tool-pin {
	cursor: cell;
}

#sf-editor-draw-canvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 2;
}

#sf-editor-pins-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 3;
	pointer-events: none; /* Let clicks pass through unless on a pin */
}

/* ─── Pin Markers ───────────────────────────────────────────────────── */
.sf-pin-marker {
	position: absolute;
	width: 28px;
	height: 28px;
	background: #f43f5e;
	color: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 14px;
	transform: translate(-50%, -50%);
	box-shadow: 0 2px 8px rgba(0,0,0,0.3);
	pointer-events: auto; /* Catch clicks */
	cursor: pointer;
	border: 2px solid #fff;
	z-index: 10;
}

.sf-pin-marker:hover {
	background: #e11d48;
}

/* Number badge inside the marker — kept in its own element so it can be
   relabelled on delete without disturbing the attached input wrapper. */
.sf-pin-num {
	line-height: 1;
	pointer-events: none;
}

/* "Delete pin" button inside a pin's input wrapper. */
.sf-pin-input-wrap .sf-btn.sf-pin-delete {
	background: #fee2e2;
	color: #b91c1c;
	border: 1px solid #fca5a5;
}

.sf-pin-input-wrap .sf-btn.sf-pin-delete:hover {
	background: #fecaca;
}

.sf-pin-input-wrap {
	position: absolute;
	top: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background: #fff;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0,0,0,0.2);
	padding: 10px;
	width: 264px;
	z-index: 20;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sf-pin-input-wrap textarea {
	width: 100%;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	padding: 6px;
	font-size: 13px;
	resize: vertical;
	min-height: 60px;
	color: #111827;
}

.sf-pin-input-wrap textarea:focus {
	outline: none;
	border-color: #6366f1;
}

.sf-pin-input-wrap .sf-btn-group {
	display: flex;
	justify-content: flex-end;
	gap: 4px;
}

.sf-pin-input-wrap .sf-btn {
	padding: 4px 8px;
	font-size: 12px;
}

/* Per-pin photo attachment */
.sf-pin-attach {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 12px;
	color: #4b5563;
	margin-top: 2px;
}

.sf-pin-attach-label {
	font-weight: 600;
	color: #6366f1;
}

.sf-pin-attach input[type="file"] {
	width: 100%;
	font-size: 11px;
	color: #4b5563;
}

.sf-pin-attach input[type="file"]::-webkit-file-upload-button {
	margin-right: 8px;
	padding: 4px 10px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	background: #f3f4f6;
	color: #374151;
	font-size: 11px;
	cursor: pointer;
}

.sf-pin-attach input[type="file"]::file-selector-button {
	margin-right: 8px;
	padding: 4px 10px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	background: #f3f4f6;
	color: #374151;
	font-size: 11px;
	cursor: pointer;
}

.sf-pin-attach input[type="file"]::file-selector-button:hover {
	background: #e5e7eb;
}

.sf-pin-thumb {
	display: none;
	width: 100%;
	max-height: 130px;
	object-fit: contain;
	background: #f9fafb;
	border-radius: 6px;
	border: 1px solid #e5e7eb;
	padding: 4px;
}

/* Pin marker that carries a photo gets a ring */
.sf-pin-marker.sf-pin-has-photo {
	box-shadow: 0 0 0 3px #fbbf24, 0 2px 8px rgba(0,0,0,0.3);
}

/* ─── Preview (in-modal) with overlaid pins ─────────────────────────── */
.sf-preview-viewer {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: 0;
}

.sf-preview-pins {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.sf-preview-pin {
	position: absolute;
	width: 22px;
	height: 22px;
	transform: translate(-50%, -50%);
	background: #f43f5e;
	color: #fff;
	border: 2px solid #fff;
	border-radius: 50%;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(0,0,0,0.4);
	line-height: 1;
}

.sf-preview-pin.sf-pin-has-photo {
	box-shadow: 0 0 0 2px #fbbf24, 0 1px 4px rgba(0,0,0,0.4);
}

/* ─── Device View Selector (in-modal) ───────────────────────────────── */
.sf-device-select {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.sf-device-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	color: #374151;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.sf-device-btn:hover {
	background: #f3f4f6;
}

/* !important: theme button styles (e.g. Elementor kit button:focus/hover)
   otherwise repaint the clicked button and the selected state becomes
   invisible right after clicking it. */
.sf-device-btn.active,
.sf-device-btn.active:hover,
.sf-device-btn.active:focus {
	background: #6366f1 !important;
	border-color: #6366f1 !important;
	color: #fff !important;
}

.sf-device-hint {
	margin: 6px 0 0;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.4;
}

/* ─── Device View Simulator ─────────────────────────────────────────── */
#sf-device-overlay {
	position: fixed;
	inset: 0;
	z-index: 1000001;
	background: rgba(17, 24, 39, 0.96);
	display: none;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sf-device-toolbar {
	flex: none;
	height: 60px;
	background: #1f2937;
	border-bottom: 1px solid #374151;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px;
	gap: 12px;
}

.sf-device-switch {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

/* Same theme-bleed hardening as the editor tools: dark text/icon over a
   light chip, and an !important active state so it survives theme
   button:focus/hover rules. */
.sf-device-toolbar .sf-device-btn {
	background: #e5e7eb;
	border-color: #e5e7eb;
	color: #111827 !important;
}

.sf-device-toolbar .sf-device-btn:hover {
	background: #d1d5db;
	color: #111827 !important;
}

.sf-device-toolbar .sf-device-btn.active,
.sf-device-toolbar .sf-device-btn.active:hover,
.sf-device-toolbar .sf-device-btn.active:focus {
	background: #4f46e5 !important;
	border-color: #4f46e5 !important;
	color: #fff !important;
}

.sf-device-size {
	font-size: 12px;
	color: #9ca3af;
	white-space: nowrap;
	margin-left: 6px;
}

.sf-device-stage {
	flex: 1;
	overflow: auto;
	padding: 20px;
}

.sf-device-frame {
	width: 375px;
	margin: 0 auto;
	height: calc(100vh - 104px);
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	overflow: hidden;
	transition: width 0.25s ease;
}

#sf-device-iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* ─── Editor: image mode (annotating a captured device view) ────────── */
#sf-editor-overlay.sf-editor-image-mode {
	position: fixed;
	inset: 0;
	width: auto;
	height: auto;
	overflow: auto;
	background: rgba(17, 24, 39, 0.92);
	pointer-events: auto;
	padding: 80px 16px 24px; /* leave room for the fixed toolbar */
}

.sf-editor-image-mode .sf-editor-canvas-container {
	position: relative;
	top: auto;
	left: auto;
	margin: 0 auto;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
	border-radius: 6px;
}

#sf-editor-base {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	border-radius: 6px;
}

/* ─── "Saving capture" loading overlay ──────────────────────────────── */
.sf-capture-loading {
	position: fixed;
	inset: 0;
	z-index: 2147483646;
	background: rgba(17, 24, 39, 0.55);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	display: none;
	align-items: center;
	justify-content: center;
}

.sf-capture-loading-box {
	background: #fff;
	border-radius: 12px;
	padding: 26px 30px;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	max-width: 340px;
	text-align: center;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sf-capture-loading-box p {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: #111827;
	line-height: 1.4;
}

.sf-capture-loading-box p span {
	font-weight: 400;
	font-size: 13px;
	color: #6b7280;
}

.sf-spinner {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 4px solid #e5e7eb;
	border-top-color: #6366f1;
	animation: sf-spin 0.8s linear infinite;
}

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