/* Root widget placement and theme tokens for a cleaner modern UI. */
.an4soft-chat-widget {
	--an4soft-accent: #2563eb;
	--an4soft-accent-strong: #1d4ed8;
	--an4soft-bg-soft: #f8fafc;
	--an4soft-text: #0f172a;
	--an4soft-text-muted: #334155;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 9998;
	font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-end;
}

.an4soft-chat-widget-left {
	left: 24px;
	right: auto;
	align-items: flex-start;
}

/* Modern floating icon button that opens the chat box. */
.an4soft-chat-toggle {
	border: 0;
	border-radius: 999px;
	width: 60px;
	height: 60px;
	background: linear-gradient(135deg, var(--an4soft-accent), var(--an4soft-accent-strong));
	color: #fff;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
	transition: transform 0.15s ease, box-shadow 0.2s ease, width 0.2s ease, height 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.an4soft-chat-toggle:hover {
	transform: translateY(-1px);
	box-shadow: 0 14px 28px rgba(37, 99, 235, 0.38);
}

.an4soft-chat-toggle:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.3);
	outline-offset: 2px;
}

/* Keep the button fixed but smaller while chat panel is open. */
.an4soft-chat-widget-open .an4soft-chat-toggle {
	width: 44px;
	height: 44px;
	box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

/* Icon inside toggle button for a clean, text-free launcher. */
.an4soft-chat-toggle-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-size: 26px;
	line-height: 1;
	transition: font-size 0.2s ease;
}

/* Shrink icon in sync with the smaller open-state button. */
.an4soft-chat-widget-open .an4soft-chat-toggle-icon {
	font-size: 18px;
}

/* Main chat card with rounded corners and soft modern shadow. */
.an4soft-chat-panel {
	width: min(360px, calc(100vw - 32px));
	height: 460px;
	margin-bottom: 12px;
	border-radius: 18px;
	overflow: hidden;
	background: #fff;
	border: 0;
	box-shadow: 0 20px 45px rgba(15, 23, 42, 0.22);
	display: flex;
	flex-direction: column;
}

/* Keep panel hidden until JavaScript opens it via button click. */
.an4soft-chat-panel[hidden] {
	display: none !important;
}

/* Gradient header for strong visual identity and hierarchy. */
.an4soft-chat-header {
	background: linear-gradient(135deg, var(--an4soft-accent), var(--an4soft-accent-strong));
	color: #fff;
	padding: 14px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 0;
}

.an4soft-chat-header strong {
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.an4soft-chat-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.an4soft-chat-title-cart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
	width: 20px;
	height: 20px;
	line-height: 1;
	color: #fff;
	text-decoration: none;
}

.an4soft-chat-title-cart svg {
	display: block;
	width: 100%;
	height: 100%;
	fill: currentColor;
}

.an4soft-chat-cart-count {
	position: absolute;
	top: -7px;
	right: -10px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	border-radius: 999px;
	background: #ef4444;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
	box-sizing: border-box;
}

.an4soft-chat-cart-count.is-empty {
	display: none;
}

.an4soft-chat-header-actions {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

/* Circular close control that stays visible on gradient background. */
.an4soft-chat-maximize,
.an4soft-chat-close {
	border: 0;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 999px;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

.an4soft-chat-maximize {
	font-size: 13px;
}

.an4soft-chat-maximize:hover,
.an4soft-chat-close:hover {
	background: rgba(255, 255, 255, 0.28);
}

.an4soft-chat-maximize:focus-visible,
.an4soft-chat-close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.7);
	outline-offset: 1px;
}

/* Expanded state for larger desktop chat area. */
.an4soft-chat-widget-maximized .an4soft-chat-panel {
	width: min(520px, calc(100vw - 32px));
	height: 100vh;
	max-height: 100vh;
	margin-bottom: 0;
	border-radius: 0;
}

/* Hide launcher while maximized, because panel already fills viewport height. */
.an4soft-chat-widget-maximized .an4soft-chat-toggle {
	display: none;
}

/* Pin maximized widget to viewport edges to remove bottom gap. */
.an4soft-chat-widget.an4soft-chat-widget-maximized {
	bottom: 0;
	right: 0;
}

.an4soft-chat-widget.an4soft-chat-widget-maximized.an4soft-chat-widget-left {
	left: 0;
	right: auto;
}

/* Message area with comfortable spacing and soft surface color. */
.an4soft-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 10px 14px 14px;
	background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
	display: flex;
	flex-direction: column;
}

/* Suggestion chips displayed above message list for quick interactions. */
.an4soft-chat-suggestions {
	display: flex;
	gap: 10px;
	justify-content: center;
	padding: 7px 10px;
	border-bottom: 1px solid #e2e8f0;
	background: #f1f5f9;
	overflow-x: auto;
	scrollbar-width: thin;
}

.an4soft-chat-suggestion-pill {
	border: 1px solid #cbd5e1;
	border-radius: 999px;
	background: #f8fafc;
	color: #334155;
	font-size: 11px;
	font-weight: 600;
	padding: 5px 14px;
	white-space: nowrap;
	line-height: 1.2;
	cursor: pointer;
}

.an4soft-chat-suggestion-pill:hover {
	background: #e2e8f0;
}

.an4soft-chat-suggestion-pill:focus-visible {
	outline: 2px solid rgba(37, 99, 235, 0.35);
	outline-offset: 1px;
}

/* Appointment form — full-width card aligned with chat widget styling. */
.an4soft-chat-message.an4soft-chat-appointment-wrap {
	width: 100%;
	max-width: 100%;
	align-self: stretch;
	box-sizing: border-box;
	padding: 14px 14px 16px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.an4soft-chat-appointment-form {
	display: flex;
	flex-direction: column;
	gap: 0;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	margin: 0;
	box-sizing: border-box;
}

.an4soft-chat-appointment-form__head {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0 0 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid #eef2f7;
}

.an4soft-chat-appointment-form__title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.01em;
	color: var(--an4soft-text);
}

.an4soft-chat-appointment-form__intro {
	margin: 0;
	font-size: 13px;
	line-height: 1.4;
	color: #64748b;
}

.an4soft-chat-appointment-form__fields {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.an4soft-chat-appointment-form__field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
}

.an4soft-chat-appointment-form__label {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.25;
	color: #334155;
}

.an4soft-chat-appointment-form__label:has(+ .an4soft-chat-appointment-form__input[required])::after {
	content: ' *';
	color: #dc2626;
	font-weight: 700;
}

.an4soft-chat-appointment-form__input {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	font-size: 14px;
	line-height: 1.35;
	font-family: inherit;
	color: var(--an4soft-text);
	background: #f8fafc;
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease,
		background-color 0.15s ease;
}

.an4soft-chat-appointment-form__input::placeholder {
	color: #94a3b8;
}

/* Match native date control border/background to text, email, and tel fields. */
.an4soft-chat-appointment-form__input[type='date'] {
	border: 1px solid #cbd5e1;
	background-color: #f8fafc;
	appearance: none;
	-webkit-appearance: none;
	color-scheme: light;
	min-height: 42px;
}

.an4soft-chat-appointment-form__input[type='date']::-webkit-datetime-edit,
.an4soft-chat-appointment-form__input[type='date']::-webkit-datetime-edit-fields-wrapper {
	padding: 0;
	background: transparent;
	color: var(--an4soft-text);
}

.an4soft-chat-appointment-form__input[type='date']::-webkit-calendar-picker-indicator {
	cursor: pointer;
	opacity: 0.7;
}

.an4soft-chat-appointment-form__input:hover,
.an4soft-chat-appointment-form__input[type='date']:hover {
	border-color: #94a3b8;
}

.an4soft-chat-appointment-form__input:focus,
.an4soft-chat-appointment-form__input[type='date']:focus {
	outline: none;
	border-color: var(--an4soft-accent);
	background: #ffffff;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Empty required date is :invalid by default — keep the same border as other fields. */
.an4soft-chat-appointment-form__input[type='date']:invalid:not(:focus) {
	border-color: #cbd5e1;
	background-color: #f8fafc;
	box-shadow: none;
}

.an4soft-chat-appointment-form__input:user-invalid:not(:placeholder-shown):not([type='date']),
.an4soft-chat-appointment-form__input:invalid:not(:focus):not(:placeholder-shown):not([type='date']) {
	border-color: #f87171;
	background: #fffafb;
}

.an4soft-chat-appointment-form--show-errors .an4soft-chat-appointment-form__input:invalid:not(:focus) {
	border-color: #f87171;
	background: #fffafb;
}

.an4soft-chat-appointment-form__actions {
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid #eef2f7;
}

.an4soft-chat-appointment-form__submit {
	display: block;
	width: 100%;
	margin: 0;
	padding: 11px 16px;
	border: 0;
	border-radius: 10px;
	background: var(--an4soft-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
	transition:
		background-color 0.15s ease,
		box-shadow 0.15s ease,
		transform 0.12s ease;
}

.an4soft-chat-appointment-form__submit:hover {
	background: var(--an4soft-accent-strong);
	box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
}

.an4soft-chat-appointment-form__submit:active {
	transform: translateY(1px);
}

.an4soft-chat-appointment-form__submit:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.25);
	outline-offset: 2px;
}

.an4soft-chat-appointment-form__submit:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Maximized: Name full row, Email + Phone row, Date full row. */
.an4soft-chat-widget-maximized .an4soft-chat-appointment-form__fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px 14px;
}

.an4soft-chat-widget-maximized .an4soft-chat-appointment-form__field--full {
	grid-column: 1 / -1;
}

.an4soft-chat-widget-maximized .an4soft-chat-appointment-form__field--half {
	grid-column: span 1;
}

/* Scale suggestion layout for maximized chat mode. */
.an4soft-chat-widget-maximized .an4soft-chat-suggestions {
	gap: 30px;
	padding: 10px 14px;
	justify-content: center;
	flex-wrap: wrap;
	overflow-x: visible;
}

.an4soft-chat-widget-maximized .an4soft-chat-suggestion-pill {
	font-size: 12px;
	padding: 9px 18px;
}

/* Generic bubble style shared by bot and user messages. */
.an4soft-chat-message {
	margin: 0 0 10px;
	padding: 9px 12px;
	border-radius: 14px;
	width: fit-content;
	max-width: 86%;
	word-break: break-word;
	white-space: pre-line;
	font-size: 14px;
	line-height: 1.5;
	color: var(--an4soft-text);
}

/* Bot bubble stays on left with neutral background. */
.an4soft-chat-message-bot {
	background: #fff;
	border: 1px solid #e2e8f0;
	color: var(--an4soft-text-muted);
	align-self: flex-start;
}

/* User bubble aligns right and uses accent tint background. */
.an4soft-chat-message-user {
	background: #dbeafe;
	border: 1px solid #93c5fd;
	align-self: flex-end;
}

/* Product cards rendered by WooCommerce product-name matches. */
.an4soft-chat-cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	align-items: start;
	gap: 12px;
	width: 100%;
	max-width: 100%;
	margin: 0 0 10px;
	align-self: flex-start;
}

.an4soft-chat-card {
	display: inline-flex;
	flex-direction: column;
	align-items: stretch;
	background: #fff;
	border: 1px solid #d7e3f4;
	border-radius: 14px;
	padding: 10px;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.an4soft-chat-card-title {
	margin: 0 0 6px;
	font-size: 15px;
	line-height: 1.3;
	font-weight: 600;
	color: #0f172a;
}

.an4soft-chat-card-price {
	margin: 0 0 10px;
	font-size: 14px;
	font-weight: 700;
	color: #0b5f56;
}

.an4soft-chat-card-price del {
	color: #64748b;
	font-weight: 500;
	margin-right: 6px;
}

.an4soft-chat-card-price ins {
	text-decoration: none;
}

.an4soft-chat-card-image {
	display: block;
	width: 100%;
	max-width: none;
	aspect-ratio: 1 / 1;
	height: auto;
	border-radius: 12px;
	border: 0;
	margin: 0 0 10px;
	object-fit: contain;
	object-position: center;
	background: #fff;
}

.an4soft-chat-card-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 100%;
	padding: 9px 10px;
	border-radius: 8px;
	background: var(--an4soft-accent);
	color: #fff;
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	box-sizing: border-box;
	transition: background 0.2s ease, opacity 0.2s ease;
	cursor: pointer;
}

.an4soft-chat-card-button:hover {
	background: var(--an4soft-accent-strong);
	color: #fff;
}

.an4soft-chat-card-button.is-loading {
	opacity: 0.75;
	pointer-events: none;
}

.an4soft-chat-card-button.is-added {
	background: #16a34a;
}

.an4soft-chat-quantity-controls {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 8px;
	border-radius: 10px;
	border: 1px solid #dbe3ef;
	background: #fff;
	margin: 0 0 10px;
	align-self: flex-start;
}

.an4soft-chat-qty-btn {
	width: 24px;
	height: 24px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	background: #f8fafc;
	color: #0f172a;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.an4soft-chat-qty-value {
	min-width: 16px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: #0f172a;
}

.an4soft-chat-qty-confirm {
	border: 0;
	border-radius: 8px;
	padding: 9px 10px;
	background: var(--an4soft-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	display: inline-block;
	margin-top: 8px;
	margin-left: 10px;
	transition: background 0.2s ease, opacity 0.2s ease;
}

.an4soft-chat-qty-confirm:hover {
	background: var(--an4soft-accent-strong);
}

.an4soft-chat-qty-confirm:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.an4soft-chat-order-actions {
	display: inline-flex;
	gap: 8px;
}

.an4soft-chat-order-btn {
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 9px 10px;
	background: #fff;
	color: #0f172a;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.an4soft-chat-order-yes {
	background: var(--an4soft-accent);
	border-color: var(--an4soft-accent);
	color: #fff;
}

.an4soft-chat-order-yes:hover {
	background: var(--an4soft-accent-strong);
	border-color: var(--an4soft-accent-strong);
}

.an4soft-chat-order-no {
	background: #f8fafc;
	border-color: #cbd5e1;
	color: #334155;
}

.an4soft-chat-order-no:hover {
	background: #e2e8f0;
	border-color: #94a3b8;
}

.an4soft-chat-order-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.an4soft-chat-order-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.an4soft-chat-order-form-message {
	width: auto;
	max-width: 92%;
	box-sizing: border-box;
	align-self: flex-start;
}

.an4soft-chat-message-bot.an4soft-chat-order-form-message {
	max-width: 92%;
}

.an4soft-chat-order-form {
	width: auto;
	min-width: 240px;
	display: grid;
	grid-template-columns: auto 1fr;
	column-gap: 10px;
	row-gap: 8px;
	align-items: center;
}

.an4soft-chat-order-label {
	font-size: 12px;
	font-weight: 600;
	color: #334155;
	white-space: nowrap;
}

.an4soft-chat-order-input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 13px;
	color: #0f172a;
	background: #fff;
}

.an4soft-chat-order-textarea {
	min-height: 64px;
	resize: vertical;
}

.an4soft-chat-order-form-submit {
	border: 0;
	border-radius: 8px;
	padding: 9px 10px;
	background: var(--an4soft-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	align-self: flex-start;
	grid-column: 1 / -1;
	box-sizing: border-box;
	transition: background 0.2s ease, opacity 0.2s ease;
}

.an4soft-chat-order-form-submit:hover {
	background: var(--an4soft-accent-strong);
}

.an4soft-chat-order-form-submit:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.an4soft-chat-rating-stars {
	display: inline-flex;
	gap: 4px;
}

.an4soft-chat-star-btn {
	border: 0;
	background: transparent;
	padding: 0;
	line-height: 1;
	font-size: 22px;
	color: #f59e0b;
	cursor: pointer;
}

.an4soft-chat-star-btn.is-active {
	color: #f59e0b;
}

.an4soft-chat-star-btn:disabled {
	cursor: default;
	opacity: 0.95;
}

/* Input row with clear separation from the message area. */
.an4soft-chat-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px 12px 10px;
	border-top: 1px solid #e2e8f0;
	background: #fff;
}

/* Keep input and send button in one row. */
.an4soft-chat-input-row {
	display: flex;
	gap: 8px;
}

/* Rounded modern text input with focus ring. */
.an4soft-chat-input {
	flex: 1;
	min-width: 0;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 14px;
	color: var(--an4soft-text);
}

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

.an4soft-chat-input::placeholder {
	color: #94a3b8;
}

/* Modern send button matching the brand accent color. */
.an4soft-chat-send {
	border: 0;
	border-radius: 10px;
	padding: 10px 14px;
	background: var(--an4soft-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease;
	min-width: 72px;
}

.an4soft-chat-send:hover {
	background: var(--an4soft-accent-strong);
}

.an4soft-chat-send:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.25);
	outline-offset: 1px;
}

/* Centered consent note shown under the message field. */
.an4soft-chat-privacy-note {
	margin: 4px 0 0;
	font-size: 11px;
	line-height: 1.4;
	color: var(--an4soft-text-muted);
	text-align: center;
}

/* Better fit on smaller screens while keeping comfortable spacing. */
@media (max-width: 480px) {
	.an4soft-chat-widget {
		right: 12px;
		bottom: 12px;
	}

	.an4soft-chat-widget-left {
		left: 12px;
		right: auto;
	}

	.an4soft-chat-panel {
		height: 72vh;
		max-height: 520px;
	}

	.an4soft-chat-widget-open.an4soft-chat-widget {
		inset: 0;
		align-items: stretch;
	}

	.an4soft-chat-widget-open.an4soft-chat-widget-left {
		left: 0;
		right: 0;
	}

	.an4soft-chat-widget-open .an4soft-chat-panel {
		width: 100%;
		height: 100%;
		max-height: none;
		margin-bottom: 0;
		border-radius: 0;
	}

	.an4soft-chat-widget-open .an4soft-chat-toggle {
		display: none;
	}
}
