/**
 * Стили виджета чата
 * 
 * Стили для виджета чата с интеграцией Telegram
 * Адаптирован для десктопных и мобильных устройств
 */

/* Основной контейнер виджета */
#shodrop-chat-widget {
	position: fixed;
	bottom: 100px; /* Выровнено с уровнем Telegram (20px + 60px + 20px отступ) */
	right: 20px; /* Такое же расположение как у Telegram */
	z-index: 9999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	display: flex;
	align-items: center;
}

/* Блокировка прокрутки и взаимодействия с фоном при открытом чате - ТОЛЬКО ДЛЯ МОБИЛЬНЫХ */
@media (max-width: 480px) {
	body.chat-open {
		overflow: hidden !important;
		position: fixed !important;
		width: 100% !important;
		height: 100% !important;
		touch-action: none !important;
		-webkit-overflow-scrolling: none;
		overscroll-behavior: none !important;
	}
	
	html.chat-open {
		overflow: hidden !important;
		height: 100% !important;
	}
	
	/* Блокировка прокрутки при открытом чате для всех элементов кроме чата */
	body.chat-open * {
		overscroll-behavior: none;
		pointer-events: none !important;
	}
	
	body.chat-open #shodrop-chat-widget,
	body.chat-open #shodrop-chat-widget * {
		overscroll-behavior: auto;
		pointer-events: auto !important;
	}
}

/* Надпись над чатом */
.chat-fixed__label {
	position: relative;
	margin-right: 20px; /* Отступ от кнопки (как у Telegram) */
}

.chat-fixed__label::after {
	z-index: 1;
	content: '';
	background: url('../img/tg-fixed_icon.svg') center / cover no-repeat;
	width: 20px;
	height: 20px;
	transform: rotate(-30deg);
	display: block;
	position: absolute;
	right: -13px;
	top: 10px;
}

.chat-fixed__label span {
	border-radius: 10px;
	display: block;
	background: #695858;
	padding: 15px 10px;
	position: relative;
	z-index: 2;
	color: white;
	font-size: 14px;
	font-weight: 500;
	white-space: nowrap;
}

/* Кнопка открытия чата */
.chat-button {
	width: 55px; /* Немного меньше */
	height: 55px; /* Немного меньше */
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: all 0.3s ease;
	position: relative;
	color: white;
	flex-shrink: 0;
}

.chat-button svg {
	width: 22px; /* Немного меньше для меньшей кнопки */
	height: 22px; /* Немного меньше для меньшей кнопки */
}

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

/* Бейдж с количеством непрочитанных сообщений */
.chat-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	background: #ff4444;
	color: white;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: bold;
	border: 2px solid white;
}

/* Надпись и кнопка скрываются когда чат открыт на десктопе */
#shodrop-chat-widget.open .chat-button,
#shodrop-chat-widget.open .chat-fixed__label {
	display: none;
}

/* Окно чата - позиционируется ниже кнопки */
.chat-window {
	position: absolute;
	bottom: 70px; /* Немного ниже кнопки */
	right: 0;
	width: 360px;
	height: 550px;
	max-height: 75vh;
	background: white;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
	display: none;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transition: opacity 0.3s ease;
	transform: none !important; /* Предотвращение любого масштабирования */
}

/* Открытое состояние окна чата - статичная фиксация без масштабирования */
#shodrop-chat-widget.open .chat-window {
	display: flex;
	opacity: 1;
	transform: none !important; /* Принудительно убираем любое масштабирование */
}

/* Предотвращение приближения страницы при открытии чата */
#shodrop-chat-widget.open {
	transform: none !important;
}

/* Заголовок окна чата */
.chat-header {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	padding: 16px 20px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.chat-header-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.chat-header-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	font-size: 18px;
	letter-spacing: 0.5px;
}

.chat-icon {
	font-size: 20px;
	display: inline-block;
}

.chat-title-text {
	text-transform: uppercase;
}

.chat-status-online {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 400;
	opacity: 0.95;
}

.chat-status-indicator {
	width: 8px;
	height: 8px;
	background: #4ade80;
	border-radius: 50%;
	display: inline-block;
	box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
	animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
	0%, 100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.7;
		transform: scale(1.1);
	}
}

.chat-status {
	width: 8px;
	height: 8px;
	background: rgba(255, 255, 255, 0.5);
	border-radius: 50%;
	display: inline-block;
}

.chat-status.connected {
	background: #4ade80;
	box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.chat-close {
	background: none;
	border: none;
	color: white;
	font-size: 28px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s;
}

.chat-close:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* Область сообщений чата */
.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
	width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
	background: #9ca3af;
}

/* Приветственное сообщение */
.chat-welcome {
	text-align: center;
	color: #6b7280;
	font-size: 14px;
	line-height: 1.6;
	margin-bottom: 20px;
}

.chat-welcome p {
	margin: 8px 0;
}

/* Стили сообщений в чате */
.chat-message {
	margin-bottom: 16px;
	display: flex;
	flex-direction: column;
	animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.chat-message.customer {
	align-items: flex-end;
}

.chat-message.admin {
	align-items: flex-start;
}

.message-content {
	max-width: 75%;
	padding: 12px 16px;
	border-radius: 18px;
	word-wrap: break-word;
	line-height: 1.4;
	font-size: 14px;
}

.chat-message.customer .message-content {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border-bottom-right-radius: 4px;
}

.chat-message.admin .message-content {
	background: white;
	color: #1f2937;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

.message-time {
	font-size: 11px;
	color: #9ca3af;
	margin-top: 4px;
	padding: 0 4px;
}

/* Область ввода */
.chat-input-area {
	padding: 12px;
	background: white;
	border-top: 1px solid #e5e7eb;
	display: flex;
	gap: 6px;
	align-items: center;
}

#chat-input {
	flex: 1;
	border: 1px solid #e5e7eb;
	border-radius: 20px;
	padding: 8px 12px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}

#chat-input:focus {
	border-color: #667eea;
}

#chat-input:disabled {
	background: #f3f4f6;
	cursor: not-allowed;
}

.chat-send-btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border: none;
	color: white;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
	flex-shrink: 0;
}

.chat-send-btn:hover {
	transform: scale(1.1);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.chat-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.chat-send-btn svg {
	width: 18px;
	height: 18px;
}

/* Сообщение об ошибке */
.chat-error {
	background: #fee2e2;
	color: #991b1b;
	padding: 12px;
	border-radius: 8px;
	margin: 12px 0;
	font-size: 13px;
	border-left: 3px solid #ef4444;
}

/* Адаптивность для планшетов и маленьких экранов */
@media (max-width: 768px) {
	#shodrop-chat-widget {
		bottom: 70px; /* Поднят выше */
		right: 20px;
	}
	
	.chat-button {
		width: 42px; /* Немного меньше */
		height: 42px; /* Немного меньше */
	}
	
	.chat-button svg {
		width: 20px;
		height: 20px;
	}
	
	.chat-fixed__label span {
		padding: 10px 8px;
		font-size: 12px;
	}
	
	.chat-fixed__label::after {
		width: 15px;
		height: 15px;
		right: -10px;
		top: 8px;
	}
	
	.chat-fixed__label {
		margin-right: 15px;
	}
	
	.chat-window {
		width: calc(100vw - 20px);
		max-width: 400px;
		height: calc(100vh - 120px);
		max-height: 70vh;
		bottom: 60px; /* Немного ниже кнопки */
		right: 0;
	}
	
	.chat-header {
		padding: 14px 16px;
	}
	
	.chat-header-title {
		font-size: 16px;
	}
	
	.chat-status-online {
		font-size: 12px;
	}
}

/* Стили для мобильных устройств (маленькие экраны) */
@media (max-width: 480px) {
	/* Контейнер виджета - позиционирование справа, кнопка поднята выше */
	#shodrop-chat-widget {
		bottom: 70px; /* Поднят выше */
		right: 20px; /* Такое же расположение как у Telegram */
	}
	
	.chat-button {
		width: 38px; /* Немного меньше */
		height: 38px; /* Немного меньше */
	}
	
	.chat-button svg {
		width: 18px;
		height: 18px;
	}
	
	.chat-fixed__label span {
		padding: 8px 6px;
		font-size: 11px;
	}
	
	.chat-fixed__label::after {
		width: 12px;
		height: 12px;
		right: -8px;
		top: 6px;
	}
	
	.chat-fixed__label {
		margin-right: 12px;
	}
	
	/* Окно чата - полноэкранный режим на мобильных устройствах */
	.chat-window {
		width: 100vw;
		height: 100vh;
		max-width: 100vw;
		max-height: 100vh;
		bottom: 0;
		right: 0;
		left: 0;
		top: 0;
		border-radius: 0;
		position: fixed;
		transform: none !important; /* Предотвращение масштабирования */
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		z-index: 10000;
		background: white;
	}
	
	/* Затемнение фона (опционально) */
	#shodrop-chat-widget.open::before {
		content: '';
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.5);
		z-index: 9998;
		display: none; /* Для мобильной версии не нужен, так как чат полноэкранный */
	}
	
	/* Кнопка и надпись скрываются когда чат открыт */
	#shodrop-chat-widget.open .chat-button,
	#shodrop-chat-widget.open .chat-fixed__label {
		display: none;
	}
	
	/* Открытое состояние - полноэкранный режим */
	#shodrop-chat-widget.open .chat-window {
		transform: none !important;
	}
	
	/* Контейнер при открытом чате - полноэкранный */
	#shodrop-chat-widget.open {
		width: 100vw;
		height: 100vh;
		bottom: 0;
		right: 0;
		left: 0;
		top: 0;
		position: fixed;
	}
	
	
	/* Заголовок в полноэкранном режиме - более заметный */
	#shodrop-chat-widget.open .chat-header {
		padding: 14px 16px;
		border-radius: 0;
	}
	
	/* Кнопка закрытия более заметна в полноэкранном режиме */
	#shodrop-chat-widget.open .chat-close {
		width: 36px;
		height: 36px;
		font-size: 28px;
	}
	
	/* Заголовок чата - компактный */
	.chat-header {
		padding: 10px 12px;
	}
	
	.chat-header-title {
		font-size: 14px;
		gap: 6px;
	}
	
	.chat-icon {
		font-size: 16px;
	}
	
	.chat-title-text {
		font-size: 12px;
		letter-spacing: 0.2px;
	}
	
	.chat-status-online {
		font-size: 10px;
		gap: 4px;
	}
	
	.chat-status-indicator {
		width: 6px;
		height: 6px;
	}
	
	/* Область сообщений - уменьшенные отступы */
	.chat-messages {
		padding: 12px;
	}
	
	.chat-welcome {
		font-size: 12px;
		margin-bottom: 12px;
	}
	
	/* Сообщения - компактные */
	.message-content {
		max-width: 80%;
		font-size: 12px;
		padding: 8px 12px;
	}
	
	.message-time {
		font-size: 10px;
	}
	
	/* Область ввода - компактная */
	.chat-input-area {
		padding: 10px;
		gap: 6px;
	}
	
	#chat-input {
		padding: 10px 14px;
		font-size: 16px; /* Минимум 16px для предотвращения авто-зума на мобильных - важно! */
	}
	
	.chat-send-btn {
		width: 36px;
		height: 36px;
	}
	
	.chat-send-btn svg {
		width: 16px;
		height: 16px;
	}
	
	/* Кнопка закрытия - компактная */
	.chat-close {
		width: 28px;
		height: 28px;
		font-size: 24px;
	}
}

/* Кнопки быстрых ответов */
.chat-quick-replies {
	margin: 16px 0;
}

.chat-quick-reply {
	margin-bottom: 12px;
	display: flex;
	justify-content: center;
}

.chat-quick-btn {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: none;
	border-radius: 24px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chat-quick-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-quick-btn:active {
	transform: translateY(0);
}

/* Предложение оставить контакты */
.chat-contact-proposal .message-content {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.chat-contact-proposal-btn {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: none;
	border-radius: 20px;
	padding: 10px 20px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	align-self: flex-start;
	box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chat-contact-proposal-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Форма контактов */
.chat-contact-form {
	background: white;
	border-top: 1px solid #e5e7eb;
	padding: 20px;
	animation: slideUp 0.3s ease;
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.chat-contact-form-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
	padding-bottom: 12px;
	border-bottom: 1px solid #e5e7eb;
}

.chat-contact-form-header h4 {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: #1f2937;
}

.chat-contact-close {
	background: none;
	border: none;
	color: #9ca3af;
	font-size: 24px;
	cursor: pointer;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: all 0.2s;
}

.chat-contact-close:hover {
	background: #f3f4f6;
	color: #1f2937;
}

.chat-contact-form-body {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.chat-contact-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.chat-contact-field label {
	font-size: 13px;
	font-weight: 600;
	color: #374151;
}

.chat-contact-field input {
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chat-contact-field input:focus {
	border-color: #667eea;
	box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-contact-field input::placeholder {
	color: #9ca3af;
}

.chat-contact-form-note {
	text-align: center;
}

.chat-contact-form-note small {
	color: #6b7280;
	font-size: 12px;
}

.chat-contact-submit {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: none;
	border-radius: 24px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	margin-top: 8px;
	box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.chat-contact-submit:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-contact-submit:active {
	transform: translateY(0);
}

.chat-contact-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

/* Адаптивность для формы контактов на мобильных */
@media (max-width: 480px) {
	.chat-quick-btn {
		font-size: 13px;
		padding: 10px 20px;
	}
	
	.chat-contact-form {
		padding: 16px;
	}
	
	.chat-contact-form-header h4 {
		font-size: 15px;
	}
	
	.chat-contact-field input {
		padding: 10px;
		font-size: 16px; /* Для предотвращения зума на iOS */
	}
	
	.chat-contact-submit {
		font-size: 14px;
		padding: 12px 20px;
	}
}

