/* =====================================================
   HauenMedia Live Chat — Public Widget CSS
   Light Theme · v1.0.0
   ===================================================== */

:root {
	--hmlc-accent:      #2563EB;
	--hmlc-accent-h:    #1d4ed8;
	--hmlc-accent-rgb:  37,99,235;
	--hmlc-accent-light:#eff6ff;
	--hmlc-white:       #ffffff;
	--hmlc-bg:          #f8fafc;
	--hmlc-border:      #e2e8f0;
	--hmlc-text:        #1e293b;
	--hmlc-muted:       #64748b;
	--hmlc-xs:          #94a3b8;
	--hmlc-radius:      20px;
	--hmlc-radius-sm:   12px;
	--hmlc-shadow:      0 24px 64px -12px rgba(0,0,0,.22), 0 8px 24px rgba(0,0,0,.09);
	--hmlc-shadow-btn:  0 4px 14px rgba(37,99,235,.38);
	--hmlc-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
	--hmlc-z:           2147483647;
}

/* ── Root container ── */
#hmlc-root {
	position: fixed;
	bottom: 28px;
	right: 28px;
	z-index: var(--hmlc-z);
	font-family: var(--hmlc-font);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	color: var(--hmlc-text);
}
#hmlc-root[data-position="left"] { right: auto; left: 28px; }

/* ════════════════ BUBBLE ════════════════ */
#hmlc-bubble {
	width: 60px; height: 60px;
	border-radius: 50%;
	background: var(--hmlc-accent);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--hmlc-shadow-btn);
	transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
	position: relative;
	outline: none;
}
#hmlc-bubble:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 24px rgba(var(--hmlc-accent-rgb),.5);
}
#hmlc-bubble:active { transform: scale(.94); }

/* Icon swap animation */
#hmlc-bubble .icon-chat,
#hmlc-bubble .icon-close {
	position: absolute;
	transition: transform .25s ease, opacity .2s ease;
}
#hmlc-bubble .icon-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
#hmlc-bubble.is-open .icon-chat  { opacity: 0; transform: rotate(90deg) scale(.5); }
#hmlc-bubble.is-open .icon-close { opacity: 1; transform: rotate(0) scale(1); }

/* Notification dot */
#hmlc-notif-dot {
	position: absolute;
	top: 4px; right: 4px;
	width: 14px; height: 14px;
	background: #ef4444;
	border: 3px solid var(--hmlc-white);
	border-radius: 50%;
	display: none;
	animation: hmlc-pop .3s cubic-bezier(.34,1.56,.64,1);
}
#hmlc-notif-dot.visible { display: block; }
@keyframes hmlc-pop { from { transform:scale(0); } to { transform:scale(1); } }

/* ════════════════ CHAT WINDOW ════════════════ */
#hmlc-window {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 375px;
	max-height: 600px;
	background: var(--hmlc-white);
	border-radius: var(--hmlc-radius);
	box-shadow: var(--hmlc-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transform: scale(.88) translateY(16px);
	opacity: 0;
	pointer-events: none;
	transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
	border: 1px solid rgba(0,0,0,.06);
}
#hmlc-root[data-position="left"] #hmlc-window {
	right: auto; left: 0;
	transform-origin: bottom left;
}
#hmlc-window.is-open {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: all;
}

/* ════════════════ HEADER ════════════════ */
#hmlc-header {
	padding: 18px 20px 16px;
	background: var(--hmlc-accent);
	color: #fff;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
.hmlc-header-avatar {
	width: 44px; height: 44px;
	border-radius: 50%;
	background: rgba(255,255,255,.18);
	display: flex; align-items: center; justify-content: center;
	font-size: 22px; flex-shrink: 0;
	border: 2px solid rgba(255,255,255,.28);
}
.hmlc-header-text { flex: 1; min-width: 0; }
.hmlc-header-title {
	font-size: 15px; font-weight: 700; letter-spacing: -.01em;
}
.hmlc-header-subtitle {
	font-size: 11.5px; opacity: .82; margin-top: 2px;
	display: flex; align-items: center; gap: 5px;
}
.hmlc-online-dot {
	width: 7px; height: 7px;
	background: #4ade80; border-radius: 50%; flex-shrink: 0;
	box-shadow: 0 0 0 2px rgba(74,222,128,.3);
	animation: hmlc-pulse 2s ease-in-out infinite;
}
@keyframes hmlc-pulse {
	0%,100% { box-shadow: 0 0 0 2px rgba(74,222,128,.3); }
	50%      { box-shadow: 0 0 0 6px rgba(74,222,128,.08); }
}
.hmlc-header-close {
	width: 32px; height: 32px; border-radius: 50%;
	background: rgba(255,255,255,.15); border: none;
	color: #fff; cursor: pointer; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	transition: background .15s;
}
.hmlc-header-close:hover { background: rgba(255,255,255,.28); }

/* ════════════════ BODY / PANELS ════════════════ */
#hmlc-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.hmlc-panel {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	min-height: 0;
}

/* ════════════════ PRE-CHAT PANEL ════════════════ */
#hmlc-panel-prechat {
	padding: 24px 20px 20px;
	background: var(--hmlc-bg);
	gap: 0;
}

.hmlc-prechat-welcome {
	text-align: center;
	padding-bottom: 22px;
}
.hmlc-prechat-welcome-icon {
	font-size: 46px;
	line-height: 1;
	margin-bottom: 12px;
}
.hmlc-prechat-welcome h3 {
	font-size: 17px; font-weight: 700;
	color: var(--hmlc-text); margin: 0 0 6px;
}
.hmlc-prechat-welcome p {
	font-size: 13.5px; color: var(--hmlc-muted); margin: 0;
}

/* Form fields */
.hmlc-field { margin-bottom: 14px; }

.hmlc-label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--hmlc-text);
	margin-bottom: 7px;
	letter-spacing: .01em;
}
.hmlc-required { color: #ef4444; }

.hmlc-field-input {
	width: 100%;
	padding: 11px 14px;
	border: 1.5px solid var(--hmlc-border);
	border-radius: var(--hmlc-radius-sm);
	font-size: 14px;
	font-family: var(--hmlc-font);
	color: var(--hmlc-text);
	background: var(--hmlc-white);
	box-sizing: border-box;
	outline: none;
	transition: border-color .15s, box-shadow .15s;
	-webkit-appearance: none;
}
.hmlc-field-input::placeholder { color: var(--hmlc-xs); }
.hmlc-field-input:focus {
	border-color: var(--hmlc-accent);
	box-shadow: 0 0 0 3.5px rgba(var(--hmlc-accent-rgb),.13);
}
.hmlc-field-input.error {
	border-color: #ef4444;
	box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

.hmlc-start-btn {
	width: 100%;
	padding: 13px 20px;
	margin-top: 4px;
	background: var(--hmlc-accent);
	color: #fff;
	border: none;
	border-radius: var(--hmlc-radius-sm);
	font-size: 14.5px;
	font-weight: 700;
	font-family: var(--hmlc-font);
	cursor: pointer;
	transition: background .15s, transform .1s, box-shadow .15s;
	box-shadow: var(--hmlc-shadow-btn);
	letter-spacing: .01em;
}
.hmlc-start-btn:hover:not(:disabled) {
	background: var(--hmlc-accent-h);
	box-shadow: 0 6px 20px rgba(var(--hmlc-accent-rgb),.42);
}
.hmlc-start-btn:active:not(:disabled) { transform: scale(.98); }
.hmlc-start-btn:disabled {
	opacity: .6; cursor: not-allowed; box-shadow: none;
}

.hmlc-error-msg {
	display: none;
	margin-top: 10px;
	padding: 10px 14px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 8px;
	font-size: 13px;
	color: #dc2626;
	text-align: center;
}

/* ════════════════ OFFLINE PANEL ════════════════ */
#hmlc-panel-offline {
	padding: 40px 24px;
	text-align: center;
	background: var(--hmlc-bg);
	align-items: center;
	justify-content: center;
	gap: 12px;
}
.hmlc-offline-icon { font-size: 44px; }
.hmlc-offline-text {
	font-size: 14px; color: var(--hmlc-muted);
	line-height: 1.65; max-width: 260px;
}

/* ════════════════ CHAT PANEL ════════════════ */
#hmlc-panel-chat {
	background: var(--hmlc-bg);
	padding: 0;
	overflow: hidden;     /* children handle their own scroll */
	overflow-y: unset;    /* override .hmlc-panel's overflow-y: auto */
}

#hmlc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 0;
}

/* Message rows */
.hmlc-msg-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	animation: hmlc-slide-up .2s ease;
}
@keyframes hmlc-slide-up {
	from { opacity:0; transform:translateY(8px); }
	to   { opacity:1; transform:translateY(0); }
}
.hmlc-msg-row.mine        { flex-direction: row-reverse; }
.hmlc-msg-row.system-row  { justify-content: center; }

.hmlc-msg-av {
	width: 30px; height: 30px; border-radius: 50%;
	background: var(--hmlc-accent); color: #fff;
	font-size: 12px; font-weight: 700; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	margin-bottom: 2px;
}
.hmlc-msg-av.bot-av { background: #7c3aed; font-size: 15px; }

.hmlc-msg-body {
	max-width: 78%;
	display: flex; flex-direction: column; gap: 3px;
}
.hmlc-msg-row.mine .hmlc-msg-body { align-items: flex-end; }

.hmlc-bubble {
	padding: 10px 14px;
	border-radius: 18px 18px 18px 4px;
	font-size: 13.5px; line-height: 1.5;
	word-break: break-word;
	background: var(--hmlc-white);
	color: var(--hmlc-text);
	border: 1px solid var(--hmlc-border);
	box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.hmlc-msg-row.mine .hmlc-bubble {
	background: var(--hmlc-accent); color: #fff;
	border: none; border-radius: 18px 18px 4px 18px;
	box-shadow: 0 2px 10px rgba(var(--hmlc-accent-rgb),.28);
}
.hmlc-bubble.system {
	background: #f1f5f9; color: var(--hmlc-muted);
	font-size: 12px; border: none; border-radius: 8px;
	padding: 6px 14px; box-shadow: none; text-align: center;
}
.hmlc-msg-time {
	font-size: 10px; color: var(--hmlc-xs); padding: 0 2px;
}

/* Input bar */
#hmlc-input-bar {
	padding: 12px 14px;
	border-top: 1px solid var(--hmlc-border);
	background: var(--hmlc-white);
	display: flex;
	align-items: flex-end;
	gap: 10px;
	flex-shrink: 0;
}
#hmlc-text-input {
	flex: 1; resize: none;
	border: 1.5px solid var(--hmlc-border);
	border-radius: 14px;
	padding: 10px 14px;
	font-size: 13.5px;
	font-family: var(--hmlc-font);
	color: var(--hmlc-text);
	background: var(--hmlc-bg);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
	max-height: 110px; min-height: 42px;
	overflow-y: auto; line-height: 1.45;
}
#hmlc-text-input:focus {
	border-color: var(--hmlc-accent);
	background: var(--hmlc-white);
	box-shadow: 0 0 0 3px rgba(var(--hmlc-accent-rgb),.1);
}
#hmlc-text-input::placeholder { color: var(--hmlc-xs); }
#hmlc-send {
	width: 44px; height: 44px; border-radius: 50%;
	background: var(--hmlc-accent); color: #fff;
	border: none; cursor: pointer; flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	transition: background .15s, transform .1s, box-shadow .15s;
	box-shadow: 0 2px 8px rgba(var(--hmlc-accent-rgb),.32);
}
#hmlc-send:hover:not(:disabled) {
	background: var(--hmlc-accent-h);
	box-shadow: 0 4px 16px rgba(var(--hmlc-accent-rgb),.42);
}
#hmlc-send:active { transform: scale(.9); }
#hmlc-send:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ════════════════ RATING PANEL ════════════════ */
#hmlc-panel-rating {
	padding: 28px 24px 20px;
	text-align: center;
	background: var(--hmlc-bg);
	align-items: center;
	justify-content: center;
	gap: 12px;
}
.hmlc-rating-title { font-size: 16px; font-weight: 700; color: var(--hmlc-text); }
.hmlc-rating-sub   { font-size: 13.5px; color: var(--hmlc-muted); }
.hmlc-stars { display: flex; gap: 6px; }
.hmlc-star {
	font-size: 32px; cursor: pointer;
	color: #d1d5db;
	transition: color .12s, transform .12s;
}
.hmlc-star:hover,
.hmlc-star.active { color: #f59e0b; }
.hmlc-star:hover  { transform: scale(1.2); }
.hmlc-rate-comment {
	width: 100%; padding: 10px 12px;
	border: 1.5px solid var(--hmlc-border); border-radius: var(--hmlc-radius-sm);
	font-size: 13px; font-family: var(--hmlc-font);
	resize: none; outline: none; box-sizing: border-box;
}
.hmlc-rate-comment:focus { border-color: var(--hmlc-accent); }
.hmlc-rate-submit {
	padding: 11px 28px;
	background: var(--hmlc-accent); color: #fff;
	border: none; border-radius: var(--hmlc-radius-sm);
	font-size: 13.5px; font-weight: 600;
	font-family: var(--hmlc-font); cursor: pointer;
	box-shadow: var(--hmlc-shadow-btn);
	transition: background .15s;
}
.hmlc-rate-submit:hover { background: var(--hmlc-accent-h); }

.hmlc-thankyou {
	display: flex; flex-direction: column;
	align-items: center; gap: 10px;
	padding: 20px;
	font-size: 14px; color: var(--hmlc-muted);
}
.hmlc-thankyou strong { font-size: 16px; color: var(--hmlc-text); }

/* ════════════════ FOOTER ════════════════ */
#hmlc-footer {
	padding: 8px 14px;
	font-size: 11px;
	color: var(--hmlc-xs);
	border-top: 1px solid var(--hmlc-border);
	background: var(--hmlc-white);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}
.hmlc-close-chat-link {
	color: var(--hmlc-xs);
	text-decoration: none;
	cursor: pointer;
	border-left: 1px solid var(--hmlc-border);
	padding-left: 8px;
	transition: color .12s;
}
.hmlc-close-chat-link:hover { color: #ef4444; }

/* ════════════════ SCROLLBARS ════════════════ */
#hmlc-messages::-webkit-scrollbar,
#hmlc-panel-prechat::-webkit-scrollbar { width: 4px; }
#hmlc-messages::-webkit-scrollbar-track,
#hmlc-panel-prechat::-webkit-scrollbar-track { background: transparent; }
#hmlc-messages::-webkit-scrollbar-thumb,
#hmlc-panel-prechat::-webkit-scrollbar-thumb {
	background: #cbd5e1; border-radius: 2px;
}

/* ════════════════ MOBILE ════════════════ */
@media (max-width: 440px) {
	#hmlc-root { bottom: 16px; right: 16px; }
	#hmlc-root[data-position="left"] { left: 16px; right: auto; }
	#hmlc-window {
		width: calc(100vw - 24px);
		right: -8px;
		max-height: 72vh;
	}
	#hmlc-root[data-position="left"] #hmlc-window { left: -8px; right: auto; }
}

/* ── File upload button ── */
#hmlc-upload-btn {
	width: 36px; height: 36px;
	border-radius: 10px;
	background: transparent;
	color: var(--hmlc-text-muted);
	border: 1.5px solid var(--hmlc-border);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: all .15s;
}
#hmlc-upload-btn:hover {
	background: var(--hmlc-accent-light);
	color: var(--hmlc-accent);
	border-color: var(--hmlc-accent);
}

/* ── Chat image ── */
.hmlc-chat-img {
	max-width: 200px;
	max-height: 200px;
	border-radius: 10px;
	display: block;
	cursor: pointer;
	object-fit: cover;
}

/* ── File link ── */
.hmlc-file-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: inherit;
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	padding: 2px 0;
}
.hmlc-file-link:hover { text-decoration: underline; }
.hmlc-msg-row.mine .hmlc-file-link { color: #fff; }

/* ── Upload pending bubble ── */
.hmlc-upload-pending {
	opacity: .6;
	font-style: italic;
}

/* ── Department picker ── */
#hmlc-dept-picker {
	background: var(--hmlc-white);
	border: 1px solid var(--hmlc-border);
	border-radius: 14px;
	padding: 12px 14px;
	margin: 4px 0;
	align-self: stretch;
	animation: hmlc-slide-up .22s ease;
}
.hmlc-dept-picker-prompt {
	font-size: 12.5px;
	color: var(--hmlc-text-muted);
	margin-bottom: 10px;
	line-height: 1.45;
}
.hmlc-dept-picker-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}
.hmlc-dept-pill {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 6px 14px;
	border-radius: 20px;
	border: none;
	background: var(--dc, #2563EB);
	color: #fff;
	font-size: 12.5px;
	font-weight: 600;
	font-family: var(--hmlc-font);
	cursor: pointer;
	transition: transform .12s, box-shadow .12s, filter .12s;
	box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.hmlc-dept-pill:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0,0,0,.18);
	filter: brightness(1.08);
}
.hmlc-dept-pill:active { transform: scale(.96); }

/* System message for dept selection */
.hmlc-dept-selected-msg {
	font-size: 12px;
	color: var(--hmlc-text-muted);
}
.hmlc-dept-selected-msg strong { color: var(--hmlc-text); }

/* ── Emoji button ── */
#hmlc-emoji-wrap {
	position: relative;
	flex-shrink: 0;
}
#hmlc-emoji-btn {
	width: 36px; height: 36px;
	border-radius: 10px;
	background: transparent;
	border: 1.5px solid var(--hmlc-border);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
	line-height: 1;
	transition: all .15s;
	flex-shrink: 0;
}
#hmlc-emoji-btn:hover {
	background: var(--hmlc-accent-light);
	border-color: var(--hmlc-accent);
}

/* ── Emoji picker ── */
#hmlc-emoji-picker {
	display: none;
	position: absolute;
	bottom: calc(100% + 8px);
	left: 0;
	width: 288px;
	background: var(--hmlc-white);
	border: 1px solid var(--hmlc-border);
	border-radius: 14px;
	box-shadow: 0 16px 40px rgba(0,0,0,.16);
	z-index: 9999;
	overflow: hidden;
	animation: hmlc-pop .18s cubic-bezier(.34,1.56,.64,1);
}
#hmlc-emoji-picker.open { display: block; }

/* Tabs row */
.hmlc-ep-tabs {
	display: flex;
	gap: 0;
	border-bottom: 1px solid var(--hmlc-border);
	background: var(--hmlc-bg);
	padding: 6px 6px 0;
}
.hmlc-ep-tab {
	flex: 1;
	padding: 6px 2px;
	border: none;
	background: transparent;
	border-radius: 8px 8px 0 0;
	font-size: 16px;
	cursor: pointer;
	transition: background .12s;
	line-height: 1;
}
.hmlc-ep-tab:hover  { background: var(--hmlc-border); }
.hmlc-ep-tab.active {
	background: var(--hmlc-white);
	box-shadow: 0 -2px 0 var(--hmlc-accent) inset;
}

/* Emoji grids */
.hmlc-ep-grid {
	display: none;
	grid-template-columns: repeat(8, 1fr);
	gap: 0;
	padding: 6px;
	max-height: 200px;
	overflow-y: auto;
}
.hmlc-ep-grid.active { display: grid; }
.hmlc-ep-grid::-webkit-scrollbar { width: 3px; }
.hmlc-ep-grid::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.hmlc-ep-em {
	width: 32px; height: 32px;
	border: none;
	background: transparent;
	border-radius: 6px;
	font-size: 17px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .1s, transform .1s;
	line-height: 1;
}
.hmlc-ep-em:hover {
	background: var(--hmlc-accent-light);
	transform: scale(1.2);
}

/* ── Typing indicator ── */
#hmlc-typing {
	display: none;
	padding: 0 16px 8px;
	background: var(--hmlc-bg);
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: var(--hmlc-text-muted);
	flex-shrink: 0;
}
#hmlc-typing.visible { display: flex; }

.hmlc-typing-dots { display: flex; gap: 3px; align-items: center; }
.hmlc-typing-dots span {
	width: 6px; height: 6px;
	background: var(--hmlc-text-xs);
	border-radius: 50%;
	animation: hmlc-typing .9s ease-in-out infinite;
}
.hmlc-typing-dots span:nth-child(2) { animation-delay: .15s; }
.hmlc-typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes hmlc-typing {
	0%,80%,100% { transform:translateY(0); opacity:.5; }
	40%          { transform:translateY(-4px); opacity:1; }
}
