/* Nextorr Email System — settings UI (matches dashboard / appointment settings) */

.nss-page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 22px;
	flex-wrap: wrap;
}

.nss-page-header-text h1 {
	font-size: 20px;
	font-weight: 700;
	color: #111827;
	margin: 0 0 2px;
}

.nss-page-header-text p {
	font-size: 13px;
	color: #6b7280;
	margin: 0;
}

/* Main module tabs */
.nss-tab-bar {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
	margin-bottom: 18px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 6px 8px;
}

.nss-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border-radius: 7px;
	border: none;
	background: none;
	font-size: 13px;
	font-weight: 500;
	color: #6b7280;
	cursor: pointer;
	transition: background 0.12s, color 0.12s;
	white-space: nowrap;
	font-family: inherit;
}

.nss-tab:hover {
	background: #f3f4f6;
	color: #111827;
}

.nss-tab.active {
	background: #dbeafe;
	color: #1d4ed8;
	font-weight: 600;
}

/* Sub-tabs inside a module (e.g. appointment templates / reminders) */
.nss-sub-tab-bar {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
	margin-bottom: 14px;
}

.nss-sub-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 7px;
	border: 1px solid #e5e7eb;
	background: #fff;
	font-size: 12.5px;
	font-weight: 500;
	color: #6b7280;
	cursor: pointer;
	font-family: inherit;
}

.nss-sub-tab:hover {
	border-color: #cbd5e1;
	color: #111827;
}

.nss-sub-tab.active {
	background: #f0f4ff;
	border-color: #93c5fd;
	color: #1d4ed8;
}

.nss-tab-panel { display: block; }
.nss-tab-panel[hidden] { display: none; }
.nss-sub-panel { display: block; }
.nss-sub-panel[hidden] { display: none; }

.nss-settings-panel { margin-bottom: 16px; }
.nss-settings-panel--wide { max-width: none; }

.nss-settings-panel .rd-panel-header h3 {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
}

.nss-settings-body {
	padding: 16px 20px 20px;
}

.nss-field-group { margin-bottom: 14px; }

.nss-field-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
	margin-bottom: 14px;
}

.nss-label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: #374151;
	margin-bottom: 5px;
}

.nss-label--compact { margin-bottom: 0; }

.nss-input,
.nss-textarea,
select.nss-input {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 13.5px !important;
	color: #111827;
	background: #fff;
	font-family: inherit;
	box-sizing: border-box;
}

.nss-input:focus,
.nss-textarea:focus {
	outline: none;
	border-color: #93c5fd;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.nss-input--sm { max-width: 88px; }

/* Accent color card */
.nss-accent-card {
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	background: #f9fafb;
	padding: 14px 16px 12px;
	margin-bottom: 20px;
}

.nss-accent-card__grid {
	display: flex;
	flex-direction: row;
	gap: 20px;
	align-items: center;
}

.nss-accent-card__color .nss-label {
	margin-bottom: 8px;
}

.nss-accent-card__color .rd-ss-color-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.nss-accent-card__color .rd-ss-color-picker {
	width: 44px;
	height: 40px;
	padding: 0;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	cursor: pointer;
	background: #fff;
	flex-shrink: 0;
}

.nss-accent-card__color .rd-ss-accent-text {
	width: 100%;
	max-width: 160px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 14px !important;
	color: #111827;
	background: #fff;
	box-sizing: border-box;
}

.nss-accent-card__sync {
	display: flex;
	flex-direction: row;
	align-items: center;
	padding-left: 20px;
	border-left: 1px solid #e5e7eb;
}

.nss-accent-sync-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	cursor: pointer;
}

.nss-accent-sync-row .nss-switch {
	flex-shrink: 0;
}

.nss-accent-sync-text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.nss-accent-sync-text strong {
	font-size: 13.5px;
	font-weight: 600;
	color: #111827;
	line-height: 1.3;
}

.nss-accent-sync-text span {
	font-size: 12.5px;
	color: #6b7280;
	line-height: 1.45;
}

.nss-accent-card__hint {
	margin: 12px 0 0;
	padding-top: 10px;
	border-top: 1px solid #e5e7eb;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.45;
}

.nss-accent-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 500;
	color: #15803d;
}

.nss-accent-status--synced::before {
	content: '';
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #22c55e;
	flex-shrink: 0;
}

.nss-accent-card.is-synced .nss-accent-controls {
	opacity: 0.55;
}

.nss-accent-card.is-synced .nss-accent-controls .rd-ss-color-picker,
.nss-accent-card.is-synced .nss-accent-controls .rd-ss-accent-text {
	cursor: not-allowed;
}

@media (max-width: 720px) {
	.nss-accent-card__grid {
		flex-direction: column;
		align-items: stretch;
		gap: 14px;
	}

	.nss-accent-card__sync {
		padding-left: 0;
		padding-top: 14px;
		border-left: none;
		border-top: 1px solid #e5e7eb;
	}
}

.nss-textarea { resize: vertical; min-height: 80px; }

.nss-field-hint {
	display: block;
	margin-top: 4px;
	font-size: 12px;
	color: #6b7280;
}

.nss-wh-intro {
	font-size: 12px;
	color: #6b7280;
	margin: 0 0 14px;
	line-height: 1.5;
	max-width: 80ch;
}

.nss-module-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 36px 24px;
	border: 1px dashed #d1d5db;
	border-radius: 12px;
	background: #f9fafb;
	text-align: center;
	color: #6b7280;
}

.nss-module-placeholder p {
	margin: 0;
	font-size: 13px;
	max-width: 42ch;
	line-height: 1.5;
}

.nss-btn-primary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 38px;
	padding: 0 18px;
	background: #1d4ed8;
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s;
}

.nss-btn-primary:hover { background: #1e40af; }
.nss-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.nss-btn-secondary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	color: #334155;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	white-space: nowrap;
}

.nss-btn-secondary:hover {
	background: #f8fafc;
	border-color: #94a3b8;
	color: #111827;
}

.nss-btn-secondary:active {
	background: #f1f5f9;
}

.nss-settings-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	padding-bottom: 24px;
	margin-top: 8px;
}

.nss-settings-msg {
	font-size: 13px;
	font-weight: 500;
	margin-right: auto;
}

.nss-settings-msg.success { color: #15803d; }
.nss-settings-msg.error { color: #dc2626; }

/* Switch */
.nss-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	flex-shrink: 0;
}

.nss-switch input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 0;
	height: 0;
}

.nss-switch-track {
	position: relative;
	display: inline-block;
	width: 38px;
	height: 22px;
	background: #d1d5db;
	border-radius: 999px;
	transition: background 0.18s;
}

.nss-switch-track::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.18s;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.nss-switch input:checked + .nss-switch-track {
	background: var(--rd-site-accent, #2563eb);
}

.nss-switch input:checked + .nss-switch-track::after {
	transform: translateX(16px);
}

.nss-switch--header { flex-shrink: 0; }

/* Email panels */
.nss-email-panel { margin-bottom: 16px; }

/* Accordion panels */
.nss-accordion .nss-accordion-trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 20px;
	border: none;
	border-bottom: 1px solid #f3f4f6;
	background: #fff;
	cursor: pointer;
	font-family: inherit;
	text-align: left;
	transition: background 0.12s;
}

.nss-accordion.is-collapsed .nss-accordion-trigger {
	border-bottom: none;
}

.nss-accordion-trigger:hover {
	background: #f9fafb;
}

.nss-accordion-trigger-text {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
}

.nss-accordion-title {
	font-size: 14px;
	font-weight: 600;
	color: #111827;
}

.nss-accordion-count {
	font-size: 12px;
	font-weight: 500;
	color: #6b7280;
	background: #f3f4f6;
	padding: 2px 8px;
	border-radius: 999px;
	margin-left: 4px;
}

.nss-accordion-chevron {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #6b7280;
	transition: transform 0.2s ease;
	flex-shrink: 0;
}

.nss-accordion:not(.is-collapsed) .nss-accordion-chevron {
	transform: rotate(180deg);
}

.nss-accordion-content[hidden] {
	display: none;
}

.nss-placeholder-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 8px;
}

.nss-placeholder-chip {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	padding: 8px 10px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	cursor: pointer;
	text-align: left;
	font-family: inherit;
}

.nss-placeholder-chip code {
	font-family: 'SFMono-Regular', Consolas, monospace;
	font-size: 12.5px;
	color: #2563eb;
	background: transparent;
	padding: 0;
}

.nss-placeholder-chip span { font-size: 11.5px; color: #6b7280; }
.nss-placeholder-chip:hover { border-color: #c7d2fe; background: #f8faff; }
.nss-placeholder-chip--copied { border-color: #34d399; background: #ecfdf5; }

.nss-email-tpl-header {
	display: flex;
	align-items: center;
	gap: 14px;
}

.nss-email-template.is-collapsed .nss-email-tpl-desc {
	display: none;
}

.nss-email-template.is-collapsed .nss-email-tpl-header {
	border-bottom: none;
}

.nss-email-tpl-status {
	display: none;
	font-size: 12px;
	font-weight: 500;
	color: #6b7280;
	background: #f3f4f6;
	padding: 2px 8px;
	border-radius: 999px;
	white-space: nowrap;
	flex-shrink: 0;
}

.nss-email-template.is-collapsed .nss-email-tpl-status {
	display: inline-flex;
	align-items: center;
}

.nss-email-template-content[hidden] {
	display: none;
}

.nss-email-tpl-title { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.nss-email-tpl-title h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.nss-email-tpl-desc { font-size: 12px; color: #6b7280; }

.nss-email-tpl-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	padding-top: 8px;
	padding-bottom: 4px;
	border-top: 1px dashed #e5e7eb;
	margin-top: 8px;
}

.nss-cta-group {
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 12px 14px;
	margin-bottom: 14px;
}

.nss-cta-group-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.nss-cta-group-title {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 600;
	color: #6b7280;
	text-transform: uppercase;
	margin-bottom: 0;
}

.nss-cta-group-fields--disabled {
	opacity: 0.55;
	pointer-events: none;
}

.nss-cta-group-fields .nss-field-row {
	margin-bottom: 0;
}

/* Reminders */
.nss-reminders { display: flex; flex-direction: column; gap: 10px; }

.nss-reminder-row {
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	background: #fff;
	overflow: hidden;
}

.nss-reminder-row.is-collapsed .nss-reminder-head {
	border-bottom: none;
}

.nss-reminder-body[hidden] {
	display: none;
}

.nss-reminder-head {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	background: #f9fafb;
	border-bottom: 1px solid #e5e7eb;
	flex-wrap: wrap;
}

.nss-reminder-timing {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 220px;
}

.nss-reminder-timing .nss-input--sm { width: 80px; }
.nss-reminder-timing select.nss-input { width: auto; min-width: 110px; }
.nss-reminder-suffix { font-size: 12.5px; color: #6b7280; }
.nss-reminder-actions { display: flex; gap: 4px; margin-left: auto; }
.nss-reminder-body { padding: 14px 16px 16px; }
.nss-reminders-footer { margin-top: 14px; padding-bottom: 4px; }

.nss-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 7px;
	background: #fff;
	border: 1px solid #e5e7eb;
	color: #6b7280;
	cursor: pointer;
	font-family: inherit;
}

.nss-icon-btn:hover { border-color: #c7d2fe; color: #2563eb; background: #f8faff; }
.nss-icon-btn.nss-action-danger { color: #dc2626; }
.nss-icon-btn.nss-action-danger:hover { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }

/* Preview modal */
.nss-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.nss-modal-backdrop[hidden] { display: none !important; }

.nss-modal--email {
	background: #fff;
	border-radius: 14px;
	width: 100%;
	max-width: 780px;
	max-height: 92vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

.nss-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 18px;
	border-bottom: 1px solid #e5e7eb;
	background: #f9fafb;
}

.nss-modal-header h3 {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 6px;
}

.nss-modal-close {
	background: none;
	border: none;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	cursor: pointer;
	color: #6b7280;
}

.nss-modal-close:hover { background: #e5e7eb; color: #111827; }

.nss-modal-body { padding: 14px 18px; overflow: auto; }

.nss-em-preview-subject {
	display: flex;
	gap: 6px;
	padding: 8px 12px;
	margin-bottom: 10px;
	background: #f3f4f6;
	border-radius: 8px;
	font-size: 13px;
}

.nss-em-preview-label { color: #6b7280; font-weight: 500; }
.nss-em-preview-value { color: #111827; font-weight: 500; }

.nss-em-preview-frame {
	width: 100%;
	height: 70vh;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	background: #f3f4f6;
}

@media (max-width: 640px) {
	.nss-field-row { grid-template-columns: 1fr; }
	.nss-reminder-timing { min-width: 100%; order: 2; }
	.nss-reminder-actions { order: 1; margin-left: auto; }
}

/*
 * Isolated UI: theme button resets can override generic `button` rules.
 * Scope critical controls under body.rd-isolated-ui for reliable styling.
 */
body.rd-isolated-ui .nss-btn-primary,
body.rd-isolated-ui button.nss-btn-primary {
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none;
}

body.rd-isolated-ui .nss-btn-secondary,
body.rd-isolated-ui button.nss-btn-secondary,
body.rd-isolated-ui .nss-email-tpl-actions .rd-btn-ghost {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	color: #334155;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	text-decoration: none;
	box-shadow: none;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

body.rd-isolated-ui .nss-btn-secondary:hover,
body.rd-isolated-ui button.nss-btn-secondary:hover,
body.rd-isolated-ui .nss-email-tpl-actions .rd-btn-ghost:hover {
	background: #f8fafc;
	border-color: #94a3b8;
	color: #111827;
}

body.rd-isolated-ui .nss-accordion.rd-panel {
	overflow: hidden;
}

body.rd-isolated-ui .nss-accordion .nss-accordion-trigger,
body.rd-isolated-ui button.nss-accordion-trigger {
	-webkit-appearance: none;
	appearance: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 16px 20px;
	margin: 0;
	border: none;
	border-bottom: 1px solid #f3f4f6;
	border-radius: 0;
	background: #fff;
	color: #111827;
	cursor: pointer;
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	text-align: left;
	box-shadow: none;
	transition: background 0.12s;
}

body.rd-isolated-ui .nss-accordion.is-collapsed .nss-accordion-trigger {
	border-bottom: none;
}

body.rd-isolated-ui .nss-accordion-trigger:hover,
body.rd-isolated-ui button.nss-accordion-trigger:hover {
	background: #f9fafb;
}

body.rd-isolated-ui .nss-accordion-trigger:focus-visible,
body.rd-isolated-ui button.nss-accordion-trigger:focus-visible {
	outline: none;
	box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

body.rd-isolated-ui .nss-placeholder-chip,
body.rd-isolated-ui button.nss-placeholder-chip {
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none;
}

body.rd-isolated-ui .nss-icon-btn,
body.rd-isolated-ui button.nss-icon-btn {
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none;
}

/* Input font sizes — theme overrides isolated UI inherit rules */
body.rd-isolated-ui .nss-input,
body.rd-isolated-ui .nss-textarea,
body.rd-isolated-ui select.nss-input,
body.rd-isolated-ui .nss-accent-card .rd-ss-accent-text,
body.rd-isolated-ui .nss-accent-card .rd-form-input {
	font-size: 13.5px !important;
	line-height: 1.4 !important;
}

body.rd-isolated-ui .nss-accent-card .rd-ss-accent-text {
	font-size: 14px !important;
}

/* SMS provider settings (super admin) */
.nss-provider-card {
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 16px 18px;
	margin-bottom: 18px;
	background: #f9fafb;
}

.nss-provider-panels {
	margin-top: 14px;
}

.nss-provider-panel {
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 14px 16px;
	background: #fff;
}

.nss-provider-panel-title {
	font-size: 14px;
	font-weight: 600;
	color: #111827;
	margin: 0 0 12px;
}

.nss-provider-actions {
	margin-top: 14px;
}

.nss-readonly-provider {
	border: 1px dashed #d1d5db;
	border-radius: 10px;
	padding: 12px 14px;
	margin-bottom: 16px;
	background: #fff;
}

.nss-field-row--switch {
	margin-bottom: 14px;
}

.nss-switch-row {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	cursor: pointer;
}

.nss-switch-row-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 13px;
	color: #6b7280;
}

.nss-switch-row-text strong {
	color: #111827;
	font-size: 14px;
}

.nss-sms-preview-meta {
	display: flex;
	gap: 12px;
	font-size: 12px;
	color: #6b7280;
	margin-bottom: 10px;
}

.nss-sms-preview-text {
	white-space: pre-wrap;
	word-break: break-word;
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 14px;
	margin: 0;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
	color: #111827;
}

.nss-sms-tpl-header,
.nss-sms-tpl-title h3 {
	display: flex;
	align-items: center;
	gap: 8px;
}

.nss-sms-tpl-desc {
	display: block;
	font-size: 12.5px;
	color: #6b7280;
	font-weight: 400;
	margin-top: 2px;
}

.nss-sms-tpl-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 12px;
}

