/**
 * Sales Wolf Chatbot UI Styles
 * Metodología BEM (sw-chat)
 */

:root {
	--sw-primary: #2563eb;
	--sw-primary-hover: #1d4ed8;
	--sw-bg-dark: #0b1120;
	--sw-bubble-bg: #1e293b;
	--sw-text-main: #f8fafc;
	--sw-text-muted: #94a3b8;
	--sw-user-bg: #2563eb;
	--sw-bot-bg: #1e293b;
	--sw-border: rgba(255, 255, 255, 0.1);
	--sw-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* Contenedor Principal Flotante */
.sw-chat-widget {
	position: fixed;
	bottom: 85px; /* Elevado por defecto para no tapar GTranslate o widgets de idioma */
	right: 24px;
	z-index: 999990;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

/* Modificadores de Posicionamiento */
.sw-chat-widget--bottom-right-elevated {
	bottom: 85px;
	right: 24px;
	left: auto;
	align-items: flex-end;
}

.sw-chat-widget--bottom-right {
	bottom: 24px;
	right: 24px;
	left: auto;
	align-items: flex-end;
}

.sw-chat-widget--bottom-left {
	bottom: 24px;
	left: 24px;
	right: auto;
	align-items: flex-start;
}

.sw-chat-widget--bottom-left-elevated {
	bottom: 85px;
	left: 24px;
	right: auto;
	align-items: flex-start;
}

/* Botón Burbuja Flotante (El Lobo) */
.sw-chat-trigger {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
	border: 2px solid #3b82f6;
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
	transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
	outline: none;
	position: relative;
}

.sw-chat-trigger:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 12px 28px rgba(37, 99, 235, 0.5);
	border-color: #60a5fa;
}

.sw-chat-trigger__icon {
	font-size: 30px;
	line-height: 1;
	user-select: none;
	transition: transform 0.3s ease;
}

.sw-chat-trigger__badge {
	position: absolute;
	top: -3px;
	right: -3px;
	width: 14px;
	height: 14px;
	background: #10b981;
	border: 2px solid #0f172a;
	border-radius: 50%;
	animation: sw-pulse 2s infinite;
}

@keyframes sw-pulse {
	0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
	70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
	100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Ventana de Conversación */
.sw-chat-window {
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 110px);
	background: #0f172a;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 16px;
	box-shadow: var(--sw-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	margin-bottom: 16px;
	animation: sw-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sw-chat-window--open {
	display: flex;
}

@keyframes sw-slide-up {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Cabecera del Chat */
.sw-chat-header {
	background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.sw-chat-header__info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.sw-chat-header__avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #2563eb;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.sw-chat-header__title {
	font-size: 15px;
	font-weight: 700;
	color: #f8fafc;
	margin: 0;
	line-height: 1.2;
}

.sw-chat-header__subtitle {
	font-size: 12px;
	color: #10b981;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 5px;
}

.sw-chat-header__subtitle::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #10b981;
}

.sw-chat-header__close {
	background: transparent;
	border: none;
	color: #94a3b8;
	font-size: 22px;
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	transition: color 0.2s ease;
}

.sw-chat-header__close:hover {
	color: #ffffff;
}

/* Área de Mensajes */
.sw-chat-body {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: #0b1120;
	scroll-behavior: smooth;
}

.sw-chat-body::-webkit-scrollbar {
	width: 6px;
}
.sw-chat-body::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.15);
	border-radius: 3px;
}

/* Mensajes individuales */
.sw-chat-msg {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: sw-msg-fade 0.25s ease-out;
}

@keyframes sw-msg-fade {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.sw-chat-msg--bot {
	align-self: flex-start;
}

.sw-chat-msg--user {
	align-self: flex-end;
}

.sw-chat-msg__bubble {
	padding: 12px 16px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.45;
	word-break: break-word;
}

.sw-chat-msg--bot .sw-chat-msg__bubble {
	background: #1e293b;
	color: #f1f5f9;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-bottom-left-radius: 4px;
}

.sw-chat-msg--user .sw-chat-msg__bubble {
	background: #2563eb;
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.sw-chat-msg__time {
	font-size: 10.5px;
	color: #64748b;
	margin-top: 4px;
	padding: 0 4px;
}

.sw-chat-msg--user .sw-chat-msg__time {
	align-self: flex-end;
}

/* Indicador de Escribiendo (Typing) */
.sw-chat-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 16px;
	background: #1e293b;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	align-self: flex-start;
	width: fit-content;
}

.sw-chat-typing__dot {
	width: 6px;
	height: 6px;
	background: #94a3b8;
	border-radius: 50%;
	animation: sw-bounce 1.4s infinite ease-in-out both;
}

.sw-chat-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.sw-chat-typing__dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input y Footer */
.sw-chat-footer {
	padding: 12px;
	background: #0f172a;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sw-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #1e293b;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 24px;
	padding: 4px 6px 4px 14px;
	transition: border-color 0.2s ease;
}

.sw-chat-form:focus-within {
	border-color: #3b82f6;
}

.sw-chat-input {
	flex: 1;
	background: transparent;
	border: none;
	color: #f8fafc;
	font-size: 14px;
	outline: none;
	padding: 8px 0;
	font-family: inherit;
}

.sw-chat-input::placeholder {
	color: #64748b;
}

.sw-chat-send {
	background: #2563eb;
	color: #ffffff;
	border: none;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.1s ease;
	outline: none;
}

.sw-chat-send:hover {
	background: #1d4ed8;
	transform: scale(1.05);
}

.sw-chat-send:disabled {
	background: #475569;
	cursor: not-allowed;
	transform: none;
}

.sw-chat-send svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
}

/* Responsive Móvil & Tablets Pequeñas */
@media (max-width: 600px) {
	.sw-chat-widget {
		bottom: 85px;
		right: 16px;
	}

	.sw-chat-widget--bottom-right-elevated {
		bottom: 85px;
		right: 16px;
		left: auto;
	}

	.sw-chat-widget--bottom-left {
		bottom: 16px;
		left: 16px;
		right: auto;
	}

	.sw-chat-widget--bottom-left-elevated {
		bottom: 85px;
		left: 16px;
		right: auto;
	}

	.sw-chat-widget--bottom-right {
		bottom: 16px;
		right: 16px;
		left: auto;
	}

	/* Cuando el chat está abierto en móvil, tomar pantalla completa limpia estilo app */
	.sw-chat-widget--is-open {
		position: fixed;
		inset: 0;
		bottom: 0 !important;
		right: 0 !important;
		left: 0 !important;
		top: 0 !important;
		width: 100vw !important;
		height: 100vh !important;
		height: 100dvh !important;
		z-index: 9999999 !important;
		align-items: stretch !important;
	}

	.sw-chat-widget--is-open .sw-chat-trigger {
		display: none !important;
	}

	.sw-chat-widget--is-open .sw-chat-window {
		width: 100vw !important;
		max-width: 100vw !important;
		height: 100vh !important;
		height: 100dvh !important;
		max-height: 100dvh !important;
		border-radius: 0 !important;
		border: none !important;
		margin: 0 !important;
	}
}
