/**
 * RegSync Contact Manager — Styles
 *
 * Card UI, modal dialog, drag-and-drop states, and phone slots.
 * Icons via inline SVG (.regsync-cm-icon).
 *
 * GF 2.5+ "orbital/gravity" theme uses high-specificity selectors.
 * We prefix card rules with .gform_wrapper to compete.
 */

/* ── Wrapper ─────────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-wrapper {
	margin: 10px 0 !important;
	padding: 0 !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ── Section Count ───────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-section-count {
	font-size: 12px !important;
	color: #9ca3af !important;
	margin-bottom: 8px !important;
	padding: 0 !important;
	border: none !important;
	background: none !important;
}

/* ── Card List ───────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-card-list {
	display: flex !important;
	flex-direction: column !important;
	gap: 10px !important;
	margin: 0 0 14px 0 !important;
	padding: 0 !important;
	min-height: 48px;
	border: none !important;
	background: none !important;
}

.gform_wrapper .regsync-cm-card-list:empty::after {
	content: 'No contacts added yet.';
	display: block !important;
	padding: 24px !important;
	text-align: center !important;
	color: #9ca3af !important;
	font-size: 13px !important;
	background: #fafafa !important;
	border: 2px dashed #e5e7eb !important;
	border-radius: 8px !important;
}

/* ── Card ────────────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-card {
	display: flex !important;
	flex-direction: row !important;
	align-items: center !important;
	flex-wrap: nowrap !important;
	background: #fff !important;
	border: 1px solid #d1d5db !important;
	border-radius: 8px !important;
	overflow: hidden !important;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06) !important;
	padding: 0 !important;
	margin: 0 !important;
	max-width: none !important;
	width: auto !important;
	cursor: grab !important;
	user-select: none;
}

.gform_wrapper .regsync-cm-card:hover {
	border-color: #9ca3af !important;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.gform_wrapper .regsync-cm-card:active {
	cursor: grabbing !important;
}

/* Prevent GF styles from breaking card child layout */
.gform_wrapper .regsync-cm-card > div {
	max-width: none !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	background: transparent !important;
	box-shadow: none !important;
}

/* Ghost state during drag */
.gform_wrapper .regsync-cm-card--ghost {
	opacity: 0.3 !important;
	background: #eff6ff !important;
	border-color: #93c5fd !important;
	border-style: dashed !important;
}

/* Chosen state — the card being dragged */
.gform_wrapper .regsync-cm-card--chosen {
	box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
	transform: rotate(0.5deg);
}

.regsync-cm-card-list .sortable-fallback {
	opacity: 0 !important;
}

/* ── Drag Handle ─────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-drag-handle {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	align-self: stretch !important;
	width: 28px !important;
	min-width: 28px !important;
	color: #d1d5db !important;
	background: #f9fafb !important;
	border: none !important;
	border-right: 1px solid #e5e7eb !important;
	flex-shrink: 0 !important;
	user-select: none;
	font-size: 12px !important;
	padding: 0 !important;
}

/* ── Priority Number ─────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-priority {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	align-self: stretch !important;
	width: 44px !important;
	min-width: 44px !important;
	flex-shrink: 0 !important;
	font-size: 20px !important;
	font-weight: 700 !important;
	color: #3b82f6 !important;
	background: #f8fafc !important;
	border: none !important;
	border-right: 1px solid #e5e7eb !important;
	padding: 0 !important;
}

.gform_wrapper .regsync-cm-priority--emergency {
	color: #dc2626 !important;
}

/* ── Card Body ───────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-card-body {
	flex: 1 1 0% !important;
	min-width: 0 !important;
	padding: 12px 16px !important;
	background: transparent !important;
	border: none !important;
}

.gform_wrapper .regsync-cm-card-name {
	font-size: 15px !important;
	font-weight: 600 !important;
	color: #111827 !important;
	line-height: 1.4 !important;
	margin: 0 !important;
	padding: 0 !important;
}

.gform_wrapper .regsync-cm-card-relation {
	font-weight: 400 !important;
	color: #6b7280 !important;
	font-size: 13px !important;
	margin-left: 6px !important;
}

.gform_wrapper .regsync-cm-card-details {
	display: flex !important;
	flex-wrap: wrap !important;
	gap: 4px 18px !important;
	margin-top: 6px !important;
	font-size: 13px !important;
	color: #4b5563 !important;
	line-height: 1.6 !important;
	padding: 0 !important;
	border: none !important;
	background: none !important;
}

.gform_wrapper .regsync-cm-card-detail {
	display: inline-flex !important;
	align-items: center !important;
	gap: 6px !important;
}

/* ── Inline SVG Icons ────────────────────────────────────────────────── */

.regsync-cm-icon {
	display: inline-block !important;
	width: 1em !important;
	height: 1em !important;
	vertical-align: -0.125em !important;
	fill: currentColor !important;
	flex-shrink: 0 !important;
}

.gform_wrapper .regsync-cm-card-detail .regsync-cm-icon {
	width: 12px !important;
	height: 12px !important;
	color: #9ca3af !important;
}

/* ── Badges ──────────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-card-badges {
	display: flex !important;
	gap: 6px !important;
	margin-top: 8px !important;
	flex-wrap: wrap !important;
	padding: 0 !important;
	border: none !important;
	background: none !important;
}

.gform_wrapper .regsync-cm-badge {
	display: inline-flex !important;
	align-items: center !important;
	gap: 5px !important;
	font-size: 11px !important;
	font-weight: 500 !important;
	padding: 2px 8px !important;
	border-radius: 4px !important;
	line-height: 1.6 !important;
	border: none !important;
}

.gform_wrapper .regsync-cm-badge .regsync-cm-icon {
	width: 10px !important;
	height: 10px !important;
}

.gform_wrapper .regsync-cm-badge--legal {
	background: #eff6ff !important;
	color: #1e40af !important;
}

.gform_wrapper .regsync-cm-badge--custodial {
	background: #f5f3ff !important;
	color: #6d28d9 !important;
}

.gform_wrapper .regsync-cm-badge--living {
	background: #ecfdf5 !important;
	color: #065f46 !important;
}

/* ── Card Actions (inline within card body) ─────────────────────────── */

.gform_wrapper .regsync-cm-card-actions {
	display: flex !important;
	flex-direction: row !important;
	gap: 8px !important;
	margin-top: 8px !important;
	padding: 0 !important;
	border: none !important;
	background: none !important;
}

.gform_wrapper .regsync-cm-card-action {
	display: inline-flex !important;
	align-items: center !important;
	gap: 4px !important;
	border: none !important;
	background: transparent !important;
	cursor: pointer !important;
	color: #9ca3af !important;
	font-size: 12px !important;
	font-weight: 500 !important;
	padding: 3px 8px !important;
	border-radius: 4px !important;
	box-shadow: none !important;
	line-height: 1.4 !important;
	margin: 0 !important;
	text-decoration: none !important;
	outline: none !important;
	min-height: 0 !important;
	width: auto !important;
	min-width: 0 !important;
}

.gform_wrapper .regsync-cm-card-action .regsync-cm-icon {
	width: 11px !important;
	height: 11px !important;
}

.gform_wrapper .regsync-cm-card-action:hover {
	text-decoration: none !important;
}

.gform_wrapper .regsync-cm-card-action--edit:hover {
	background: #eff6ff !important;
	color: #2563eb !important;
}

.gform_wrapper .regsync-cm-card-action--remove:hover {
	background: #fef2f2 !important;
	color: #dc2626 !important;
}

/* ── Add Button ──────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-add-btn {
	display: inline-flex !important;
	align-items: center !important;
	gap: 6px !important;
	padding: 8px 18px !important;
	font-size: 13px !important;
	font-weight: 500 !important;
	border-radius: 6px !important;
	border: 1px dashed #d1d5db !important;
	background: #fafafa !important;
	color: #6b7280 !important;
	cursor: pointer !important;
	transition: all 0.15s ease !important;
	box-shadow: none !important;
	text-decoration: none !important;
	line-height: 1.4 !important;
}

.gform_wrapper .regsync-cm-add-btn:hover {
	border-color: #3b82f6 !important;
	border-style: solid !important;
	background: #eff6ff !important;
	color: #2563eb !important;
}

.gform_wrapper .regsync-cm-add-btn:disabled {
	opacity: 0.4 !important;
	cursor: not-allowed !important;
	border-color: #e5e7eb !important;
	background: #f3f4f6 !important;
	color: #d1d5db !important;
}

.gform_wrapper .regsync-cm-add-btn .regsync-cm-icon {
	width: 12px !important;
	height: 12px !important;
}

/* ── Editor Placeholder ──────────────────────────────────────────────── */

.regsync-cm-editor-placeholder {
	padding: 24px;
	background: #f9fafb;
	border: 2px dashed #d1d5db;
	border-radius: 8px;
	text-align: center;
	color: #6b7280;
	font-style: italic;
}

/* ── Modal ───────────────────────────────────────────────────────────── */

.regsync-cm-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100100;
	display: flex;
	align-items: center;
	justify-content: center;
}

.regsync-cm-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(2px);
}

.regsync-cm-modal-dialog {
	position: relative;
	background: #fff;
	border-radius: 10px;
	width: 90%;
	max-width: 640px;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.regsync-cm-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px;
	border-bottom: 1px solid #e5e7eb;
}

.regsync-cm-modal-title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: #111827;
}

.regsync-cm-modal-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: none;
	border: none;
	border-radius: 6px;
	font-size: 18px;
	cursor: pointer;
	color: #9ca3af;
	transition: background 0.15s, color 0.15s;
}

.regsync-cm-modal-close:hover {
	background: #f3f4f6;
	color: #374151;
}

.regsync-cm-modal-body {
	padding: 24px;
	overflow-y: auto;
	flex: 1;
}

.regsync-cm-modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 16px 24px;
	border-top: 1px solid #e5e7eb;
	background: #f9fafb;
	border-radius: 0 0 10px 10px;
}

/* ── Modal Fields ────────────────────────────────────────────────────── */

.regsync-cm-fieldset {
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	padding: 14px 16px;
	margin-bottom: 16px;
}

.regsync-cm-fieldset legend {
	font-weight: 600;
	font-size: 13px;
	padding: 0 8px;
	color: #374151;
}

.regsync-cm-field-row {
	display: flex;
	gap: 12px;
	margin-bottom: 14px;
}

.regsync-cm-field-row:last-child {
	margin-bottom: 0;
}

.regsync-cm-field-row--2col > .regsync-cm-field {
	flex: 1;
}

.regsync-cm-field-row--3col > .regsync-cm-field {
	flex: 1;
}

.regsync-cm-field--narrow {
	max-width: 120px;
	flex: 0 0 auto !important;
}

.regsync-cm-field label {
	display: block;
	font-size: 12px;
	font-weight: 500;
	color: #6b7280;
	margin-bottom: 4px;
}

.regsync-cm-input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	box-sizing: border-box;
	transition: border-color 0.15s, box-shadow 0.15s;
	background: #fff;
	color: #111827;
}

.regsync-cm-input:focus {
	border-color: #3b82f6;
	box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
	outline: none;
}

.regsync-cm-required {
	color: #dc2626;
}

/* ── Toggles ─────────────────────────────────────────────────────────── */

.regsync-cm-toggles {
	flex-wrap: wrap;
	gap: 16px;
	padding: 4px 0;
}

.regsync-cm-toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	cursor: pointer;
	padding: 4px 0;
	color: #4b5563;
}

.regsync-cm-toggle input[type="checkbox"] {
	margin: 0;
}

/* ── Phone Slots ─────────────────────────────────────────────────────── */

.regsync-cm-phones-group {
	margin-bottom: 0;
}

.regsync-cm-phone-slot {
	margin-bottom: 10px;
	padding-bottom: 10px;
	border-bottom: 1px solid #f3f4f6;
}

.regsync-cm-phone-slot:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.regsync-cm-phone-header {
	font-size: 13px;
	font-weight: 600;
	color: #374151;
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 8px;
}

.regsync-cm-phone-header[role="button"] {
	cursor: pointer;
	user-select: none;
	padding: 4px 0;
}

.regsync-cm-phone-header[role="button"]:hover {
	color: #2563eb;
}

.regsync-cm-phone-toggle-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border-radius: 3px;
	background: #f3f4f6;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	color: #6b7280;
}

.regsync-cm-phone-collapsed .regsync-cm-phone-fields {
	display: none;
}

/* ── Entry Detail View ───────────────────────────────────────────────── */

.regsync-cm-entry-detail {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.regsync-cm-entry-contact {
	padding: 10px 14px;
	background: #f9fafb;
	border-radius: 6px;
	font-size: 13px;
	border-left: 3px solid #3b82f6;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.regsync-cm-field-row--2col,
	.regsync-cm-field-row--3col {
		flex-direction: column;
	}

	.regsync-cm-field--narrow {
		max-width: none;
	}

	.regsync-cm-modal-dialog {
		width: 95%;
		max-height: 90vh;
	}

	.gform_wrapper .regsync-cm-drag-handle {
		display: none !important;
	}

	.gform_wrapper .regsync-cm-priority {
		display: none !important;
	}
}

/* ── Field Notes (Communication descriptions) ─────────────────────── */

.gform_wrapper .regsync-cm-field-note {
	display: block !important;
	font-size: 11px !important;
	line-height: 1.4 !important;
	color: #666 !important;
	margin-top: 3px !important;
	font-style: italic !important;
}

.gform_wrapper .regsync-cm-comm-note--inline {
	display: inline !important;
	margin-top: 0 !important;
	margin-left: 4px !important;
	font-weight: normal !important;
	font-size: 0.85em !important;
}

/* ── Dropzone ────────────────────────────────────────────────────────── */

.gform_wrapper .regsync-cm-dropzone {
	border: 2px dashed #d1d5db !important;
	border-radius: 10px !important;
	padding: 16px !important;
	margin-top: 10px !important;
	transition: border-color 0.2s ease, background-color 0.2s ease;
}

.gform_wrapper .regsync-cm-drag-hint {
	text-align: center !important;
	font-size: 12px !important;
	color: #9ca3af !important;
	padding: 6px 0 !important;
	font-style: italic !important;
	user-select: none;
}
