/* =========================================================
   CityDealers Chat - Frontend Styles
   ========================================================= */

/* ---- Contact Seller button ---- */
.cdchat-button {
	display: inline-block;
	background: #1aad4b;
	color: #fff;
	border: none;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 600;
	border-radius: 6px;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.2s ease;
}
.cdchat-button:hover { background: #158a3c; color: #fff; }
.cdchat-own-listing { color: #888; font-style: italic; }

/* ---- Modal overlay ---- */
.cdchat-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
}
.cdchat-modal {
	background: #fff;
	width: 100%;
	max-width: 440px;
	height: 600px;
	max-height: 85vh;
	border-radius: 12px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.cdchat-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	background: #1aad4b;
	color: #fff;
}
.cdchat-modal-headinfo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cdchat-modal-avatar {
	width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
	flex-shrink: 0; border: 2px solid rgba(255,255,255,0.6); background: #fff;
}
.cdchat-modal-title {
	font-weight: 600; font-size: 16px;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cdchat-modal-close {
	background: none; border: none; color: #fff; font-size: 28px;
	line-height: 1; cursor: pointer; padding: 0; width: 30px; height: 30px;
}
.cdchat-modal-body { flex: 1; overflow-y: auto; padding: 16px; background: #f3f5f7; }
.cdchat-modal-footer {
	display: flex; gap: 8px; padding: 12px;
	border-top: 1px solid #e3e6e8; background: #fff;
}

/* ---- Message bubbles ---- */
.cdchat-msg { display: flex; flex-direction: column; margin-bottom: 12px; max-width: 80%; }
.cdchat-msg-mine { margin-left: auto; align-items: flex-end; }
.cdchat-msg-theirs { margin-right: auto; align-items: flex-start; }
.cdchat-bubble { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.cdchat-msg-mine .cdchat-bubble { background: #1aad4b; color: #fff; border-bottom-right-radius: 4px; }
.cdchat-msg-theirs .cdchat-bubble { background: #fff; color: #222; border: 1px solid #e3e6e8; border-bottom-left-radius: 4px; }
.cdchat-bubble p { margin: 0 0 6px; }
.cdchat-bubble p:last-child { margin: 0; }
.cdchat-msg-meta { font-size: 11px; color: #99a1a8; margin-top: 4px; }

/* ---- Attachments in messages ---- */
.cdchat-attach-img {
	display: block;
	max-width: 220px;
	max-height: 220px;
	border-radius: 8px;
	cursor: pointer;
}
.cdchat-bubble-text { margin-top: 6px; }
.cdchat-bubble:has(.cdchat-attach-img) { padding: 6px; }
.cdchat-attach-audio { display: block; width: 240px; max-width: 60vw; }
.cdchat-sticker { width: 110px; height: 110px; object-fit: contain; }

/* ---- Input + send ---- */
.cdchat-input {
	flex: 1; border: 1px solid #d0d5d9; border-radius: 8px;
	padding: 10px 12px; font-size: 14px; resize: none; font-family: inherit; outline: none;
}
.cdchat-input:focus { border-color: #1aad4b; }
.cdchat-send-btn {
	background: #1aad4b; color: #fff; border: none; border-radius: 8px;
	padding: 0 20px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.cdchat-send-btn:hover { background: #158a3c; }
.cdchat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Loading / empty / error ---- */
.cdchat-loading, .cdchat-empty-thread, .cdchat-error {
	text-align: center; color: #99a1a8; padding: 30px 10px; font-size: 14px;
}
.cdchat-error { color: #c0392b; }

/* =========================================================
   Inbox layout
   ========================================================= */
.cdchat-inbox {
	display: flex; border: 1px solid #e3e6e8; border-radius: 12px;
	overflow: hidden; height: 600px; max-height: 80vh; background: #fff;
}
.cdchat-inbox-list { width: 320px; border-right: 1px solid #e3e6e8; overflow-y: auto; flex-shrink: 0; }
.cdchat-inbox-heading {
	margin: 0; padding: 16px 18px; font-size: 16px;
	border-bottom: 1px solid #e3e6e8; background: #f9fafb;
}
.cdchat-empty { padding: 20px 18px; color: #99a1a8; }

/* ---- Conversation list item ---- */
.cdchat-conv-item {
	display: flex; gap: 12px; padding: 14px 18px; cursor: pointer;
	border-bottom: 1px solid #f0f2f4; transition: background 0.15s ease;
}
.cdchat-conv-item:hover { background: #f9fafb; }
.cdchat-conv-item.cdchat-active { background: #eafaf0; }
.cdchat-conv-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.cdchat-conv-service-img { border-radius: 8px; }
.cdchat-conv-details { flex: 1; min-width: 0; }
.cdchat-conv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cdchat-conv-name {
	font-weight: 600; font-size: 14px; color: #222;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cdchat-unread-badge {
	background: #e74c3c; color: #fff; font-size: 11px; font-weight: 700;
	min-width: 20px; height: 20px; border-radius: 10px;
	display: inline-flex; align-items: center; justify-content: center;
	padding: 0 6px; flex-shrink: 0;
}
.cdchat-conv-service { font-size: 12px; color: #1aad4b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdchat-conv-preview { font-size: 13px; color: #99a1a8; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cdchat-has-unread .cdchat-conv-preview, .cdchat-has-unread .cdchat-conv-name { font-weight: 700; color: #222; }

/* ---- Thread (reading pane) ---- */
.cdchat-inbox-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cdchat-thread-header { padding: 16px 20px; border-bottom: 1px solid #e3e6e8; background: #f9fafb; font-weight: 600; }
.cdchat-thread-placeholder { color: #99a1a8; font-weight: 400; }
.cdchat-thread-messages { flex: 1; overflow-y: auto; padding: 18px; background: #f3f5f7; }

/* ---- Reply bar (toolbar + input + panels) ---- */
.cdchat-thread-footer {
	display: flex; flex-direction: column;
	border-top: 1px solid #e3e6e8; background: #fff; position: relative;
}
.cdchat-toolbar { display: flex; gap: 4px; padding: 8px 10px 0; }
.cdchat-tool {
	background: none; border: none; cursor: pointer; font-size: 20px;
	line-height: 1; padding: 6px; border-radius: 6px;
}
.cdchat-tool:hover { background: #f0f2f4; }
.cdchat-tool:disabled { opacity: 0.5; cursor: not-allowed; }
.cdchat-input-row { display: flex; gap: 8px; padding: 8px 10px 10px; }

/* Emoji panel */
.cdchat-emoji-panel {
	display: flex; flex-wrap: wrap; gap: 2px; padding: 10px;
	max-height: 180px; overflow-y: auto;
	border-bottom: 1px solid #e3e6e8; background: #fafbfc;
}
.cdchat-emoji {
	background: none; border: none; cursor: pointer; font-size: 22px;
	padding: 4px; border-radius: 6px; line-height: 1;
}
.cdchat-emoji:hover { background: #eceff1; }

/* Sticker panel */
.cdchat-sticker-panel {
	display: flex; flex-wrap: wrap; gap: 8px; padding: 10px;
	max-height: 200px; overflow-y: auto;
	border-bottom: 1px solid #e3e6e8; background: #fafbfc;
}
.cdchat-sticker-choice { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 8px; }
.cdchat-sticker-choice:hover { background: #eceff1; }
.cdchat-sticker-choice img { width: 64px; height: 64px; object-fit: contain; display: block; }

/* Recording bar */
.cdchat-recording {
	display: flex; align-items: center; gap: 10px; padding: 10px 12px;
	background: #fff4f4; border-bottom: 1px solid #f0d0d0;
}
.cdchat-rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e74c3c; animation: cdchat-pulse 1s infinite; }
.cdchat-rec-label { color: #c0392b; font-weight: 600; flex: 1; }
@keyframes cdchat-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- Inbox login prompt ---- */
.cdchat-inbox-login { padding: 40px; text-align: center; border: 1px solid #e3e6e8; border-radius: 12px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 768px) {
	.cdchat-inbox { flex-direction: column; height: auto; max-height: none; }
	.cdchat-inbox-list { width: 100%; max-height: 300px; border-right: none; border-bottom: 1px solid #e3e6e8; }
	.cdchat-inbox-thread { min-height: 420px; }

	/* Full-screen popup on mobile only. */
	.cdchat-modal-overlay { padding: 0; }
	.cdchat-modal {
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}
}

/* Prevent background scroll while popup is open (helps on mobile). */
body.cdchat-modal-open { overflow: hidden; }

/* =========================================================
   Delete button on own messages
   ========================================================= */
.cdchat-msg { position: relative; }
.cdchat-del {
	position: absolute;
	top: -8px;
	left: -8px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: none;
	background: #e74c3c;
	color: #fff;
	font-size: 16px;
	line-height: 20px;
	cursor: pointer;
	display: none;
	padding: 0;
	box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.cdchat-msg-mine .cdchat-del { left: auto; right: -8px; }
.cdchat-msg:hover .cdchat-del { display: block; }

/* =========================================================
   Image preview before sending
   ========================================================= */
.cdchat-preview {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px;
	border-bottom: 1px solid #e3e6e8;
	background: #fafbfc;
}
.cdchat-preview-img {
	max-width: 120px;
	max-height: 120px;
	border-radius: 8px;
	object-fit: cover;
}
.cdchat-preview-remove {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: none;
	background: #e74c3c;
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

/* =========================================================
   Navbar unread badge
   ========================================================= */
.cdchat-navbadge {
	position: relative;
	display: inline-flex;
	align-items: center;
	text-decoration: none;
	font-size: 20px;
	line-height: 1;
	color: inherit;
}
.cdchat-navbadge-icon { display: inline-block; }
.cdchat-navbadge-count {
	position: absolute;
	top: -8px;
	right: -10px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: #e74c3c;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
}
