/* DWC AI Real Estate Concierge — widget styles
 * Scoped under #dwc-ai-concierge-root to avoid theme conflicts.
 * Accent color is injected at runtime via the --dwc-accent custom property.
 */

#dwc-ai-concierge-root {
	--dwc-accent: #0f766e;
	--dwc-accent-dark: #0b574f;
	--dwc-bg: #ffffff;
	--dwc-text: #1f2937;
	--dwc-muted: #6b7280;
	--dwc-user-bubble: #0f766e;
	--dwc-bot-bubble: #f3f4f6;
	--dwc-border: #e5e7eb;
	--dwc-surface: #fafafa;
	--dwc-radius: 16px;
	--dwc-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Dark mode ─────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
	#dwc-ai-concierge-root {
		--dwc-bg: #1e1e2e;
		--dwc-text: #e2e8f0;
		--dwc-muted: #94a3b8;
		--dwc-bot-bubble: #2d2d44;
		--dwc-border: #3f3f5c;
		--dwc-surface: #16162a;
		--dwc-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
	}
}

/* ── Launcher button ───────────────────────────────────────────────────── */
.dwc-launcher {
	position: fixed;
	bottom: 22px;
	z-index: 999990;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	background: var(--dwc-accent);
	color: #fff;
	cursor: pointer;
	box-shadow: var(--dwc-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.dwc-launcher:hover  { transform: translateY(-3px) scale(1.06); background: var(--dwc-accent-dark); box-shadow: 0 16px 48px rgba(0,0,0,0.24); }
.dwc-launcher:active { transform: translateY(0) scale(0.97); }
.dwc-launcher svg    { width: 28px; height: 28px; }

/* ── Avatar launcher ───────────────────────────────────────────────────── */
/* When an avatar is configured the photo *is* the button: the accent circle
   and padding are dropped so the transparent PNG edge reads as the edge. */
.dwc-launcher.dwc-has-avatar {
	width: 68px;
	height: 68px;
	background: transparent;
	box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
	overflow: visible;
}
.dwc-launcher.dwc-has-avatar:hover { background: transparent; }
.dwc-launcher.dwc-has-avatar > span { width: 100%; height: 100%; }
.dwc-launcher-avatar {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	display: block;
	object-fit: cover;
}

/* Attention pulse while the panel has not been opened yet. */
@keyframes dwc-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(41, 141, 235, 0.55); }
	70%  { box-shadow: 0 0 0 16px rgba(41, 141, 235, 0); }
	100% { box-shadow: 0 0 0 0 rgba(41, 141, 235, 0); }
}
.dwc-launcher.dwc-pulsing .dwc-launcher-avatar { animation: dwc-pulse 2.2s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
	.dwc-launcher.dwc-pulsing .dwc-launcher-avatar { animation: none; }
	.dwc-launcher { transition: none; }
}
.dwc-pos-right .dwc-launcher { right: 22px; }
.dwc-pos-left  .dwc-launcher { left:  22px; }

/* Unread badge on launcher */
.dwc-launcher-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	padding: 0 5px;
	box-sizing: border-box;
	border: 2px solid #fff;
	animation: dwc-badge-pop 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
	pointer-events: none;
}
@keyframes dwc-badge-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ── Panel ─────────────────────────────────────────────────────────────── */
/*
 * FIX: Previously used display:none which breaks CSS transitions.
 * Now uses visibility + pointer-events so opacity/transform animate properly.
 * JS still adds/removes .dwc-open; the hidden state is handled by CSS.
 */
.dwc-panel {
	position: fixed;
	bottom: 96px;
	z-index: 999991;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 130px);
	background: var(--dwc-bg);
	border-radius: var(--dwc-radius);
	box-shadow: var(--dwc-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	/* Hidden state — no display:none so transitions work */
	visibility: hidden;
	pointer-events: none;
	opacity: 0;
	transform: translateY(16px) scale(0.97);
	transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.3,0.64,1), visibility 0s linear 0.22s;
}
.dwc-panel.dwc-open {
	visibility: visible;
	pointer-events: auto;
	opacity: 1;
	transform: translateY(0) scale(1);
	transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.3,0.64,1), visibility 0s linear 0s;
}
.dwc-pos-right .dwc-panel { right: 22px; }
.dwc-pos-left  .dwc-panel { left:  22px; }

/* ── Header ────────────────────────────────────────────────────────────── */
.dwc-header {
	background: linear-gradient(135deg, var(--dwc-accent) 0%, var(--dwc-accent-dark) 100%);
	color: #fff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.dwc-header-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dwc-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	display: inline-block;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
	animation: dwc-status-pulse 2.4s infinite;
}
@keyframes dwc-status-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(74,222,128,0.6); }
	60%  { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
	100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.dwc-close { background: none; border: none; color: #fff; cursor: pointer; opacity: 0.8; padding: 4px; border-radius: 6px; transition: opacity 0.15s ease, background 0.15s ease; }
.dwc-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* ── Messages ──────────────────────────────────────────────────────────── */
.dwc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--dwc-surface);
	scroll-behavior: smooth;
}
.dwc-msg {
	max-width: 84%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	/* Fade-in animation for each new message */
	animation: dwc-msg-in 0.22s ease both;
}
@keyframes dwc-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}
.dwc-msg-bot  { background: var(--dwc-bot-bubble); color: var(--dwc-text); align-self: flex-start; border-bottom-left-radius: 4px; }
.dwc-msg-user { background: var(--dwc-accent);     color: #fff;            align-self: flex-end;   border-bottom-right-radius: 4px; }
.dwc-msg a    { color: inherit; text-decoration: underline; }

/* ── Typing indicator ──────────────────────────────────────────────────── */
.dwc-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; transition: opacity 0.2s ease; }
.dwc-typing.dwc-fade-out { opacity: 0; }
.dwc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--dwc-muted); animation: dwc-bounce 1.2s infinite ease-in-out; }
.dwc-typing span:nth-child(2) { animation-delay: 0.15s; }
.dwc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dwc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ── Suggested prompts ─────────────────────────────────────────────────── */
.dwc-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.dwc-chip {
	background: var(--dwc-bg);
	border: 1px solid var(--dwc-accent);
	color: var(--dwc-accent);
	border-radius: 20px;
	padding: 6px 12px;
	font-size: 12px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.dwc-chip:hover  { background: var(--dwc-accent); color: #fff; transform: translateY(-1px); }
.dwc-chip:active { transform: translateY(0); }

/* ── Lead form ─────────────────────────────────────────────────────────── */
.dwc-lead-form { padding: 14px 16px; border-top: 1px solid var(--dwc-border); background: var(--dwc-bg); }
.dwc-lead-form h4 { margin: 0 0 8px; font-size: 14px; color: var(--dwc-text); }
.dwc-lead-form input {
	width: 100%;
	padding: 9px 11px;
	margin-bottom: 8px;
	border: 1px solid var(--dwc-border);
	border-radius: 8px;
	font-size: 14px;
	box-sizing: border-box;
	background: var(--dwc-bg);
	color: var(--dwc-text);
	transition: border-color 0.15s ease;
}
.dwc-lead-form input:focus { outline: none; border-color: var(--dwc-accent); }
.dwc-lead-form button { width: 100%; }

/* ── GDPR consent gate ─────────────────────────────────────────────────── */
.dwc-consent { padding: 14px 16px; border-top: 1px solid var(--dwc-border); background: var(--dwc-bg); font-size: 13px; color: var(--dwc-text); }
.dwc-consent p { margin: 0 0 10px; line-height: 1.4; }

/* ── Inline booking embed ──────────────────────────────────────────────── */
.dwc-booking-embed { align-self: stretch; margin: 4px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--dwc-border); background: var(--dwc-bg); }
.dwc-booking-embed iframe { width: 100%; height: 320px; border: none; display: block; }
.dwc-booking-fallback { padding: 6px 10px; font-size: 11px; text-align: center; background: var(--dwc-surface); border-top: 1px solid var(--dwc-border); }
.dwc-booking-fallback a { color: var(--dwc-accent); }

/* ── Structured listing cards ──────────────────────────────────────────── */
.dwc-listings-row { align-self: stretch; display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.dwc-listing-card {
	display: flex;
	gap: 10px;
	background: var(--dwc-bg);
	border: 1px solid var(--dwc-border);
	border-radius: 10px;
	padding: 8px;
	cursor: pointer;
	text-decoration: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.dwc-listing-card:hover {
	border-color: var(--dwc-accent);
	box-shadow: 0 4px 16px rgba(15,118,110,0.18);
	transform: translateY(-2px);
}
.dwc-listing-card img, .dwc-listing-noimg { width: 72px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--dwc-border); flex-shrink: 0; }
.dwc-listing-body { flex: 1; min-width: 0; }
.dwc-listing-price { font-weight: 700; font-size: 14px; color: var(--dwc-text); }
.dwc-listing-meta { font-size: 12px; color: var(--dwc-muted); margin: 2px 0; }
.dwc-listing-addr { font-size: 12px; color: var(--dwc-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dwc-listing-link { font-size: 12px; color: var(--dwc-accent); text-decoration: underline; }
.dwc-save-search-link { align-self: flex-start; font-size: 12px; color: var(--dwc-accent); text-decoration: underline; margin: 2px 0 6px 4px; }

/* ── Composer ──────────────────────────────────────────────────────────── */
.dwc-composer { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--dwc-border); background: var(--dwc-bg); flex-shrink: 0; }
.dwc-input {
	flex: 1;
	border: 1px solid var(--dwc-border);
	border-radius: 22px;
	padding: 10px 14px;
	font-size: 14px;
	outline: none;
	resize: none;
	max-height: 90px;
	background: var(--dwc-bg);
	color: var(--dwc-text);
	transition: border-color 0.15s ease;
}
.dwc-input:focus { border-color: var(--dwc-accent); }
.dwc-btn {
	border: none; background: var(--dwc-accent); color: #fff; width: 40px; height: 40px;
	border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
	flex-shrink: 0; transition: background 0.15s ease, transform 0.12s ease;
}
.dwc-btn:hover    { background: var(--dwc-accent-dark); transform: scale(1.08); }
.dwc-btn:active   { transform: scale(0.95); }
.dwc-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.dwc-btn svg { width: 18px; height: 18px; }
.dwc-mic.dwc-listening { background: #dc2626; animation: dwc-pulse 1.2s infinite; }
@keyframes dwc-pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); } 70% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }

.dwc-footer-note { text-align: center; font-size: 11px; color: var(--dwc-muted); padding: 4px 0 10px; flex-shrink: 0; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	.dwc-panel { width: calc(100vw - 24px); height: calc(100vh - 110px); bottom: 88px; }
	.dwc-pos-right .dwc-panel, .dwc-pos-left .dwc-panel { right: 12px; left: 12px; }
}
