/* =============================================================
   BotFluxo — Public Chatbot Styles
   ============================================================= */

/* ---- Design System: Paleta de Cores Profissional ---- */
:root {
	/* Primary - Azul Profissional */
	--bf-primary: #3b5bdb;
	--bf-primary-light: #5568e8;
	--bf-primary-dark: #2d47b3;
	
	/* Backgrounds */
	--bf-bg-primary: #ffffff;
	--bf-bg-secondary: #f8f9fc;
	--bf-bg-tertiary: #f0f3f9;
	
	/* Text */
	--bf-text-primary: #1a202c;
	--bf-text-secondary: #4a5568;
	--bf-text-tertiary: #718096;
	--bf-text-inverse: #ffffff;
	
	/* Accents */
	--bf-accent-success: #48bb78;
	--bf-accent-info: #4299e1;
	--bf-accent-warning: #ed8936;
	--bf-accent-danger: #f56565;
	
	/* Borders & Dividers */
	--bf-border: #e2e8f0;
	--bf-border-light: #edf2f7;
	
	/* Shadows */
	--bf-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
	--bf-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
	--bf-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.14);
	
	/* Spacing & Typography */
	--bf-radius: 12px;
	--bf-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
	--bf-font-weight-regular: 400;
	--bf-font-weight-medium: 500;
	--bf-font-weight-semibold: 600;
	--bf-font-weight-bold: 700;

	/* Runtime-customizable chat colors */
	--bf-chat-bg: var(--bf-bg-primary);
	--bf-bot-bubble-bg: var(--bf-bg-secondary);
	--bf-bot-bubble-text: var(--bf-text-primary);
	--bf-user-bubble-bg: var(--bf-primary);
	--bf-user-bubble-text: var(--bf-text-inverse);
}

/* ---- Container ---- */
.botfluxo-chatbot {
	font-family: var(--bf-font-family);
	max-width: 480px;
	width: 100%;
	margin: 24px auto;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: var(--bf-shadow-lg);
	background: var(--bf-bg-secondary);
	display: flex;
	flex-direction: column;
	position: relative;
}

/* ---- Header ---- */
.bf-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	background: linear-gradient(135deg, var(--bf-primary) 0%, var(--bf-primary-dark) 100%);
	color: var(--bf-text-inverse);
}
.bf-chat-avatar {
	font-size: 24px;
	line-height: 1;
}
.bf-chat-info { flex: 1; }
.bf-chat-name {
	font-weight: var(--bf-font-weight-bold);
	font-size: 14px;
	line-height: 1.2;
}
.bf-chat-status {
	font-size: 11px;
	opacity: .85;
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 1px;
}
.bf-status-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: var(--bf-accent-success);
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}

/* Secure badge */
.bf-secure-badge {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	background: rgba(72, 187, 120, 0.15);
	border: 1.5px solid rgba(72, 187, 120, 0.35);
	border-radius: 50%;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	transition: all 0.2s ease;
	cursor: help;
}
.bf-secure-badge:hover {
	background: rgba(72, 187, 120, 0.25);
	border-color: rgba(72, 187, 120, 0.5);
	transform: scale(1.1);
}
.bf-secure-badge .bf-secure-icon {
	font-size: 14px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	color: rgba(72, 187, 120, 0.9);
	flex-shrink: 0;
}
.bf-secure-badge .bf-secure-label {
	display: none;
}

.bf-header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	margin-left: auto;
}

.bf-reward-test-btn,
.bf-restart-btn {
	background: rgba(255,255,255,.2);
	border: none;
	color: var(--bf-text-inverse);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 16px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s;
	flex-shrink: 0;
}
.bf-chat-header .bf-header-actions {
	display: flex !important;
	visibility: visible !important;
	opacity: 1 !important;
}
.bf-reward-test-btn {
	display: none;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .2px;
}
.bf-reward-test-btn:hover,
.bf-restart-btn:hover { background: rgba(255,255,255,.35); }

/* ---- Messages area ---- */
.bf-messages {
	flex: 1;
	min-height: 280px;
	max-height: 420px;
	overflow-y: auto;
	padding: 18px 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
	background: var(--bf-chat-bg);
}
.bf-messages::-webkit-scrollbar { width: 4px; }
.bf-messages::-webkit-scrollbar-track { background: transparent; }
.bf-messages::-webkit-scrollbar-thumb { background: var(--bf-border); border-radius: 4px; }

/* ---- Message rows ---- */
.bf-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	width: 100%;
	animation: bfFadeIn .25s ease-out;
}
.bf-msg-bot  { justify-content: flex-start; }
.bf-msg-user { justify-content: flex-end; }

/* Full-width HTML/script block */
.bf-msg-html {
	width: 100%;
	max-width: 100%;
	padding: 0;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	animation: bfFadeIn .25s ease-out;
}

.bf-msg-html-title {
	margin: 0 0 8px;
	font-size: 13px;
	font-weight: 300;
	letter-spacing: 0.2px;
	color: var(--bf-text-secondary);
	text-transform: uppercase;
	text-align: center;
	position: relative;
	z-index: 2;
}

.bf-msg-html-content {
	width: 100%;
	position: relative;
	z-index: 1;
}

.bf-msg-html ins.adsbygoogle {
	display: block !important;
	width: 100% !important;
	max-width: 100%;
	min-height: 90px;
}

@keyframes bfFadeIn {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ---- Avatars ---- */
.bf-bot-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--bf-primary), var(--bf-primary-light));
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	flex-shrink: 0;
	overflow: hidden;
}
.bf-bot-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
	display: block;
}
.bf-chat-avatar img {
	width: 36px;
	height: 36px;
	object-fit: cover;
	border-radius: 50%;
	display: block;
}

/* ---- Bubbles ---- */
.bf-bubble {
	max-width: 75%;
	padding: 10px 14px;
	border-radius: 18px;
	font-size: 14px;
	line-height: 1.55;
	word-break: break-word;
	font-weight: var(--bf-font-weight-regular);
}
.bf-msg-bot .bf-bubble {
	background: var(--bf-bot-bubble-bg);
	color: var(--bf-bot-bubble-text);
	border-bottom-left-radius: 4px;
	box-shadow: var(--bf-shadow-sm);
}
.bf-msg-user .bf-bubble {
	background: var(--bf-user-bubble-bg);
	color: var(--bf-user-bubble-text);
	border-bottom-right-radius: 4px;
}

/* Title variant */
.bf-msg-title .bf-bubble {
	background: var(--bf-bg-tertiary);
	color: var(--bf-primary-dark);
	font-size: 15px;
	font-weight: var(--bf-font-weight-bold);
	border-radius: 12px;
}

/* Image variant */
.bf-msg-image .bf-bubble {
	background: transparent;
	padding: 0;
	box-shadow: none;
}
.bf-msg-image .bf-bubble img {
	max-width: 240px;
	width: 100%;
	border-radius: 14px;
	display: block;
}
.bf-img-caption {
	font-size: 12px;
	color: #888;
	margin-top: 5px;
	text-align: center;
}

/* Audio variant */
.bf-msg-audio .bf-bubble {
	padding: 8px 10px;
	max-width: 280px;
	border-radius: 12px;
	background: var(--bf-bot-bubble-bg);
	border: none;
	box-shadow: none;
}
.bf-audio-player {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 2px 0;
	border-radius: 999px;
	background: transparent;
	border: none;
}
.bf-audio-play {
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: var(--bf-primary);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	cursor: pointer;
	flex-shrink: 0;
	box-shadow: none;
	transition: background .15s ease;
}
.bf-audio-play:hover {
	background: var(--bf-primary-dark);
}
.bf-audio-play-icon {
	line-height: 1;
	transform: translateX(1px);
}
.bf-audio-player[data-state="playing"] .bf-audio-play-icon {
	transform: none;
}
.bf-audio-meta {
	min-width: 80px;
	max-width: 110px;
	flex: 1;
}
.bf-audio-title {
	font-size: 11px;
	font-weight: 600;
	color: var(--bf-bot-bubble-text);
	line-height: 1.2;
}
.bf-audio-time {
	font-size: 11px;
	margin-top: 2px;
	color: var(--bf-text-tertiary);
	font-variant-numeric: tabular-nums;
}
.bf-audio-bars {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 16px;
	width: 28px;
	flex-shrink: 0;
	opacity: .45;
}
.bf-audio-bars span {
	display: block;
	width: 3px;
	border-radius: 999px;
	background: var(--bf-primary);
	height: 6px;
	animation: bfAudioBar .9s ease-in-out infinite;
	animation-play-state: paused;
}
.bf-audio-bars span:nth-child(2) {
	height: 12px;
	animation-delay: .1s;
}
.bf-audio-bars span:nth-child(3) {
	height: 8px;
	animation-delay: .2s;
}
.bf-audio-bars span:nth-child(4) {
	height: 14px;
	animation-delay: .3s;
}
.bf-audio-player[data-state="playing"] .bf-audio-bars span {
	animation-play-state: running;
}
.bf-audio-native {
	position: absolute;
	width: 0;
	height: 0;
	opacity: 0;
	pointer-events: none;
}
.bf-audio-caption {
	font-size: 12px;
	color: #888;
	margin-top: 6px;
	text-align: left;
}

@keyframes bfAudioBar {
	0%, 100% { transform: scaleY(.55); opacity: .5; }
	50% { transform: scaleY(1); opacity: 1; }
}

/* End message */
.bf-msg-end .bf-bubble {
	background: none;
	color: #aaa;
	font-style: italic;
	font-size: 13px;
	box-shadow: none;
	text-align: center;
	padding: 4px 0;
	max-width: 100%;
}

/* ---- Typing bubble wrapper ---- */
.bf-bubble--typing {
	min-width: 140px;
	padding: 12px 16px !important;
}

/* ---- Typing indicator ---- */
.bf-typing {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.bf-typing-label {
	font-size: 12px;
	line-height: 1.3;
	color: var(--bf-bot-bubble-text);
}
.bf-typing-dots {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-shrink: 0;
}
.bf-typing-dots span {
	display: block;
	width: 8px;
	height: 8px;
	background: rgba(59, 91, 219, 0.5);
	border-radius: 50%;
	animation: bfDot .9s infinite ease-in-out;
}
.bf-typing-dots span:nth-child(2) { animation-delay: .18s; }
.bf-typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bfDot {
	0%,80%,100% { transform: scale(.6); opacity: .5; }
	40%         { transform: scale(1.1); opacity: 1; }
}

/* ---- Input area ---- */
.bf-input-area {
	padding: 12px 14px;
	background: var(--bf-bg-primary);
	border-top: 1px solid var(--bf-border);
	min-height: 54px;
	display: flex;
	align-items: center;
	position: relative;
	z-index: 1000;
}

/* Buttons layout */
.bf-buttons-wrap {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	max-width: 320px;
	padding: 4px 0 8px 44px; /* indent to align with bot bubbles */
}
.bf-btn-choice {
	width: 100%;
	text-align: center;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 18px;
	min-height: 50px;
	background: var(--bf-primary);
	border: 2px solid var(--bf-primary);
	border-radius: 24px;
	color: var(--bf-text-inverse);
	text-decoration: none;
	font-size: 13px;
	font-weight: var(--bf-font-weight-semibold);
	cursor: pointer;
	transition: background .15s, border-color .15s, transform .1s;
}
.bf-btn-choice:hover {
	background: var(--bf-primary-dark);
	border-color: var(--bf-primary-dark);
	transform: scale(1.02);
	text-decoration: none;
}
.bf-btn-choice.has-avatar {
	justify-content: center;
	text-align: center;
	position: relative;
	padding-left: 52px;
	padding-right: 52px;
}
.bf-btn-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: rgba(255,255,255,.2);
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
}
.bf-btn-label {
	line-height: 1.2;
	text-align: center;
}
.bf-btn-item {
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.bf-btn-notice {
	font-size: 10px;
	color: var(--bf-text-tertiary);
	text-align: center;
	padding: 0 4px;
	line-height: 1.4;
}

/* Text input layout */
.bf-text-wrap {
	display: flex;
	gap: 8px;
	width: 100%;
}
.bf-text-input {
	flex: 1;
	padding: 10px 16px;
	border: 1.5px solid var(--bf-border);
	border-radius: 24px;
	font-size: 14px;
	outline: none;
	background: var(--bf-bg-secondary);
	color: var(--bf-text-primary);
	transition: border-color .15s, background .15s;
	font-family: inherit;
	font-weight: var(--bf-font-weight-regular);
}
.bf-text-input:focus {
	border-color: var(--bf-primary);
	background: var(--bf-bg-primary);
}
.bf-text-input::placeholder {
	color: var(--bf-text-tertiary);
}
.bf-send-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--bf-primary);
	border: none;
	color: var(--bf-text-inverse);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s, transform .1s;
}
.bf-send-btn:hover  { background: #5a52d4; transform: scale(1.08); }

/* Search loader */
.bf-search-loader {
	display: flex;
	width: 100%;
	max-width: 320px;
	padding: 4px 0 8px 44px;
}
.bf-search-box {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 16px 18px;
	background: linear-gradient(135deg, var(--bf-primary) 0%, var(--bf-primary-dark) 100%);
	border-radius: 18px;
	box-shadow: var(--bf-shadow-md);
	min-width: 200px;
}
.bf-search-icon {
	flex-shrink: 0;
	color: var(--bf-text-inverse);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	line-height: 1;
	min-width: 32px;
	animation: bf-search-icon-pulse 1.5s ease-in-out infinite;
}
.bf-search-icon svg {
	width: 24px;
	height: 24px;
	stroke: currentColor;
	color: var(--bf-text-inverse);
}
.bf-search-icon i {
	font-size: 24px;
	color: var(--bf-text-inverse);
}
.bf-search-text {
	flex: 1;
	font-size: 13px;
	font-weight: var(--bf-font-weight-medium);
	color: var(--bf-text-inverse);
	line-height: 1.4;
}
.bf-search-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}
.bf-search-dots span {
	display: inline-block;
	width: 5px;
	height: 5px;
	background: rgba(255, 255, 255, 0.8);
	border-radius: 50%;
	animation: bf-search-pulse 1.4s infinite ease-in-out;
}
.bf-search-dots span:nth-child(2) { animation-delay: 0.2s; }
.bf-search-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bf-search-icon-pulse {
	0%, 100% { transform: scale(1); opacity: 1; }
	50%      { transform: scale(1.15); opacity: 0.8; }
}
@keyframes bf-search-pulse {
	0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
	40%           { transform: scale(1);   opacity: 1; }
}
.bf-send-btn svg    { pointer-events: none; }

/* External link warning dynamic page */
.bf-external-warning-screen {
	min-height: 100vh;
	width: 100%;
	background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.bf-external-warning-card {
	width: 100%;
	max-width: 560px;
	background: #ffffff;
	border-radius: 14px;
	padding: 20px;
	box-shadow: 0 16px 45px rgba(2, 6, 23, .35);
	color: #0f172a;
}
.bf-external-warning-card h3 {
	font-size: 20px;
	line-height: 1.3;
	margin: 0 0 10px;
}
.bf-ext-site,
.bf-ext-count {
	margin: 0 0 8px;
	font-size: 14px;
	line-height: 1.5;
}
.bf-ext-countdown {
	color: #dc2626;
}
.bf-ext-custom-warning {
	margin-top: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	background: #fffbeb;
	border: 1px solid #fde68a;
	font-size: 13px;
	line-height: 1.5;
	color: #78350f;
}
.bf-ext-actions {
	margin-top: 16px;
	display: flex;
	gap: 10px;
	justify-content: center;
}
.bf-ext-cancel {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 14px;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	border: none;
	cursor: pointer;
}
.bf-ext-cancel {
	background: #e2e8f0;
	color: #0f172a;
}

/* ---- Responsive ---- */
@media (max-width: 520px) {
	.botfluxo-chatbot {
		border-radius: 0;
		margin: 0;
		max-width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
	}
	
	.bf-messages { 
		flex: 1;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 18px 14px;
		padding-bottom: 20px;
		scroll-padding-bottom: 74px;
		min-height: 0; /* Allow flex to work properly */
	}

	.botfluxo-chatbot.bf-has-input .bf-messages {
		padding-bottom: 28px;
		scroll-padding-bottom: 150px;
	}

	.botfluxo-chatbot:not(.bf-has-input) .bf-input-area {
		display: none;
		min-height: 0;
		padding: 0;
		border-top: 0;
	}
	
	.bf-input-area {
		padding: 12px 14px;
		position: fixed;
		bottom: calc(42px + env(safe-area-inset-bottom));
		left: 0;
		right: 0;
		width: 100%;
		max-width: 100%;
		background: var(--bf-bg-primary);
		border-radius: 0;
		z-index: 9999;
		box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
		margin: 0;
		min-height: auto;
		max-height: none;
	}

	.bf-chatbot-footer-nav {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 9998;
		background: #ffffff;
		border-top: 1px solid rgba(15, 23, 42, 0.08);
		padding-bottom: max(6px, env(safe-area-inset-bottom));
	}
	
	.bf-text-input {
		font-size: 16px; /* Prevent iOS zoom on input focus */
		padding: 12px 14px;
	}
	
	.bf-send-btn {
		width: 36px;
		height: 36px;
	}
	
	/* Reserve vertical space for fixed footer */
	.botfluxo-chatbot::after {
		content: '';
		display: block;
		height: 48px;
		flex-shrink: 0;
	}

	/* Reserve extra space when fixed input is visible above footer */
	.botfluxo-chatbot.bf-has-input::after {
		height: 122px;
	}
}

