/**
 * dime-ChatBot – Frontend-Widget-Styles
 * Verwendet CSS-Variablen, damit die im Admin gewählte Widget-Farbe
 * (per inline style auf #dime-chatbot-root) das ganze Widget einfärbt.
 */

#dime-chatbot-root {
	--dime-chatbot-color: #0073aa;
	--dime-chatbot-color-dark: #005177;
	--dime-chatbot-radius: 14px;
	--dime-chatbot-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	all: initial;
	font-family: var(--dime-chatbot-font);
	color: #1e1e1e;
	line-height: 1.45;
}

#dime-chatbot-root *,
#dime-chatbot-root *::before,
#dime-chatbot-root *::after {
	box-sizing: border-box;
	font-family: inherit;
}

/* --- Schwebender Toggle-Button --- */
.dime-chatbot-toggle {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	background: var(--dime-chatbot-color);
	color: #fff;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dime-chatbot-toggle:hover {
	transform: scale(1.06);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

/* --- Position: links unten (Standard ist rechts unten, s.o.) --- */
#dime-chatbot-root.dime-chatbot-pos-left .dime-chatbot-toggle {
	right: auto;
	left: 20px;
}

#dime-chatbot-root.dime-chatbot-pos-left .dime-chatbot-window {
	right: auto;
	left: 20px;
}

#dime-chatbot-root.dime-chatbot-pos-left .dime-chatbot-toggle-badge {
	right: auto;
	left: -2px;
}

@media (max-width: 480px) {
	#dime-chatbot-root.dime-chatbot-pos-left .dime-chatbot-toggle {
		left: 14px;
	}
	#dime-chatbot-root.dime-chatbot-pos-left .dime-chatbot-window {
		left: 10px;
	}
}

.dime-chatbot-toggle:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.dime-chatbot-toggle svg {
	width: 26px;
	height: 26px;
}

.dime-chatbot-toggle .dime-chatbot-icon-close {
	display: none;
}

#dime-chatbot-root.is-open .dime-chatbot-icon-open {
	display: none;
}

#dime-chatbot-root.is-open .dime-chatbot-icon-close {
	display: block;
}

/* Kleiner Punkt auf dem Button für die Begrüßung beim ersten Besuch */
.dime-chatbot-toggle-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #e0402d;
	border: 2px solid #fff;
}

/* --- Chat-Fenster --- */
.dime-chatbot-window {
	position: fixed;
	right: 20px;
	bottom: 90px;
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 540px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: var(--dime-chatbot-radius);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.16s ease, transform 0.16s ease;
	z-index: 999998;
}

#dime-chatbot-root.is-open .dime-chatbot-window {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* --- Header --- */
.dime-chatbot-header {
	background: var(--dime-chatbot-color);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.dime-chatbot-header-title {
	font-size: 15px;
	font-weight: 600;
	margin: 0;
}

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

.dime-chatbot-icon-btn {
	background: transparent;
	border: none;
	color: #fff;
	opacity: 0.85;
	cursor: pointer;
	width: 30px;
	height: 30px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.dime-chatbot-icon-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.15);
}

.dime-chatbot-icon-btn svg {
	width: 17px;
	height: 17px;
}

/* --- Nachrichtenbereich --- */
.dime-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f7f8;
}

.dime-chatbot-messages[hidden] {
	display: none;
}

.dime-chatbot-msg {
	max-width: 82%;
	padding: 9px 12px;
	border-radius: 14px;
	font-size: 13.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.dime-chatbot-msg--assistant {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e6e6e8;
	border-bottom-left-radius: 4px;
	color: #1e1e1e;
}

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

.dime-chatbot-msg--error {
	align-self: center;
	background: #fdecea;
	color: #a3291c;
	border: 1px solid #f5c6c0;
	font-size: 12.5px;
	text-align: center;
}

/* Typing-Indikator */
.dime-chatbot-msg--typing {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e6e6e8;
	border-bottom-left-radius: 4px;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 11px 14px;
}

.dime-chatbot-msg--typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #b5b5ba;
	animation: dime-chatbot-blink 1.2s infinite ease-in-out;
}

.dime-chatbot-msg--typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.dime-chatbot-msg--typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes dime-chatbot-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.dime-chatbot-msg--typing span {
		animation: none;
		opacity: 0.6;
	}
	.dime-chatbot-toggle,
	.dime-chatbot-window {
		transition: none;
	}
}

/* --- Datenschutz-Hinweis --- */
.dime-chatbot-privacy-note {
	font-size: 11px;
	color: #8a8a8f;
	padding: 6px 16px;
	text-align: center;
	background: #f7f7f8;
	flex-shrink: 0;
}

/* --- Handoff: Support-Kontaktformular --- */
.dime-chatbot-handoff {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f7f7f8;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.dime-chatbot-handoff[hidden] {
	display: none;
}

.dime-chatbot-handoff-intro {
	font-size: 13px;
	color: #55555a;
	margin: 0;
}

.dime-chatbot-handoff-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.dime-chatbot-handoff-field label {
	font-size: 12px;
	font-weight: 600;
	color: #1e1e1e;
}

.dime-chatbot-handoff-field input,
.dime-chatbot-handoff-field textarea {
	border: 1px solid #dcdce0;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 13.5px;
	background: #fff;
}

.dime-chatbot-handoff-field textarea {
	resize: vertical;
	min-height: 80px;
}

.dime-chatbot-handoff-actions {
	display: flex;
	gap: 8px;
	margin-top: 4px;
}

.dime-chatbot-handoff-submit {
	flex: 1;
	border: none;
	border-radius: 18px;
	background: var(--dime-chatbot-color);
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	padding: 10px 14px;
	cursor: pointer;
}

.dime-chatbot-handoff-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.dime-chatbot-handoff-cancel {
	border: 1px solid #dcdce0;
	border-radius: 18px;
	background: #fff;
	color: #1e1e1e;
	font-size: 13.5px;
	padding: 10px 14px;
	cursor: pointer;
}

.dime-chatbot-handoff-status {
	font-size: 12.5px;
	border-radius: 8px;
	padding: 8px 10px;
}

.dime-chatbot-handoff-status--success {
	background: #eaf7ec;
	color: #23643a;
	border: 1px solid #c3e6cb;
}

.dime-chatbot-handoff-status--error {
	background: #fdecea;
	color: #a3291c;
	border: 1px solid #f5c6c0;
}

.dime-chatbot-handoff-status[hidden] {
	display: none;
}

/* --- Inline-Vorschlag "Mit einem Mitarbeiter sprechen" --- */
.dime-chatbot-suggest {
	align-self: flex-start;
	max-width: 82%;
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: -4px;
}

.dime-chatbot-suggest-text {
	font-size: 11.5px;
	color: #8a8a8f;
}

.dime-chatbot-suggest-btn {
	align-self: flex-start;
	border: 1px solid var(--dime-chatbot-color);
	color: var(--dime-chatbot-color);
	background: #fff;
	border-radius: 14px;
	font-size: 12px;
	font-weight: 600;
	padding: 6px 12px;
	cursor: pointer;
}

.dime-chatbot-suggest-btn:hover {
	background: var(--dime-chatbot-color);
	color: #fff;
}

/* --- DSGVO-Consent-Gate (ersetzt die Eingabeleiste, bis akzeptiert wurde) --- */
.dime-chatbot-consent {
	padding: 14px 16px 16px;
	border-top: 1px solid #ececee;
	background: #fff;
	flex-shrink: 0;
}

.dime-chatbot-consent-title {
	font-size: 13px;
	font-weight: 600;
	margin: 0 0 6px;
	color: #1e1e1e;
}

.dime-chatbot-consent-text {
	font-size: 12px;
	color: #55555a;
	margin: 0 0 10px;
	line-height: 1.5;
}

.dime-chatbot-consent-text a {
	color: var(--dime-chatbot-color);
}

.dime-chatbot-consent-accept {
	width: 100%;
	border: none;
	border-radius: 18px;
	background: var(--dime-chatbot-color);
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	padding: 10px 14px;
	cursor: pointer;
}

.dime-chatbot-consent-accept:focus-visible {
	outline: 2px solid var(--dime-chatbot-color);
	outline-offset: 2px;
}

.dime-chatbot-consent[hidden],
.dime-chatbot-inputbar[hidden] {
	display: none;
}

/* --- Eingabebereich --- */
.dime-chatbot-inputbar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #ececee;
	background: #fff;
	flex-shrink: 0;
}

.dime-chatbot-input {
	flex: 1;
	resize: none;
	border: 1px solid #dcdce0;
	border-radius: 18px;
	padding: 9px 14px;
	font-size: 13.5px;
	max-height: 90px;
	min-height: 38px;
	line-height: 1.35;
}

.dime-chatbot-input:focus-visible {
	outline: 2px solid var(--dime-chatbot-color);
	outline-offset: 1px;
}

.dime-chatbot-send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	background: var(--dime-chatbot-color);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.dime-chatbot-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.dime-chatbot-send svg {
	width: 16px;
	height: 16px;
}

/* --- Mobile / kleine Viewports --- */
@media (max-width: 480px) {
	.dime-chatbot-window {
		right: 10px;
		bottom: 84px;
		left: 10px;
		width: auto;
		max-width: none;
		height: calc(100vh - 104px);
		max-height: none;
	}

	.dime-chatbot-toggle {
		right: 14px;
		bottom: 14px;
	}
}
