/**
 * CC AI Assistant — chat widget styles.
 *
 * A quiet, confident interface: plenty of breathing room, one accent
 * colour (configurable per store), and a single deliberate signature
 * touch — the soft "thinking" pulse on the avatar while a reply is
 * being put together — rather than scattered motion everywhere.
 */

.cc-ai-widget {
	--cc-ai-accent: #1c2521;
	--cc-ai-ink: #1c2521;
	--cc-ai-muted: #6b7670;
	--cc-ai-surface: #ffffff;
	--cc-ai-surface-soft: #f3f6f4;
	--cc-ai-border: #e1e6e3;
	--cc-ai-radius: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--cc-ai-ink);
	box-sizing: border-box;
}

.cc-ai-widget * {
	box-sizing: border-box;
}

/* ---------- Inline placement ---------- */

.cc-ai-widget--inline {
	max-width: 420px;
}

.cc-ai-widget--inline .cc-ai-panel {
	height: var(--cc-ai-height, 480px);
	border: 1px solid var(--cc-ai-border);
	border-radius: var(--cc-ai-radius);
	box-shadow: 0 1px 2px rgba(20, 30, 25, 0.04);
}

/* ---------- Floating placement ---------- */

.cc-ai-widget--floating {
	position: fixed;
	bottom: 24px;
	z-index: 9999;
}

.cc-ai-widget--right {
	right: 24px;
}

.cc-ai-widget--left {
	left: 24px;
}

.cc-ai-widget--floating .cc-ai-panel {
	position: absolute;
	bottom: 72px;
	width: 360px;
	max-height: 70vh;
	height: 520px;
	border-radius: var(--cc-ai-radius);
	box-shadow: 0 12px 32px rgba(20, 30, 25, 0.18);
	border: 1px solid var(--cc-ai-border);
}

.cc-ai-widget--right .cc-ai-panel {
	right: 0;
}

.cc-ai-widget--left .cc-ai-panel {
	left: 0;
}

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

.cc-ai-launcher {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--cc-ai-accent);
	box-shadow: 0 6px 16px rgba(20, 30, 25, 0.22);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
}

.cc-ai-launcher:hover {
	transform: translateY(-1px) scale(1.03);
}

.cc-ai-launcher:focus-visible {
	outline: 2px solid var(--cc-ai-accent);
	outline-offset: 3px;
}

.cc-ai-launcher__icon {
	width: 22px;
	height: 22px;
	display: block;
	background: #fff;
	/*mask: radial-gradient(circle at 30% 30%, transparent 0, transparent 0) , none;*/
	border-radius: 6px 6px 6px 2px;
	position: relative;
}

.cc-ai-launcher__icon::before,
.cc-ai-launcher__icon::after {
	content: "";
	position: absolute;
	background: var(--cc-ai-accent);
}

.cc-ai-launcher__icon::before {
	left: 4px;
	top: 4px;
	right: 4px;
	bottom: 8px;
	background: #fff;
	border-radius: 5px;
}

/* ---------- Panel ---------- */

.cc-ai-panel {
	display: flex;
	flex-direction: column;
	background: var(--cc-ai-surface);
	overflow: hidden;
}

.cc-ai-panel__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--cc-ai-border);
	background: var(--cc-ai-surface-soft);
}

.cc-ai-panel__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--cc-ai-accent);
	flex-shrink: 0;
}

.cc-ai-panel__avatar.cc-ai-thinking {
	animation: cc-ai-pulse 1.1s ease-in-out infinite;
}

@keyframes cc-ai-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.55; transform: scale(0.85); }
}

.cc-ai-panel__name {
	font-weight: 600;
	font-size: 14px;
	flex-grow: 1;
}

.cc-ai-panel__close {
	border: none;
	background: transparent;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	color: var(--cc-ai-muted);
	padding: 4px;
	transform: scale(1.48);
}

.cc-ai-panel__main-menu {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	border: 1px solid var(--cc-ai-border);
	border-radius: 5px;
	padding: 5px 7px;
	background: var(--cc-ai-surface);
	color: var(--cc-ai-ink);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}

.cc-ai-panel__main-menu:hover {
	border-color: var(--cc-ai-accent);
	color: var(--cc-ai-accent);
}

.cc-ai-panel__close:focus-visible,
.cc-ai-panel__send:focus-visible,
.cc-ai-panel__input:focus-visible,
.cc-ai-panel__main-menu:focus-visible,
.cc-ai-quick-action:focus-visible {
	outline: 2px solid var(--cc-ai-accent);
	outline-offset: 2px;
	border-radius: inherit;
}

.cc-ai-panel__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--cc-ai-surface);
}

.cc-ai-panel__form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--cc-ai-border);
	background: var(--cc-ai-surface-soft);
}

.cc-ai-panel__input {
	flex: 1;
	border: 1px solid var(--cc-ai-border);
	border-radius: 999px;
	padding: 10px 14px;
	font-size: 14px;
	background: var(--cc-ai-surface);
	color: var(--cc-ai-ink);
}

.cc-ai-panel__send {
	border: none;
	border-radius: 3px;
	padding: 10px 18px;
	background: var(--cc-ai-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.cc-ai-panel__send img {
  width: 18px;
  height: 18px;
  display: block;
  filter: invert(1);
  transform: scale(1.24);
}

.cc-ai-panel__send:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ---------- Messages ---------- */

.cc-ai-message {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.45;
}

.cc-ai-message--user {
	align-self: flex-end;
	background: var(--cc-ai-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.cc-ai-message--user p {
	margin: 0;
}

.cc-ai-message--assistant {
	align-self: flex-start;
	background: var(--cc-ai-surface-soft);
	border: 1px solid var(--cc-ai-border);
	border-bottom-left-radius: 4px;
	max-width: 92%;
}

.cc-ai-message__image {
	width: 100%;
	max-height: 140px;
	object-fit: cover;
	border-radius: 8px;
	margin-bottom: 8px;
}

.cc-ai-message__title {
	margin: 0 0 4px;
	font-size: 14.5px;
	font-weight: 700;
}

.cc-ai-message__summary {
	margin: 0 0 6px;
	color: var(--cc-ai-ink);
}

.cc-ai-message__quick-actions-intro {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--cc-ai-muted);
}

.cc-ai-quick-actions {
	display: grid;
	grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	gap: 6px;
	margin-top: 10px;
}

.cc-ai-quick-action {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	padding: 8px;
	border: 1px solid var(--cc-ai-border);
	border-radius: 5px;
	background: var(--cc-ai-surface);
	color: var(--cc-ai-ink);
	font-size: 12px;
	font-weight: 600;
	line-height: 1.25;
	text-align: left;
	cursor: pointer;
}

.cc-ai-quick-action:hover {
	border-color: var(--cc-ai-accent);
	color: var(--cc-ai-accent);
}

.cc-ai-quick-action__icon {
	flex: 0 0 auto;
}

.cc-ai-message__facts {
	margin: 0 0 8px;
	padding-left: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cc-ai-message__facts li {
	font-size: 13px;
	color: var(--cc-ai-muted);
}

.cc-ai-message__facts li::before {
	content: "•  ";
	color: var(--cc-ai-accent);
}

.cc-ai-message__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 6px;
}

.cc-ai-action {
	font-size: 12.5px;
	font-weight: 600;
	padding: 6px 11px;
	border-radius: 999px;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
}

.cc-ai-action--link {
	background: var(--cc-ai-accent);
	color: #fff;
}

.cc-ai-action--prompt {
	background: #fff;
	border: 1px solid var(--cc-ai-accent);
	color: var(--cc-ai-accent);
}

.cc-ai-action--static {
	background: var(--cc-ai-surface);
	border: 1px solid var(--cc-ai-border);
	color: var(--cc-ai-muted);
}

.cc-ai-message--error {
	align-self: flex-start;
	background: #fdecea;
	border: 1px solid #f3c2bd;
	color: #8a2c22;
}

@media (prefers-reduced-motion: reduce) {
	.cc-ai-panel__avatar.cc-ai-thinking {
		animation: none;
	}
}

@media (max-width: 480px) {
	.cc-ai-widget--floating .cc-ai-panel {
		width: calc(100vw - 32px);
		right: 0;
		left: 0;
		margin: 0 16px;
	}

	.cc-ai-widget--right .cc-ai-panel,
	.cc-ai-widget--left .cc-ai-panel {
		right: -8px;
		left: auto;
	}
}

/* ==========================================================================
   Custom Avatar & Launcher Icon
   Added when the admin uploads images via the Media Library. The CSS-only
   fallback rules above continue to apply when no image is configured.
   ========================================================================== */

/*
 * Avatar — image variant.
 *
 * wp_get_attachment_image() outputs an <img> with class cc-ai-panel__avatar
 * when an image is set. Override the background colour and add object-fit so
 * it always fills the 28 × 28 circle cleanly.
 *
 * The .cc-ai-thinking pulse animation is declared on .cc-ai-panel__avatar
 * (regardless of element type) so it works on both the <span> and <img>
 * variants without any extra rules.
 */
img.cc-ai-panel__avatar,
img.cc-ai-panel__avatar--image {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: transparent;
	display: block;
}

/*
 * Launcher icon — image variant.
 *
 * Displayed inside the 56 × 56 circular .cc-ai-launcher button. Sized to
 * 32 × 32 so it sits comfortably inside the button with visible padding,
 * matching the visual weight of the original CSS icon.
 *
 * The <span class="cc-ai-launcher__icon"> CSS rules above target the span
 * and its ::before / ::after pseudo-elements only, so uploading a custom
 * image doesn't produce an invisible ghost element alongside the image.
 */
img.cc-ai-launcher__icon--custom {
	width: 32px;
	height: 32px;
	/*border-radius: 50%;*/
	object-fit: contain;
	display: block;
	flex-shrink: 0;
	/* Remove pseudo-element artifacts from the span rule that won't apply
	   to an img, but be explicit so overrides are easy to reason about. */
	background: transparent;
}

/* ==========================================================================
   Custom CSS.
   ========================================================================== */
a.cc-ai-action--link:active, a.cc-ai-action--link:focus, a.cc-ai-action--link:hover,a.cc-ai-action--link:visited {
  color: #fff;
}
