/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */

/* Widget Container */
.cwaw-widget {
	position: fixed;
	bottom: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.cwaw-widget.cwaw-position-right {
	right: 20px;
}

.cwaw-widget.cwaw-position-left {
	left: 20px;
}

/* Button Wrapper */
.cwaw-button-wrapper {
	position: relative;
	margin-bottom: 15px;
}

/* Floating Button */
.cwaw-button {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background-color: var(--cwaw-theme-color, #25d366);
	color: white;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	padding: 0;
	position: relative;
}

.cwaw-button:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.cwaw-button:focus {
	outline: 2px solid rgba(255, 255, 255, 0.5);
	outline-offset: 2px;
}

.cwaw-button svg {
	width: 32px;
	height: 32px;
	fill: currentColor;
}

.cwaw-button img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

/* Badge */
.cwaw-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	background-color: #ff0000;
	color: white;
	border-radius: 50%;
	min-width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	padding: 0 6px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
	border: 2px solid white;
	line-height: 1;
	box-sizing: border-box;
}

.cwaw-position-left .cwaw-badge {
	left: -5px;
	right: auto;
}

/* Tooltip */
.cwaw-tooltip {
	position: absolute;
	white-space: nowrap;
	background-color: rgba(0, 0, 0, 0.8);
	color: white;
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 14px;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease, transform 0.3s ease;
	bottom: 50%;
	transform: translateY(50%);
}

.cwaw-position-right .cwaw-tooltip {
	right: 75px;
}

.cwaw-position-left .cwaw-tooltip {
	left: 75px;
}

.cwaw-tooltip::after {
	content: '';
	position: absolute;
	width: 0;
	height: 0;
	border-style: solid;
	top: 50%;
	transform: translateY(-50%);
}

.cwaw-position-right .cwaw-tooltip::after {
	right: -6px;
	border-width: 6px 0 6px 6px;
	border-color: transparent transparent transparent rgba(0, 0, 0, 0.8);
}

.cwaw-position-left .cwaw-tooltip::after {
	left: -6px;
	border-width: 6px 6px 6px 0;
	border-color: transparent rgba(0, 0, 0, 0.8) transparent transparent;
}

.cwaw-button-wrapper:hover .cwaw-tooltip {
	opacity: 1;
}

/* Chat Window */
.cwaw-window {
	position: absolute;
	bottom: 85px;
	width: 360px;
	max-width: calc(100vw - 40px);
	background: white;
	border-radius: 12px 12px 0 0;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	opacity: 0;
	transform: translateY(10px) scale(0.95);
	transition: opacity 0.3s ease, transform 0.3s ease;
	max-height: calc(100vh - 120px);
}

.cwaw-position-right .cwaw-window {
	right: 0;
}

.cwaw-position-left .cwaw-window {
	left: 0;
}

.cwaw-window:not([hidden]).cwaw-open {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* Close Button */
.cwaw-window__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(255, 255, 255, 0.2);
	color: white;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	justify-content: center;
	z-index: 10;
	transition: background-color 0.2s ease;
}

.cwaw-window__close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.cwaw-window__close:focus {
	outline: 2px solid rgba(255, 255, 255, 0.5);
	outline-offset: 2px;
}

/* Header */
.cwaw-window__header {
	background-color: var(--cwaw-theme-color, #25d366);
	color: white;
	padding: 15px;
	display: flex;
	align-items: center;
	gap: 12px;
	position: relative;
	min-height: 60px;
}

.cwaw-window__avatar {
	position: absolute;
	left: 12px;
	width: 40px;
	height: 40px;
	overflow: hidden;
	flex-shrink: 0;
	position: relative;
	margin-right: 8px;
}

.cwaw-window__avatar-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.3);
}

.cwaw-window__status-dot {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 12px;
	height: 12px;
	background-color: #4ade80;
	border: 2px solid white;
	border-radius: 50%;
}

.cwaw-window__info {
	flex: 1;
	min-width: 0;
}

.cwaw-window__name {
	font-weight: 600;
	font-size: 16px;
	line-height: 1.3;
	margin-bottom: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cwaw-window__status {
	font-size: 13px;
	opacity: 0.9;
	line-height: 1.2;
}

/* Chat Body */
.cwaw-window__chat {
	flex: 1;
	overflow-y: auto;
	padding: 20px 12px;
	min-height: 200px;
	max-height: 400px;
	position: relative;
	background-image: url('../img/background-whatsapp.jpg');
	background-repeat: no-repeat;
	background-size: cover;
	background-position: center;
	background-blend-mode: overlay;
}

.cwaw-window__time {
	text-align: center;
	font-size: 12px;
	color: rgba(0, 0, 0, 0.45);
	margin-bottom: 12px;
	padding: 6px 12px;
	background: rgba(255, 255, 255, 0.7);
	border-radius: 8px;
	display: inline-block;
	width: 100%;
	box-sizing: border-box;
}

/* Bubble */
.cwaw-bubble {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-bottom: 8px;
	max-width: 75%;
	position: relative;
}

.cwaw-bubble--incoming {
	flex-direction: row;
}

.cwaw-bubble__content {
	background: white;
	padding: 6px 9px;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.4;
	color: #303030;
	word-wrap: break-word;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cwaw-bubble__content br {
	display: block;
	content: '';
	margin: 4px 0;
}

/* Footer */
.cwaw-window__footer {
	background: #f0f0f0;
	padding: 8px 12px;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	border-top: 1px solid #e5ddd5;
}

.cwaw-field {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	background: white;
	border-radius: 24px;
	padding: 4px 12px;
	min-height: 42px;
	box-sizing: border-box;
}

.cwaw-field__textarea {
	width: 100%;
	border: none;
	outline: none;
	resize: none;
	font-size: 15px;
	font-family: inherit;
	line-height: 1.4;
	padding: 8px 0;
	min-height: 20px;
	max-height: 120px;
	overflow-y: auto;
	background: transparent;
	color: #303030;
}

.cwaw-field__textarea::placeholder {
	color: #999;
}

.cwaw-send {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	background-color: var(--cwaw-theme-color, #25d366);
	color: white;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.2s ease, opacity 0.2s ease;
	padding: 0;
}

.cwaw-send:hover {
	transform: scale(1.05);
	opacity: 0.9;
}

.cwaw-send:focus {
	outline: 2px solid var(--cwaw-theme-color, #25d366);
	outline-offset: 2px;
}

.cwaw-send:active {
	transform: scale(0.95);
}

.cwaw-send svg {
	fill: currentColor;
}

/* Animaciones para el botón con delay */
.cwaw-widget.cwaw-delayed .cwaw-button-wrapper {
	opacity: 0;
	transform: scale(0.5);
	animation: cwaw-button-appear 0.5s ease forwards;
}

@keyframes cwaw-button-appear {
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* Scrollbar personalizada para el chat */
.cwaw-window__chat::-webkit-scrollbar {
	width: 6px;
}

.cwaw-window__chat::-webkit-scrollbar-track {
	background: transparent;
}

.cwaw-window__chat::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.2);
	border-radius: 3px;
}

.cwaw-window__chat::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 480px) {
	.cwaw-window {
		width: calc(100vw - 40px);
		max-width: 360px;
		bottom: 15px;
	}

	.cwaw-widget {
		bottom: 15px;
	}

	.cwaw-widget.cwaw-position-right {
		right: 15px;
	}

	.cwaw-widget.cwaw-position-left {
		left: 15px;
	}

	.cwaw-window__chat {
		max-height: 50vh;
	}
}
