/**
 * New Message Template form styles.
 * Tailwind-like aesthetic, WordPress-compatible (scoped with wacc-tpl- prefix).
 *
 * @package AfroIT_Messaging_WorkflowAutomations
 */

/* Page wrapper */
.wacc-tpl-wrap {
	--wacc-bg: #f8fafc;
	--wacc-card-bg: #ffffff;
	--wacc-border: #e2e8f0;
	--wacc-text: #1e293b;
	--wacc-text-muted: #64748b;
	--wacc-accent: #2563eb;
	--wacc-accent-hover: #1d4ed8;
	--wacc-success: #22c55e;
	--wacc-radius: 8px;
	--wacc-radius-lg: 12px;
	--wacc-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
	--wacc-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--wacc-preview-bg: #f5f5f0;
	--wacc-bubble: #e8e4dc;
}

.wacc-tpl-wrap {
	min-height: 100vh;
	padding: 20px 20px 40px;
	margin: 0;
	max-width: 100%;
	overflow-x: hidden;
	box-sizing: border-box;
}


/* Two-column layout */
.wacc-tpl-layout {
	display: flex;
	gap: 24px;
	margin-top: 24px;
	max-width: 100%;
	min-width: 0;
}

.wacc-tpl-main {
	flex: 1;
	min-width: 0;
	max-width: 100%;
	overflow-wrap: break-word;
}

.wacc-tpl-sidebar {
	flex: 0 0 340px;
	min-width: 0;
	position: sticky;
	top: 32px;
	align-self: flex-start;
	max-width: 340px;
}

/* Card sections */
.wacc-tpl-card {
	background: var(--wacc-card-bg);
	border-radius: var(--wacc-radius-lg);
	box-shadow: var(--wacc-shadow);
	padding: 24px;
	margin-bottom: 10px;
	max-width: 100%;
	min-width: 0;
	overflow-wrap: break-word;
}

.wacc-tpl-card__title {
	font-size: 16px;
	font-weight: 600;
	color: var(--wacc-text);
	margin: 0 0 20px;
	padding: 0;
	line-height: 1.4;
}

.wacc-tpl-description {
	font-size: 14px;
	color: var(--wacc-text-muted);
	line-height: 1.5;
	margin: 0 0 16px;
}

.wacc-tpl-description a {
	color: var(--wacc-accent);
	text-decoration: none;
}

.wacc-tpl-description a:hover {
	text-decoration: underline;
}

/* Form fields */
.wacc-tpl-field {
	margin-bottom: 20px;
}

/* Row layout - fields side by side */
.wacc-tpl-row {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
}

.wacc-tpl-row .wacc-tpl-field:first-child {
	flex: 0 0 50%;
	min-width: 200px;
}

.wacc-tpl-label {
	display: block;
	font-size: 14px;
	font-weight: 500;
	color: var(--wacc-text);
	margin-bottom: 8px;
}

.wacc-tpl-optional {
	font-weight: 400;
	color: var(--wacc-text-muted);
	font-size: 13px;
}

.wacc-tpl-info-icon {
	display: inline-block;
	margin-left: 4px;
	font-size: 12px;
	color: var(--wacc-text-muted);
	cursor: help;
}

/* Inputs */
.wacc-tpl-input,
.wacc-tpl-select,
.wacc-tpl-textarea {
	width: 100%;
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--wacc-text);
	background: var(--wacc-card-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wacc-tpl-input:focus,
.wacc-tpl-select:focus,
.wacc-tpl-textarea:focus {
	outline: none;
	border-color: var(--wacc-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.wacc-tpl-input.error,
.wacc-tpl-textarea.error {
	border-color: #dc2626;
}

.wacc-tpl-input::placeholder,
.wacc-tpl-textarea::placeholder {
	color: var(--wacc-text-muted);
}

.wacc-tpl-select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	padding-right: 36px;
}

.wacc-tpl-textarea {
	min-height: 120px;
	resize: vertical;
}

/* Input wrap with char count */
.wacc-tpl-input-wrap {
	position: relative;
}

.wacc-tpl-input-wrap .wacc-tpl-input {
	padding-right: 60px;
}

.wacc-tpl-char-count {
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 12px;
	color: var(--wacc-text-muted);
	pointer-events: none;
}

.wacc-tpl-textarea-wrap {
	position: relative;
}

.wacc-tpl-textarea-wrap .wacc-tpl-char-count--right {
	top: auto;
	bottom: 12px;
	right: 12px;
	transform: none;
}

.wacc-tpl-textarea-wrap .wacc-tpl-textarea {
	padding-bottom: 36px;
}

/* Format toolbar */
.wacc-tpl-format-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 8px;
	padding: 6px 0;
}

.wacc-tpl-toolbar-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: transparent;
	border: 1px solid var(--wacc-border);
	border-radius: 6px;
	color: var(--wacc-text-muted);
	cursor: pointer;
	font-size: 14px;
	transition: background 0.15s, color 0.15s;
}

.wacc-tpl-toolbar-btn:hover {
	background: var(--wacc-bg);
	color: var(--wacc-text);
}

.wacc-tpl-add-var {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: 8px;
}

.wacc-tpl-add-var-link {
	color: var(--wacc-accent);
	text-decoration: none;
	font-size: 14px;
}

.wacc-tpl-add-var-link:hover {
	text-decoration: underline;
}

/* Add button */
.wacc-tpl-add-btn-wrap {
	margin-top: 12px;
}

.wacc-tpl-add-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 500;
	color: var(--wacc-text);
	background: var(--wacc-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.wacc-tpl-add-btn:hover {
	background: #f1f5f9;
	border-color: #cbd5e1;
}

.wacc-tpl-add-btn-icon {
	font-size: 16px;
	line-height: 1;
}

.wacc-tpl-dropdown-arrow {
	font-size: 10px;
	margin-left: 4px;
	color: var(--wacc-text-muted);
}

/* Toggle switch */
.wacc-tpl-toggle-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin: 16px 0 12px;
}

.wacc-tpl-toggle-label {
	font-size: 14px;
	font-weight: 600;
	color: var(--wacc-text);
	cursor: pointer;
	flex: 1;
}

.wacc-tpl-toggle {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	flex-shrink: 0;
}

.wacc-tpl-toggle__input {
	opacity: 0;
	width: 0;
	height: 0;
}

.wacc-tpl-toggle__slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #cbd5e1;
	border-radius: 24px;
	transition: 0.3s;
}

.wacc-tpl-toggle__slider::before {
	position: absolute;
	content: "";
	height: 18px;
	width: 18px;
	left: 3px;
	bottom: 3px;
	background-color: #475569;
	border-radius: 50%;
	transition: 0.3s;
}

.wacc-tpl-toggle__input:checked + .wacc-tpl-toggle__slider {
	background-color: var(--wacc-accent);
}

.wacc-tpl-toggle__input:checked + .wacc-tpl-toggle__slider::before {
	transform: translateX(20px);
	background-color: white;
}

.wacc-tpl-helper {
	font-size: 13px;
	color: var(--wacc-text-muted);
	line-height: 1.5;
	margin: 0;
}

/* Submit actions */
.wacc-tpl-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 8px;
	padding: 20px 0;
}

.wacc-tpl-actions .spinner {
	float: none;
	margin: 0;
	visibility: hidden;
}

.wacc-tpl-actions .spinner.is-active {
	visibility: visible;
}

.wacc-tpl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	border-radius: var(--wacc-radius);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
	border: none;
	font-family: inherit;
}

.wacc-tpl-btn--primary {
	background: var(--wacc-accent);
	color: white;
}

.wacc-tpl-btn--primary:hover:not(:disabled) {
	background: var(--wacc-accent-hover);
}

.wacc-tpl-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Template variables */
.wacc-tpl-variables {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wacc-tpl-variable {
	font-family: "Courier New", Courier, monospace;
	font-weight: 500;
	color: #888;
	background: #efefef;
	padding: 2px;
	border-radius: 6px;
	font-size: 13px;
}

/* Template preview */
.wacc-tpl-preview-card {
	min-height: 200px;
}

.wacc-tpl-preview {
	background: var(--wacc-preview-bg);
	border-radius: var(--wacc-radius);
	padding: 24px;
	min-height: 160px;
}

.wacc-tpl-preview__bubble {
	display: inline-block;
	max-width: 95%;
    width: 95%;
	background: #ffffff;
	border-radius: 12px;
	border-bottom-left-radius: 4px;
	position: relative;
	box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.wacc-tpl-preview__bubble::before {
	content: "";
	position: absolute;
	left: -8px;
	bottom: 0;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0 0 12px 12px;
	border-color: transparent transparent #ffffff transparent;
}

.wacc-tpl-preview__text {
	display: block;
	font-size: 14px;
	color: var(--wacc-text);
	line-height: 1.5;
    padding: 10px 15px
}

.wacc-tpl-preview__time {
	display: block;
	font-size: 11px;
	color: var(--wacc-text-muted);
	text-align: right;
    padding-right: 15px;
	margin-top: 4px;
}

/* WhatsApp-style button preview - inside bubble, text-like with icon */
.wacc-tpl-preview__buttons {
	margin-top: 10px 0px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: flex-start;
}

.wacc-tpl-preview__btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0;
	font-size: 14px;
	background: none;
	border: none;
	color: #0088cc;
	cursor: default;
    display: inline-block;
    width: 100%;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding: 10px 0;
}

.wacc-tpl-preview__btn--url,
.wacc-tpl-preview__btn--phone,
.wacc-tpl-preview__btn--flow {
	color: #0088cc;
}

.wacc-tpl-preview__btn--copy {
	color: #64748b;
}

/* Add button dropdown */
.wacc-tpl-btn-dropdown {
	position: relative;
}

.wacc-tpl-btn-type-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	margin: 4px 0 0;
	padding: 8px 0;
	min-width: 220px;
	background: var(--wacc-card-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	box-shadow: var(--wacc-shadow);
	list-style: none;
	z-index: 100;
}

.wacc-tpl-btn-dropdown.is-open .wacc-tpl-btn-type-menu {
	display: block;
}

.wacc-tpl-btn-type-menu li {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	cursor: pointer;
	font-size: 14px;
	color: var(--wacc-text);
}

.wacc-tpl-btn-type-menu li:hover {
	background: var(--wacc-bg);
}

.wacc-tpl-btn-type-icon {
	opacity: 0.7;
	font-size: 16px;
}

/* Buttons list */
.wacc-tpl-buttons-list {
	margin-top: 16px;
}

.wacc-tpl-btn-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	margin-bottom: 8px;
	background: var(--wacc-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
}

.wacc-tpl-btn-item__label {
	flex: 1;
	font-size: 14px;
	color: var(--wacc-text);
}

.wacc-tpl-btn-item__type {
	font-size: 12px;
	color: var(--wacc-text-muted);
}

.wacc-tpl-btn-item__actions {
	display: flex;
	gap: 8px;
}

.wacc-tpl-btn-item__actions button {
	padding: 4px 10px;
	font-size: 12px;
	border-radius: 6px;
	border: 1px solid var(--wacc-border);
	background: var(--wacc-card-bg);
	cursor: pointer;
}

.wacc-tpl-btn-item__actions button:hover {
	background: var(--wacc-bg);
}

.wacc-tpl-btn-item__actions .wacc-btn-delete {
	color: #dc2626;
	border-color: #dc2626;
}

/* Button form */
.wacc-tpl-btn-form-wrap {
	margin-top: 16px;
	padding: 16px;
	background: var(--wacc-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
}

.wacc-tpl-btn-form-actions {
	display: flex;
	gap: 12px;
	margin-top: 16px;
}

/* Header adjustments */
.wacc-tpl-wrap .wp-header-end {
	margin: 16px 0 0;
}

/* Messaging list (templates.php) - prevent horizontal scroll */
.wacc-messaging-wrap {
	max-width: 100%;
	overflow-x: hidden;
	box-sizing: border-box;
}

.wacc-messaging-wrap .wp-list-table,
.wacc-messaging-wrap .tablenav {
	max-width: 100%;
}
.wacc-messaging-wrap .tablenav.top {
    display: none !important;
}

.wacc-messaging-wrap .afromewo-pro-upgrade {
	margin: 12px 0 16px;
	background: #e7f5fe;
	border-left-color: #2271b1;
}

/* Responsive */
@media screen and (max-width: 1024px) {
	.wacc-tpl-layout {
		flex-direction: column;
	}

	.wacc-tpl-sidebar {
		flex: none;
		position: static;
	}
}

@media screen and (max-width: 782px) {
	.wacc-tpl-wrap {
		padding: 12px;
	}

	.wacc-tpl-card {
		padding: 16px;
	}

	.wacc-tpl-row {
		flex-direction: row;
		flex-wrap: wrap;
	}

	.wacc-tpl-row .wacc-tpl-field {
		min-width: 0;
	}

	.wacc-tpl-toggle-row {
		flex-direction: row;
		align-items: center;
	}
}

/* Template list table status badges */
.wacc-template-status {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 500;
}
.wacc-status-approved {
	background: #dcfce7;
	color: #166534;
}
.wacc-status-pending {
	background: #fef3c7;
	color: #92400e;
}
.wacc-status-rejected,
.wacc-status-disabled {
	background: #fee2e2;
	color: #991b1b;
}
.wacc-status-paused {
	background: #e5e7eb;
	color: #4b5563;
}
