/* Portfolio chat widget — matches the site's dark #1E1E1E theme */
:root {
	--chat-footer-offset: 0px;
	--chat-gap: 24px;

	/* ---- Theme: matches styles.css (header/footer glass + active nav green) ---- */
	--chat-purple:        rgb(50, 25, 150);          /* same indigo as header/footer */
	--chat-purple-hover:  rgb(72, 44, 186);
	--chat-purple-glass:  rgba(50, 25, 150, 0.45);   /* bubble background */
	--chat-purple-tint:   rgba(50, 25, 150, 0.22);   /* bot messages, header */
	--chat-green:         #50CC16;                   /* active nav item color */
	--chat-panel-bg:      rgba(22, 16, 44, 0.92);    /* window background */
	--chat-line:          rgba(255, 255, 255, 0.15); /* dividers */
}

/* ---------- Floating bubble ---------- */
#chat-launcher {
	position: fixed;
	right: var(--chat-gap);
	bottom: calc(var(--chat-gap) + var(--chat-footer-offset));
	z-index: 99999;
	width: 60px;
	height: 60px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1.5px solid var(--chat-green);
	border-radius: 50%;
	background: var(--chat-purple-glass);
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 10px rgba(80, 204, 22, 0.3);
	transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
#chat-launcher:hover { background: rgba(50, 25, 150, 0.7); transform: scale(1.06); }
#chat-launcher:focus-visible { outline: 2px solid var(--chat-green); outline-offset: 4px; }
#chat-launcher svg { width: 28px; height: 28px; }
#chat-launcher.hidden { opacity: 0; transform: scale(0.6); pointer-events: none; }

/* Dot shown when a reply arrives while the chat is minimized */
.chat-unread {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #e5534b;
	border: 2px solid #1E1E1E;
	display: none;
}
#chat-launcher.has-unread .chat-unread { display: block; }

/* ---------- Floating chat window ---------- */
#chat-panel {
	position: fixed;
	right: var(--chat-gap);
	bottom: calc(var(--chat-gap) + var(--chat-footer-offset));
	z-index: 99999;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 500px;
	max-height: calc(100vh - 48px - var(--chat-footer-offset));
	min-height: 260px;
	display: flex;
	flex-direction: column;
	background: var(--chat-panel-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border: 1px solid rgba(80, 204, 22, 0.45);
	border-radius: 12px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
	overflow: hidden;
	font: 400 14px/1.6 "Lato", sans-serif;
	color: #ddd;
	/* hidden state: slides down and fades out */
	visibility: hidden;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	transform-origin: bottom right;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
#chat-panel.open {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 12px 12px 16px;
	background: var(--chat-purple-tint);
	border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.chat-header h4 {
	margin: 0;
	font: 600 13px "Lato", sans-serif;
	letter-spacing: 3px;
	text-transform: uppercase;
	color: #fff;
}
.chat-header small { display: block; color: var(--chat-green); font-size: 11px; letter-spacing: 0; text-transform: none; }
.chat-minimize {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	background: none;
	border: none;
	border-radius: 6px;
	color: #aaa;
	cursor: pointer;
}
.chat-minimize:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.chat-minimize:focus-visible { outline: 2px solid var(--chat-green); }
.chat-minimize svg { width: 18px; height: 18px; }

.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.chat-msg {
	max-width: 85%;
	padding: 9px 13px;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
	text-align: left;
}
.chat-msg.bot  { align-self: flex-start; background: var(--chat-purple-tint); color: #ececf4; border: 1px solid rgba(255, 255, 255, 0.08); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end;   background: var(--chat-purple); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.error { align-self: flex-start; background: #3a2323; color: #f2c4c4; }

.chat-typing { display: inline-flex; gap: 4px; }
.chat-typing span {
	width: 6px; height: 6px; border-radius: 50%; background: #999;
	animation: chat-blink 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat-suggestions:empty { display: none; }
.chat-suggestions button {
	background: transparent;
	border: 1px solid rgba(80, 204, 22, 0.5);
	border-radius: 999px;
	color: #cfe9c2;
	font: 12px "Lato", sans-serif;
	padding: 4px 10px;
	cursor: pointer;
}
.chat-suggestions button:hover { border-color: var(--chat-green); background: var(--chat-purple-tint); color: #fff; }

.chat-form { display: flex; align-items: stretch; gap: 8px; padding: 12px; border-top: 1px solid var(--chat-line); background: transparent; }
.chat-form textarea {
	flex: 1;
	display: block;
	margin: 0;
	max-width: none;
	resize: none;
	height: 40px;
	max-height: 100px;
	padding: 9px 12px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.35);
	color: #eee !important;
	font: 14px "Lato", sans-serif;
}
.chat-form textarea:focus { outline: none; border-color: var(--chat-green); }
.chat-form button {
	padding: 0 16px;
	border: none;
	border-radius: 8px;
	background: var(--chat-purple);
	color: #fff;
	font: 600 13px "Lato", sans-serif;
	cursor: pointer;
	transition: background 0.15s ease;
}
.chat-form button:hover:not(:disabled) { background: var(--chat-purple-hover); }
.chat-form button:focus-visible { outline: 2px solid var(--chat-green); outline-offset: 2px; }
.chat-form button:disabled { opacity: 0.5; cursor: default; }

.chat-footnote { padding: 0 12px 8px; background: transparent; font-size: 10px; color: #8a86a3; text-align: center; }

@media (prefers-reduced-motion: reduce) {
	#chat-launcher, #chat-panel { transition: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 480px) {
	:root { --chat-gap: 16px; }
	#chat-launcher { width: 56px; height: 56px; }
	#chat-panel { width: calc(100vw - 32px); height: calc(100vh - 32px - var(--chat-footer-offset)); }
}

/* ---------- Section mode: chat placed inside <div id="chat-embed"> ---------- */
.chat-section-intro {
	text-align: center;
	color: #bbb;
	max-width: 720px;
	margin: 0 auto 24px;
}
#chat-embed {
	position: relative;
	z-index: 1;
	clear: both;
	max-width: 720px;
	margin: 0 auto;
}
#chat-panel.embedded {
	position: static;
	width: 100%;
	max-width: 100%;
	height: 480px;
	max-height: none;
	visibility: visible;
	opacity: 1;
	transform: none;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#chat-panel.embedded .chat-minimize { display: none; }

@media (max-width: 480px) {
	#chat-panel.embedded { height: 440px; }
}
