/**
 * Workflow builder styles.
 * Extends new-message-template.css (wacc-tpl-*) with workflow-specific layout.
 *
 * @package AfroIT_Messaging_WorkflowAutomations
 */

/* Workflow builder layout: Actions left, Workflow right */
.wacc-workflow-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-radius: 8px;
	--wacc-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

/* Workflow settings & conditions */
.wacc-workflow-settings .wacc-tpl-row {
	display: flex;
	flex-wrap: wrap;
	gap: 24px;
	align-items: flex-end;
}

.wacc-workflow-settings .wacc-tpl-field {
	flex: 1;
	min-width: 200px;
}

.wacc-workflow-settings .wacc-tpl-field--toggle {
	flex: 0 0 auto;
	margin-bottom: 0;
}

.wacc-workflow-settings .wacc-tpl-field--toggle .wacc-tpl-toggle-row {
	justify-content: flex-start;
	gap: 12px;
	margin: 0;
}

.wacc-workflow-settings .wacc-tpl-field--toggle .wacc-tpl-toggle-label {
	flex: none;
}

.wacc-workflow-conditions .wacc-tpl-row {
	align-items: flex-end;
}

.wacc-conditions-list {
	margin-bottom: 16px;
}

.wacc-condition-row {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: flex-end;
	margin-bottom: 12px;
}

.wacc-condition-row .wacc-tpl-field {
	min-width: 0;
}

/* Variable: flexible, takes remaining space */
.wacc-condition-row .wacc-tpl-field:first-child {
	flex: 0 1 200px;
	min-width: 180px;
}

/* Operator: fixed width for dropdown */
.wacc-condition-row .wacc-tpl-field:nth-child(2) {
	flex: 0 0 160px;
	min-width: 140px;
}

/* Value: flexible, room for input */
.wacc-condition-row .wacc-tpl-field:nth-child(3) {
	flex: 0 1 200px;
	min-width: 160px;
}

.wacc-condition-row .wacc-condition-actions {
	flex: 0 0 auto;
	min-width: 40px;
}

.wacc-condition-row .wacc-condition-remove {
	min-width: 32px;
	height: 32px;
	padding: 0;
	font-size: 20px;
	line-height: 1;
	color: var(--wacc-text-muted);
	background: transparent;
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	cursor: pointer;
}

.wacc-condition-row .wacc-condition-remove:hover {
	color: #dc2626;
	border-color: #dc2626;
}

.wacc-workflow-builder {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	margin-top: 10px;
	max-width: 100%;
	min-width: 0;
}
.wacc-workflow-wrap .wacc-tpl-card {
    max-width: 1060px !important;
}
/* Actions panel (left) - fixed width, does not grow with workflow steps */
.wacc-workflow-actions {
	flex: 0 0 200px;
	min-width: 0;
	align-self: flex-start;
}

.wacc-workflow-actions-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wacc-action-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	margin-bottom: 8px;
	background: var(--wacc-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	cursor: grab;
	transition: background 0.15s, border-color 0.15s;
}

.wacc-action-item:hover {
	background: #f1f5f9;
	border-color: #cbd5e1;
}

.wacc-action-item:active {
	cursor: grabbing;
}

.wacc-action-handle {
	font-size: 14px;
	color: var(--wacc-text-muted);
}

.wacc-action-label {
	font-size: 14px;
	font-weight: 500;
	color: var(--wacc-text);
}

/* Workflow panel (right) */
.wacc-workflow-wrap .wacc-workflow-canvas {
	flex: 1;
	min-width: 0;
    max-width: 800px !important;
    box-shadow: none !important;
}

.wacc-workflow-steps-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
	list-style: none;
	margin: 0 0 20px;
	padding: 16px;
	min-height: 120px;
	border: 2px dashed var(--wacc-border);
	border-radius: var(--wacc-radius);
	background: var(--wacc-bg);
}

.wacc-workflow-steps-list:empty::before {
	content: attr(data-empty-text);
	display: block;
	text-align: center;
	color: var(--wacc-text-muted);
	font-size: 14px;
	padding: 24px;
}

.wacc-workflow-step {
	
}

.wacc-step-row {
	display: flex;
	align-items: center;
	gap: 12px;

    display: flex;
	flex-direction: row;
	padding: 12px 16px;
	margin-bottom: 0;
	background: var(--wacc-card-bg);
	border: 1px solid var(--wacc-border);
	border-radius: var(--wacc-radius);
	box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.wacc-workflow-step:last-child {
	margin-bottom: 0;
}

/* Arrow connector between steps - short vertical line with arrowhead */
.wacc-step-connector {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-top: 6px;
	margin-bottom: 4px;
	min-height: 18px;
}

.wacc-workflow-step:last-child .wacc-step-connector {
	display: none;
}

.wacc-step-connector::before {
	content: '';
	display: block;
	width: 2px;
	height: 10px;
	background: var(--wacc-border);
}

.wacc-step-connector::after {
	content: '';
	display: block;
	width: 0;
	height: 0;
	margin-top: 2px;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid var(--wacc-border);
}

.wacc-step-row .wacc-step-handle {
	flex-shrink: 0;
	font-size: 14px;
	color: var(--wacc-text-muted);
	cursor: grab;
}

.wacc-step-row .wacc-step-handle:active {
	cursor: grabbing;
}

.wacc-step-row .wacc-step-label {
	flex: 1;
	font-size: 14px;
	font-weight: 500;
	color: var(--wacc-text);
}

.wacc-step-row .wacc-step-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.wacc-step-row .wacc-step-btn {
	padding: 4px 8px;
	font-size: 18px;
	line-height: 1;
	color: var(--wacc-text-muted);
	background: transparent;
	border: none;
	cursor: pointer;
	opacity: 0.7;
	transition: color 0.15s, opacity 0.15s;
}

.wacc-step-row .wacc-step-btn:hover {
	color: var(--wacc-text);
	opacity: 1;
}

.wacc-step-row .wacc-step-btn--delete:hover {
	color: #dc2626;
}

/* Step arrows - downward flow */
.wacc-step-arrow {
	display: block;
	width: 0;
	height: 0;
	border-left: 6px solid transparent;
	border-right: 6px solid transparent;
	border-top: 8px solid var(--wacc-border);
	flex-shrink: 0;
	margin-right: 4px;
}

.wacc-step-arrow--toggle {
	cursor: pointer;
	background: none;
	padding: 0;
	margin: 0;
	-webkit-appearance: none;
	appearance: none;
	border-left: 6px solid transparent;
	border-right: 6px solid transparent;
	border-top: 8px solid var(--wacc-border);
	border-bottom: none;
}

.wacc-step-arrow--toggle:focus {
	outline: 1px solid var(--wacc-accent);
	outline-offset: 2px;
}

.wacc-step-arrow--toggle {
	transition: transform 0.2s ease;
}

.wacc-workflow-step--branch-collapsed .wacc-step-arrow--toggle {
	transform: rotate(-90deg);
}

.wacc-workflow-step--branch-collapsed .wacc-branch-connector,
.wacc-workflow-step--branch-collapsed .wacc-branch-panels {
	display: none;
}

.wacc-workflow-step--branch {
	flex-direction: column;
	align-items: stretch;
}

.wacc-step-header {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
}

.wacc-branch-panels {
	display: flex;
	gap: 16px;
	margin-top: 8px;
	width: 100%;
}

.wacc-branch-panel {
	flex: 1;
	min-width: 180px;
	border: 2px dashed var(--wacc-border);
	border-radius: var(--wacc-radius);
	background: var(--wacc-bg);
	padding: 12px;
	min-height: 80px;
}

.wacc-branch-panel-label {
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 8px;
	padding-bottom: 4px;
	border-bottom: 1px solid var(--wacc-border);
}

.wacc-branch-panel--true .wacc-branch-panel-label {
	color: #059669;
}

.wacc-branch-panel--false .wacc-branch-panel-label {
	color: #dc2626;
}

.wacc-branch-steps {
	list-style: none;
	margin: 0;
	padding: 0;
	min-height: 60px;
}

.wacc-branch-steps:empty::before {
	content: attr(data-empty-text);
	display: block;
	text-align: center;
	color: var(--wacc-text-muted);
	font-size: 12px;
	padding: 16px 8px;
}

.wacc-branch-steps .wacc-workflow-step {
	margin-bottom: 8px;
	max-width: 350px;
}

.wacc-workflow-steps-list .wacc-workflow-step.wacc-workflow-step--branch {
	max-width: 90%;
	display: flex;
	align-items: center;
	flex-direction: column;
}

.wacc-branch-steps .wacc-workflow-step:last-child {
	margin-bottom: 0;
}

#wacc-workflow-steps {
    min-height: 420px;
}

/* Sortable ghost */
.sortable-ghost {
	opacity: 0.4;
	background: #e2e8f0;
}

.sortable-drag {
	opacity: 0.9;
}

/* Modal */
.wacc-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
}

.wacc-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 1;
}

.wacc-modal-content {
	position: relative;
	z-index: 2;
	min-width: 400px;
	max-width: 90vw;
	margin: 20px;
	background: #ffffff;
	border-radius: 8px;
	box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
	padding: 24px;
}

#wacc-modal-body {
	min-height: 80px;
}

#wacc-modal-body.wacc-modal-body-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

#wacc-modal-body .wacc-modal-spinner {
	float: none;
	margin: 0;
}

.wacc-modal-actions {
	display: flex;
	gap: 12px;
	margin-top: 20px;
}

.wacc-modal-instructions {
	font-size: 13px;
	color: var(--wacc-text-muted);
	line-height: 1.5;
	margin: 16px 0 0;
	padding: 12px;
	background: var(--wacc-bg);
	border-radius: var(--wacc-radius);
	border-left: 3px solid var(--wacc-accent);
}
.wacc-tpl-hidden {
    display: none !important;
}

/* Responsive */
@media screen and (max-width: 1024px) {
	.wacc-workflow-builder {
		flex-direction: column;
	}

	.wacc-workflow-actions {
		flex: none;
	}
}

.afromewo-row-spinner{
    display:inline-block;
    width:12px;height:12px;
    border:2px solid rgba(0,0,0,.15);
    border-top-color:#2271b1;
    border-radius:50%;
    vertical-align:middle;
    margin-left:6px;
    animation: afromewo-spin .8s linear infinite;
}
@keyframes afromewo-spin{ to { transform: rotate(360deg); } }
.afromewo-exec-modal{ padding: 12px 4px 4px; }
.afromewo-exec-modal__title{ margin: 0 0 6px; }
.afromewo-exec-modal__subtitle{ margin: 0 0 12px; }
.afromewo-exec-modal__body pre{ max-height: 260px; overflow:auto; background:#f6f7f7; padding: 10px; }
.afromewo-exec-modal__raw{ margin-top: 12px; }

.wacc-workflow-wrap .afromewo-pro-upgrade {
	max-width: 1060px;
	margin: 0 0 16px;
	background: #e7f5fe;
	border-left-color: #2271b1;
}

.wacc-workflow-wrap .afromewo-pro-upgrade ul {
	list-style: disc;
	margin: 0 0 12px 1.25em;
}

.wacc-workflow-wrap .afromewo-pro-upgrade .button-link {
	margin-left: 8px;
	text-decoration: none;
}
