/* ============================================================
 *  Customer Chat Widget (cw-) — Floating live chat for frontend
 * ============================================================ */

/* ── FAB Button ── */
.cw-fab {
	position: fixed;
	bottom: 90px;
	right: 20px;
	z-index: 9999;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.25);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #c49a2a 0%, #a67f1a 100%);
	color: #fff;
	box-shadow: 0 4px 20px rgba(196, 154, 42, 0.5),
	            0 2px 8px rgba(0, 0, 0, 0.3);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
	animation: cwPulse 2.5s ease-in-out 3s 3;
}
@keyframes cwPulse {
	0%, 100% { box-shadow: 0 4px 20px rgba(196, 154, 42, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3); }
	50%      { box-shadow: 0 4px 30px rgba(196, 154, 42, 0.8), 0 0 0 8px rgba(196, 154, 42, 0.15); }
}
.cw-fab:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 28px rgba(196, 154, 42, 0.7), 0 2px 10px rgba(0, 0, 0, 0.4);
	animation: none;
}
.cw-fab:active {
	transform: scale(0.95);
}
.cw-fab--open {
	animation: none;
}
/* Mobile: hide FAB when panel is open (blocks chat content) */
@media (max-width: 767px) {
	.cw-fab--open {
		display: none;
	}
}
.cw-fab__icon {
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.cw-fab__icon--close {
	position: absolute;
	opacity: 0;
	transform: rotate(-90deg);
}
.cw-fab--open .cw-fab__icon:not(.cw-fab__icon--close) {
	opacity: 0;
	transform: rotate(90deg);
}
.cw-fab--open .cw-fab__icon--close {
	opacity: 1;
	transform: rotate(0);
}

/* Badge */
.cw-fab__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	background: #dc3545;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	padding: 0 5px;
	pointer-events: none;
}

/* ── Chat Panel ── */
.cw-panel {
	position: fixed;
	bottom: 0;
	right: 0;
	width: 100%;
	max-height: 75vh;
	z-index: 9998;
	display: flex;
	flex-direction: column;
	background: rgba(15, 20, 30, 0.88);
	backdrop-filter: blur(24px) saturate(1.4);
	-webkit-backdrop-filter: blur(24px) saturate(1.4);
	border-top: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.4);
	transform: translateY(100%);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
	            opacity 0.25s ease;
}
.cw-panel--open {
	transform: translateY(0);
	opacity: 1;
	pointer-events: auto;
}

/* ── Panel Header ── */
.cw-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	flex-shrink: 0;
}
.cw-panel__title {
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.cw-panel__close {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.6);
	font-size: 22px;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	transition: color 0.15s;
}
.cw-panel__close:hover {
	color: #fff;
}

/* ── Email Bar ── */
.cw-panel__email-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: rgba(196, 154, 42, 0.15);
	border-bottom: 1px solid rgba(196, 154, 42, 0.2);
	flex-shrink: 0;
	flex-wrap: wrap;
}
.cw-panel__email-hint {
	color: rgba(255, 255, 255, 0.75);
	font-size: 12px;
	margin: 0;
	flex: 1 1 100%;
}
.cw-panel__email-form {
	display: flex;
	gap: 6px;
	flex: 1;
}
.cw-panel__email-input {
	flex: 1;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 6px;
	padding: 5px 8px;
	color: #fff;
	font-size: 13px;
	outline: none;
}
.cw-panel__email-input:focus {
	border-color: #c49a2a;
}
.cw-panel__email-input::placeholder {
	color: rgba(255, 255, 255, 0.35);
}
.cw-panel__email-btn {
	background: #c49a2a;
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s;
}
.cw-panel__email-btn:hover {
	background: #a67f1a;
}
.cw-panel__email-dismiss {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.4);
	font-size: 18px;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	flex-shrink: 0;
}
.cw-panel__email-dismiss:hover {
	color: #fff;
}

/* ── Messages Area ── */
.cw-panel__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 200px;
	max-height: calc(75vh - 130px);
	overscroll-behavior: contain;
}

/* Welcome screen */
.cw-welcome {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 32px 16px;
	flex: 1;
}
.cw-welcome__icon {
	color: rgba(255, 255, 255, 0.2);
	margin-bottom: 12px;
}
.cw-welcome__text {
	color: rgba(255, 255, 255, 0.55);
	font-size: 14px;
	line-height: 1.6;
	margin: 0;
}

/* Message bubbles */
.cw-msg {
	max-width: 82%;
	padding: 8px 12px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
	animation: cwFadeIn 0.2s ease;
}
@keyframes cwFadeIn {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Customer (mine) — right side, accent */
.cw-msg--mine {
	align-self: flex-end;
	background: linear-gradient(135deg, #c49a2a 0%, #b08a24 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* Staff — left side, glass */
.cw-msg--staff {
	align-self: flex-start;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: rgba(255, 255, 255, 0.9);
	border-bottom-left-radius: 4px;
}
.cw-msg__sender {
	font-size: 11px;
	color: #c49a2a;
	margin-bottom: 2px;
	font-weight: 600;
}

/* System message */
.cw-msg--system {
	align-self: center;
	max-width: 90%;
	background: none;
	text-align: center;
	color: rgba(255, 255, 255, 0.35);
	font-size: 12px;
	padding: 4px 8px;
}

/* Timestamp */
.cw-msg__time {
	font-size: 10px;
	color: rgba(255, 255, 255, 0.4);
	margin-top: 2px;
	text-align: right;
}
.cw-msg--mine .cw-msg__time {
	color: rgba(255, 255, 255, 0.65);
}

/* Sending indicator */
.cw-msg--sending {
	opacity: 0.6;
}

/* ── Input Area ── */
.cw-panel__input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	flex-shrink: 0;
}
.cw-panel__textarea {
	flex: 1;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 20px;
	padding: 8px 14px;
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	outline: none;
	max-height: 100px;
	overflow-y: auto;
	transition: border-color 0.15s;
}
.cw-panel__textarea:focus {
	border-color: rgba(196, 154, 42, 0.5);
}
.cw-panel__textarea::placeholder {
	color: rgba(255, 255, 255, 0.3);
}
.cw-panel__send {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	background: #c49a2a;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, opacity 0.15s;
}
.cw-panel__send:disabled {
	opacity: 0.3;
	cursor: default;
}
.cw-panel__send:not(:disabled):hover {
	background: #a67f1a;
}

/* ── Desktop: floating panel ── */
@media (min-width: 768px) {
	.cw-fab {
		bottom: 28px;
		right: 28px;
	}
	.cw-panel {
		right: 28px;
		bottom: 100px;
		width: 380px;
		max-height: 520px;
		border-radius: 16px;
		border: 1px solid rgba(255, 255, 255, 0.1);
		transform: translateY(20px) scale(0.95);
	}
	.cw-panel--open {
		transform: translateY(0) scale(1);
	}
	.cw-panel__messages {
		max-height: 340px;
	}
}

/* ── Scrollbar ── */
.cw-panel__messages::-webkit-scrollbar {
	width: 4px;
}
.cw-panel__messages::-webkit-scrollbar-track {
	background: transparent;
}
.cw-panel__messages::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
}

/* ── Email saved toast ── */
.cw-panel__email-bar--saved {
	background: rgba(40, 167, 69, 0.15);
	border-bottom-color: rgba(40, 167, 69, 0.2);
}
.cw-panel__email-bar--saved .cw-panel__email-hint {
	color: rgba(40, 167, 69, 0.9);
}
