/* Mantica AI Shopper – widget */
.mas-root {
	--mas-accent: #111;
	--mas-bg: #fff;
	--mas-fg: #1a1a1a;
	--mas-muted: #6b6b6b;
	--mas-line: #e6e6e6;
	--mas-soft: #f5f5f4;
	--mas-radius: 14px;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--mas-fg);
	box-sizing: border-box;
}
.mas-root *, .mas-root *::before, .mas-root *::after { box-sizing: inherit; }

/* Flottante */
.mas-floating { position: fixed; right: 20px; bottom: 20px; z-index: 99990; }
.mas-toggle {
	width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
	background: var(--mas-accent); color: #fff; display: grid; place-items: center;
	box-shadow: 0 6px 24px rgba(0,0,0,.22); transition: transform .15s ease;
}
.mas-toggle:hover { transform: scale(1.05); }
.mas-floating .mas-panel {
	position: absolute; right: 0; bottom: 72px; width: 390px; height: min(640px, calc(100vh - 110px));
	display: none;
}
.mas-floating.mas-open .mas-panel { display: flex; }

/* Inline (shortcode) */
.mas-inline .mas-panel { display: flex; height: 640px; max-height: 80vh; width: 100%; }

.mas-panel {
	flex-direction: column; background: var(--mas-bg); border: 1px solid var(--mas-line);
	border-radius: var(--mas-radius); box-shadow: 0 12px 40px rgba(0,0,0,.16); overflow: hidden;
}
.mas-head {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 12px 14px; background: var(--mas-accent); color: #fff;
}
.mas-title { font-weight: 600; letter-spacing: .02em; }
.mas-badge { margin-left: 8px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; vertical-align: 1px; }
.mas-head-actions { display: flex; gap: 4px; }
.mas-icon-btn {
	background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 20px; line-height: 1;
	width: 32px; height: 32px; border-radius: 8px; padding: 0;
}
.mas-icon-btn svg { display: block; margin: auto; }
.mas-icon-btn:hover { background: rgba(255,255,255,.15); }

.mas-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--mas-soft); }
.mas-log > * { flex-shrink: 0; }
.mas-msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; word-wrap: break-word; }
.mas-msg p { margin: 0 0 6px; }
.mas-msg p:last-child { margin-bottom: 0; }
.mas-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.mas-msg li { margin: 2px 0; }
.mas-user { align-self: flex-end; background: var(--mas-accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.mas-bot { align-self: flex-start; background: #fff; border: 1px solid var(--mas-line); border-bottom-left-radius: 4px; }
.mas-bot a { color: inherit; text-decoration: underline; }
.mas-error { align-self: center; background: #fdecec; color: #8a1c1c; font-size: 13px; }
.mas-typing { color: var(--mas-muted); font-size: 13px; }
.mas-typing span {
	display: inline-block; width: 6px; height: 6px; margin-right: 2px; border-radius: 50%;
	background: var(--mas-muted); animation: mas-dot 1s infinite ease-in-out;
}
.mas-typing span:nth-child(2) { animation-delay: .15s; }
.mas-typing span:nth-child(3) { animation-delay: .3s; margin-right: 6px; }
@keyframes mas-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Schede prodotto */
.mas-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x mandatory; }
.mas-card {
	flex: 0 0 160px; background: #fff; border: 1px solid var(--mas-line); border-radius: 12px;
	overflow: hidden; scroll-snap-align: start; display: flex; flex-direction: column;
}
.mas-card-img { display: block; aspect-ratio: 4 / 5; background: var(--mas-soft); }
.mas-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mas-card-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.mas-card-name { font-size: 13px; font-weight: 600; color: inherit; text-decoration: none; line-height: 1.3; }
.mas-card-name:hover { text-decoration: underline; }
.mas-card-price { font-size: 13px; color: var(--mas-muted); }
.mas-select {
	width: 100%; font-size: 13px; padding: 5px 6px; border: 1px solid var(--mas-line); border-radius: 8px;
	background: #fff; color: inherit; height: auto; min-height: 0;
}
.mas-add {
	margin-top: auto; width: 100%; border: 0; border-radius: 8px; padding: 8px; cursor: pointer;
	background: var(--mas-accent); color: #fff; font-size: 13px; font-weight: 600;
}
.mas-add:disabled { opacity: .45; cursor: not-allowed; }
.mas-card-note { font-size: 12px; color: #8a1c1c; min-height: 0; }
.mas-card-note:empty { display: none; }

/* Carrello */
.mas-cartbar {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 8px 14px; border-top: 1px solid var(--mas-line); background: #fff; font-size: 13px;
}
.mas-cartbar[hidden] { display: none; }
.mas-checkout {
	background: var(--mas-accent); color: #fff !important; text-decoration: none !important;
	padding: 6px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap;
}

/* Input */
.mas-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--mas-line); background: #fff; }
.mas-input {
	flex: 1; resize: none; border: 1px solid var(--mas-line); border-radius: 10px; padding: 9px 10px;
	font: inherit; color: inherit; background: #fff; max-height: 120px; min-height: 40px;
}
.mas-input:focus { outline: 2px solid var(--mas-accent); outline-offset: -1px; }
.mas-send {
	border: 0; border-radius: 10px; padding: 0 14px; cursor: pointer;
	background: var(--mas-accent); color: #fff; font-weight: 600;
}
.mas-busy .mas-send { opacity: .5; pointer-events: none; }

/* Mobile: pannello a tutto schermo */
@media (max-width: 520px) {
	.mas-floating { right: 16px; bottom: 16px; }
	.mas-floating .mas-panel {
		position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; border: 0;
	}
	.mas-floating.mas-open .mas-toggle { display: none; }
}
