/* ==========================================================================
   Hermes RAG — Stili frontend + admin (nessun framework)
   ========================================================================== */

:root {
	--hermes-primary: #7c3aed;
	--hermes-primary-dark: #5b21b6;
	--hermes-accent: #4f46e5;
	--hermes-bg: #ffffff;
	--hermes-bg-alt: #f6f5fb;
	--hermes-text: #1f2937;
	--hermes-muted: #6b7280;
	--hermes-border: #e7e5f0;
	--hermes-danger: #dc2626;
	--hermes-success: #16a34a;
	--hermes-radius: 18px;
	--hermes-shadow: 0 24px 60px rgba(76, 29, 149, 0.18), 0 4px 16px rgba(76, 29, 149, 0.10);
}

/* --------------------------------------------------------------------------
   Chat (inline + widget) — design "human first"
   -------------------------------------------------------------------------- */

.hermes-chat {
	display: flex;
	flex-direction: column;
	background: var(--hermes-bg);
	border: 1px solid var(--hermes-border);
	border-radius: var(--hermes-radius);
	overflow: hidden;
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--hermes-text);
	max-width: 720px;
}

.hermes-chat-inline {
	margin: 16px 0;
	box-shadow: var(--hermes-shadow);
}

/* Header con avatar e stato "online": sembra un consulente vero */
.hermes-chat-header {
	position: relative;
	background: linear-gradient(135deg, var(--hermes-primary) 0%, var(--hermes-accent) 100%);
	color: #fff;
	padding: 14px 18px 14px 58px;
	font-weight: 600;
	font-size: 15px;
	letter-spacing: 0.2px;
}

/* Avatar circolare */
.hermes-chat-header::before {
	content: "🤖";
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	border: 2px solid rgba(255, 255, 255, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
}

/* Stato "Online ora" sotto il nome */
.hermes-chat-header .hermes-chat-title::after {
	content: "Online · risponde subito";
	display: block;
	font-size: 11px;
	font-weight: 400;
	opacity: 0.85;
	margin-top: 2px;
}

.hermes-chat-messages {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 18px 16px;
	min-height: 200px;
	max-height: 420px;
	overflow-y: auto;
	background:
		radial-gradient(circle at 15% 20%, rgba(124, 58, 237, 0.05), transparent 40%),
		radial-gradient(circle at 85% 80%, rgba(79, 70, 229, 0.05), transparent 40%),
		var(--hermes-bg-alt);
	scroll-behavior: smooth;
}

/* Scrollbar discreta */
.hermes-chat-messages::-webkit-scrollbar {
	width: 6px;
}
.hermes-chat-messages::-webkit-scrollbar-thumb {
	background: rgba(124, 58, 237, 0.25);
	border-radius: 3px;
}

/* Entrata morbida dei messaggi */
@keyframes hermes-msg-in {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hermes-msg {
	position: relative;
	max-width: 84%;
	padding: 11px 15px;
	border-radius: 18px;
	line-height: 1.55;
	font-size: 14px;
	white-space: pre-wrap;
	word-break: break-word;
	box-shadow: 0 1px 2px rgba(31, 41, 55, 0.06);
	animation: hermes-msg-in 0.25s ease both;
}

.hermes-msg-user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--hermes-primary), var(--hermes-accent));
	color: #fff;
	border-bottom-right-radius: 6px;
	box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.hermes-msg-assistant {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--hermes-border);
	border-bottom-left-radius: 6px;
	/* spazio per l'avatar */
	margin-left: 30px;
}

/* Avatar dell'assistente accanto al messaggio */
.hermes-msg-assistant::before {
	content: "🤖";
	position: absolute;
	left: -30px;
	bottom: 0;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--hermes-primary), var(--hermes-accent));
	color: #fff;
	font-size: 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.hermes-msg-error {
	background: #fef2f2;
	border-color: #fecaca;
	color: var(--hermes-danger);
}

/* Indicatore "sta scrivendo" con puntini animati */
.hermes-msg-pending {
	font-style: normal;
	color: var(--hermes-muted);
	opacity: 1;
}

.hermes-msg-pending::after {
	content: "";
	display: inline-block;
	width: 1.2em;
	text-align: left;
	animation: hermes-dots 1.2s steps(4, end) infinite;
}

@keyframes hermes-dots {
	0%   { content: ""; }
	25%  { content: "."; }
	50%  { content: ".."; }
	75%  { content: "..."; }
	100% { content: ""; }
}

/* Form input: pill moderna */
.hermes-chat-form {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border-top: 1px solid var(--hermes-border);
	background: #fff;
}

.hermes-chat-input {
	flex: 1;
	padding: 12px 16px;
	border: 1.5px solid var(--hermes-border);
	border-radius: 999px;
	font-size: 14px;
	background: var(--hermes-bg-alt);
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.hermes-chat-input:focus {
	outline: none;
	border-color: var(--hermes-primary);
	background: #fff;
	box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.hermes-chat-send {
	padding: 11px 20px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--hermes-primary), var(--hermes-accent));
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.hermes-chat-send:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.hermes-chat-send:active {
	transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Bubble widget flottante
   -------------------------------------------------------------------------- */

.hermes-chat-bubble {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--hermes-primary), var(--hermes-primary-dark));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(109, 40, 217, 0.4);
	transition: transform 0.15s ease;
}

.hermes-chat-bubble:hover {
	transform: scale(1.06);
}

/* Modalità "doppio bubble": Chatwoot a destra, Hermes AI a sinistra. */
.hermes-chat-bubble.hermes-chat-left {
	right: auto;
	left: 20px;
}

.hermes-chat-panel.hermes-chat-left {
	right: auto;
	left: 20px;
}

.hermes-chat-bubble-icon {
	font-size: 24px;
	line-height: 1;
}

.hermes-chat-panel {
	position: fixed;
	right: 20px;
	bottom: 88px;
	z-index: 99991;
	width: 360px;
	max-width: calc(100vw - 40px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	border-radius: var(--hermes-radius);
}

.hermes-chat-panel .hermes-chat {
	max-width: none;
	border: 0;
}

.hermes-chat-panel .hermes-chat-messages {
	max-height: 320px;
}

.hermes-chat-panel-close {
	position: absolute;
	top: 8px;
	right: 10px;
	z-index: 2;
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	line-height: 1;
}

/* --------------------------------------------------------------------------
   Shopping product card — stile Tidio/Shopify Inbox: card orizzontale
   compatta (thumb a sinistra, dati e CTA a destra), non domina la chat.
   -------------------------------------------------------------------------- */

.hermes-products {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-self: stretch;
	margin-top: 4px;
	animation: hermes-msg-in 0.3s ease both;
}

.hermes-product-card {
	display: grid;
	grid-template-columns: 72px 1fr;
	grid-template-areas:
		"img name"
		"img price"
		"img reason"
		"img actions";
	column-gap: 12px;
	align-items: start;
	background: #fff;
	border: 1px solid var(--hermes-border);
	border-radius: 16px;
	padding: 10px;
	box-shadow: 0 2px 8px rgba(31, 41, 55, 0.05);
	transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.hermes-product-card:hover {
	transform: translateY(-2px);
	border-color: rgba(124, 58, 237, 0.35);
	box-shadow: 0 10px 24px rgba(124, 58, 237, 0.14);
}

.hermes-product-image {
	grid-area: img;
	width: 72px;
	height: 72px;
	object-fit: cover;
	border-radius: 12px;
	background: var(--hermes-bg-alt);
}

.hermes-product-name {
	grid-area: name;
	font-weight: 650;
	font-size: 13.5px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.hermes-product-name a {
	color: var(--hermes-text);
	text-decoration: none;
}

.hermes-product-name a:hover {
	color: var(--hermes-primary);
}

/* Prezzo in evidenza; gestisce il prezzo scontato WooCommerce (<del>) */
.hermes-product-price {
	grid-area: price;
	font-size: 15px;
	font-weight: 750;
	color: var(--hermes-primary);
	margin-top: 2px;
}

.hermes-product-price del {
	color: var(--hermes-muted);
	font-weight: 400;
	font-size: 12px;
	margin-right: 6px;
}

.hermes-product-price ins {
	text-decoration: none;
}

.hermes-product-reason {
	grid-area: reason;
	font-size: 11.5px;
	line-height: 1.35;
	color: var(--hermes-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-top: 3px;
}

.hermes-product-actions {
	grid-area: actions;
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 7px;
	flex-wrap: wrap;
}

.hermes-btn {
	display: inline-block;
	padding: 6px 12px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 650;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.hermes-btn-cart {
	background: linear-gradient(135deg, var(--hermes-primary), var(--hermes-accent));
	color: #fff !important;
	box-shadow: 0 3px 8px rgba(124, 58, 237, 0.25);
}

.hermes-btn-cart:hover {
	transform: translateY(-1px);
	box-shadow: 0 5px 12px rgba(124, 58, 237, 0.35);
}

.hermes-btn-view {
	background: transparent;
	color: var(--hermes-primary) !important;
	border: 1.5px solid rgba(124, 58, 237, 0.4);
}

.hermes-btn-view:hover {
	border-color: var(--hermes-primary);
	background: rgba(124, 58, 237, 0.06);
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */

.hermes-admin .hermes-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 16px;
	margin: 16px 0 24px;
}

.hermes-card {
	background: #fff;
	border: 1px solid var(--hermes-border);
	border-radius: 10px;
	padding: 16px 20px;
}

.hermes-card h2 {
	margin-top: 0;
	font-size: 15px;
}

.hermes-status {
	font-size: 18px;
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 6px;
}

.hermes-status-ok { color: var(--hermes-success); }
.hermes-status-ko { color: var(--hermes-danger); }

.hermes-kpi {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hermes-kpi li {
	padding: 4px 0;
}

.hermes-test-result {
	margin-left: 10px;
	font-weight: 600;
}

.hermes-ok { color: var(--hermes-success); }
.hermes-ko { color: var(--hermes-danger); }

.hermes-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	background: #e5e7eb;
	color: #374151;
}

.hermes-badge-pending { background: #fef3c7; color: #92400e; }
.hermes-badge-approved, .hermes-badge-sent { background: #dcfce7; color: #166534; }
.hermes-badge-rejected, .hermes-badge-failed { background: #fee2e2; color: #991b1b; }
.hermes-badge-draft { background: #e0e7ff; color: #3730a3; }
.hermes-badge-sending { background: #cffafe; color: #155e75; }
.hermes-badge-archived { background: #f3f4f6; color: #6b7280; }

.hermes-two-col {
	display: grid;
	grid-template-columns: minmax(280px, 380px) 1fr;
	gap: 24px;
	align-items: start;
}

@media (max-width: 1100px) {
	.hermes-two-col { grid-template-columns: 1fr; }
}

.hermes-seo-result {
	margin-top: 8px;
	padding: 10px;
	border-radius: 8px;
	background: var(--hermes-bg-alt);
	font-size: 13px;
}

.hermes-seo-ok { border-left: 3px solid var(--hermes-success); }
.hermes-seo-error { border-left: 3px solid var(--hermes-danger); }

.hermes-mkt-preview {
	margin: 16px 0;
	padding: 16px;
	background: #fff;
	border: 1px dashed var(--hermes-primary);
	border-radius: 10px;
}

.hermes-row-actions .button {
	margin: 2px 2px 2px 0;
}

.hermes-stats-table code {
	font-size: 13px;
}

/* --------------------------------------------------------------------------
   Setup wizard (.hermes-wizard) — pagina admin a tutto schermo
   -------------------------------------------------------------------------- */

body.hermes-wizard-page #wpadminbar,
body.hermes-wizard-page #adminmenumain,
body.hermes-wizard-page #wpfooter,
body.hermes-wizard-page #screen-meta-links {
	display: none;
}

body.hermes-wizard-page #wpcontent,
body.hermes-wizard-page #wpbody-content {
	margin-left: 0;
	padding-left: 0;
}

body.hermes-wizard-page {
	background: var(--hermes-bg-alt);
}

.hermes-wizard {
	max-width: 760px;
	margin: 40px auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--hermes-text);
}

.hermes-wizard-header {
	text-align: center;
	margin-bottom: 20px;
}

.hermes-wizard-header h1 {
	font-size: 24px;
	color: var(--hermes-primary-dark);
}

.hermes-wizard-steps {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	justify-content: center;
	margin: 0 0 24px;
	padding: 0;
	list-style: none;
}

.hermes-wizard-steps li {
	font-size: 13px;
	font-weight: 600;
	color: var(--hermes-muted);
	padding-bottom: 4px;
	border-bottom: 2px solid transparent;
}

.hermes-wizard-steps li.is-done {
	color: var(--hermes-success);
}

.hermes-wizard-steps li.is-done::before {
	content: "✓ ";
}

.hermes-wizard-steps li.is-active {
	color: var(--hermes-primary);
	border-bottom-color: var(--hermes-primary);
}

.hermes-wizard-content {
	background: var(--hermes-bg);
	border: 1px solid var(--hermes-border);
	border-radius: var(--hermes-radius);
	padding: 28px 32px;
	box-shadow: 0 8px 30px rgba(109, 40, 217, 0.08);
}

.hermes-wizard-content h2 {
	margin-top: 0;
}

.hermes-wizard-choice {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 8px 0 4px;
}

.hermes-wizard-choice label {
	display: block;
	padding: 12px 14px;
	border: 1px solid var(--hermes-border);
	border-radius: 10px;
	cursor: pointer;
}

.hermes-wizard-choice label:hover {
	border-color: var(--hermes-primary);
}

.hermes-wizard-choice.hermes-wizard-disabled,
.hermes-wizard-choice .hermes-wizard-disabled {
	opacity: 0.65;
}

.hermes-wizard-actions {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-top: 24px;
	padding-top: 18px;
	border-top: 1px solid var(--hermes-border);
}

.hermes-wizard-actions .button-hero {
	margin-left: auto;
}

.hermes-wizard-skip {
	text-align: center;
	margin: 14px 0 0;
	font-size: 12px;
}

/* Semaforo modelli Ollama (step Connessione Brain) */

.hermes-wizard-models {
	margin: 14px 0;
	padding: 14px 16px;
	border: 1px solid var(--hermes-border);
	border-radius: 10px;
	background: var(--hermes-bg-alt);
}

.hermes-wizard-models h3 {
	margin-top: 0;
	font-size: 14px;
}

.hermes-wizard-models-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hermes-wizard-models-list li {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 0;
	font-family: Consolas, Monaco, monospace;
	font-size: 13px;
}

.hermes-model-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex: none;
}

.hermes-model-dot.hermes-model-ok { background: var(--hermes-success); }
.hermes-model-dot.hermes-model-missing { background: var(--hermes-danger); }

.hermes-wizard-models-list .hermes-model-note {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 12px;
	color: var(--hermes-muted);
}

.hermes-wizard-summary td {
	padding: 10px 12px;
}
