﻿/* =========================================================
   IA GERAL - CSS CONSOLIDADO
   ---------------------------------------------------------
   Conteúdo consolidado de:
   - ia_geral.css (base/reset)
   - ia_index.css (layout/chat)
   - pivot_ia.css (header IA e botões)
   - overrides inline do ASPX
   ========================================================= */

/* =========================================================
   1) RESET / BASE
   ========================================================= */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	outline: none;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

img {
	width: auto;
	height: auto;
}

button:hover {
	cursor: pointer;
}

button:disabled {
	opacity: 0.3;
}

/* =========================================================
   2) VARIÁVEIS / TEMA
   ========================================================= */
:root {
	--ui-bg: #ffffff;
	--ui-text: #000000;
	--ui-border: #d9d9d9;
	--ui-border-strong: #bdbdbd;
	--ui-shadow: rgba(0, 0, 0, 0.08);

	--footer-bg: #d9d9d9;
	--footer-field-bg: #f2f2f2;

	--ia-header-h: 48px;
	--footer-h: 58px;
}

/* =========================================================
   3) VIEWPORT / LAYOUT GLOBAL
   ========================================================= */
html,
body {
	height: 100% !important;
	margin: 0;
}

body {
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow: hidden; /* scroll só no chat */
	background: var(--ui-bg);
	color: var(--ui-text);
}

@supports (height: 100svh) {
	body {
		min-height: 100svh;
	}
}

form[runat="server"] {
	height: 100vh;
	display: block;
}

/* Main fica entre header fixo e footer fixo */
main {
	position: fixed;
	top: var(--ia-header-h);
	left: 0;
	right: 0;
	bottom: var(--footer-h);
	overflow: hidden;
	background: var(--ui-bg);
	display: block;
}

/* Estrutura base */
.section-main,
.article-main {
	height: 100%;
	min-height: 0;
	margin: 0;
}

.section-main {
	width: 100%;
	padding: 0;
	display: block;
	background: var(--ui-bg);
}

.article-main {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px 12px;
	background: var(--ui-bg);
	overflow: hidden;
}

/* =========================================================
   4) HEADER IA (fixo no topo)
   ========================================================= */
.kb-ia-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1000;

	height: var(--ia-header-h);
	box-sizing: border-box;

	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 10px;

	margin: 0;
	border-radius: 0;
	background: var(--footer-bg);
	border-bottom: 1px solid var(--ui-border-strong);
}

/* Força visual consistente no header */
.kb-ia-header,
.kb-ia-header * {
	color: #000;
	font-weight: 700;
}

.kb-ia-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
}

.kb-ia-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.kb-ia-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;

	border: 1px solid #000;
	border-radius: 6px;
	background: #fff;
	color: #000;
	cursor: pointer;

	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.kb-ia-btn:hover {
	background: #000;
	color: #fff;
	border-color: #000;
}

.kb-ia-btn:active {
	transform: scale(0.96);
}

.kb-ia-btn i {
	color: inherit;
}

/* Ícones do header seguem cor do botão */
.kb-ia-btn i {
	color: inherit;
}

/* =========================================================
   5) ÁREA CENTRAL (CHAT + LOADING + GRÁFICO)
   ========================================================= */
.div-chat-form {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--ui-bg);
}

/* Chat scrollável */
#chat-box,
.div-chat-main {
	flex: 1 1 auto;
	min-height: 0;
	height: auto;
	overflow-y: auto;
	overflow-x: hidden;

	display: flex;
	flex-direction: column;
	gap: 12px;

	padding-right: 4px;
	background: var(--ui-bg);
}

/* Esconde scrollbar visual */
#chat-box::-webkit-scrollbar,
.div-chat-form::-webkit-scrollbar {
	display: none;
}

#chat-box,
.div-chat-form {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

/* =========================================================
   6) MENSAGENS / CHAT
   ========================================================= */
.div-chat {
	align-self: stretch;
	display: inline-flex;
	justify-content: flex-start;
	align-items: flex-start;
	gap: 8px;
	max-width: 1200px;
	width: 80%;
}

.div-chat-usuario {
	align-self: stretch;
	display: inline-flex;
	justify-content: flex-end;
	align-items: flex-start;
	gap: 12px;
}

.div-chat-mensagem {
	display: inline-flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: flex-start;
	gap: 4px;

	padding: 12px;
	border-radius: 10px;

	background: #fff;
	border: 1px solid var(--ui-border);
	box-shadow: 0 1px 4px var(--ui-shadow);
}

.div-chat-mensagem.ia,
.div-chat-mensagem.usuario {
	background: #fff;
	border: 1px solid var(--ui-border);
	box-shadow: 0 1px 4px var(--ui-shadow);
}

.div-chat-mensagem.usuario .div-chat-mensagem-info {
	justify-content: flex-end;
}

.div-chat-mensagem-info {
	align-self: stretch;
	display: inline-flex;
	justify-content: flex-start;
	align-items: center;
	gap: 8px;
	max-width: 940px;
}

.span-nome,
.span-tempo,
.span-meta {
	color: #000;
	font-weight: 700;
	word-wrap: break-word;
}

.span-nome {
	font-size: 16px;
}

.span-tempo {
	font-size: 12px;
}

.p-mensagem {
	color: #000;
	font-size: 14px;
	font-weight: 700;
	word-wrap: break-word;
	white-space: pre-wrap;
}

/* =========================================================
   7) FEEDBACK / BOTÕES DENTRO DAS MENSAGENS
   ========================================================= */
.div-feedback {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
	margin-top: 4px;
}

.btn-feedback {
	border: none;
	background: none;
	cursor: pointer;
	padding: 2px;
	color: #000;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-feedback:hover i,
.btn-feedback:hover svg {
	opacity: 0.6;
	transform: scale(1.1);
}

.btn-copy-pergunta,
.btn-go-end-pergunta {
	color: inherit;
}

/* Ícones comuns */
.btn-feedback,
.btn-copy-pergunta,
.btn-go-end-pergunta {
	border-radius: 6px;
	padding: 3px 5px;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-feedback:hover,
.btn-copy-pergunta:hover,
.btn-go-end-pergunta:hover {
	background: rgba(0, 0, 0, 0.08);
	color: #000;
}

.btn-feedback:active,
.btn-copy-pergunta:active,
.btn-go-end-pergunta:active {
	transform: scale(0.96);
}

/* =========================================================
   8) LOADING / BOLINHAS
   ========================================================= */
.div-chat-main-loading {
	align-self: stretch;
	display: flex;
	justify-content: flex-end;
}

.div-resposta {
	align-self: stretch;
	display: inline-flex;
	justify-content: flex-end;
	align-items: flex-start;
	gap: 12px;
	margin-top: 8px;
}

.div-resposta-balao {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;

	padding: 10px 14px;
	height: 40px;
	margin: 10px 0;

	background: #fff;
	border: 1px solid var(--ui-border);
	border-radius: 20px;
	box-shadow: 0 1px 3px var(--ui-shadow);
}

.ia-loading-status {
	align-items: center;
	max-width: min(420px, calc(100vw - 140px));
	min-height: 32px;
	margin: 14px 0 0 4px;
	padding: 7px 11px;
	border: 1px solid var(--ui-border);
	border-radius: 8px;
	background: #ffffff;
	color: #1f2933;
	font-size: 13px;
	line-height: 1.25;
	box-shadow: 0 1px 3px var(--ui-shadow);
	white-space: normal;
	overflow-wrap: anywhere;
}

.div-resposta-balao div {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background-color: #777;
	opacity: 0.4;
	animation: bounce 1.2s infinite ease-in-out;
}

.div-balao-inativo {
	background: #777;
}

.div-balao-ativo {
	background: #000;
	opacity: 1;
}

/* Atrasos do efeito */
.div-resposta-balao div:nth-child(1) {
	animation-delay: 0s;
}

.div-resposta-balao div:nth-child(2) {
	animation-delay: 0.2s;
}

.div-resposta-balao div:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes bounce {
	0%, 80%, 100% {
		transform: scale(0.8);
		opacity: 0.4;
	}
	40% {
		transform: scale(1.2);
		opacity: 1;
	}
}

/* =========================================================
   9) INPUT (pergunta + botão enviar)
   ========================================================= */
.div-input-main {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	gap: 12px;

	position: static; /* header/footer já são fixed */
	background: #fff;
	padding-top: 4px;
}

.div-input {
	flex-grow: 1;
	align-self: stretch;

	display: inline-flex;
	align-items: center;
	justify-content: flex-start;
	gap: 12px;

	padding: 8px 16px;
	border-radius: 12px;
	border: 2px solid var(--ui-border);
	background: #fff;
}

textarea {
	letter-spacing: 1px;
	resize: none;
	border: 0;
}

#user-input {
	flex-grow: 1;
	align-self: stretch;
	width: 100%;

	background: #fff;
	color: #000;
	border: 1px solid var(--ui-border);
	border-radius: 8px;

	font-size: 16px;
	font-weight: 700;
	line-height: 1.4;

	resize: none;
	overflow-y: hidden;

	transform: translateZ(0);
	-webkit-text-size-adjust: 100%;
	-webkit-appearance: none;
}

#user-input::placeholder {
	color: #444;
	font-weight: 700;
	opacity: 1;
}

button {
	border: 0;
}

#send-button,
.buttonSubmit {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	background: #fff;
	border: 1px solid var(--ui-border);
	border-radius: 10px;
	padding: 8px 10px;
	box-shadow: 0 1px 3px var(--ui-shadow);
	color: #000;

	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

#send-button:hover:not(:disabled),
.buttonSubmit:hover:not(:disabled) {
	background: #000;
	color: #fff;
	border-color: #000;
}

#send-button:active:not(:disabled),
.buttonSubmit:active:not(:disabled) {
	transform: scale(0.98);
}

#send-button i,
.buttonSubmit i {
	color: inherit; /* ícone acompanha a cor do botão */
}

/* Mantém compatibilidade se ainda houver botão com imagem */
button > img {
	width: 16px;
}

/* =========================================================
   10) GRÁFICO
   ========================================================= */
.chart-container {
	flex: 0 0 220px;
	max-height: 35vh;
	min-height: 120px;

	padding: 8px 12px;
	box-sizing: border-box;
	margin-top: 4px;

	background: #fff;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
	box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.04);

	display: none; /* começa escondido; JS mostra */
}

#chart-canvas {
	width: 100%;
	height: 100%;
	background: #fff;
	border-radius: 4px;
}

/* =========================================================
   11) BLOCO SQL
   ========================================================= */
.sql-block {
	background: #fff;
	color: #000;
	border: 1px solid var(--ui-border);
	border-radius: 6px;

	padding: 16px;                 /* antes 8px -> 2x */
	margin-top: 8px;
	min-height: 180px;             /* aumenta bastante o espaço visível */
	max-height: 420px;             /* ~3x mais área útil */
	overflow: auto;

	font-family: Consolas, "Courier New", monospace;
	font-size: 24px;               /* antes 12px -> 2x */
	line-height: 1.35;
	font-weight: 700;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Ícone alternativo de SQL (se tiveres classe dedicada) */
.btn-sql,
.btn-sql-feedback {
	color: #000;
}

/* =========================================================
   12) RODAPÉ / FILTROS (fixo em baixo)
   ========================================================= */
footer {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000;

	min-height: var(--footer-h);
	height: auto;
	box-sizing: border-box;

	margin: 0;
	padding: 8px 12px;

	background: var(--footer-bg);
	color: #000;
	border-top: 1px solid var(--ui-border-strong);

	font-size: 14px;
	font-weight: 700;
}

footer > div {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;

	background: var(--footer-bg);
	color: #000;
	font-weight: 700;
}

footer label {
	color: #000;
	font-weight: 700;
}

footer select {
	background: var(--footer-field-bg);
	color: #000;
	border: 1px solid var(--ui-border-strong);
	border-radius: 4px;
	font-weight: 700;
	padding: 2px 4px;
}

/* Inputs visíveis (geral) */
footer input:not([type="hidden"]) {
	color: #000;
	font-weight: 700;
}

/* TxtEmpresa e TxtUtilizador_ sem caixa e com fundo igual ao bloco */
footer input[id$="TxtEmpresa"],
footer input[id$="TxtUtilizador_"] {
	background: var(--footer-bg);
	color: #000;

	border: none;
	box-shadow: none;
	outline: none;
	border-radius: 0;

	padding: 0 4px;
	font-weight: 700;
}

footer input[id$="TxtEmpresa"]:focus,
footer input[id$="TxtUtilizador_"]:focus {
	border: none;
	box-shadow: none;
	outline: none;
}

/* =========================================================
   13) CLASSES LEGADAS / COMPATIBILIDADE (se existirem)
   ========================================================= */
.div-main {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 24px;
}

.div-main > h1,
.div-main > h2,
.h1-main {
	color: #000;
}

.h1-main {
	font-size: 32px;
	font-weight: 400;
	word-wrap: break-word;
}

.div-menu-itens {
	display: flex;
	flex-direction: column;
	gap: 16px;
	border-radius: 10px;
	background-color: #f3f3f3;
	padding: 12px;
}

.div-menu-itens > h3 {
	color: #000;
}

.form-submit {
	display: inline-flex;
	flex-grow: 1;
}

.img-adicionar {
	width: 16px;
}

/* =========================================================
   14) SAFE AREAS (iPhone / mobile)
   ========================================================= */
@supports (padding: max(0px)) {
	.kb-ia-header {
		padding-top: max(8px, env(safe-area-inset-top));
		height: calc(var(--ia-header-h) + env(safe-area-inset-top));
	}

	main {
		top: calc(var(--ia-header-h) + env(safe-area-inset-top));
		bottom: calc(var(--footer-h) + env(safe-area-inset-bottom));
	}

	footer {
		padding-bottom: max(8px, env(safe-area-inset-bottom));
	}
}
/* CODEx_IA_BUTTONS_WHITE_BLACK */
#IAButton,
input#IAButton,
.procurarButton#IAButton,
.kb-ia-panel button,
.kb-ia-header button,
.kb-ia-footer button,
#IA_PANEL button,
.msg-actions button,
.div-feedback button,
.kb-ia-btn,
.kb-ia-btn:hover,
.btn-feedback,
.btn-feedback:hover,
.btn-copy-pergunta,
.btn-copy-pergunta:hover,
.btn-go-end-pergunta,
.btn-go-end-pergunta:hover,
#IA_Send,
#IA_Send:hover,
#send-button,
#send-button:hover:not(:disabled),
.buttonSubmit,
.buttonSubmit:hover:not(:disabled) {
	background: #fff !important;
	background-color: #fff !important;
	color: #000 !important;
	border-color: #000 !important;
	box-shadow: none !important;
}
#IAButton,
input#IAButton,
.procurarButton#IAButton,
.kb-ia-panel button,
.kb-ia-header button,
.kb-ia-footer button,
#IA_PANEL button,
.msg-actions button,
.div-feedback button,
.kb-ia-btn,
.btn-feedback,
.btn-copy-pergunta,
.btn-go-end-pergunta,
#IA_Send,
#send-button,
.buttonSubmit {
	border: 1px solid #000 !important;
}
#IAButton *,
.kb-ia-panel button *,
.kb-ia-header button *,
.kb-ia-footer button *,
#IA_PANEL button *,
.msg-actions button *,
.div-feedback button *,
.kb-ia-btn i,
.btn-feedback i,
.btn-copy-pergunta i,
.btn-go-end-pergunta i,
#IA_Send i,
#send-button i,
.buttonSubmit i,
.kb-ia-btn svg,
.btn-feedback svg,
.btn-copy-pergunta svg,
.btn-go-end-pergunta svg,
#IA_Send svg,
#send-button svg,
.buttonSubmit svg,
.kb-ia-btn svg *,
.btn-feedback svg *,
.btn-copy-pergunta svg *,
.btn-go-end-pergunta svg *,
#IA_Send svg *,
#send-button svg *,
.buttonSubmit svg * {
	background: #fff !important;
	background-color: #fff !important;
	color: #000 !important;
	fill: #000 !important;
	stroke: #000 !important;
}
#IAButton:before,
.kb-ia-panel button:before,
.kb-ia-header button:before,
.kb-ia-footer button:before,
#IA_PANEL button:before,
.msg-actions button:before,
.div-feedback button:before,
.kb-ia-btn i:before,
.btn-feedback i:before,
.btn-copy-pergunta i:before,
.btn-go-end-pergunta i:before,
#IA_Send i:before,
#send-button i:before,
.buttonSubmit i:before {
	background: #fff !important;
	background-color: #fff !important;
	color: #000 !important;
}
/* /CODEx_IA_BUTTONS_WHITE_BLACK */
