/**
 * DriveEV AI Chatbot Widget Styles (WP-007)
 *
 * Fixed-position chat icon and panel with scale animation.
 * All selectors prefixed with driveev- to avoid theme conflicts.
 */

/* ─── Chat Icon Wrapper (bottom-right robot image) ─── */
#driveev-chat-icon-wrap {
	position: fixed;
	bottom: 16px;
	right: 16px !important;
	left: auto !important;
	direction: ltr !important;
	z-index: 99998;
}

#driveev-chat-icon {
	width: 300px;
	height: auto;
	background: transparent;
	border: none;
	border-radius: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: none;
	transition: transform 0.15s;
	padding: 0;
}

#driveev-chat-icon:hover {
	transform: scale(1.05);
}

.driveev-chat-icon-img {
	width: 280px;
	height: auto;
}

#driveev-chat-icon svg {
	display: none;
}

/* ─── X close button on robot speech bubble ─── */
#driveev-chat-icon-close {
	position: absolute;
	top: 2%;
	right: 50%;
	width: 20px;
	height: 21px;
	border-radius: 50%;
	background: #00337a;
	color: #fff;
	border: none;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	z-index: 1;
}

#driveev-chat-icon-close:hover {
	background: #424242;
}

/* ─── Mini chat icon (shown after dismissing robot) ─── */
#driveev-chat-icon-mini {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 50px;
	height: 50px;
	border-radius: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: none;
	z-index: 99998;
	transition: transform 0.15s;
	padding: 0;
}

#driveev-chat-icon-mini:hover {
	transform: scale(1.1);
}

.driveev-chat-mini-img {
	width: 100%;
	height: auto;
	display: block;
}

/* ─── Chat Panel ─── */
#driveev-chat-panel {
	direction: ltr !important;
	text-align: left !important;
	position: fixed;
	bottom: 16px;
	right: 24px;
	width: 380px;
	height: 560px;
	max-height: calc(100vh - 32px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
	display: flex;
	flex-direction: column;
	z-index: 99999;
	overflow: hidden;
	transform: scale(0);
	transform-origin: bottom right;
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	pointer-events: none;
}

#driveev-chat-panel.driveev-chat-open {
	transform: scale(1);
	opacity: 1;
	pointer-events: auto;
}

/* ─── Expanded State ─── */
#driveev-chat-panel.driveev-chat-expanded {
	width: 92vw;
	max-width: 1200px;
	height: 90vh;
	bottom: 5vh;
	right: 4vw;
}

/* ─── Header ─── */
.driveev-chat-header {
	background: #00337a;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.driveev-chat-header-icon {
	width: 38px;
	height: 38px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.driveev-chat-header-icon svg {
	width: 20px;
	height: 20px;
}

.driveev-chat-header-text {
	flex: 1;
}

.driveev-chat-header-text h3 {
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	margin: 0;
	padding: 0;
}

.driveev-chat-header-text p {
	color: rgba(255, 255, 255, 0.7);
	font-size: 12px;
	margin: 2px 0 0;
	padding: 0;
}

.driveev-status-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
	margin-right: 5px;
}

.driveev-chat-header-actions {
	display: flex;
	align-items: center;
	gap: 2px;
	flex-shrink: 0;
}

.driveev-chat-close,
.driveev-chat-expand {
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px;
	color: rgba(255, 255, 255, 0.7);
	transition: color 0.2s;
	display: flex;
	align-items: center;
	border-radius: 4px;
}

.driveev-chat-close:hover,
.driveev-chat-expand:hover {
	color: #fff;
}

.driveev-chat-close svg,
.driveev-chat-expand svg {
	width: 18px;
	height: 18px;
}

/* ─── Messages Area ─── */
.driveev-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: #f8fafc;
}

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

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

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

/* ─── Message Bubbles ─── */
.driveev-msg {
	display: flex;
	gap: 10px;
	align-items: flex-end;
	max-width: 100%;
}

.driveev-msg.driveev-user {
	flex-direction: row-reverse;
}

.driveev-msg-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
}

.driveev-msg.driveev-bot .driveev-msg-avatar {
	background: #00337a;
	color: #fff;
}

.driveev-msg.driveev-user .driveev-msg-avatar {
	background: #e2e8f0;
	color: #475569;
}

.driveev-msg-avatar svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.driveev-msg-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.driveev-msg.driveev-bot .driveev-msg-bubble {
	background: #fff;
	color: #1e293b;
	border-radius: 4px 16px 16px 16px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.driveev-msg.driveev-user .driveev-msg-bubble {
	background: #00337a;
	color: #fff;
	border-radius: 16px 16px 4px 16px;
}

/* ─── Typing Dots ─── */
.driveev-typing-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
}

.driveev-typing-dots span {
	display: block;
	width: 7px;
	height: 7px;
	background: #94a3b8;
	border-radius: 50%;
	animation: driveev-bounce 1.2s infinite ease-in-out;
}

.driveev-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.driveev-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes driveev-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30%            { transform: translateY(-6px); }
}

/* ─── Suggestions ─── */
.driveev-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 8px 4px 4px;
}

.driveev-suggestion-chip {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1d4ed8;
	font-size: 12px;
	padding: 6px 12px;
	border-radius: 20px;
	cursor: pointer;
	transition: background 0.2s, border-color 0.2s;
	white-space: nowrap;
}

.driveev-suggestion-chip:hover {
	background: #dbeafe;
	border-color: #93c5fd;
}

/* ─── Input Area ─── */
.driveev-chat-input-area {
	padding: 8px 14px 6px;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}

.driveev-chat-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #f1f5f9;
	border-radius: 24px;
	padding: 6px 6px 6px 14px;
}

#driveev-chat-input {
	flex: 1;
	background: none;
	border: none;
	outline: none;
	font-size: 14px;
	color: #1e293b;
	resize: none;
	height: 22px;
	min-height: 22px;
	max-height: 80px;
	line-height: 1.4;
	font-family: inherit;
	overflow-y: hidden;
	padding: 0;
	margin: 0;
	text-indent: 0;
	box-shadow: none;
}

#driveev-chat-input::placeholder {
	color: #94a3b8;
}

#driveev-send-btn {
	width: 36px;
	height: 36px;
	background: #00337a;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.2s, transform 0.1s;
	padding: 0;
}

#driveev-send-btn:hover {
	background: #004099;
}

#driveev-send-btn:active {
	transform: scale(0.92);
}

#driveev-send-btn:disabled {
	background: #cbd5e1;
	cursor: not-allowed;
}

#driveev-send-btn svg {
	width: 16px;
	height: 16px;
}

.driveev-input-hint {
	text-align: center;
	font-size: 11px;
	color: #94a3b8;
	margin: 4px 0 0;
	padding: 0;
}

/* ─── Markdown rendering inside bubbles ─── */
.driveev-msg-bubble p { margin: 0 0 4px; }
.driveev-msg-bubble p:last-child { margin-bottom: 0; }
.driveev-msg-bubble ul,
.driveev-msg-bubble ol {
	margin: 4px 0 4px 18px;
	padding: 0;
}
.driveev-msg-bubble li { margin-bottom: 2px; }

.driveev-md-table-wrap {
	overflow-x: auto;
	margin: 6px 0;
}

.driveev-md-table {
	border-collapse: collapse;
	font-size: 13px;
	width: 100%;
}

.driveev-md-table th {
	background: #00337a;
	color: #fff;
	padding: 6px 10px;
	text-align: left;
	white-space: nowrap;
	font-weight: 600;
}

.driveev-md-table td {
	padding: 5px 10px;
	border-bottom: 1px solid #e2e8f0;
	color: #1e293b;
	white-space: nowrap;
}

.driveev-md-table tr:nth-child(even) td { background: #f8fafc; }
.driveev-md-table tr:hover td { background: #eff6ff; }

/* ─── Single Vehicle Card ─── */
.driveev-card {
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	overflow: hidden;
	margin-bottom: 8px;
}

.driveev-card-img {
	width: 100%;
	max-height: 160px;
	object-fit: cover;
	display: block;
	border-radius: 8px 8px 0 0;
}

.driveev-card-img-link {
	display: block;
}

.driveev-card-info {
	padding: 10px 12px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.driveev-card-name {
	font-size: 14px;
	font-weight: 700;
	color: #00337a;
	text-decoration: none;
}

a.driveev-card-name:hover {
	text-decoration: underline;
}

.driveev-card-meta {
	font-size: 13px;
	color: #4a5568;
}

.driveev-card-detail {
	padding: 8px 0 0;
	font-size: 13px;
	line-height: 1.6;
	color: #1a202c;
}

.driveev-card-detail strong {
	color: #00337a;
}

.driveev-card-detail ul {
	padding-left: 16px;
	margin: 4px 0;
}

.driveev-card-detail li {
	margin-bottom: 2px;
}

/* ─── Multi-Vehicle List ─── */
.driveev-vlist {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 8px;
}

.driveev-vlist-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 10px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #fff;
}

.driveev-vlist-img {
	width: 64px;
	height: 44px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
	display: block;
}

.driveev-vlist-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.driveev-vlist-name {
	font-size: 13px;
	font-weight: 700;
	color: #00337a;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

a.driveev-vlist-name:hover {
	text-decoration: underline;
}

.driveev-vlist-meta {
	font-size: 11px;
	color: #4a5568;
	margin-top: 1px;
}

.driveev-vlist-detail {
	padding: 4px 0 0;
	font-size: 13px;
	line-height: 1.6;
	color: #1a202c;
}

.driveev-vlist-detail strong {
	color: #00337a;
}

.driveev-vlist-detail ul {
	padding-left: 16px;
	margin: 4px 0;
}

.driveev-vlist-detail li {
	margin-bottom: 2px;
}

/* ─── Inline Vehicle Images (in body text) ─── */
.driveev-inline-vehicle-img {
	margin: 8px 0 4px;
}

.driveev-inline-vehicle-img img {
	width: 100%;
	max-height: 140px;
	object-fit: cover;
	border-radius: 8px;
	display: block;
}

.driveev-inline-vehicle-img a {
	display: block;
}

/* ─── Clickable Vehicle Names ─── */
.driveev-vehicle-link {
	color: #1d4ed8;
	text-decoration: underline;
}

.driveev-vehicle-link:hover {
	color: #1e40af;
}

/* Bold car names in bot list responses — always underlined blue */
.driveev-msg.driveev-bot .driveev-msg-bubble li > strong:first-child,
.driveev-msg.driveev-bot .driveev-msg-bubble p > strong:first-child {
	color: #1d4ed8;
	text-decoration: underline;
}

/* ─── Laptop / small desktop (<=1024px) ─── */
@media (max-width: 1024px) and (min-width: 481px) {
	#driveev-chat-panel {
		width: calc(100vw - 48px);
		max-width: 420px;
		height: calc(100vh - 120px);
		max-height: 600px;
		right: 16px;
		bottom: 80px;
	}

	#driveev-chat-panel.driveev-chat-expanded {
		width: calc(100vw - 32px);
		max-width: none;
		height: calc(100vh - 32px);
		max-height: none;
		bottom: 16px;
		right: 16px;
	}
}

/* ─── No-scroll (mobile fullscreen) ─── */
body.driveev-chat-noscroll {
	overflow: hidden !important;
}

/* ─── Mobile (<=480px) ─── */
@media (max-width: 480px) {
	#driveev-chat-icon {
		bottom: 12px;
		right: 12px;
		width: 280px;
		height: auto;
	}
	.driveev-chat-icon-img {
		width: 280px;
		height: auto;
	}

	#driveev-chat-icon svg {
		width: 20px;
		height: 20px;
	}

	#driveev-chat-panel.driveev-chat-open {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
		transform-origin: bottom right;
	}

	/* Hide expand button on mobile — already fullscreen */
	.driveev-chat-expand {
		display: none;
	}
}
