/*
 * AI Protecnos
 * Interfaz flotante responsive para Dolibarr
 */

#iaprotecnos-float-button {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: 54px;
	height: 54px;
	border: 0;
	border-radius: 50%;
	background: #2563eb;
	color: #fff;
	cursor: pointer;
	z-index: 99990;
	box-shadow: 0 4px 14px rgba(0,0,0,.25);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 25px;
	line-height: 1;
	transition: transform .15s ease, box-shadow .15s ease;
}

#iaprotecnos-float-button:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 18px rgba(0,0,0,.30);
}

#iaprotecnos-float-button:focus {
	outline: 3px solid rgba(37,99,235,.25);
	outline-offset: 2px;
}

#iaprotecnos-chat {
	position: fixed;
	right: 20px;
	bottom: 86px;
	width: 390px;
	max-width: calc(100vw - 30px);
	height: 560px;
	max-height: calc(100vh - 110px);
	background: #fff;
	border: 1px solid #d8dde5;
	border-radius: 12px;
	box-shadow: 0 10px 35px rgba(0,0,0,.25);
	z-index: 99991;
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: inherit;
}

#iaprotecnos-chat.iaprotecnos-open {
	display: flex;
}

.iaprotecnos-chat-header {
	flex: 0 0 auto;
	min-height: 58px;
	padding: 10px 12px;
	background: #f8f9fa;
	border-bottom: 1px solid #e1e5ea;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.iaprotecnos-chat-title {
	display: flex;
	align-items: center;
	gap: 9px;
	min-width: 0;
}

.iaprotecnos-chat-icon {
	font-size: 25px;
	line-height: 1;
}

.iaprotecnos-chat-title-text {
	min-width: 0;
}

.iaprotecnos-chat-title-main {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.iaprotecnos-chat-title-sub {
	font-size: 11px;
	color: #6c757d;
	margin-top: 2px;
}

.iaprotecnos-chat-close {
	border: 0;
	background: transparent;
	color: #555;
	cursor: pointer;
	font-size: 23px;
	line-height: 1;
	padding: 5px 7px;
	border-radius: 6px;
}

.iaprotecnos-chat-close:hover {
	background: #e9ecef;
}

.iaprotecnos-chat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 15px;
	background: #fff;
	-webkit-overflow-scrolling: touch;
}

.iaprotecnos-welcome {
	max-width: 88%;
	margin: 5px auto 18px auto;
	text-align: center;
	color: #495057;
}

.iaprotecnos-welcome-icon {
	font-size: 34px;
	line-height: 1;
	margin-bottom: 8px;
}

.iaprotecnos-welcome-title {
	font-size: 18px;
	font-weight: 600;
	margin-bottom: 5px;
	color: #212529;
}

.iaprotecnos-welcome-text {
	font-size: 14px;
	line-height: 1.45;
}

.iaprotecnos-message {
	display: flex;
	margin: 0 0 12px 0;
}

.iaprotecnos-message-user {
	justify-content: flex-end;
}

.iaprotecnos-message-ai {
	justify-content: flex-start;
}

.iaprotecnos-message-bubble {
	max-width: 85%;
	padding: 9px 12px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
}

.iaprotecnos-message-user .iaprotecnos-message-bubble {
	background: #e7f1ff;
	color: #17365d;
	border-bottom-right-radius: 4px;
}

.iaprotecnos-message-ai .iaprotecnos-message-bubble {
	background: #f1f3f5;
	color: #212529;
	border-bottom-left-radius: 4px;
}

.iaprotecnos-message-error .iaprotecnos-message-bubble {
	background: #f8d7da;
	color: #842029;
}

.iaprotecnos-chat-footer {
	flex: 0 0 auto;
	border-top: 1px solid #e1e5ea;
	padding: 9px;
	background: #fff;
}

.iaprotecnos-input-row {
	display: flex;
	align-items: flex-end;
	gap: 7px;
}

#iaprotecnos-chat-input {
	flex: 1 1 auto;
	resize: none;
	min-height: 42px;
	max-height: 120px;
	border: 1px solid #cfd5dc;
	border-radius: 9px;
	padding: 10px 11px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.35;
	outline: none;
	box-sizing: border-box;
}

#iaprotecnos-chat-input:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 2px rgba(37,99,235,.10);
}

#iaprotecnos-chat-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 9px;
	background: #2563eb;
	color: #fff;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
}

#iaprotecnos-chat-send:hover {
	background: #1d4ed8;
}

#iaprotecnos-chat-send:disabled {
	opacity: .55;
	cursor: default;
}

.iaprotecnos-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
}

.iaprotecnos-typing span {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: #777;
	animation: iaprotecnosTyping 1.2s infinite ease-in-out;
}

.iaprotecnos-typing span:nth-child(2) {
	animation-delay: .15s;
}

.iaprotecnos-typing span:nth-child(3) {
	animation-delay: .30s;
}

@keyframes iaprotecnosTyping {
	0%, 60%, 100% { opacity: .25; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 600px) {
	#iaprotecnos-float-button {
		right: 14px;
		bottom: 14px;
		width: 50px;
		height: 50px;
		font-size: 23px;
	}

	#iaprotecnos-chat {
		left: 8px;
		right: 8px;
		bottom: 8px;
		width: auto;
		max-width: none;
		height: calc(100vh - 16px);
		max-height: none;
		border-radius: 10px;
	}

	.iaprotecnos-chat-header {
		min-height: 54px;
	}

	.iaprotecnos-chat-body {
		padding: 12px;
	}

	.iaprotecnos-message-bubble {
		max-width: 90%;
	}

	#iaprotecnos-chat-input {
		font-size: 16px;
	}
}

@media (min-width: 601px) and (max-width: 900px) {
	#iaprotecnos-chat {
		width: 430px;
		max-width: calc(100vw - 30px);
		height: 560px;
		max-height: calc(100vh - 100px);
	}
}
