/**
 * OctoRagChat - Chat-Widget Styles
 *
 * Eigenstaendiges CSS fuer das oeffentliche Chat-Widget.
 * Alle Selektoren unter #ragchat-widget gekapselt.
 * Hohe Spezifitaet um Konflikte mit Host-Seiten-Styles zu vermeiden.
 */

/* =========================================================================
   CSS-Variablen
   ========================================================================= */

#ragchat-widget {
	--ragchat-primary: #006899;
	--ragchat-primary-hover: #005577;
	--ragchat-msg-bot: #f3f4f6;
	--ragchat-msg-user: var(--ragchat-primary);
	--ragchat-msg-user-text: #ffffff;
	--ragchat-msg-bot-text: #1f2937;
	--ragchat-bg: #ffffff;
	--ragchat-border: #e5e7eb;
	--ragchat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ragchat-z: 99999;
	--ragchat-radius: 12px;
	--ragchat-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* =========================================================================
   Reset / Basis — hohe Spezifitaet gegen Host-Seiten-Resets
   ========================================================================= */

#ragchat-widget,
#ragchat-widget *,
#ragchat-widget *::before,
#ragchat-widget *::after {
	box-sizing: border-box !important;
}

#ragchat-widget {
	font-family: var(--ragchat-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--ragchat-msg-bot-text);
	position: fixed;
	z-index: var(--ragchat-z);
	margin: 0;
	padding: 0;
}

/* =========================================================================
   Position
   ========================================================================= */

#ragchat-widget.ragchat-bottom-right {
	bottom: 20px;
	right: 20px;
}

#ragchat-widget.ragchat-bottom-left {
	bottom: 20px;
	left: 20px;
}

/* =========================================================================
   Toggle-Button
   ========================================================================= */

#ragchat-widget .ragchat-toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--ragchat-primary);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
	transition: background 0.2s, transform 0.2s;
	position: relative;
	margin: 0;
	padding: 0;
}

#ragchat-widget .ragchat-toggle:hover {
	background: var(--ragchat-primary-hover);
	transform: scale(1.05);
}

#ragchat-widget .ragchat-toggle svg {
	width: 28px;
	height: 28px;
	fill: #ffffff;
	margin: 0;
	padding: 0;
}

#ragchat-widget .ragchat-toggle .ragchat-icon-close {
	display: none;
}

#ragchat-widget.ragchat-open .ragchat-toggle .ragchat-icon-chat {
	display: none;
}

#ragchat-widget.ragchat-open .ragchat-toggle .ragchat-icon-close {
	display: block;
}

/* =========================================================================
   Chat-Fenster
   ========================================================================= */

#ragchat-widget .ragchat-window {
	width: 380px;
	height: 520px;
	background: var(--ragchat-bg);
	border-radius: var(--ragchat-radius);
	box-shadow: var(--ragchat-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	position: absolute;
	bottom: 70px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--ragchat-border);
}

#ragchat-widget.ragchat-open .ragchat-window {
	display: flex;
	animation: ragchat-slide-in 0.25s ease-out;
}

#ragchat-widget.ragchat-bottom-right .ragchat-window {
	right: 0;
}

#ragchat-widget.ragchat-bottom-left .ragchat-window {
	left: 0;
}

@keyframes ragchat-slide-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.95);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* =========================================================================
   Header
   ========================================================================= */

#ragchat-widget .ragchat-header {
	background: var(--ragchat-primary);
	color: #ffffff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	margin: 0;
	border: none;
	border-radius: 0;
}

#ragchat-widget .ragchat-header-avatar {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.6);
	flex-shrink: 0;
	margin: 0 10px 0 0;
	padding: 0;
}

#ragchat-widget .ragchat-header-title {
	font-size: 20px;
	font-weight: 700;
	color: #ffffff;
	margin: 0;
	padding: 0;
	line-height: 1.4;
	flex: 1;
	text-align: left;
}

#ragchat-widget .ragchat-header-close {
	background: none;
	border: none;
	color: #ffffff;
	cursor: pointer;
	padding: 4px;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s;
	width: auto;
	height: auto;
}

#ragchat-widget .ragchat-header-close:hover {
	background: rgba(255, 255, 255, 0.2);
}

#ragchat-widget .ragchat-header-close svg {
	width: 18px;
	height: 18px;
	fill: #ffffff;
	margin: 0;
	padding: 0;
}

/* =========================================================================
   Nachrichten-Bereich
   ========================================================================= */

#ragchat-widget .ragchat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0;
	background: var(--ragchat-bg);
}

#ragchat-widget .ragchat-messages::-webkit-scrollbar {
	width: 6px;
}

#ragchat-widget .ragchat-messages::-webkit-scrollbar-track {
	background: transparent;
}

#ragchat-widget .ragchat-messages::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 3px;
}

/* =========================================================================
   Nachrichten-Bubbles
   ========================================================================= */

#ragchat-widget .ragchat-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	margin: 0;
	border: none;
	line-height: 1.5;
}

#ragchat-widget .ragchat-msg-bot {
	background: var(--ragchat-msg-bot);
	color: var(--ragchat-msg-bot-text);
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

#ragchat-widget .ragchat-msg-user {
	background: var(--ragchat-msg-user);
	color: var(--ragchat-msg-user-text);
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

#ragchat-widget .ragchat-msg-system {
	text-align: center;
	color: #9ca3af;
	font-size: 12px;
	align-self: center;
	max-width: 100%;
	padding: 4px 8px;
	background: none;
}

/* Markdown innerhalb Bot-Nachrichten */
#ragchat-widget .ragchat-msg-bot p {
	margin: 0 0 8px 0;
	padding: 0;
	line-height: 1.5;
}

#ragchat-widget .ragchat-msg-bot p:last-child {
	margin-bottom: 0;
}

#ragchat-widget .ragchat-msg-bot ul,
#ragchat-widget .ragchat-msg-bot ol {
	margin: 4px 0 8px 0;
	padding: 0 0 0 20px;
	list-style-position: outside;
}

#ragchat-widget .ragchat-msg-bot ul {
	list-style-type: disc;
}

#ragchat-widget .ragchat-msg-bot ol {
	list-style-type: decimal;
}

#ragchat-widget .ragchat-msg-bot li {
	margin: 0 0 2px 0;
	padding: 0;
	line-height: 1.5;
}

#ragchat-widget .ragchat-msg-bot code {
	background: rgba(0, 0, 0, 0.06);
	padding: 1px 4px;
	border-radius: 3px;
	font-size: 13px;
	font-family: "SF Mono", "Fira Code", Consolas, monospace;
	margin: 0;
	border: none;
}

#ragchat-widget .ragchat-msg-bot pre {
	background: #1f2937;
	color: #e5e7eb;
	padding: 10px 12px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 6px 0;
	font-size: 13px;
	border: none;
}

#ragchat-widget .ragchat-msg-bot pre code {
	background: none;
	padding: 0;
	color: inherit;
}

#ragchat-widget .ragchat-msg-bot a {
	color: var(--ragchat-primary);
	text-decoration: underline;
}

#ragchat-widget .ragchat-msg-bot strong {
	font-weight: 600;
}

#ragchat-widget .ragchat-msg-bot em {
	font-style: italic;
}

/* =========================================================================
   Typing-Indicator
   ========================================================================= */

#ragchat-widget .ragchat-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	background: var(--ragchat-msg-bot);
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	max-width: 85%;
	margin: 0;
	border: none;
}

#ragchat-widget .ragchat-typing-dot {
	width: 8px;
	height: 8px;
	background: #9ca3af;
	border-radius: 50%;
	animation: ragchat-bounce 1.4s infinite ease-in-out both;
	margin: 0;
	padding: 0;
	border: none;
}

#ragchat-widget .ragchat-typing-dot:nth-child(1) {
	animation-delay: 0s;
}

#ragchat-widget .ragchat-typing-dot:nth-child(2) {
	animation-delay: 0.16s;
}

#ragchat-widget .ragchat-typing-dot:nth-child(3) {
	animation-delay: 0.32s;
}

@keyframes ragchat-bounce {
	0%, 80%, 100% {
		transform: scale(0.6);
		opacity: 0.4;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* =========================================================================
   Feedback-Buttons
   ========================================================================= */

#ragchat-widget .ragchat-feedback {
	display: flex;
	gap: 4px;
	margin: 4px 0 0 0;
	padding: 0;
	align-self: flex-start;
}

#ragchat-widget .ragchat-feedback-btn {
	background: none;
	border: 1px solid var(--ragchat-border);
	border-radius: 6px;
	padding: 3px 6px;
	margin: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s, border-color 0.2s;
	color: #9ca3af;
	width: auto;
	height: auto;
	font-size: inherit;
	line-height: 1;
}

#ragchat-widget .ragchat-feedback-btn:hover {
	background: #f3f4f6;
	border-color: #d1d5db;
	color: #6b7280;
}

#ragchat-widget .ragchat-feedback-btn.ragchat-feedback-sent {
	border-color: var(--ragchat-primary);
	color: var(--ragchat-primary);
	pointer-events: none;
}

#ragchat-widget .ragchat-feedback-btn svg {
	width: 14px;
	height: 14px;
	fill: currentColor;
	margin: 0;
	padding: 0;
}

/* =========================================================================
   Quellen-Anzeige
   ========================================================================= */

#ragchat-widget .ragchat-sources {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 8px;
	padding: 4px 0;
	margin: 0;
	font-size: 12px;
	line-height: 1.4;
}

#ragchat-widget .ragchat-sources-label {
	color: #6b7280;
	font-weight: 500;
	margin: 0;
	padding: 0;
}

#ragchat-widget .ragchat-source-link {
	color: var(--ragchat-primary);
	text-decoration: none;
	margin: 0;
	padding: 0;
}

#ragchat-widget .ragchat-source-link:hover {
	text-decoration: underline;
}

/* =========================================================================
   Input-Bereich
   ========================================================================= */

#ragchat-widget .ragchat-input-area {
	padding: 12px 16px;
	margin: 0;
	border: none;
	border-top: 1px solid var(--ragchat-border);
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex-shrink: 0;
	background: var(--ragchat-bg);
}

#ragchat-widget .ragchat-input {
	flex: 1;
	border: 1px solid var(--ragchat-border);
	border-radius: 8px;
	padding: 8px 12px;
	margin: 0;
	font-family: var(--ragchat-font);
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	outline: none;
	max-height: 96px;
	min-height: 36px;
	overflow-y: auto;
	transition: border-color 0.2s;
	background: #ffffff;
	color: var(--ragchat-msg-bot-text);
	-webkit-appearance: none;
	appearance: none;
}

#ragchat-widget .ragchat-input:focus {
	border-color: var(--ragchat-primary);
	outline: none;
	box-shadow: 0 0 0 2px rgba(0, 104, 153, 0.15);
}

#ragchat-widget .ragchat-input::placeholder {
	color: #9ca3af;
}

#ragchat-widget .ragchat-send-btn {
	width: 36px;
	height: 36px;
	min-width: 36px;
	min-height: 36px;
	border-radius: 8px;
	background: var(--ragchat-primary);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.2s;
	margin: 0;
	padding: 0;
}

#ragchat-widget .ragchat-send-btn:hover {
	background: var(--ragchat-primary-hover);
}

#ragchat-widget .ragchat-send-btn:disabled {
	background: #d1d5db;
	cursor: not-allowed;
}

#ragchat-widget .ragchat-send-btn svg {
	width: 18px;
	height: 18px;
	fill: #ffffff;
	margin: 0;
	padding: 0;
}

/* =========================================================================
   Footer / Disclaimer
   ========================================================================= */

#ragchat-widget .ragchat-footer {
	text-align: center;
	padding: 6px 16px 8px;
	margin: 0;
	font-size: 11px;
	color: #9ca3af;
	flex-shrink: 0;
	background: var(--ragchat-bg);
	border: none;
}

#ragchat-widget .ragchat-privacy-link {
	color: #9ca3af;
	text-decoration: underline;
	transition: color 0.2s;
}

#ragchat-widget .ragchat-privacy-link:hover {
	color: var(--ragchat-primary);
}

/* =========================================================================
   Responsive: Fullscreen auf Mobilgeraeten
   ========================================================================= */

@media (max-width: 640px) {
	#ragchat-widget.ragchat-open .ragchat-window {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
		bottom: 0;
	}

	#ragchat-widget.ragchat-open .ragchat-toggle {
		display: none;
	}
}

/* =========================================================================
   Print: Ausblenden
   ========================================================================= */

@media print {
	#ragchat-widget {
		display: none !important;
	}
}
