/**
 * Gemini AI Chat Agent - Public Widget Stylesheet
 */

:root {
	--gaca-primary: #1a73e8;
	--gaca-primary-dark: #1557b0;
	--gaca-radius: 16px;
	--gaca-desk-x: 24px;
	--gaca-desk-y: 24px;
	--gaca-mob-x: 16px;
	--gaca-mob-y: 16px;
	--gaca-panel-width: 380px;
	--gaca-panel-height: 580px;
	--gaca-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
}

/* Container Fixed Layer */
.gaca-widget-container {
	position: fixed;
	z-index: 999999;
	font-family: var(--gaca-font-family);
	box-sizing: border-box;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.gaca-widget-container * {
	box-sizing: border-box;
}

/* PHYSICAL POSITIONING (MANDATORY REQUIREMENT) */
.gaca-widget-container.gaca-pos-bottom-right {
	right: var(--gaca-desk-x);
	left: auto;
	bottom: var(--gaca-desk-y);
}

.gaca-widget-container.gaca-pos-bottom-left {
	left: var(--gaca-desk-x);
	right: auto;
	bottom: var(--gaca-desk-y);
}

/* Floating Launcher Button */
.gaca-launcher-btn {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background-color: var(--gaca-primary);
	color: #ffffff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
	transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, box-shadow 0.2s ease;
	outline: none;
	position: relative;
}

.gaca-launcher-btn:hover {
	transform: scale(1.05);
	background-color: var(--gaca-primary-dark);
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
}

.gaca-launcher-btn:focus-visible {
	outline: 3px solid rgba(26, 115, 232, 0.6);
	outline-offset: 3px;
}

.gaca-launcher-btn .gaca-icon-chat,
.gaca-launcher-btn .gaca-icon-close {
	transition: opacity 0.2s ease, transform 0.2s ease;
	position: absolute;
}

.gaca-launcher-btn .gaca-icon-close {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.gaca-widget-container.gaca-open .gaca-launcher-btn .gaca-icon-chat {
	opacity: 0;
	transform: rotate(90deg) scale(0.6);
}

.gaca-widget-container.gaca-open .gaca-launcher-btn .gaca-icon-close {
	opacity: 1;
	transform: rotate(0) scale(1);
}

/* Launcher Tooltip */
.gaca-launcher-tooltip {
	position: absolute;
	bottom: 68px;
	background: #1e293b;
	color: #ffffff;
	font-size: 13px;
	padding: 6px 14px;
	border-radius: 8px;
	white-space: nowrap;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	pointer-events: none;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.gaca-pos-bottom-right .gaca-launcher-tooltip {
	right: 0;
}

.gaca-pos-bottom-left .gaca-launcher-tooltip {
	left: 0;
}

.gaca-widget-container:not(.gaca-open) .gaca-launcher-btn:hover + .gaca-launcher-tooltip,
.gaca-launcher-tooltip.gaca-tooltip-visible {
	opacity: 1;
	transform: translateY(0);
}

/* Chat Panel */
.gaca-chat-panel {
	position: absolute;
	bottom: 72px;
	width: var(--gaca-panel-width);
	height: var(--gaca-panel-height);
	max-height: calc(100vh - 100px);
	background: #ffffff;
	border-radius: var(--gaca-radius);
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: scale(0.94) translateY(12px);
	pointer-events: none;
	transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Inward panel anchoring based on position */
.gaca-pos-bottom-right .gaca-chat-panel {
	right: 0;
	left: auto;
	transform-origin: bottom right;
}

.gaca-pos-bottom-left .gaca-chat-panel {
	left: 0;
	right: auto;
	transform-origin: bottom left;
}

.gaca-widget-container.gaca-open .gaca-chat-panel {
	opacity: 1;
	transform: scale(1) translateY(0);
	pointer-events: auto;
}

/* Panel Header */
.gaca-panel-header {
	background: #ffffff;
	border-bottom: 1px solid #eef0f2;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.gaca-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.gaca-avatar {
	width: 36px;
	height: 36px;
	background: linear-gradient(135deg, var(--gaca-primary) 0%, var(--gaca-primary-dark) 100%);
	color: #ffffff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gaca-header-meta {
	display: flex;
	flex-direction: column;
}

.gaca-header-title {
	font-size: 15px;
	font-weight: 600;
	color: #1a1a1a;
}

.gaca-header-status {
	font-size: 12px;
	color: #16a34a;
	display: flex;
	align-items: center;
	gap: 4px;
}

.gaca-header-status::before {
	content: "";
	width: 6px;
	height: 6px;
	background: #16a34a;
	border-radius: 50%;
	display: inline-block;
}

.gaca-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.gaca-action-btn {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 6px;
	border-radius: 6px;
	color: #64748b;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}

.gaca-action-btn:hover {
	background: #f1f5f9;
	color: #0f172a;
}

/* Message History Scroll Area */
.gaca-messages-area {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: #fafbfc;
}

.gaca-message-row {
	display: flex;
	flex-direction: column;
	max-width: 86%;
}

.gaca-message-user {
	align-self: flex-end;
}

.gaca-message-assistant {
	align-self: flex-start;
}

.gaca-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.gaca-message-user .gaca-bubble {
	background: var(--gaca-primary);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.gaca-message-assistant .gaca-bubble {
	background: #ffffff;
	color: #1e293b;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.gaca-bubble a {
	color: var(--gaca-primary);
	text-decoration: underline;
}

.gaca-bubble p {
	margin: 0 0 8px 0;
}

.gaca-bubble p:last-child {
	margin-bottom: 0;
}

.gaca-bubble ul, .gaca-bubble ol {
	margin: 6px 0;
	padding-left: 20px;
}

/* Source Citations */
.gaca-sources {
	margin-top: 8px;
	padding-top: 6px;
	border-top: 1px solid #edf2f7;
	font-size: 11px;
	color: #64748b;
}

/* Fallback Contact Action Buttons */
.gaca-fallback-card {
	margin-top: 10px;
	padding-top: 8px;
	border-top: 1px dashed #cbd5e1;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.gaca-fallback-title {
	font-size: 11px;
	font-weight: 600;
	color: #475569;
	margin-bottom: 2px;
}

.gaca-fallback-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.gaca-fallback-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 600;
	text-decoration: none;
	background: #f1f5f9;
	color: #0f172a;
	border: 1px solid #cbd5e1;
	transition: all 0.15s ease;
	cursor: pointer;
}

.gaca-fallback-btn:hover {
	background: #e2e8f0;
	border-color: #94a3b8;
	color: #000000;
}

.gaca-fallback-btn.btn-whatsapp {
	background: #25d366;
	color: #ffffff;
	border-color: #20ba5a;
}

.gaca-fallback-btn.btn-whatsapp:hover {
	background: #20ba5a;
	color: #ffffff;
}

.gaca-sources-title {
	font-weight: 600;
	margin-bottom: 4px;
}

.gaca-sources-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.gaca-source-link {
	color: var(--gaca-primary);
	text-decoration: none;
	background: #f1f5f9;
	padding: 2px 6px;
	border-radius: 4px;
}

.gaca-source-link:hover {
	text-decoration: underline;
}

/* Typing Indicator */
.gaca-typing-indicator {
	padding: 0 16px 8px 16px;
	background: #fafbfc;
}

.gaca-typing-bubble {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
}

.gaca-typing-bubble span {
	width: 6px;
	height: 6px;
	background: #94a3b8;
	border-radius: 50%;
	animation: gacaBounce 1.2s infinite ease-in-out both;
}

.gaca-typing-bubble span:nth-child(1) { animation-delay: -0.32s; }
.gaca-typing-bubble span:nth-child(2) { animation-delay: -0.16s; }

@keyframes gacaBounce {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1); }
}

/* GDPR Notice */
.gaca-gdpr-notice {
	font-size: 11px;
	color: #64748b;
	padding: 6px 16px;
	background: #f8fafc;
	border-top: 1px solid #f1f5f9;
	text-align: center;
}

/* Footer Input Area */
.gaca-input-form {
	padding: 12px 14px;
	background: #ffffff;
	border-top: 1px solid #eef0f2;
	flex-shrink: 0;
}

.gaca-input-wrap {
	display: flex;
	align-items: flex-end;
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 20px;
	padding: 6px 10px 6px 14px;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.gaca-input-wrap:focus-within {
	border-color: var(--gaca-primary);
	background: #ffffff;
	box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.gaca-input-field {
	flex: 1;
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	max-height: 100px;
	outline: none;
	padding: 4px 0;
	color: #1e293b;
}

.gaca-submit-btn {
	background: var(--gaca-primary);
	color: #ffffff;
	border: none;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	margin-left: 6px;
	flex-shrink: 0;
	transition: background-color 0.15s ease, transform 0.1s ease;
}

.gaca-submit-btn:hover {
	background: var(--gaca-primary-dark);
}

.gaca-submit-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Responsive Mobile Rules */
@media (max-width: 480px) {
	.gaca-widget-container.gaca-pos-bottom-right {
		right: var(--gaca-mob-x);
		bottom: var(--gaca-mob-y);
	}
	.gaca-widget-container.gaca-pos-bottom-left {
		left: var(--gaca-mob-x);
		bottom: var(--gaca-mob-y);
	}
	.gaca-chat-panel {
		position: fixed;
		top: 0;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		margin: 0;
		z-index: 1000000;
	}
}
