/**
 * AI estimate chat — floating cloud / bubble launcher
 */

.irias-estimate-chat {
	position: fixed;
	right: 1rem;
	bottom: 5.25rem;
	z-index: 100000;
	font-family: "Plus Jakarta Sans", system-ui, sans-serif;
	pointer-events: auto;
}

@media (min-width: 768px) {
	.irias-estimate-chat {
		bottom: 1.25rem;
		right: 1.25rem;
	}
}

/* FAB column: hint + cloud bubble */
.irias-estimate-chat__fab {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.35rem;
}

.irias-estimate-chat__fab-hint {
	margin: 0;
	padding: 0.35rem 0.65rem;
	max-width: 11rem;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1.3;
	color: #3d3830;
	text-align: right;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 1rem 1rem 0.35rem 1rem;
	box-shadow: 0 2px 12px rgba(30, 20, 10, 0.12);
	border: 1px solid rgba(196, 92, 38, 0.15);
	animation: irias-chat-hint-in 0.5s ease 0.3s both;
}

@keyframes irias-chat-hint-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.irias-estimate-chat[data-open="true"] .irias-estimate-chat__fab-hint {
	display: none;
}

/* Launcher = soft cloud + chat icon */
.irias-estimate-chat__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none;
	cursor: pointer;
	background: transparent;
	filter: drop-shadow(0 6px 16px rgba(30, 20, 10, 0.2));
	transition: transform 0.2s ease, filter 0.2s ease;
}

.irias-estimate-chat__launcher:hover {
	transform: scale(1.06);
	filter: drop-shadow(0 8px 22px rgba(196, 92, 38, 0.35));
}

.irias-estimate-chat__launcher:focus-visible {
	outline: 3px solid var(--brand-accent, #c45c26);
	outline-offset: 4px;
	border-radius: 50%;
}

.irias-estimate-chat__launcher-cloud {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 4rem;
	height: 3.35rem;
	background: linear-gradient(165deg, #ffffff 0%, #fff5ee 45%, #ffe4d4 100%);
	border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
	box-shadow:
		inset 0 2px 0 rgba(255, 255, 255, 0.85),
		0 0 0 2px rgba(196, 92, 38, 0.22);
}

/* Small “cloud puffs” for a fluffier silhouette */
.irias-estimate-chat__cloud-puff {
	position: absolute;
	background: linear-gradient(180deg, #ffffff 0%, #fff0e6 100%);
	border-radius: 50%;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
	border: 1px solid rgba(196, 92, 38, 0.12);
}

.irias-estimate-chat__cloud-puff--1 {
	width: 1.35rem;
	height: 1.1rem;
	top: -0.15rem;
	left: 0.35rem;
}

.irias-estimate-chat__cloud-puff--2 {
	width: 1.5rem;
	height: 1.2rem;
	top: -0.2rem;
	right: 0.25rem;
}

.irias-estimate-chat__cloud-puff--3 {
	width: 1.1rem;
	height: 0.95rem;
	bottom: 0.1rem;
	left: -0.15rem;
}

.irias-estimate-chat__launcher-icon {
	position: relative;
	z-index: 1;
	display: flex;
	color: var(--brand-accent, #c45c26);
	margin-top: 0.15rem;
}

/* Speech-bubble tail */
.irias-estimate-chat__launcher-tail {
	position: absolute;
	bottom: -0.2rem;
	right: 1.1rem;
	width: 0.85rem;
	height: 0.85rem;
	background: linear-gradient(135deg, #ffe4d4 0%, #ffd4c0 100%);
	border-radius: 0 0 3px 0;
	transform: rotate(45deg);
	box-shadow: 2px 2px 0 rgba(196, 92, 38, 0.15);
	z-index: 0;
}

.irias-estimate-chat[data-open="true"] .irias-estimate-chat__fab {
	display: none;
}

/* Chat window — rounded “bubble” card */
.irias-estimate-chat__panel {
	position: absolute;
	right: 0;
	bottom: 0;
	width: min(100vw - 2rem, 23rem);
	max-height: min(72vh, 30rem);
	display: flex;
	flex-direction: column;
	background: linear-gradient(180deg, #fffefb 0%, #fff8f2 100%);
	border-radius: 1.25rem 1.25rem 0.75rem 1.25rem;
	box-shadow:
		0 4px 0 rgba(196, 92, 38, 0.08),
		0 20px 50px rgba(30, 20, 10, 0.22);
	border: 1px solid rgba(196, 92, 38, 0.18);
	overflow: hidden;
	animation: irias-chat-panel-in 0.25s ease;
}

/*
 * Without this, `display: flex` above overrides the native [hidden] behavior
 * in several browsers — the panel stays on screen after close.
 */
.irias-estimate-chat__panel[hidden] {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

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

.irias-estimate-chat__head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 1rem 1rem 0.75rem;
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 236, 224, 0.5));
	border-bottom: 1px solid rgba(196, 92, 38, 0.1);
}

.irias-estimate-chat__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: #1a1510;
}

.irias-estimate-chat__subtitle {
	margin: 0.2rem 0 0;
	font-size: 0.75rem;
	color: #5c5348;
}

.irias-estimate-chat__close {
	border: none;
	background: rgba(255, 255, 255, 0.7);
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	color: #5c5348;
	padding: 0.15rem 0.45rem;
	border-radius: 50%;
	transition: background 0.15s ease, color 0.15s ease;
}

.irias-estimate-chat__close:hover {
	background: rgba(196, 92, 38, 0.12);
	color: #1a1510;
}

.irias-estimate-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 0.75rem 1rem;
	min-height: 10rem;
	max-height: 16rem;
	background: rgba(255, 255, 255, 0.5);
}

.irias-estimate-chat__bubble {
	margin: 0 0 0.65rem;
	max-width: 95%;
}

.irias-estimate-chat__bubble p {
	margin: 0;
	padding: 0.55rem 0.75rem;
	border-radius: 1rem 1rem 1rem 0.35rem;
	font-size: 0.9rem;
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
}

.irias-estimate-chat__bubble--assistant p {
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.06);
	color: #2a241c;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.irias-estimate-chat__bubble--user {
	margin-left: auto;
	text-align: right;
}

.irias-estimate-chat__bubble--user p {
	background: var(--brand-accent, #c45c26);
	color: #fff;
	display: inline-block;
	text-align: left;
	border-radius: 1rem 1rem 0.35rem 1rem;
}

.irias-estimate-chat__done {
	margin: 0.5rem 0 0;
	padding: 0.5rem;
	font-size: 0.82rem;
	color: #2d6a4f;
	background: rgba(45, 106, 79, 0.1);
	border-radius: 0.75rem;
	text-align: center;
}

.irias-estimate-chat__thumb {
	display: block;
	max-width: 140px;
	max-height: 140px;
	margin-top: 0.35rem;
	border-radius: 0.5rem;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.35);
}

.irias-estimate-chat__bubble--user .irias-estimate-chat__thumb {
	margin-left: auto;
}

.irias-estimate-chat__previews {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	align-items: flex-start;
}

.irias-estimate-chat__preview {
	position: relative;
	width: 3.25rem;
	height: 3.25rem;
	flex-shrink: 0;
}

.irias-estimate-chat__preview img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 0.4rem;
	border: 1px solid rgba(0, 0, 0, 0.1);
}

.irias-estimate-chat__preview-remove {
	position: absolute;
	top: -0.4rem;
	right: -0.4rem;
	width: 1.2rem;
	height: 1.2rem;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #2a241c;
	color: #fff;
	font-size: 0.85rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.irias-estimate-chat__toolbar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.irias-estimate-chat__file {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.irias-estimate-chat__attach {
	display: inline-block;
	padding: 0.35rem 0.7rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--brand-accent, #c45c26);
	border: 1px solid rgba(196, 92, 38, 0.35);
	border-radius: 0.55rem;
	cursor: pointer;
	background: #fffef9;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.irias-estimate-chat__attach:hover {
	background: rgba(196, 92, 38, 0.08);
	border-color: rgba(196, 92, 38, 0.55);
}

.irias-estimate-chat__composer {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 0.75rem 1rem 0.5rem;
	border-top: 1px solid rgba(196, 92, 38, 0.1);
	background: #fff;
}

.irias-estimate-chat__input {
	width: 100%;
	resize: none;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 0.85rem;
	padding: 0.5rem 0.75rem;
	font: inherit;
	font-size: 0.9rem;
}

.irias-estimate-chat__input:focus {
	outline: 2px solid var(--brand-accent, #c45c26);
	outline-offset: 1px;
}

.irias-estimate-chat__send {
	align-self: flex-end;
}

.irias-estimate-chat__fineprint {
	margin: 0;
	padding: 0 1rem 0.75rem;
	font-size: 0.65rem;
	color: #7a7165;
	line-height: 1.35;
	background: #fff;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.irias-estimate-chat__fab-hint,
	.irias-estimate-chat__panel {
		animation: none;
	}
}
