/**
 * SMARTBUY AI Assistant — front-end widget styling.
 * Tech-forward palette: deep slate + professional blue accent.
 *
 * @package SmartBuy_AI_Assistant
 */

:root {
	--smartbuy-blue: #2563eb;
	--smartbuy-blue-dark: #1d4ed8;
	--smartbuy-blue-light: #3b82f6;
	--smartbuy-slate-900: #0f172a;
	--smartbuy-slate-800: #1e293b;
	--smartbuy-slate-700: #334155;
	--smartbuy-slate-200: #e2e8f0;
	--smartbuy-slate-100: #f1f5f9;
	--smartbuy-slate-50: #f8fafc;
	--smartbuy-white: #ffffff;
	--smartbuy-radius-lg: 16px;
	--smartbuy-radius-md: 12px;
	--smartbuy-radius-sm: 8px;
	--smartbuy-shadow: 0 12px 32px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
	--smartbuy-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* -------------------------------------------------------------------- */
/* Root container & launcher button                                     */
/* -------------------------------------------------------------------- */

.smartbuy-widget-root {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 999999;
	font-family: var(--smartbuy-font);
	line-height: 1.45;
}

.smartbuy-launcher {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--smartbuy-blue-light), var(--smartbuy-blue-dark));
	color: var(--smartbuy-white);
	box-shadow: var(--smartbuy-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.smartbuy-launcher:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24), 0 4px 10px rgba(15, 23, 42, 0.12);
}

.smartbuy-launcher:focus-visible {
	outline: 3px solid #93c5fd;
	outline-offset: 3px;
}

.smartbuy-launcher-icon,
.smartbuy-launcher-close {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.smartbuy-launcher-close {
	font-size: 30px;
	font-weight: 300;
	line-height: 1;
	opacity: 0;
	transform: scale(0.6) rotate(-45deg);
}

.smartbuy-launcher-icon {
	opacity: 1;
	transform: scale(1) rotate(0deg);
}

.smartbuy-widget-root.smartbuy-is-open .smartbuy-launcher-icon {
	opacity: 0;
	transform: scale(0.6) rotate(45deg);
}

.smartbuy-widget-root.smartbuy-is-open .smartbuy-launcher-close {
	opacity: 1;
	transform: scale(1) rotate(0deg);
}

/* -------------------------------------------------------------------- */
/* Chat panel                                                           */
/* -------------------------------------------------------------------- */

.smartbuy-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 140px);
	background: var(--smartbuy-white);
	border-radius: var(--smartbuy-radius-lg);
	box-shadow: var(--smartbuy-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--smartbuy-slate-200);
	animation: smartbuy-panel-in 0.18s ease;
}

@keyframes smartbuy-panel-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.smartbuy-panel[hidden] {
	display: none;
}

/* Header */

.smartbuy-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--smartbuy-slate-900), var(--smartbuy-slate-800));
	color: var(--smartbuy-white);
	flex-shrink: 0;
}

.smartbuy-panel-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.smartbuy-status-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #34d399;
	box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
	flex-shrink: 0;
}

.smartbuy-panel-title {
	margin: 0;
	font-size: 14.5px;
	font-weight: 700;
	letter-spacing: 0.2px;
}

.smartbuy-panel-subtitle {
	margin: 0;
	font-size: 11.5px;
	color: var(--smartbuy-slate-200);
	font-weight: 400;
}

.smartbuy-close-btn {
	background: transparent;
	border: none;
	color: var(--smartbuy-slate-200);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: var(--smartbuy-radius-sm);
	transition: background 0.15s ease, color 0.15s ease;
}

.smartbuy-close-btn:hover {
	background: rgba(255, 255, 255, 0.1);
	color: var(--smartbuy-white);
}

.smartbuy-close-btn:focus-visible {
	outline: 2px solid #93c5fd;
	outline-offset: 2px;
}

/* Messages area */

.smartbuy-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--smartbuy-slate-50);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.smartbuy-messages::-webkit-scrollbar {
	width: 6px;
}

.smartbuy-messages::-webkit-scrollbar-thumb {
	background: var(--smartbuy-slate-200);
	border-radius: 10px;
}

.smartbuy-bubble-row {
	display: flex;
	max-width: 100%;
}

.smartbuy-bubble-row--user {
	justify-content: flex-end;
}

.smartbuy-bubble-row--assistant,
.smartbuy-bubble-row--system {
	justify-content: flex-start;
}

.smartbuy-bubble {
	padding: 10px 13px;
	border-radius: var(--smartbuy-radius-md);
	font-size: 13.5px;
	max-width: 82%;
	word-wrap: break-word;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.smartbuy-bubble--user {
	background: var(--smartbuy-blue);
	color: var(--smartbuy-white);
	border-bottom-right-radius: 4px;
}

.smartbuy-bubble--assistant {
	background: var(--smartbuy-white);
	color: var(--smartbuy-slate-800);
	border: 1px solid var(--smartbuy-slate-200);
	border-bottom-left-radius: 4px;
}

.smartbuy-bubble-row--thinking .smartbuy-bubble {
	color: var(--smartbuy-slate-700);
	font-style: italic;
	opacity: 0.85;
}

/* Product suggestion links (rendered inside assistant bubbles) */

.smartbuy-bubble--assistant .smartbuy-product-list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.smartbuy-bubble--assistant .smartbuy-product-list li {
	background: var(--smartbuy-slate-100);
	border: 1px solid var(--smartbuy-slate-200);
	border-radius: var(--smartbuy-radius-sm);
	padding: 8px 10px;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.smartbuy-bubble--assistant .smartbuy-product-list li:hover {
	background: #e0e9ff;
	border-color: #bfdbfe;
}

.smartbuy-bubble--assistant .smartbuy-product-list a {
	color: var(--smartbuy-blue-dark);
	font-weight: 600;
	text-decoration: none;
}

.smartbuy-bubble--assistant .smartbuy-product-list a:hover {
	text-decoration: underline;
}

/* Input form */

.smartbuy-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--smartbuy-slate-200);
	background: var(--smartbuy-white);
	flex-shrink: 0;
}

.smartbuy-input {
	flex: 1;
	border: 1px solid var(--smartbuy-slate-200);
	border-radius: 999px;
	padding: 10px 14px;
	font-size: 13.5px;
	font-family: inherit;
	color: var(--smartbuy-slate-900);
	background: var(--smartbuy-slate-50);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.smartbuy-input:focus {
	outline: none;
	border-color: var(--smartbuy-blue-light);
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
	background: var(--smartbuy-white);
}

.smartbuy-input:disabled {
	opacity: 0.6;
}

.smartbuy-send-btn {
	border: none;
	background: var(--smartbuy-blue);
	color: var(--smartbuy-white);
	font-size: 13px;
	font-weight: 600;
	padding: 10px 16px;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
	flex-shrink: 0;
}

.smartbuy-send-btn:hover:not(:disabled) {
	background: var(--smartbuy-blue-dark);
}

.smartbuy-send-btn:active:not(:disabled) {
	transform: scale(0.97);
}

.smartbuy-send-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.smartbuy-send-btn:focus-visible,
.smartbuy-input:focus-visible {
	outline: 2px solid #93c5fd;
	outline-offset: 2px;
}

/* Privacy note */

.smartbuy-privacy-note {
	margin: 0;
	padding: 7px 14px 11px;
	font-size: 10.5px;
	color: var(--smartbuy-slate-700);
	text-align: center;
	background: var(--smartbuy-white);
	flex-shrink: 0;
}

/* -------------------------------------------------------------------- */
/* Responsive: small viewports                                          */
/* -------------------------------------------------------------------- */

@media (max-width: 480px) {
	.smartbuy-widget-root {
		right: 16px;
		bottom: 16px;
	}

	.smartbuy-panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 120px);
		bottom: 72px;
		right: -8px;
	}
}

/* Accessibility utility (mirrors WP core's .screen-reader-text behavior) */

.smartbuy-widget-root .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}
