/* Orto di Venere — Chat Widget */

/* Move iubenda cookie button to bottom-left to avoid overlap */
#iubenda-cs-banner .iubenda-cs-opt-group,
.iubenda-tp-btn,
.iub-btn-container,
[id*="iubenda"] .iubenda-cs-close-btn {
	/* handled by iubenda settings */
}
.iubenda-tp-btn.iubenda-tp-btn--fixed {
	left: 20px !important;
	right: auto !important;
}

.orto-chat {
	--orto-primary: #1a1a1a;
	--orto-accent: #c8a96e;
	--orto-bg: #fff;
	--orto-msg-user: #1a1a1a;
	--orto-msg-bot: #f5f0e8;
	--orto-text: #1a1a1a;
	--orto-text-light: #6b6b6b;
	--orto-border: #e5e0d6;
	--orto-radius: 16px;
	--orto-shadow: 0 8px 32px rgba(0,0,0,.18);

	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

/* Toggle button */
.orto-chat__toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--orto-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--orto-shadow);
	transition: transform .2s, background .2s;
}

.orto-chat__toggle:hover {
	transform: scale(1.08);
	background: #333;
}

.orto-chat__toggle svg {
	width: 24px;
	height: 24px;
}

.orto-chat__icon-close {
	display: none;
}

/* Teaser popup */
.orto-chat__teaser {
	position: absolute;
	bottom: 64px;
	right: 0;
	background: var(--orto-primary);
	color: #fff;
	padding: 10px 16px;
	border-radius: 12px 12px 4px 12px;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	box-shadow: 0 4px 16px rgba(0,0,0,.2);
	animation: orto-teaser-in .4s ease both;
	cursor: pointer;
	max-width: 240px;
	white-space: normal;
	line-height: 1.35;
}

.orto-chat__teaser-close {
	position: absolute;
	top: -6px;
	left: -6px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #555;
	color: #fff;
	border: none;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
	cursor: pointer;
	padding: 0;
}

.orto-chat__teaser[hidden] {
	display: none !important;
}

@keyframes orto-teaser-in {
	from { opacity: 0; transform: translateY(8px) scale(.95); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.orto-chat--open .orto-chat__icon-chat {
	display: none;
}

.orto-chat--open .orto-chat__icon-close {
	display: block;
}

/* Panel */
.orto-chat__panel {
	position: absolute;
	bottom: 72px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	max-height: min(600px, calc(100vh - 120px));
	background: var(--orto-bg);
	border-radius: var(--orto-radius);
	box-shadow: var(--orto-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: orto-chat-slide-up .25s ease;
}

.orto-chat__panel[hidden] {
	display: none !important;
}

@keyframes orto-chat-slide-up {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.orto-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--orto-primary);
	color: #fff;
}

.orto-chat__header-info strong {
	font-size: 15px;
	font-weight: 600;
}

.orto-chat__status {
	display: block;
	font-size: 12px;
	opacity: .7;
}

.orto-chat__header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.orto-chat__clear {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	opacity: .5;
	transition: opacity .15s;
	display: flex;
	align-items: center;
}

.orto-chat__clear svg {
	width: 16px;
	height: 16px;
}

.orto-chat__clear:hover {
	opacity: 1;
}

.orto-chat__close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	opacity: .7;
	transition: opacity .15s;
}

.orto-chat__close:hover {
	opacity: 1;
}

/* Messages area */
.orto-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 200px;
	scroll-behavior: smooth;
}

.orto-chat__msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.orto-chat__msg--user {
	align-self: flex-end;
	background: var(--orto-msg-user);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.orto-chat__msg--bot {
	align-self: flex-start;
	background: var(--orto-msg-bot);
	color: var(--orto-text);
	border-bottom-left-radius: 4px;
}

.orto-chat__msg--bot a {
	color: var(--orto-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 500;
}

.orto-chat__msg--bot a:hover {
	color: var(--orto-accent);
}

/* Typing indicator */
.orto-chat__typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	background: var(--orto-msg-bot);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}

.orto-chat__typing span {
	width: 7px;
	height: 7px;
	background: var(--orto-text-light);
	border-radius: 50%;
	animation: orto-typing .6s infinite alternate;
}

.orto-chat__typing span:nth-child(2) { animation-delay: .2s; }
.orto-chat__typing span:nth-child(3) { animation-delay: .4s; }

@keyframes orto-typing {
	from { opacity: .3; transform: translateY(0); }
	to   { opacity: 1; transform: translateY(-3px); }
}

/* Input form */
.orto-chat__form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--orto-border);
	background: var(--orto-bg);
}

.orto-chat__input {
	flex: 1;
	border: 1px solid var(--orto-border);
	border-radius: 16px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	background: #faf8f5;
	transition: border-color .15s;
	font-family: inherit;
	resize: none;
	overflow-y: auto;
	min-height: 40px;
	max-height: 100px;
	line-height: 1.4;
}

.orto-chat__input:focus {
	border-color: var(--orto-accent);
}

.orto-chat__send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--orto-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s;
	flex-shrink: 0;
}

.orto-chat__send:hover {
	background: #333;
}

.orto-chat__send:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.orto-chat__send svg {
	width: 18px;
	height: 18px;
}

/* Hide chat when shop filters overlay is open (toggled by JS) */
.orto-chat--hidden {
	display: none !important;
}

/* Mobile — keep bubble inside viewport and above the mobile bottom-nav.
   Theme's --mobile-bottom-nav-height is 56px + iPhone safe-area inset. */
@media (max-width: 767px) {
	.orto-chat {
		left: auto;
		right: 16px;
		bottom: calc(var(--mobile-bottom-nav-height, 56px) + 16px);
	}

	.orto-chat__toggle {
		width: 50px;
		height: 50px;
	}

	.orto-chat__teaser {
		max-width: calc(100vw - 48px);
	}

	.orto-chat__panel {
		width: calc(100vw - 24px);
		max-height: calc(100vh - 140px);
		bottom: calc(100% + 8px);
		right: 0;
		border-radius: 12px;
	}
}

/* Markdown basic formatting in bot messages */
.orto-chat__msg--bot strong {
	font-weight: 600;
}

.orto-chat__msg--bot em {
	font-style: italic;
}

.orto-chat__msg--bot p {
	margin: 0 0 8px;
}

.orto-chat__msg--bot p:last-child {
	margin-bottom: 0;
}

.orto-chat__msg--bot ul,
.orto-chat__msg--bot ol {
	margin: 4px 0;
	padding-left: 18px;
}

.orto-chat__msg--bot li {
	margin-bottom: 4px;
}

/* Product cards */
.orto-chat__products {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: 92%;
	align-self: flex-start;
}

.orto-chat__product {
	display: flex;
	gap: 10px;
	padding: 8px;
	background: #fff;
	border: 1px solid var(--orto-border);
	border-radius: 10px;
	text-decoration: none;
	color: var(--orto-text);
	transition: border-color .15s, box-shadow .15s;
}

.orto-chat__product:hover {
	border-color: var(--orto-accent);
	box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.orto-chat__product img {
	width: 56px;
	height: 56px;
	object-fit: contain;
	border-radius: 6px;
	flex-shrink: 0;
	background: #fff;
}

.orto-chat__product-info {
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 1px;
}

.orto-chat__product-name {
	font-weight: 600;
	font-size: 13px;
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.orto-chat__product-brand {
	font-size: 11px;
	color: var(--orto-text-light);
	text-transform: uppercase;
	letter-spacing: .03em;
}

.orto-chat__product-price {
	color: var(--orto-accent);
	font-weight: 700;
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 4px;
	flex-wrap: wrap;
}

.orto-chat__price-badge {
	background: #d32f2f;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 1px 5px;
	border-radius: 3px;
	line-height: 1.4;
}

.orto-chat__price-old {
	color: var(--orto-text-light);
	font-weight: 400;
	font-size: 12px;
	text-decoration: line-through;
}

.orto-chat__price-sale {
	color: #d32f2f;
	font-weight: 700;
}
