/*
 * AI ChatMate — Widget Styles
 *
 * All selectors are prefixed .attendant- to avoid collisions with the host theme.
 * The brand colour is injected at runtime via wp_add_inline_style():
 *   :root { --attendant-color: #xxxxxx; }
 * This file provides the fallback value (#0073aa — WordPress blue).
 *
 * Structure:
 *  .attendant-launcher          — floating action button (always visible)
 *  .attendant-widget            — chat panel (hidden until .is-open added by JS)
 *  .attendant-widget__header    — coloured title bar + close button
 *  .attendant-widget__messages  — scrollable messages list
 *  .attendant-msg               — single message row (--user | --bot)
 *  .attendant-msg__bubble       — text bubble
 *  .attendant-msg__sources      — source link chips below a bot message
 *  .attendant-widget__footer    — textarea + send button
 */

/* ── CSS custom properties ───────────────────────────────────────────────── */
:root {
	--attendant-color:         #0073aa; /* brand colour — overridden inline */
	--attendant-bg:            #ffffff;
	--attendant-border:        #dcdcde;
	--attendant-user-bubble:   var(--attendant-color);
	--attendant-user-text:     #ffffff;
	--attendant-bot-bubble:    #f0f0f1;
	--attendant-bot-text:      #1d2327;
	--attendant-header-text:   #ffffff;
	--attendant-radius-lg:     16px;
	--attendant-radius-sm:     8px;
	--attendant-shadow:        0 8px 32px rgba(0, 0, 0, 0.22);
	--attendant-z:             999999;
	--attendant-launcher-size: 60px;
	--attendant-panel-width:   360px;
	--attendant-panel-height:  520px;
}

/* ── Launcher button ─────────────────────────────────────────────────────── */
.attendant-launcher {
	position:        fixed;
	bottom:          24px;
	right:           24px;
	z-index:         var(--attendant-z);
	width:           var(--attendant-launcher-size);
	height:          var(--attendant-launcher-size);
	border-radius:   50%;
	background:      var(--attendant-color);
	color:           var(--attendant-header-text);
	border:          none;
	cursor:          pointer;
	display:         flex;
	align-items:     center;
	justify-content: center;
	box-shadow:      var(--attendant-shadow);
	transition:      filter 0.2s, transform 0.15s;
	/* Ensure the button always floats above page content. */
	-webkit-tap-highlight-color: transparent;
}

.attendant-launcher:hover {
	filter:    brightness(0.87);
	transform: scale(1.06);
}

.attendant-launcher:active {
	transform: scale(0.97);
}

.attendant-launcher:focus-visible {
	outline:        2px solid var(--attendant-color);
	outline-offset: 3px;
}

/* Launcher: gradient + breathing glow always; spinning ring, ripple and
   wiggle until the visitor has opened the chat once. */
#attendant-launcher {
	--attendant-lc:  var(--attendant-launcher-color, var(--attendant-color));
	width:           var(--attendant-launcher-size);
	height:          var(--attendant-launcher-size);
	padding:         0;
	margin:          0;
	border:          0;
	border-radius:   50%;
	background:      var(--attendant-lc);
	background:      linear-gradient(135deg,
	                     color-mix(in srgb, var(--attendant-lc) 70%, #ffffff) 0%,
	                     var(--attendant-lc) 55%,
	                     color-mix(in srgb, var(--attendant-lc) 75%, #000000) 100%);
	color:           #ffffff;
	box-shadow:      0 6px 20px rgba(0, 0, 0, 0.25);
	animation:       attendant-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s backwards,
	                 attendant-glow 2.6s ease-in-out 1s infinite;
}

#attendant-launcher:hover {
	filter:    brightness(1.08) saturate(1.1);
	transform: scale(1.08);
}

#attendant-launcher::before,
#attendant-launcher::after {
	content:        "";
	position:       absolute;
	border-radius:  50%;
	pointer-events: none;
	opacity:        0;
}

/* Spinning gradient ring just outside the button edge. */
#attendant-launcher::before {
	inset:      -6px;
	background: conic-gradient(from 0deg, var(--attendant-lc), transparent 35%, #ffffff 50%, transparent 65%, var(--attendant-lc));
	-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
	        mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
}

/* Ripple that expands outward. */
#attendant-launcher::after {
	inset:  0;
	border: 2px solid var(--attendant-lc);
}

#attendant-launcher.is-attention::before {
	opacity:   1;
	animation: attendant-spin 2.8s linear infinite;
}

#attendant-launcher.is-attention::after {
	animation: attendant-ripple 2.2s ease-out 1.2s infinite;
}

#attendant-launcher[aria-expanded="true"] {
	animation: none;
}

#attendant-launcher.is-attention .attendant-launcher__icon--chat {
	animation: attendant-wiggle 6s ease-in-out 2s infinite;
}

.attendant-launcher__icon {
	position:   absolute;
	top:        50%;
	left:       50%;
	margin:     0;
	transform:  translate(-50%, -50%);
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.attendant-launcher__icon--close {
	opacity:   0;
	transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}

#attendant-launcher[aria-expanded="true"] .attendant-launcher__icon--chat {
	opacity:   0;
	transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
	animation: none;
}

#attendant-launcher[aria-expanded="true"] .attendant-launcher__icon--close {
	opacity:   1;
	transform: translate(-50%, -50%) rotate(0) scale(1);
}

.attendant-launcher__badge {
	position:      absolute;
	top:           -3px;
	right:         -3px;
	min-width:     20px;
	height:        20px;
	padding:       0 5px;
	box-sizing:    border-box;
	border-radius: 10px;
	border:        2px solid #ffffff;
	background:    #e11d48;
	color:         #ffffff;
	font:          700 11px/16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-align:    center;
	animation:     attendant-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#attendant-launcher-badge[hidden],
#attendant-teaser[hidden] {
	display: none !important;
}

/* Greeting bubble next to the launcher. */
.attendant-teaser {
	position:         fixed;
	bottom:           calc(24px + var(--attendant-launcher-size) + 14px);
	right:            24px;
	z-index:          var(--attendant-z);
	max-width:        min(270px, calc(100vw - 48px));
	background:       #ffffff;
	color:            #1d2327;
	border-radius:    14px;
	box-shadow:       0 8px 28px rgba(0, 0, 0, 0.18);
	transform-origin: bottom right;
	animation:        attendant-teaser-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.attendant-teaser::after {
	content:    "";
	position:   absolute;
	bottom:     -6px;
	right:      22px;
	width:      12px;
	height:     12px;
	background: #ffffff;
	transform:  rotate(45deg);
}

#attendant-teaser .attendant-teaser__text,
#attendant-teaser .attendant-teaser__text:hover,
#attendant-teaser .attendant-teaser__text:focus {
	display:          block;
	width:            100%;
	margin:           0;
	padding:          12px 32px 12px 14px;
	border:           0;
	border-radius:    14px;
	background:       transparent;
	background-image: none;
	box-shadow:       none;
	color:            #1d2327;
	font:             500 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-align:       left;
	text-transform:   none;
	letter-spacing:   normal;
	cursor:           pointer;
	position:         relative;
	z-index:          1;
}

#attendant-teaser .attendant-teaser__close,
#attendant-teaser .attendant-teaser__close:hover,
#attendant-teaser .attendant-teaser__close:focus {
	position:      absolute;
	top:           4px;
	right:         4px;
	z-index:       2;
	width:         24px;
	height:        24px;
	min-width:     0;
	margin:        0;
	padding:       0;
	border:        0;
	border-radius: 50%;
	background:    transparent;
	box-shadow:    none;
	color:         #8c8f94;
	font:          400 18px/24px sans-serif;
	text-align:    center;
	cursor:        pointer;
}

#attendant-teaser .attendant-teaser__close:hover {
	background: #f0f0f1;
	color:      #1d2327;
}

@keyframes attendant-pop {
	from { transform: scale(0); opacity: 0; }
	to   { transform: scale(1); opacity: 1; }
}

@keyframes attendant-glow {
	0%, 100% { box-shadow: 0 6px 18px color-mix(in srgb, var(--attendant-lc) 45%, transparent), 0 0 0 0 color-mix(in srgb, var(--attendant-lc) 40%, transparent); }
	50%      { box-shadow: 0 6px 26px color-mix(in srgb, var(--attendant-lc) 70%, transparent), 0 0 24px 8px color-mix(in srgb, var(--attendant-lc) 38%, transparent); }
}

@keyframes attendant-spin {
	to { transform: rotate(360deg); }
}

@keyframes attendant-ripple {
	0%   { transform: scale(1);   opacity: 0.7; }
	100% { transform: scale(1.7); opacity: 0; }
}

@keyframes attendant-wiggle {
	0%, 88%, 100% { transform: translate(-50%, -50%) rotate(0); }
	90%           { transform: translate(-50%, -50%) rotate(-14deg); }
	92%           { transform: translate(-50%, -50%) rotate(12deg); }
	94%           { transform: translate(-50%, -50%) rotate(-8deg); }
	96%           { transform: translate(-50%, -50%) rotate(5deg); }
}

@keyframes attendant-teaser-in {
	from { transform: translateY(10px) scale(0.9); opacity: 0; }
	to   { transform: translateY(0) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	#attendant-launcher,
	#attendant-launcher.is-attention,
	#attendant-launcher::before,
	#attendant-launcher::after,
	#attendant-launcher .attendant-launcher__icon,
	.attendant-launcher__badge,
	.attendant-teaser {
		animation:  none !important;
		transition: none !important;
	}
}

/* ── Widget panel ────────────────────────────────────────────────────────── */
.attendant-widget {
	position:       fixed;
	bottom:         calc(var(--attendant-launcher-size) + 16px);
	right:          24px;
	z-index:        var(--attendant-z);
	width:          var(--attendant-panel-width);
	max-width:      calc(100vw - 32px);
	height:         var(--attendant-panel-height);
	max-height:     calc(100vh - 110px);
	border-radius:  var(--attendant-radius-lg);
	background:     var(--attendant-bg);
	box-shadow:     var(--attendant-shadow);
	border:         1px solid var(--attendant-border);
	/* Hidden by default — JS adds .is-open */
	display:        none;
	flex-direction: column;
	overflow:       hidden;
	transform-origin: bottom right;
}

.attendant-widget.is-open {
	display:   flex;
	animation: attendant-slide-up 0.2s ease-out both;
}

@keyframes attendant-slide-up {
	from { opacity: 0; transform: translateY(10px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.attendant-widget__header {
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	padding:         13px 16px;
	background:      var(--attendant-color);
	color:           var(--attendant-header-text);
	flex-shrink:     0;
	gap:             8px;
}

.attendant-widget__title {
	font-weight:   600;
	font-size:     15px;
	white-space:   nowrap;
	overflow:      hidden;
	text-overflow: ellipsis;
	flex:          1;
}

.attendant-widget__close {
	background:    transparent;
	border:        none;
	cursor:        pointer;
	color:         inherit;
	padding:       4px;
	line-height:   1;
	border-radius: var(--attendant-radius-sm);
	display:       flex;
	flex-shrink:   0;
	opacity:       0.85;
	transition:    opacity 0.15s;
}

.attendant-widget__close:hover {
	opacity: 1;
}

.attendant-widget__close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.75);
}

/* ── Messages area ───────────────────────────────────────────────────────── */
.attendant-widget__messages {
	flex:            1;
	overflow-y:      auto;
	padding:         14px 12px;
	display:         flex;
	flex-direction:  column;
	gap:             10px;
	scroll-behavior: smooth;
}

/* Thin scrollbar — Webkit */
.attendant-widget__messages::-webkit-scrollbar       { width: 4px; }
.attendant-widget__messages::-webkit-scrollbar-track  { background: transparent; }
.attendant-widget__messages::-webkit-scrollbar-thumb  {
	background:    var(--attendant-border);
	border-radius: 2px;
}

/* ── Message rows ────────────────────────────────────────────────────────── */
.attendant-msg {
	display:        flex;
	flex-direction: column;
	max-width:      85%;
	/* Animation for each incoming message */
	animation:      attendant-msg-in 0.18s ease-out both;
}

@keyframes attendant-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0);   }
}

.attendant-msg--user {
	align-self:  flex-end;
	align-items: flex-end;
}

.attendant-msg--bot {
	align-self:  flex-start;
	align-items: flex-start;
}

/* ── Message bubbles ─────────────────────────────────────────────────────── */
.attendant-msg__bubble {
	padding:       10px 13px;
	border-radius: var(--attendant-radius-lg);
	font-size:     14px;
	line-height:   1.55;
	word-break:    break-word;
}

.attendant-msg--user .attendant-msg__bubble {
	background:                var(--attendant-user-bubble);
	color:                     var(--attendant-user-text);
	border-bottom-right-radius: 4px;
}

.attendant-msg--bot .attendant-msg__bubble {
	background:               var(--attendant-bot-bubble);
	color:                    var(--attendant-bot-text);
	border-bottom-left-radius: 4px;
}

/* Live-agent (human) replies — bot side of the thread, subtly set apart */
.attendant-msg--agent {
	align-self:  flex-start;
	align-items: flex-start;
}

.attendant-msg--agent .attendant-msg__bubble {
	background:                var(--attendant-bot-bubble);
	color:                     var(--attendant-bot-text);
	border-bottom-left-radius: 4px;
	border-left:               3px solid var(--attendant-brand, #0073aa);
}

.attendant-msg__agent-name {
	font-size:     11px;
	font-weight:   600;
	opacity:       0.7;
	margin-bottom: 2px;
}

/* System divider — marks the switch to/from a live human */
.attendant-divider {
	display:     flex;
	align-items: center;
	text-align:  center;
	gap:         10px;
	margin:      14px 4px;
	color:       #646970;
	font-size:   12px;
	font-weight: 600;
}
.attendant-divider::before,
.attendant-divider::after {
	content:    "";
	flex:       1;
	height:     1px;
	background: rgba(0, 0, 0, 0.12);
}
.attendant-divider span {
	white-space: nowrap;
}

/* Inline formatting rendered by JS formatText() */
.attendant-msg__bubble strong { font-weight: 600; }
.attendant-msg__bubble br     { display: block; margin-bottom: 2px; }

/* ── Typing indicator ────────────────────────────────────────────────────── */
.attendant-msg--typing .attendant-msg__bubble {
	padding: 12px 14px;
}

.attendant-msg--typing .attendant-msg__bubble span {
	display:       inline-block;
	width:         7px;
	height:        7px;
	border-radius: 50%;
	background:    var(--attendant-color);
	margin:        0 2px;
	animation:     attendant-bounce 1.3s infinite ease-in-out;
	vertical-align: middle;
	opacity:       0.7;
}

.attendant-msg--typing .attendant-msg__bubble span:nth-child(2) { animation-delay: 0.22s; }
.attendant-msg--typing .attendant-msg__bubble span:nth-child(3) { animation-delay: 0.44s; }

@keyframes attendant-bounce {
	0%, 80%, 100% { transform: scale(0.65); opacity: 0.45; }
	40%           { transform: scale(1);    opacity: 1;    }
}

/* ── Source link chips ───────────────────────────────────────────────────── */
.attendant-msg__sources {
	margin-top: 6px;
	display:    flex;
	flex-wrap:  wrap;
	gap:        5px;
}

.attendant-msg__sources a {
	font-size:       11px;
	color:           var(--attendant-color);
	text-decoration: none;
	background:      rgba(0, 115, 170, 0.07);
	padding:         3px 8px;
	border-radius:   12px;
	border:          1px solid rgba(0, 115, 170, 0.18);
	white-space:     nowrap;
	overflow:        hidden;
	text-overflow:   ellipsis;
	max-width:       210px;
	transition:      background 0.15s;
}

.attendant-msg__sources a:hover {
	background:      rgba(0, 115, 170, 0.14);
	text-decoration: underline;
}

/* ── Footer / Input row ──────────────────────────────────────────────────── */
.attendant-widget__footer {
	display:      flex;
	align-items:  flex-end;
	gap:          8px;
	padding:      10px 12px;
	border-top:   1px solid var(--attendant-border);
	flex-shrink:  0;
	background:   var(--attendant-bg);
}

.attendant-widget__input {
	flex:          1;
	resize:        none;
	border:        1px solid var(--attendant-border);
	border-radius: var(--attendant-radius-sm);
	padding:       8px 10px;
	font-size:     14px;
	font-family:   inherit;
	line-height:   1.45;
	min-height:    36px;
	max-height:    120px;
	overflow-y:    auto;
	outline:       none;
	color:         var(--attendant-bot-text);
	background:    var(--attendant-bg);
	transition:    border-color 0.15s;
}

.attendant-widget__input:focus {
	border-color: var(--attendant-color);
}

.attendant-widget__input::placeholder {
	color:   #8c8f94;
	opacity: 1;
}

/* ID-scoped so theme / page-builder global button styles (e.g. Elementor kit) can't override it. */
#attendant-widget .attendant-widget__send,
#attendant-widget .attendant-widget__send:hover,
#attendant-widget .attendant-widget__send:focus,
#attendant-widget .attendant-widget__send:active {
	width:           36px;
	height:          36px;
	min-width:       36px;
	min-height:      36px;
	max-width:       36px;
	flex-shrink:     0;
	margin:          0;
	padding:         0;
	border-radius:   50%;
	background:      var(--attendant-color);
	background-image: none;
	color:           var(--attendant-header-text);
	border:          none;
	box-shadow:      none;
	text-shadow:     none;
	line-height:     1;
	cursor:          pointer;
	display:         flex;
	align-items:     center;
	justify-content: center;
	transition:      filter 0.15s, opacity 0.15s;
}

#attendant-widget .attendant-widget__send svg {
	display:     block;
	width:       18px;
	height:      18px;
	min-width:   18px;
	flex-shrink: 0;
	fill:        none;
	stroke:      currentColor;
}

#attendant-widget .attendant-widget__send:hover:not(:disabled) {
	filter: brightness(0.87);
}

#attendant-widget .attendant-widget__send:disabled {
	opacity: 0.45;
	cursor:  not-allowed;
}

#attendant-widget .attendant-widget__send:focus-visible {
	outline:        2px solid var(--attendant-color);
	outline-offset: 2px;
}

/* Photo attach button — ID-scoped for the same reason as the send button. */
#attendant-widget .attendant-widget__attach,
#attendant-widget .attendant-widget__attach:hover,
#attendant-widget .attendant-widget__attach:focus,
#attendant-widget .attendant-widget__attach:active {
	width:            36px;
	height:           36px;
	min-width:        36px;
	min-height:       36px;
	max-width:        36px;
	flex-shrink:      0;
	margin:           0;
	padding:          0;
	border-radius:    50%;
	background:       transparent;
	background-image: none;
	color:            var(--attendant-color);
	border:           1px solid var(--attendant-border);
	box-shadow:       none;
	text-shadow:      none;
	line-height:      1;
	cursor:           pointer;
	display:          flex;
	align-items:      center;
	justify-content:  center;
	transition:       background 0.15s, opacity 0.15s;
}

#attendant-widget .attendant-widget__attach:hover:not(:disabled) {
	background: rgba(0, 0, 0, 0.05);
}

#attendant-widget .attendant-widget__attach.attendant-is-hidden {
	display: none;
}

#attendant-widget .attendant-widget__attach:disabled {
	opacity: 0.45;
	cursor:  not-allowed;
}

#attendant-widget .attendant-widget__attach:focus-visible {
	outline:        2px solid var(--attendant-color);
	outline-offset: 2px;
}

#attendant-widget .attendant-widget__attach svg {
	display:     block;
	width:       18px;
	height:      18px;
	min-width:   18px;
	flex-shrink: 0;
	fill:        none;
	stroke:      currentColor;
}

.attendant-chip--photo::before {
	content:      "📷";
	margin-right: 4px;
}

.attendant-msg__photo {
	display:       block;
	max-width:     180px;
	max-height:    180px;
	margin-top:    6px;
	border-radius: var(--attendant-radius-sm);
	object-fit:    cover;
}

.attendant-widget__messages {
	overscroll-behavior: contain;
}

/* ── Responsive: phones (≤ 600 px) ─────────────────────────────────────────
   Bottom sheet normally; while the keyboard is up JS adds .is-kb and the
   panel is pinned to the visual viewport (--attendant-vvtop/--attendant-vvh)
   so the header, latest messages and input all stay on screen. */
@media (max-width: 600px) {
	.attendant-widget {
		width:            100%;
		max-width:        100%;
		height:           82vh;
		height:           82dvh;
		max-height:       none;
		top:              auto;
		bottom:           0;
		right:            0;
		left:             0;
		border-radius:    18px 18px 0 0;
		border-left:      none;
		border-right:     none;
		border-bottom:    none;
		transform-origin: bottom center;
		box-shadow:       0 -6px 30px rgba(0, 0, 0, 0.25);
	}

	.attendant-widget.is-open {
		animation: attendant-sheet-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
	}

	.attendant-widget.is-kb {
		top:           var(--attendant-vvtop, 0px);
		bottom:        auto;
		height:        var(--attendant-vvh, 100dvh);
		border-radius: 0;
		animation:     none;
	}

	.attendant-widget__header {
		padding: 12px 10px 12px 16px;
	}

	.attendant-widget__title {
		font-size: 16px;
	}

	.attendant-widget__hbtn,
	.attendant-widget__close {
		padding: 8px;
	}

	.attendant-msg {
		max-width: 88%;
	}

	.attendant-msg__bubble {
		font-size: 15px;
	}

	.attendant-widget__footer {
		padding:        10px 12px;
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}

	/* 16px stops iOS from zooming the page when the input is focused. */
	#attendant-widget .attendant-widget__input {
		font-size:  16px;
		min-height: 42px;
		padding:    10px 12px;
	}

	#attendant-widget .attendant-widget__send,
	#attendant-widget .attendant-widget__send:hover,
	#attendant-widget .attendant-widget__send:focus,
	#attendant-widget .attendant-widget__send:active,
	#attendant-widget .attendant-widget__attach,
	#attendant-widget .attendant-widget__attach:hover,
	#attendant-widget .attendant-widget__attach:focus,
	#attendant-widget .attendant-widget__attach:active {
		width:      42px;
		height:     42px;
		min-width:  42px;
		min-height: 42px;
		max-width:  42px;
	}

	.attendant-launcher {
		bottom: 16px;
		right:  16px;
	}

	.attendant-teaser {
		bottom: calc(16px + var(--attendant-launcher-size) + 14px);
		right:  16px;
	}

	/* Chat open on a phone: page behind stops scrolling, launcher steps aside. */
	html.attendant-mobile-open,
	html.attendant-mobile-open body {
		overflow: hidden;
	}

	html.attendant-mobile-open #attendant-launcher,
	html.attendant-mobile-open #attendant-teaser {
		display: none;
	}
}

@keyframes attendant-sheet-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

/* ── Header action buttons (history / new chat) ─────────────────────────── */
.attendant-widget__hbtn {
	background:    transparent;
	border:        none;
	cursor:        pointer;
	color:         inherit;
	padding:       4px;
	line-height:   1;
	border-radius: var(--attendant-radius-sm);
	display:       flex;
	flex-shrink:   0;
	opacity:       0.85;
	transition:    opacity 0.15s;
}

.attendant-widget__hbtn:hover {
	opacity: 1;
}

.attendant-widget__hbtn:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.75);
}

/* ── Chat history panel ──────────────────────────────────────────────────── */
/* Hidden by default; .is-history on the widget swaps the conversation view
   for the history list (no absolute positioning — plain flex swap). */
.attendant-widget__history {
	display:    none;
	flex:       1;
	overflow-y: auto;
	background: var(--attendant-bg);
}

.attendant-widget.is-history .attendant-widget__history {
	display: block;
}

.attendant-widget.is-history .attendant-widget__messages,
.attendant-widget.is-history .attendant-widget__footer {
	display: none;
}

.attendant-widget__history-head {
	padding:       12px 16px 8px;
	font-weight:   600;
	font-size:     13px;
	color:         var(--attendant-bot-text);
	border-bottom: 1px solid var(--attendant-border);
}

.attendant-widget__history-list {
	list-style: none;
	margin:     0;
	padding:    4px 0;
}

.attendant-widget__history-list li {
	margin: 0;
}

.attendant-history-empty {
	padding:   16px;
	color:     #646970;
	font-size: 13px;
}

.attendant-history-item {
	display:    block;
	width:      100%;
	text-align: left;
	background: transparent;
	border:     none;
	cursor:     pointer;
	padding:    10px 16px;
	border-bottom: 1px solid var(--attendant-border);
	font:       inherit;
	color:      var(--attendant-bot-text);
}

.attendant-history-item:hover {
	background: var(--attendant-bot-bubble);
}

.attendant-history-item.is-current {
	background: var(--attendant-bot-bubble);
}

.attendant-history-item__label {
	display:       block;
	font-size:     13.5px;
	overflow:      hidden;
	text-overflow: ellipsis;
	white-space:   nowrap;
}

.attendant-history-item__meta {
	display:   block;
	font-size: 11.5px;
	color:     #8c8f94;
	margin-top: 2px;
}

/* ── Quick-reply chips ───────────────────────────────────────────────────── */
/* .attendant-chips sits directly inside .attendant-widget__messages (same flex column
   as .attendant-msg rows). Bot message rows use align-self:flex-start with no
   left margin, so chips use the same alignment — no extra padding-left. */
.attendant-chips {
	display:   flex;
	flex-wrap: wrap;
	gap:       8px;
	margin:    4px 0 8px;
	align-self: flex-start;
}

.attendant-chip {
	background:    var(--attendant-bg);
	border:        1px solid var(--attendant-color);
	color:         var(--attendant-color);
	border-radius: 999px;
	padding:       6px 14px;
	font-size:     13px;
	font-family:   inherit;
	cursor:        pointer;
	transition:    background 0.15s, color 0.15s;
}

.attendant-chip:hover {
	background: var(--attendant-color);
	color:      var(--attendant-header-text);
}

.attendant-chip:focus-visible {
	background: var(--attendant-color);
	color:      var(--attendant-header-text);
	outline:    2px solid var(--attendant-color);
	outline-offset: 2px;
}

/* Hidden until the assistant actually needs to hand over */
.attendant-is-hidden { display: none !important; }

/* Inline "talk to a human" offer, shown when the AI falls short */
.attendant-human-offer {
	margin:        10px 4px 4px;
	padding:       12px;
	border:        1px solid rgba(0, 0, 0, 0.1);
	border-radius: var(--attendant-radius-lg);
	background:    rgba(0, 0, 0, 0.02);
	text-align:    center;
}

.attendant-human-offer__note {
	font-size:     13px;
	color:         #50575e;
	margin-bottom: 8px;
}

.attendant-human-offer__btn {
	display:       inline-block;
	padding:       9px 16px;
	border:        0;
	border-radius: 999px;
	background:    var(--attendant-color, #0073aa);
	color:         #fff;
	font-size:     13px;
	font-weight:   600;
	cursor:        pointer;
}

.attendant-human-offer__btn:hover,
.attendant-human-offer__btn:focus {
	filter: brightness(1.08);
}
