/**
 * ChatBridge frontend styles
 */

.chatbridge-wrap {
	--cb-primary-button: #2db8a1;
	--cb-end-button: #95a5a6;
	--cb-user-color: #2db8a1;
	--cb-admin-color: #3498db;
	--cb-launch-width: 350px;
	--cb-launch-height: 70px;
	--cb-launch-font: 28px;
	--cb-panel-width: 420px;
	--cb-launch-bg: var(--cb-primary-button);
	--cb-launch-bg-hover: #269b87;
	--cb-launch-text: #ffffff;
	--cb-launch-radius: 14px;
	--cb-launch-border-color: transparent;
	--cb-launch-border-width: 0px;
	max-width: 100%;
	width: 100%;
	margin-top: 1rem;
	margin-bottom: 1rem;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
	font-size: 16px;
	box-sizing: border-box;
	position: relative;
	overflow: visible;
}

.chatbridge-wrap.chatbridge-pos-right,
.chatbridge-wrap.chatbridge-pos-left,
.chatbridge-wrap.chatbridge-pos-center {
	display: flex;
}

.chatbridge-wrap.chatbridge-pos-left {
	justify-content: flex-start;
}

.chatbridge-wrap.chatbridge-pos-center {
	justify-content: center;
}

.chatbridge-wrap.chatbridge-pos-right {
	justify-content: flex-end;
}

.chatbridge-launch-screen,
.chatbridge-start-screen,
.chatbridge-chat-screen {
	width: min(420px, 100%);
}

/* Open upward overlay panels (no layout shift) */
.chatbridge-start-screen,
.chatbridge-chat-screen {
	position: fixed;
	left: 8px;
	top: 80px;
	z-index: 9999;
	width: min(var(--cb-panel-width), calc(100vw - 16px));
	max-height: min(78vh, 720px);
	overflow: auto;
}

.chatbridge-card {
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	padding: 1.5rem;
	border: 1px solid #e5e5e5;
}

.chatbridge-launch-screen {
	text-align: center;
}

.chatbridge-wrap .chatbridge-launch-btn {
	width: var(--cb-launch-width) !important;
	height: var(--cb-launch-height) !important;
	min-height: var(--cb-launch-height) !important;
	max-width: 100%;
	padding: 0 1rem !important;
	font-size: var(--cb-launch-font) !important;
	line-height: 1;
	margin-top: 0;
	border-radius: var(--cb-launch-radius);
	font-weight: 700 !important;
	letter-spacing: 0.02em;
	box-sizing: border-box;
	background: var(--cb-launch-bg) !important;
	color: var(--cb-launch-text) !important;
	border-style: solid !important;
	border-color: var(--cb-launch-border-color) !important;
	border-width: var(--cb-launch-border-width) !important;
}

.chatbridge-wrap.chatbridge-style-free .chatbridge-launch-btn {
	width: auto !important;
	height: auto !important;
	min-height: 0 !important;
	max-width: 100%;
	padding: 0.65rem 1.25rem !important;
	font-size: 1rem !important;
	line-height: 1.2;
}

.chatbridge-wrap .chatbridge-launch-btn:hover {
	background: var(--cb-launch-bg-hover) !important;
	filter: none;
}

/* Language-switch-like compact preset */
.chatbridge-wrap.chatbridge-preset-lang .chatbridge-launch-btn {
	width: auto !important;
	height: 34px !important;
	min-height: 34px !important;
	padding: 0 14px !important;
	font-size: 13px !important;
	font-weight: 700 !important;
	line-height: 1 !important;
	border-radius: 7px !important;
	border-width: 1px !important;
	border-color: rgba(255, 255, 255, 0.35) !important;
	background: var(--cb-launch-bg) !important;
	color: #ffffff !important;
	letter-spacing: 0.01em;
}

.chatbridge-wrap.chatbridge-preset-lang .chatbridge-launch-btn:hover {
	background: var(--cb-launch-bg-hover) !important;
}

.chatbridge-wrap .chatbridge-btn-primary:not(.chatbridge-launch-btn):hover {
	filter: brightness(0.92);
}

/* Start screen */
.chatbridge-start-screen .chatbridge-title {
	margin: 0 0 0.5rem;
	font-size: 1.35rem;
	color: #1a1a1a;
	padding-right: 2rem;
}

.chatbridge-close-btn {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border: 1px solid #d9d9d9;
	border-radius: 999px;
	background: #fff;
	color: #666;
	font-size: 16px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.chatbridge-close-btn:hover {
	background: #f5f5f5;
	color: #333;
}

.chatbridge-instruction {
	margin: 0 0 1.25rem;
	color: #555;
	font-size: 0.9rem;
	line-height: 1.4;
}

.chatbridge-form label {
	display: block;
	margin-top: 1rem;
	margin-bottom: 0.35rem;
	font-weight: 500;
	color: #333;
}

.chatbridge-form label:first-of-type {
	margin-top: 0;
}

.chatbridge-form select,
.chatbridge-form input[type="text"] {
	width: 100%;
	padding: 0.6rem 0.75rem;
	border: 1px solid #ccc;
	border-radius: 8px;
	font-size: 1rem;
	box-sizing: border-box;
}

.chatbridge-form select:focus,
.chatbridge-form input[type="text"]:focus {
	border-color: var(--cb-primary-button);
	outline: none;
}

.chatbridge-btn {
	display: inline-block;
	padding: 0.65rem 1.25rem;
	border: none;
	border-radius: 8px;
	font-size: 1rem;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s;
}

.chatbridge-btn-primary {
	background: var(--cb-primary-button);
	color: #fff;
	width: 100%;
	margin-top: 1.25rem;
}

.chatbridge-footer-note {
	margin: 1rem 0 0;
	font-size: 0.75rem;
	color: #888;
	line-height: 1.3;
}

.chatbridge-bar {
	margin: 1rem -1.5rem -1.5rem;
	padding: 0.5rem 1.5rem;
	background: #c0392b;
	border-radius: 0 0 12px 12px;
}

.chatbridge-brand {
	color: #fff;
	font-size: 0.85rem;
}

/* Chat screen */
.chatbridge-chat-screen {
	display: flex;
	flex-direction: column;
	min-height: 380px;
}

.chatbridge-chat-header {
	background: var(--cb-admin-color);
	color: #fff;
	padding: 0.6rem 1rem;
	margin: -1.5rem -1.5rem 1rem;
	border-radius: 12px 12px 0 0;
	font-weight: 600;
}

.chatbridge-messages {
	flex: 1;
	min-height: 220px;
	max-height: 320px;
	overflow-y: auto;
	padding-right: 0.5rem;
}

.chatbridge-msg {
	display: flex;
	align-items: flex-start;
	margin-bottom: 0.75rem;
}

.chatbridge-msg.user {
	flex-direction: row;
}

.chatbridge-msg.admin {
	flex-direction: row-reverse;
}

.chatbridge-msg-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.7rem;
	font-weight: 600;
	color: #fff;
}

.chatbridge-msg.user .chatbridge-msg-avatar {
	background: var(--cb-user-color);
	margin-right: 0.5rem;
}

.chatbridge-msg.admin .chatbridge-msg-avatar {
	background: var(--cb-admin-color);
	margin-left: 0.5rem;
}

.chatbridge-msg-bubble {
	max-width: 80%;
	padding: 0.6rem 0.9rem;
	border-radius: 12px;
	line-height: 1.4;
	font-size: 0.95rem;
}

.chatbridge-msg.user .chatbridge-msg-bubble {
	background: #ecf0f1;
	background: color-mix(in srgb, var(--cb-user-color) 14%, #ffffff);
	color: #2c3e50;
	border-bottom-left-radius: 4px;
}

.chatbridge-msg.admin .chatbridge-msg-bubble {
	background: #e8f4f8;
	background: color-mix(in srgb, var(--cb-admin-color) 14%, #ffffff);
	color: #2c3e50;
	border-bottom-right-radius: 4px;
}

.chatbridge-msg-time {
	font-size: 0.7rem;
	color: #888;
	margin-top: 0.25rem;
}

.chatbridge-chat-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.chatbridge-chat-actions input {
	flex: 1;
	padding: 0.6rem 0.75rem;
	border: 1px solid #ccc;
	border-radius: 8px;
	font-size: 1rem;
}

.chatbridge-chat-actions input:focus {
	border-color: var(--cb-primary-button);
	outline: none;
}

.chatbridge-enter-hint {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 0.4rem;
	border: 1px solid #d6d6d6;
	border-radius: 8px;
	background: #f8f8f8;
	color: #666;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1;
	user-select: none;
}

.chatbridge-btn-end {
	background: var(--cb-end-button);
	color: #fff;
	width: 100%;
	margin-top: 0.75rem;
}

.chatbridge-btn-end:hover {
	filter: brightness(0.92);
}

.chatbridge-chat-screen .chatbridge-footer-note {
	margin-top: 0.75rem;
}

.chatbridge-loading {
	text-align: center;
	color: #888;
	padding: 1rem;
}

.chatbridge-error {
	background: #fdecea;
	color: #c0392b;
	padding: 0.6rem 0.9rem;
	border-radius: 8px;
	margin-bottom: 0.75rem;
	font-size: 0.9rem;
}

@media (max-width: 480px) {
	.chatbridge-wrap {
		max-width: 100%;
	}
	.chatbridge-start-screen,
	.chatbridge-chat-screen {
		width: min(420px, calc(100vw - 16px));
		max-height: min(72vh, 640px);
	}
	.chatbridge-card {
		padding: 1rem;
	}
	.chatbridge-msg-bubble {
		max-width: 90%;
	}
}
