/* Messaggistica WhatsApp — cliente e venditore P.IVA */

:root {
	--vc-wa-header: #075e54;
	--vc-wa-header-alt: #128c7e;
	--vc-wa-bg: #e5ddd5;
	--vc-wa-bg-pattern: #efeae2;
	--vc-wa-in: #ffffff;
	--vc-wa-out: #dcf8c6;
	--vc-wa-line: #d1d7db;
	--vc-wa-muted: #667781;
	--vc-wa-ink: #111b21;
	--vc-wa-send: #00a884;
	--vc-brand-blue: #0445af;
	--vc-brand-cyan: #04b8d8;
	--vc-brand-gold: #ffc532;
}

/* Pulsante «Scrivi al venditore» — solo vetrine negozi virtuali */
body.vc-product-vendor-store .wcfm_catalog_enquiry_button_wrapper {
	margin: 1rem 0 0.35rem;
	padding: 0;
}

body.vc-product-vendor-store a.wcfm_catalog_enquiry {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	width: 100%;
	min-height: 48px;
	padding: 0.85rem 1.15rem !important;
	margin: 0 !important;
	border: none !important;
	border-radius: 12px !important;
	background: linear-gradient(135deg, var(--vc-brand-blue) 0%, #0356c9 55%, var(--vc-brand-cyan) 100%) !important;
	color: #fff !important;
	font-size: 1.02rem !important;
	font-weight: 700 !important;
	letter-spacing: -0.01em;
	text-decoration: none !important;
	box-shadow: 0 6px 18px rgba(4, 69, 175, 0.22) !important;
	transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

body.vc-product-vendor-store a.wcfm_catalog_enquiry:hover,
body.vc-product-vendor-store a.wcfm_catalog_enquiry:focus-visible {
	filter: brightness(1.05);
	transform: translateY(-1px);
	box-shadow: 0 8px 22px rgba(4, 69, 175, 0.3) !important;
	color: #fff !important;
	outline: none;
}

body.vc-product-vendor-store a.wcfm_catalog_enquiry .wcfmfa {
	font-size: 1.15rem;
	line-height: 1;
}

body.vc-product-vendor-store a.wcfm_catalog_enquiry .add_enquiry_label {
	color: #fff !important;
}

/* AE dropship: nascondi messaging e badge piattaforma */
body.vc-product-ae .wcfm_catalog_enquiry_button_wrapper,
body.vc-product-ae a.wcfm_catalog_enquiry,
body.vc-product-ae .wcfm_enquiry_tab,
body.vc-product-ae .wcfm_policies_tab,
body.vc-product-ae .setting-product-sidebar,
body.vc-product-ae #setting-product-overlay,
body.vc-product-ae .setting-product-active,
body.vc-product-ae .aliexpress-button,
body.vc-product-ae .aliexpress-info {
	display: none !important;
}

/* Grandi marche (Ralph Lauren / Philips): niente chat, politiche, richieste */
body.vc-product-affiliate-brand .wcfm_catalog_enquiry_button_wrapper,
body.vc-product-affiliate-brand a.wcfm_catalog_enquiry,
body.vc-product-affiliate-brand .wcfm_enquiry_tab,
body.vc-product-affiliate-brand .wcfm_policies_tab,
body.vc-product-affiliate-brand li.wcfm_enquiry_tab_tab,
body.vc-product-affiliate-brand li.wcfm_policies_tab_tab,
body.vc-product-affiliate-brand #tab-title-wcfm_enquiry_tab,
body.vc-product-affiliate-brand #tab-title-wcfm_policies_tab,
body.vc-product-affiliate-brand #tab-wcfm_enquiry_tab,
body.vc-product-affiliate-brand #tab-wcfm_policies_tab {
	display: none !important;
}

body.vc-wa-messaggi-page .woocommerce-MyAccount-content,
body.vc-wa-messaggi-page #wcfm-content .wcfm-collapse-content {
	padding: 0 !important;
}

/* Nasconde chrome Enquiry WCFM (tabella) — UI unica WhatsApp per privato e P.IVA */
body.vc-wa-messaggi-page .wcfm-page-headig,
body.vc-wa-messaggi-page .wcfm-top-element-container,
body.vc-wa-messaggi-page #wcfm_enquiry_listing,
body.vc-wa-messaggi-page .wcfm_enquiry_filter_wrap,
body.vc-wa-messaggi-page #wcfm-enquiry_wrapper,
body.vc-wa-messaggi-page .touch-scroll-table,
body.vc-wa-messaggi-page .woocommerce-enquiry-table,
body.vc-wa-messaggi-page #wcfm_page_load,
body.vc-wa-messaggi-page .wcfm-page-heading-text,
body.vc-wa-messaggi-page .dataTables_wrapper,
body.vc-wa-messaggi-page table#wcfm-enquiry,
body.vc-wa-messaggi-page table.display {
	display: none !important;
}

/*
 * Dashboard P.IVA (manager-negozio): stessa esperienza del privato.
 * Sidebar/drawer nascosti su Messaggi; tab bar Home/Profilo resta visibile.
 */
body.vc-wa-messaggi-page #wcfm_menu,
body.vc-wa-messaggi-page #wcfm-main-contentainer #wcfm_menu,
body.vc-wa-messaggi-page #vc-wcfm-drawer-backdrop,
body.vc-wa-messaggi-page .wcfm_responsive_menu_toggler,
body.vc-wa-messaggi-page .vitacomoda-wcfm-desktop-narrow-toggler,
body.vc-wa-messaggi-page .wcfm_menu_toggler,
body.vc-wa-messaggi-page .vc-mobile-wcfm-profile,
body.vc-wa-messaggi-page .vc-mobile-wcfm-settings-back,
body.vc-wa-messaggi-page .aliexpress-button,
body.vc-wa-messaggi-page .aliexpress-info {
	display: none !important;
}

body.vc-wa-messaggi-page #wcfm-main-contentainer,
body.vc-wa-messaggi-page #wcfm-main-contentainer.wcfm_menu_off,
body.vc-wa-messaggi-page #wcfm-content,
body.vc-wa-messaggi-page #wcfm-content > .wcfm-collapse,
body.vc-wa-messaggi-page #wcfm-content .wcfm-collapse-content {
	width: 100% !important;
	max-width: 100% !important;
	margin: 0 !important;
	margin-left: 0 !important;
	left: 0 !important;
	float: none !important;
	padding: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	border: 0 !important;
}

body.vc-wa-messaggi-page #wcfm-content .wcfm-collapse {
	display: block !important;
}

/* Messaggi mobile: full-bleed + tab bar Home/Profilo (footer nascosto dai CSS dashboard) */
@media (max-width: 781px) {
	body.vc-wa-messaggi-page .site-footer,
	body.vc-wa-messaggi-page footer#colophon,
	body.vc-wa-messaggi-page #colophon,
	body.vc-wa-messaggi-page .ast-footer-overlay {
		display: none !important;
	}

	body.vc-wa-messaggi-page .vc-mobile-wcfm-tabbar {
		display: flex !important;
	}

	body.vc-wa-messaggi-page .vc-wa-chat,
	body.vc-wa-messaggi-page .vc-wa-thread {
		max-width: none !important;
		width: 100% !important;
		margin: 0 !important;
		border-radius: 0 !important;
		border: 0 !important;
		box-shadow: none !important;
	}

	body.vc-wa-messaggi-page #wcfm-main-contentainer,
	body.vc-wa-messaggi-page #wcfm-content,
	body.vc-wa-messaggi-page .woocommerce-MyAccount-content {
		padding-left: 0 !important;
		padding-right: 0 !important;
		padding-bottom: calc(var(--vc-mprof-tab-h, 56px) + 8px) !important;
	}

	body.vc-wa-messaggi-page .entry-content,
	body.vc-wa-messaggi-page .site-content,
	body.vc-wa-messaggi-page #content,
	body.vc-wa-messaggi-page .ast-container {
		padding-left: 0 !important;
		padding-right: 0 !important;
		max-width: 100% !important;
	}
}

/* Desktop: card centrata come sul privato */
@media (min-width: 782px) {
	body.vc-wa-messaggi-page .vc-wa-chat,
	body.vc-wa-messaggi-page .vc-wa-thread {
		max-width: 720px;
		margin: 12px auto 24px;
		border-radius: 12px;
		border: 1px solid var(--vc-wa-line);
		overflow: hidden;
		box-shadow: 0 8px 28px rgba(17, 27, 33, 0.08);
	}
}

/* Pulsante Indietro sotto il composer della chat */
.vc-wa-thread-footer {
	padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
	background: #f0f2f5;
	border-top: 1px solid var(--vc-wa-line);
}

.vc-wa-thread-back-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 46px;
	padding: 0.7rem 1.2rem;
	border-radius: 12px;
	border: 1.5px solid var(--vc-wa-header);
	background: #fff;
	color: var(--vc-wa-header) !important;
	font-size: 1rem;
	font-weight: 700;
	text-decoration: none !important;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

.vc-wa-thread-back-btn:hover,
.vc-wa-thread-back-btn:focus-visible {
	background: var(--vc-wa-header);
	color: #fff !important;
	outline: none;
}

/* Lista conversazioni */
.vc-wa-chat {
	background: #fff;
	min-height: 60vh;
}

.vc-wa-chat__header {
	background: var(--vc-wa-header);
	color: #fff;
	padding: 16px 18px 14px;
}

.vc-wa-chat__title {
	margin: 0;
	font-size: 1.2rem;
	font-weight: 700;
}

.vc-wa-chat__subtitle {
	margin: 4px 0 0;
	font-size: 0.85rem;
	opacity: 0.9;
}

.vc-wa-chat__empty {
	padding: 48px 24px;
	text-align: center;
	color: var(--vc-wa-muted);
}

.vc-wa-chat__empty-icon {
	font-size: 2.5rem;
	display: block;
	margin-bottom: 12px;
}

.vc-wa-chat__empty-hint {
	font-size: 0.9rem;
	margin-top: 8px;
}

.vc-wa-chat__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.vc-wa-chat__link {
	display: grid;
	grid-template-columns: 52px 1fr;
	gap: 12px;
	align-items: center;
	padding: 12px 16px;
	text-decoration: none !important;
	color: var(--vc-wa-ink) !important;
	border-bottom: 1px solid var(--vc-wa-line);
	min-height: 72px;
}

.vc-wa-chat__link:active {
	background: #f5f6f6;
}

.vc-wa-chat__thumb {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	background: #dfe5e7;
	flex-shrink: 0;
}

.vc-wa-chat__thumb--placeholder {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.4rem;
	background: #f0f2f5;
}

.vc-wa-chat__body {
	min-width: 0;
}

.vc-wa-chat__row {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	align-items: baseline;
}

.vc-wa-chat__name {
	font-size: 1rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.vc-wa-chat__time {
	font-size: 0.75rem;
	color: var(--vc-wa-muted);
	flex-shrink: 0;
}

.vc-wa-chat__product {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	font-size: 0.78rem;
	color: var(--vc-wa-header-alt);
	margin-top: 2px;
	line-height: 1.3;
	font-weight: 500;
}

.vc-wa-chat__preview {
	display: block;
	font-size: 0.88rem;
	color: var(--vc-wa-muted);
	margin-top: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Thread */
.vc-wa-thread {
	display: flex;
	flex-direction: column;
	min-height: calc(100dvh - 120px);
	background: var(--vc-wa-bg-pattern);
}

.vc-wa-thread__header {
	display: grid;
	grid-template-columns: 40px 1fr;
	gap: 10px;
	align-items: center;
	background: var(--vc-wa-header);
	color: #fff;
	padding: 10px 12px;
	position: sticky;
	top: 0;
	z-index: 20;
}

.vc-wa-thread__back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	color: #fff !important;
	text-decoration: none !important;
	font-size: 1.25rem;
	border-radius: 50%;
}

.vc-wa-thread__name {
	display: block;
	font-size: 1rem;
	font-weight: 600;
}

.vc-wa-thread__role {
	display: block;
	font-size: 0.78rem;
	opacity: 0.85;
}

.vc-wa-thread__product-bar {
	background: #fff;
	border-bottom: 1px solid var(--vc-wa-line);
	padding: 10px 12px;
	position: sticky;
	top: 56px;
	z-index: 19;
}

.vc-wa-thread__product-link {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	text-decoration: none !important;
	color: var(--vc-wa-ink) !important;
}

.vc-wa-thread__product-thumb {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	background: #f0f2f5;
	flex-shrink: 0;
}

.vc-wa-thread__product-title {
	font-size: 0.88rem;
	line-height: 1.35;
	font-weight: 500;
	color: var(--vc-wa-header);
	word-break: break-word;
}

.vc-wa-thread__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 12px 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background:
		linear-gradient(rgba(229, 221, 213, 0.9), rgba(229, 221, 213, 0.9)),
		url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='%23e5ddd5'/%3E%3C/svg%3E");
}

.vc-wa-bubble {
	max-width: 82%;
	padding: 8px 10px 6px;
	border-radius: 8px;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
	word-break: break-word;
}

.vc-wa-bubble--in {
	align-self: flex-start;
	background: var(--vc-wa-in);
	border-top-left-radius: 0;
}

.vc-wa-bubble--out {
	align-self: flex-end;
	background: var(--vc-wa-out);
	border-top-right-radius: 0;
}

.vc-wa-bubble__text {
	font-size: 0.98rem;
	line-height: 1.4;
	color: var(--vc-wa-ink);
}

.vc-wa-bubble__time {
	display: block;
	text-align: right;
	font-size: 0.68rem;
	color: var(--vc-wa-muted);
	margin-top: 4px;
}

.vc-wa-thread__composer {
	display: grid;
	grid-template-columns: 1fr 48px;
	gap: 8px;
	align-items: end;
	padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
	background: #f0f2f5;
	border-top: 1px solid var(--vc-wa-line);
	position: sticky;
	bottom: 0;
	z-index: 20;
}

.vc-wa-thread__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: none;
	background: transparent;
	font-size: 1.35rem;
	cursor: pointer;
	border-radius: 50%;
}

.vc-wa-thread__send {
	background: var(--vc-wa-send);
	color: #fff;
	font-size: 1.1rem;
}

.vc-wa-thread__input {
	width: 100%;
	min-height: 44px;
	max-height: 120px;
	resize: none;
	border: none;
	border-radius: 22px;
	padding: 11px 14px;
	font-size: 16px;
	line-height: 1.35;
	background: #fff;
	box-sizing: border-box;
}

.vc-wa-thread__status {
	grid-column: 1 / -1;
	font-size: 0.85rem;
	padding: 4px 6px 0;
	color: var(--vc-wa-muted);
}

.vc-wa-thread__status.is-error {
	color: #c62828;
}

.vc-wa-thread__status.is-success {
	color: #2e7d32;
}

body.vc-private-myaccount-shell .vc-mobile-wcfm-profile__row[href*="inquiry"] .vc-mobile-wcfm-profile__icon,
body.vc-wcfm-mobile-shell .vc-mobile-wcfm-profile__row[href*="enquiry"] .vc-mobile-wcfm-profile__icon {
	color: var(--vc-wa-header-alt);
}

@media (max-width: 782px) {
	.vc-wa-thread {
		min-height: calc(100dvh - 120px - env(safe-area-inset-bottom, 0px));
	}

	body.vc-private-myaccount-section .vc-wa-chat,
	body.vc-private-myaccount-section .vc-wa-thread {
		margin: 0;
		max-width: none;
		width: 100%;
	}

	body.vc-wa-messaggi-page .vc-wa-thread__composer,
	body.vc-wcfm-mobile-profile-section .vc-wa-thread__composer,
	body.vc-private-myaccount-section .vc-wa-thread__composer {
		bottom: 0;
	}

	body.vc-wa-messaggi-page .vc-wa-thread,
	body.vc-private-myaccount-section .vc-wa-thread {
		padding-bottom: 0;
		margin-bottom: 0;
	}

	body.vc-wa-messaggi-page .vc-wa-thread-footer {
		padding-bottom: calc(14px + var(--vc-mprof-tab-h, 56px));
	}
}
