/**
 * Hicabistan AI Chat — UX refresh (black/white brand, above WhatsApp).
 */

.hic-ai-chat {
	--hic-ai-ink: #111;
	--hic-ai-muted: #6b6560;
	--hic-ai-line: #ebe7e1;
	--hic-ai-bg: #f7f5f2;
	--hic-ai-surface: #fff;
	--hic-ai-accent: #111;
	--hic-ai-gold: #c4922a;
	--hic-ai-wa: #25d366;
	--hic-ai-panel-w: min(392px, calc(100vw - 20px));
	--hic-ai-right: 18px;
	--hic-ai-bottom-btn: 88px;
	--hic-ai-launcher-h: 48px;
	--hic-ai-z: 99990;
	--hic-ai-gap: 8px;
	--hic-ai-radius: 16px;
	/* Panel sits just above the launcher; height is capped so the top never leaves the viewport. */
	--hic-ai-panel-bottom: calc(var(--hic-ai-bottom-btn) + var(--hic-ai-launcher-h) + var(--hic-ai-gap));
	font-family: Montserrat, system-ui, sans-serif;
	/* Full-viewport fixed layer so absolute children use real viewport edges */
	position: fixed;
	inset: 0;
	width: auto;
	height: auto;
	overflow: visible;
	z-index: var(--hic-ai-z);
	pointer-events: none;
}

.hic-ai-chat[hidden] {
	display: none !important;
}

.hic-ai-chat * {
	box-sizing: border-box;
}

.hic-ai-chat__launcher,
.hic-ai-chat__panel,
.hic-ai-chat__backdrop {
	pointer-events: auto;
}

/* —— Backdrop (mobile focus) —— */
.hic-ai-chat__backdrop {
	position: fixed;
	inset: 0;
	border: 0;
	padding: 0;
	margin: 0;
	background: rgba(17, 17, 17, 0.28);
	backdrop-filter: blur(2px);
	z-index: calc(var(--hic-ai-z) - 1);
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.22s ease;
}

.hic-ai-chat__backdrop:not([hidden]) {
	opacity: 1;
}

@media (min-width: 721px) {
	.hic-ai-chat__backdrop {
		display: none !important;
	}
}

/* —— Launcher —— */
.hic-ai-chat__launcher {
	position: fixed;
	right: var(--hic-ai-right);
	bottom: var(--hic-ai-bottom-btn);
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: auto !important;
	max-width: none !important;
	min-width: 48px;
	min-height: 48px;
	height: 48px !important;
	margin: 0 !important;
	padding: 0 16px 0 14px !important;
	border: 0 !important;
	border-radius: 999px !important;
	background: var(--hic-ai-accent) !important;
	color: #fff !important;
	cursor: pointer;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
	transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
	white-space: nowrap;
	line-height: 1 !important;
	text-transform: none;
	z-index: var(--hic-ai-z);
}

.hic-ai-chat__launcher:hover {
	background: #222 !important;
	transform: translateY(-2px);
	box-shadow: 0 14px 32px rgba(0, 0, 0, 0.3);
}

.hic-ai-chat__launcher:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.hic-ai-chat__launcher.is-open {
	transform: scale(0.96);
}

.hic-ai-chat__launcher-pulse {
	position: absolute;
	inset: -4px;
	border-radius: inherit;
	border: 2px solid rgba(17, 17, 17, 0.35);
	animation: hic-ai-pulse 2.4s ease-out infinite;
	pointer-events: none;
}

.hic-ai-chat__launcher.is-open .hic-ai-chat__launcher-pulse {
	display: none;
}

@keyframes hic-ai-pulse {
	0% {
		transform: scale(0.92);
		opacity: 0.55;
	}
	70% {
		transform: scale(1.12);
		opacity: 0;
	}
	100% {
		opacity: 0;
	}
}

.hic-ai-chat__launcher-icon {
	display: inline-flex;
	width: 26px;
	height: 26px;
	align-items: center;
	justify-content: center;
}

.hic-ai-chat__launcher-label {
	font-size: 0.76rem;
	font-weight: 650;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	padding-right: 2px;
}

.hic-ai-chat__launcher-label--short {
	display: none;
}

/* —— Panel —— */
.hic-ai-chat__panel {
	position: fixed;
	right: var(--hic-ai-right);
	bottom: var(--hic-ai-panel-bottom);
	width: var(--hic-ai-panel-w);
	height: min(560px, calc(100vh - var(--hic-ai-panel-bottom) - 24px));
	height: min(560px, calc(100dvh - var(--hic-ai-panel-bottom) - 24px));
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--hic-ai-surface);
	border: 1px solid var(--hic-ai-line);
	border-radius: var(--hic-ai-radius);
	box-shadow: 0 22px 56px rgba(0, 0, 0, 0.2);
	overflow: hidden;
	z-index: calc(var(--hic-ai-z) + 1);
	transform-origin: bottom right;
	animation: hic-ai-panel-in 0.22s ease;
}

.hic-ai-chat__panel[hidden] {
	display: none !important;
	animation: none;
}

/* Short desktop windows: drop the panel to the bottom edge so it keeps a usable height
   (it temporarily covers the launcher/WhatsApp; close button remains available). */
@media (min-width: 721px) and (max-height: 600px) {
	.hic-ai-chat__panel {
		bottom: 12px;
		height: calc(100vh - 24px);
		height: calc(100dvh - 24px);
	}
}

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

.hic-ai-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 10px;
	background: var(--hic-ai-ink);
	color: #fff;
}

.hic-ai-chat__brand {
	display: flex;
	align-items: center;
	gap: 11px;
	min-width: 0;
}

.hic-ai-chat__avatar {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.18);
}

.hic-ai-chat__title {
	margin: 0;
	font-size: 0.98rem;
	font-weight: 650;
	letter-spacing: 0.01em;
}

.hic-ai-chat__status {
	margin: 3px 0 0;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.7rem;
	opacity: 0.85;
}

.hic-ai-chat__status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3ddc84;
	box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.22);
}

.hic-ai-chat__close {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	margin: 0 !important;
	padding: 0 !important;
	border: 1px solid rgba(255, 255, 255, 0.28) !important;
	border-radius: 50% !important;
	background: rgba(255, 255, 255, 0.16) !important;
	color: #fff !important;
	fill: none !important;
	cursor: pointer;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	line-height: 1 !important;
	box-shadow: none !important;
	text-shadow: none !important;
	opacity: 1 !important;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.hic-ai-chat__close svg {
	display: block;
	width: 16px;
	height: 16px;
	stroke: #fff !important;
	stroke-width: 2.4 !important;
	stroke-linecap: round;
	stroke-linejoin: round;
	fill: none !important;
	color: #fff !important;
	opacity: 1 !important;
}

.hic-ai-chat__close:hover {
	background: rgba(255, 255, 255, 0.28) !important;
	border-color: rgba(255, 255, 255, 0.5) !important;
	color: #fff !important;
}

.hic-ai-chat__close:hover svg {
	stroke: #fff !important;
}

.hic-ai-chat__subtitle {
	margin: 0;
	padding: 8px 16px;
	font-size: 0.72rem;
	line-height: 1.4;
	color: var(--hic-ai-muted);
	background: #fbfaf8;
	border-bottom: 1px solid var(--hic-ai-line);
}

.hic-ai-chat__body {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--hic-ai-bg);
}

.hic-ai-chat__lead,
.hic-ai-chat__conversation {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

/* —— Lead form —— */
.hic-ai-chat__lead {
	padding: 14px;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.hic-ai-chat__lead-card {
	background: var(--hic-ai-surface);
	border: 1px solid var(--hic-ai-line);
	border-radius: 12px;
	padding: 14px;
}

.hic-ai-chat__badge {
	display: inline-block;
	font-size: 0.64rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--hic-ai-gold);
	margin-bottom: 8px;
}

.hic-ai-chat__lead-intro {
	margin: 0 0 14px;
	font-size: 0.86rem;
	line-height: 1.5;
	color: var(--hic-ai-muted);
}

.hic-ai-chat__form label {
	display: block;
	margin: 0 0 11px;
}

.hic-ai-chat__form label > span {
	display: block;
	font-size: 0.66rem;
	font-weight: 650;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: #555;
	margin-bottom: 5px;
}

.hic-ai-chat__form input,
.hic-ai-chat__form select,
.hic-ai-chat__composer textarea {
	width: 100%;
	border: 1px solid #ddd7cf;
	border-radius: 8px;
	background: #fff;
	color: var(--hic-ai-ink);
	min-height: 42px;
	padding: 0.55rem 0.75rem;
	font: inherit;
	font-size: 0.9rem;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hic-ai-chat__form input:focus,
.hic-ai-chat__form select:focus,
.hic-ai-chat__composer textarea:focus {
	border-color: #111;
	outline: none;
	box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.hic-ai-chat__form small {
	display: block;
	margin-top: 5px;
	font-size: 0.7rem;
	color: var(--hic-ai-muted);
	line-height: 1.35;
}

.hic-ai-chat__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.hic-ai-chat__phone {
	display: grid;
	grid-template-columns: minmax(92px, 118px) 1fr;
	gap: 8px;
	align-items: stretch;
}

.hic-ai-chat__phone select {
	min-width: 0;
	padding-left: 0.55rem;
	padding-right: 0.35rem;
	font-size: 0.86rem;
	font-variant-numeric: tabular-nums;
}

.hic-ai-chat__phone input {
	min-width: 0;
}

.hic-ai-chat__hp {
	position: absolute !important;
	left: -10000px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
	opacity: 0 !important;
}

.hic-ai-chat__hint {
	margin: 0 0 12px;
	padding: 9px 11px;
	font-size: 0.74rem;
	line-height: 1.45;
	color: #5a534c;
	background: #f3efe8;
	border-radius: 8px;
	border-left: 3px solid var(--hic-ai-gold);
}

.hic-ai-chat[dir="rtl"] .hic-ai-chat__hint {
	border-left: 0;
	border-right: 3px solid var(--hic-ai-gold);
}

.hic-ai-chat__form-error {
	margin: 0 0 10px;
	padding: 9px 11px;
	border: 1px solid #f0c2c2;
	background: #fff5f5;
	color: #8a1f1f;
	font-size: 0.82rem;
	border-radius: 8px;
}

.hic-ai-chat__submit,
.hic-ai-chat__send {
	font: inherit;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	border: 1px solid #000;
	background: #000;
	color: #fff;
	cursor: pointer;
	border-radius: 8px;
	transition: background 0.15s ease, transform 0.15s ease;
}

.hic-ai-chat__submit {
	width: 100%;
	min-height: 48px;
	padding: 0.8em 1em;
	font-size: 0.78rem;
}

.hic-ai-chat__submit:hover {
	background: #222;
}

.hic-ai-chat__submit:disabled,
.hic-ai-chat__send:disabled,
.hic-ai-chat__composer textarea:disabled {
	opacity: 0.55;
	cursor: wait;
}

/* —— Messages —— */
.hic-ai-chat__messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 14px 14px 6px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.hic-ai-chat__bubble {
	max-width: 88%;
	padding: 11px 13px;
	font-size: 0.875rem;
	line-height: 1.5;
	word-break: break-word;
	animation: hic-ai-bubble-in 0.18s ease;
}

@keyframes hic-ai-bubble-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.hic-ai-chat__bubble--assistant {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--hic-ai-line);
	color: var(--hic-ai-ink);
	border-radius: 4px 14px 14px 14px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.hic-ai-chat__bubble--user {
	align-self: flex-end;
	background: #111;
	color: #fff;
	border-radius: 14px 14px 4px 14px;
	white-space: pre-wrap;
}

.hic-ai-chat__p {
	margin: 0 0 0.5em;
}

.hic-ai-chat__p:last-child {
	margin-bottom: 0;
}

.hic-ai-chat__list {
	margin: 0.1em 0 0.5em;
	padding: 0 0 0 1.15em;
}

.hic-ai-chat__list:last-child {
	margin-bottom: 0;
}

.hic-ai-chat__list li {
	margin: 0.22em 0;
}

.hic-ai-chat__bubble strong {
	font-weight: 700;
}

.hic-ai-chat__link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 600;
	word-break: break-all;
}

.hic-ai-chat__bubble--assistant .hic-ai-chat__link {
	color: #0b57d0;
}

/* —— Chips —— */
.hic-ai-chat__chips {
	padding: 4px 14px 10px;
}

.hic-ai-chat__chips[hidden] {
	display: none !important;
}

.hic-ai-chat__chips-label {
	display: block;
	font-size: 0.66rem;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--hic-ai-muted);
	margin-bottom: 7px;
}

.hic-ai-chat__chips-row {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.hic-ai-chat__chip {
	appearance: none;
	border: 1px solid #d9d3cb;
	background: #fff;
	color: #222;
	border-radius: 999px;
	padding: 7px 11px;
	font: inherit;
	font-size: 0.74rem;
	font-weight: 560;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.hic-ai-chat__chip:hover {
	border-color: #111;
	background: #faf9f7;
	transform: translateY(-1px);
}

/* —— Typing —— */
.hic-ai-chat__typing {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 14px 8px;
	padding: 8px 12px;
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--hic-ai-line);
	border-radius: 12px;
	width: fit-content;
	max-width: 88%;
}

.hic-ai-chat__typing[hidden] {
	display: none !important;
}

.hic-ai-chat__typing-dots {
	display: inline-flex;
	gap: 4px;
	align-items: center;
}

.hic-ai-chat__typing-dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #999;
	display: block;
	animation: hic-ai-dot 1.2s infinite ease-in-out;
}

.hic-ai-chat__typing-dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.hic-ai-chat__typing-dots i:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes hic-ai-dot {
	0%,
	80%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-2px);
	}
}

.hic-ai-chat__typing-text {
	font-size: 0.72rem;
	color: var(--hic-ai-muted);
}

/* —— WhatsApp CTA —— */
.hic-ai-chat__wa {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 12px 8px;
	padding: 10px 12px;
	text-decoration: none;
	color: #0b3d1f;
	background: #eefaf2;
	border: 1px solid #c9ebd4;
	border-radius: 10px;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.hic-ai-chat__wa:hover {
	background: #e3f7ea;
	border-color: #a9dfba;
	color: #0b3d1f;
}

.hic-ai-chat__wa-icon {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--hic-ai-wa);
	color: #fff;
}

.hic-ai-chat__wa-copy {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.hic-ai-chat__wa-copy strong {
	font-size: 0.8rem;
	font-weight: 650;
}

.hic-ai-chat__wa-copy small {
	font-size: 0.68rem;
	opacity: 0.8;
	line-height: 1.3;
}

/* —— Composer —— */
.hic-ai-chat__composer {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--hic-ai-line);
	background: #fff;
}

.hic-ai-chat__composer textarea {
	min-height: 44px;
	max-height: 110px;
	resize: none;
	line-height: 1.4;
	padding-top: 0.7rem;
}

.hic-ai-chat__send {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border-radius: 50%;
}

.hic-ai-chat__send:hover {
	background: #222;
}

.hic-ai-chat__footer {
	padding: 8px 14px;
	border-top: 1px solid var(--hic-ai-line);
	background: #fbfaf8;
	font-size: 0.66rem;
	color: var(--hic-ai-muted);
	letter-spacing: 0.02em;
	text-align: center;
}

/* RTL */
.hic-ai-chat[dir="rtl"] .hic-ai-chat__launcher,
.hic-ai-chat[dir="rtl"] .hic-ai-chat__panel {
	right: auto;
	left: var(--hic-ai-right);
}

.hic-ai-chat[dir="rtl"] .hic-ai-chat__panel {
	transform-origin: bottom left;
}

.hic-ai-chat[dir="rtl"] .hic-ai-chat__bubble--assistant {
	align-self: flex-end;
	border-radius: 14px 4px 14px 14px;
}

.hic-ai-chat[dir="rtl"] .hic-ai-chat__bubble--user {
	align-self: flex-start;
	border-radius: 14px 14px 14px 4px;
}

@media (max-width: 720px) {
	html.hic-ai-chat-open,
	html.hic-ai-chat-open body {
		overflow: hidden;
	}

	body.hso-cta-visible .hic-ai-chat {
		display: none !important;
	}

	.hic-ai-chat {
		--hic-ai-right: 14px;
		--hic-ai-bottom-btn: 78px;
		--hic-ai-launcher-h: 48px;
		--hic-ai-gap: 8px;
	}

	.hic-ai-chat__launcher-label--full {
		display: none;
	}

	.hic-ai-chat__launcher-label--short {
		display: inline;
		font-size: 0.72rem;
		letter-spacing: 0.04em;
		padding-right: 2px;
	}

	.hic-ai-chat__launcher {
		width: auto !important;
		height: 48px !important;
		min-width: 48px !important;
		min-height: 48px !important;
		padding: 0 14px 0 12px !important;
		justify-content: center;
		gap: 7px;
		border-radius: 999px !important;
	}

	.hic-ai-chat__launcher-icon {
		width: 22px;
		height: 22px;
	}

	.hic-ai-chat__launcher-icon svg {
		width: 20px;
		height: 20px;
	}

	.hic-ai-chat__launcher-pulse {
		inset: -3px;
	}

	.hic-ai-chat__panel {
		left: max(8px, env(safe-area-inset-left, 0px));
		right: max(8px, env(safe-area-inset-right, 0px));
		bottom: max(8px, env(safe-area-inset-bottom, 0px));
		width: auto;
		height: min(85dvh, calc(100dvh - 16px - env(safe-area-inset-bottom, 0px)));
		max-height: none;
		border-radius: 14px;
	}

	.hic-ai-chat[dir="rtl"] .hic-ai-chat__panel {
		left: max(8px, env(safe-area-inset-left, 0px));
		right: max(8px, env(safe-area-inset-right, 0px));
	}

	.hic-ai-chat__launcher.is-open {
		opacity: 0;
		pointer-events: none;
		transform: scale(0.8);
	}
}

@media (max-width: 380px) {
	.hic-ai-chat__row {
		grid-template-columns: 1fr;
	}

	.hic-ai-chat__phone {
		grid-template-columns: minmax(84px, 100px) 1fr;
	}

	.hic-ai-chat__wa-copy small {
		display: none;
	}
}
