/* WhatsApp template form – scoped to avoid w3.css conflicts */
.wa-tpl-modal-content {
	max-width: 1180px !important;
	width: 98% !important;
	margin: 24px auto !important;
}

.wa-tpl-modal-content .wa-tpl-modal-body {
	max-height: calc(100vh - 120px);
	overflow-y: auto;
	overflow-x: hidden;
	padding: 16px 20px 20px !important;
}

.wa-tpl-form {
	box-sizing: border-box;
}

.wa-tpl-form *,
.wa-tpl-form *::before,
.wa-tpl-form *::after {
	box-sizing: border-box;
}

.wa-tpl-form label {
	display: block !important;
	float: none !important;
	width: 100% !important;
	text-align: left !important;
	margin: 0 0 6px 0 !important;
}

.wa-tpl-form .w3-input,
.wa-tpl-form .w3-select {
	width: 100% !important;
	margin-bottom: 0 !important;
}

.wa-tpl-field {
	margin-bottom: 14px;
}

.wa-tpl-grid-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.wa-tpl-grid-3 {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 14px;
	align-items: end;
}

.wa-tpl-inline-check {
	padding-bottom: 8px;
}

.wa-tpl-inline-check label {
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	width: auto !important;
	margin: 0 !important;
	cursor: pointer;
}

.wa-tpl-section {
	margin-bottom: 18px;
}

.wa-tpl-section-title {
	font-size: 13px;
	font-weight: 700;
	color: #444;
	margin: 0 0 10px 0;
	padding-bottom: 6px;
	border-bottom: 1px solid #eee;
}

.wa-tpl-preview-section {
	display: block;
	background: #f8f9fa;
	border: 1px solid #e8e8e8;
	border-radius: 8px;
	padding: 14px;
}

.wa-tpl-split-section {
	display: grid;
	grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
	gap: 18px;
	align-items: start;
	margin-bottom: 8px;
}

.wa-tpl-split-section.wa-preview-only {
	grid-template-columns: 1fr;
}

.wa-tpl-split-col {
	min-width: 0;
}

.wa-tpl-split-preview .wa-tpl-preview-section {
	position: sticky;
	top: 0;
}

.wa-tpl-split-mapping .wa-mapping-card {
	max-height: 420px;
	display: flex;
	flex-direction: column;
}

.wa-tpl-split-mapping .wa-mapping-table-wrap {
	flex: 1;
	overflow: auto;
	max-height: 340px;
}

.wa-tpl-preview-center {
	display: flex;
	justify-content: center;
	padding: 4px 0 8px;
}

.wa-template-status-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}

.wa-status-pill {
	font-size: 11px;
	padding: 3px 9px;
	border-radius: 10px;
	background: #eceff1;
	color: #546e7a;
}

.wa-status-pill.approved {
	background: #e8f5e9;
	color: #2e7d32;
}

/* Mapping */
.wa-mapping-card {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	overflow: hidden;
}

.wa-mapping-card-header {
	background: #f7f8fa;
	padding: 12px 14px;
	border-bottom: 1px solid #e8e8e8;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
}

.wa-mapping-card-header-left {
	flex: 1;
	min-width: 180px;
}

.wa-mapping-progress {
	font-size: 12px;
	color: #666;
	margin-top: 2px;
}

.wa-mapping-progress-bar {
	height: 4px;
	background: #e0e0e0;
	border-radius: 2px;
	margin-top: 8px;
	max-width: 200px;
}

.wa-mapping-progress-fill {
	height: 100%;
	background: #25d366;
	border-radius: 2px;
	transition: width 0.2s;
}

.wa-mapping-table-wrap {
	overflow-x: auto;
}

.wa-mapping-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
	min-width: 480px;
}

.wa-mapping-table th {
	text-align: left;
	padding: 9px 12px;
	background: #fafafa;
	color: #555;
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	border-bottom: 1px solid #eee;
	white-space: nowrap;
}

.wa-mapping-table td {
	padding: 10px 12px;
	border-bottom: 1px solid #f0f0f0;
	vertical-align: middle;
}

.wa-mapping-table tr:last-child td {
	border-bottom: none;
}

.wa-mapping-table tr.wa-map-row-unmapped td {
	background: #fffdf5;
}

.wa-mapping-table tr.wa-map-row-mapped td {
	background: #f8fff9;
}

.wa-ph-badge {
	display: inline-block;
	background: #e3f2fd;
	color: #1565c0;
	font-weight: 700;
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 4px;
	font-family: Consolas, monospace;
	white-space: nowrap;
}

.wa-ph-example {
	display: block;
	font-size: 11px;
	color: #888;
	margin-top: 4px;
	font-style: italic;
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wa-map-arrow {
	color: #ccc;
	text-align: center;
	width: 28px;
}

.wa-var-map-select {
	font-size: 13px !important;
	padding: 7px 8px !important;
	width: 100% !important;
	min-width: 180px;
}

.wa-mapping-table .select2-container {
	width: 100% !important;
	min-width: 180px;
}

.wa-mapping-table .select2-container--default .select2-selection--single {
	min-height: 34px;
	font-size: 13px;
	border-color: #ccc;
	border-radius: 2px;
}

.wa-mapping-table .select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: 32px;
	padding-left: 8px;
	color: #333;
}

.wa-mapping-table .select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 32px;
}

.wa-mapping-table .select2-container--default .select2-selection--single .select2-selection__placeholder {
	color: #888;
}

.w3-modal .select2-container--open .select2-dropdown {
	z-index: 10001;
}

.wa-map-status {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
}

.wa-map-status.mapped { background: #25d366; }
.wa-map-status.unmapped { background: #ffb300; }

.wa-btn-suggest {
	font-size: 12px !important;
	padding: 6px 12px !important;
	white-space: nowrap;
}

.wa-tpl-hint {
	font-size: 12px;
	color: #888;
	margin: 8px 0 0;
}

/* Phone preview – compact */
.wa-phone-frame {
	background: #111b21;
	border-radius: 20px;
	padding: 10px 8px 12px;
	width: 100%;
	max-width: 300px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.wa-phone-notch {
	width: 60px;
	height: 4px;
	background: #2a3942;
	border-radius: 2px;
	margin: 0 auto 8px;
}

.wa-phone-screen {
	background: #efeae2;
	border-radius: 10px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.wa-chat-header {
	background: #008069;
	color: #fff;
	padding: 9px 12px;
	font-size: 13px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
}

.wa-chat-body {
	padding: 12px 10px 14px;
	min-height: 120px;
	max-height: 320px;
	overflow-y: auto;
}

.wa-bubble-wrap {
	display: flex;
	justify-content: flex-start;
}

.wa-bubble {
	background: #fff;
	border-radius: 0 7px 7px 7px;
	box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
	max-width: 100%;
	width: 100%;
	overflow: hidden;
	position: relative;
}

.wa-bubble::before {
	content: '';
	position: absolute;
	left: -5px;
	top: 0;
	border: 5px solid transparent;
	border-right-color: #fff;
	border-top-color: #fff;
}

.wa-bubble-header {
	font-weight: 700;
	font-size: 13px;
	color: #111;
	padding: 8px 10px 0;
	line-height: 1.35;
}

.wa-bubble-media-inner {
	background: #e9edef;
	min-height: 90px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #667781;
	font-size: 12px;
}

.wa-bubble-media-inner i {
	font-size: 22px;
	margin-right: 6px;
}

.wa-bubble-body {
	font-size: 13px;
	color: #111;
	line-height: 1.45;
	padding: 8px 10px 4px;
	white-space: pre-wrap;
	word-break: break-word;
}

.wa-bubble-footer {
	font-size: 11px;
	color: #667781;
	padding: 0 10px 4px;
}

.wa-bubble-time {
	text-align: right;
	font-size: 10px;
	color: #667781;
	padding: 0 10px 6px;
}

.wa-bubble-buttons {
	border-top: 1px solid #e9edef;
}

.wa-bubble-btn {
	display: block;
	text-align: center;
	color: #008069;
	font-size: 12px;
	font-weight: 500;
	padding: 9px;
	border-bottom: 1px solid #e9edef;
}

.wa-bubble-btn:last-child {
	border-bottom: none;
}

.wa-preview-meta {
	margin-top: 10px;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
}

.wa-preview-badge {
	font-size: 11px;
	padding: 3px 8px;
	border-radius: 12px;
	background: #e8f5e9;
	color: #2e7d32;
}

.wa-preview-badge.status-pending {
	background: #fff3e0;
	color: #e65100;
}

.wa-preview-empty {
	text-align: center;
	color: #8696a0;
	padding: 24px 12px;
	font-size: 12px;
}

.wa-preview-empty i {
	font-size: 28px;
	display: block;
	margin-bottom: 8px;
	opacity: 0.5;
}

.wa-var-chip {
	display: inline;
	padding: 1px 5px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 500;
}

.wa-var-chip.wa-var-mapped {
	background: #dcf8c6;
	color: #1b5e20;
}

.wa-var-chip.wa-var-unmapped {
	background: #fff8e1;
	color: #f57f17;
	border: 1px dashed #ffca28;
}

.wa-tpl-form-actions {
	text-align: center;
	padding-top: 8px;
	border-top: 1px solid #eee;
	margin-top: 4px;
}

@media (max-width: 900px) {
	.wa-tpl-split-section {
		grid-template-columns: 1fr;
	}

	.wa-tpl-split-preview .wa-tpl-preview-section {
		position: static;
	}
}

@media (max-width: 640px) {
	.wa-tpl-grid-2,
	.wa-tpl-grid-3 {
		grid-template-columns: 1fr;
	}

	.wa-mapping-card-header {
		flex-direction: column;
	}
}

/* Toggle checkbox (provider, rules, templates) */
.wa-toggle-field {
	margin: 8px 0 0 0;
}

.wa-toggle-label {
	display: inline-flex !important;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	float: none !important;
	width: auto !important;
	margin: 0 !important;
}

.wa-toggle-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.wa-toggle-switch {
	position: relative;
	width: 44px;
	height: 24px;
	background: #ccc;
	border-radius: 999px;
	transition: background 0.2s ease;
	flex-shrink: 0;
}

.wa-toggle-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.2s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wa-toggle-input:checked + .wa-toggle-switch {
	background: #25D366;
}

.wa-toggle-input:checked + .wa-toggle-switch::after {
	transform: translateX(20px);
}

.wa-toggle-text {
	font-weight: 600;
	color: #333;
}

.wa-toggle-help {
	margin: 6px 0 0 54px;
	font-size: 12px;
	color: #777;
}

/* Status badges (queue + delivery) */
.wa-status-badge {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 600;
	text-transform: capitalize;
	white-space: nowrap;
}

.wa-status-muted { background: #eceff1; color: #546e7a; }
.wa-status-pending { background: #fff3e0; color: #ef6c00; }
.wa-status-processing { background: #e3f2fd; color: #1565c0; }
.wa-status-sent { background: #e8f5e9; color: #2e7d32; }
.wa-status-delivered { background: #e0f2f1; color: #00695c; }
.wa-status-read { background: #e8eaf6; color: #283593; }
.wa-status-failed { background: #ffebee; color: #c62828; }

/* Patient search (manual send + timeline) */
.wa-patient-search-wrap {
	position: relative;
	z-index: 50;
}

.wa-patient-search-results {
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	z-index: 100;
	max-height: 220px;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #ddd;
	border-top: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.wa-patient-search-results table {
	width: 100%;
	border-collapse: collapse;
}

.wa-patient-search-results th,
.wa-patient-search-results td {
	padding: 8px 10px;
	font-size: 12px;
	border-bottom: 1px solid #eee;
	text-align: left;
}

.wa-patient-search-results tr:hover {
	background: #f5f5f5;
	cursor: pointer;
}

.wa-patient-selected {
	background: #e8f5e9;
	border: 1px solid #c8e6c9;
	border-radius: 6px;
	padding: 10px 12px;
	margin-top: 8px;
	font-size: 13px;
}

.wa-manual-modal-content {
	max-width: 1180px !important;
	width: 98% !important;
	margin: 24px auto !important;
}

.wa-manual-split {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-top: 12px;
}

.wa-manual-mapping-readonly table {
	width: 100%;
	font-size: 12px;
	border-collapse: collapse;
}

.wa-manual-mapping-readonly th,
.wa-manual-mapping-readonly td {
	padding: 6px 8px;
	border-bottom: 1px solid #eee;
	text-align: left;
}

.wa-manual-agree {
	margin-top: 14px;
	padding: 12px;
	background: #fff8e1;
	border: 1px solid #ffe082;
	border-radius: 6px;
}

@media (max-width: 900px) {
	.wa-manual-split {
		grid-template-columns: 1fr;
	}
}

/* Context-aware sender modal (whatsapp-sender.php) */
.wa-sender-modal {
	max-width: 480px !important;
	width: 94% !important;
	margin: 40px auto !important;
	overflow: visible !important;
}

.wa-sender-header {
	padding: 10px 16px !important;
}

.wa-sender-header h5 {
	font-size: 15px;
}

.wa-sender-body {
	padding: 14px 16px 16px !important;
	overflow: visible !important;
	max-height: none !important;
}

.wa-sender-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
	color: #666;
}

.wa-sender-context-badge {
	display: inline-block;
	padding: 2px 8px;
	background: #25d366;
	color: #fff;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 600;
}

.wa-sender-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
}

.wa-sender-tab {
	flex: 1;
	border: 1px solid #ddd;
	background: #fafafa;
	border-radius: 6px;
	padding: 8px 10px;
	font-size: 12px;
	cursor: pointer;
	color: #444;
	transition: border-color 0.15s, background 0.15s;
}

.wa-sender-tab i {
	margin-right: 4px;
	color: #25d366;
}

.wa-sender-tab.is-active {
	border-color: #25d366;
	background: #f0faf3;
	font-weight: 600;
}

.wa-sender-panel {
	margin-bottom: 4px;
}

.wa-sender-label {
	display: block;
	margin: 10px 0 4px 0 !important;
	font-size: 13px;
}

.wa-sender-textarea {
	min-height: 0 !important;
	resize: vertical;
	font-size: 13px;
}

.wa-sender-preview {
	margin-top: 10px;
	padding: 10px 12px;
	background: #e8f5e9;
	border-radius: 8px;
	border: 1px solid #c8e6c9;
	max-height: 120px;
	overflow-y: auto;
}

.wa-sender-preview-bubble {
	font-size: 13px;
	line-height: 1.45;
	color: #222;
	white-space: pre-wrap;
	word-break: break-word;
}

.wa-sender-hint {
	margin: 0 0 10px 0;
}

.wa-sender-footer {
	margin-top: 14px;
	text-align: center;
}

.wa-sender-submit {
	width: 100%;
	padding: 10px 16px !important;
}

#loadWhatsappModel.w3-modal {
	overflow-y: auto;
	padding-top: 20px;
	padding-bottom: 20px;
}

/* Communication queue listing filters */
.wa-queue-filters {
	box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.07);
	align-items: flex-end;
}

.wa-queue-filter-field {
	padding: 0 8px 8px 8px;
}

.wa-queue-filter-actions {
	padding: 0 8px 8px 8px;
}

.wa-queue-filter-btns {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.wa-queue-filter-btns .w3-button {
	margin: 0 !important;
	padding: 8px 12px !important;
	flex: 1;
	min-width: 70px;
}

.wa-queue-search-meta {
	margin: 0 16px 6px 16px;
}

.wa-table-panel {
	margin: 0 0 12px 0;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	background: #fff;
	overflow: hidden;
}

.wa-table-scroll {
	overflow-x: auto;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
}

.wa-table-scroll .w3-table-all {
	margin-bottom: 0;
}

.wa-table-panel .wa-pagination {
	border-top: 1px solid #e0e0e0;
	border-radius: 0;
	margin: 0;
}

.wa-pagination-info {
	color: #666;
	min-width: 140px;
}

.wa-pagination-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	justify-content: center;
}

.wa-pagination-nav .w3-button {
	min-width: 34px;
	padding: 4px 8px !important;
	margin: 0 !important;
}

.wa-pagination-nav .wa-pagination-active {
	background: #4caf50 !important;
	color: #fff !important;
	border-color: #4caf50 !important;
}

.wa-pagination-size {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wa-pagination-size select {
	width: 72px;
	margin: 0 !important;
	padding: 4px 6px !important;
}

.wa-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 16px;
	background: #fafafa;
}

@media (max-width: 768px) {
	.wa-pagination {
		flex-direction: column;
		align-items: stretch;
	}

	.wa-pagination-nav {
		justify-content: center;
	}

	.wa-pagination-size {
		justify-content: flex-end;
	}
}


