/**
 * AutoPro Core — Messages inbox (Phase 10).
 * Two-pane messaging UI. Depends on the shared dark tokens from apc-auth.css.
 */

/* ===== Layout ===== */
.apc-msgs {
	margin: 0;
}

.apc-msgs .apc-inbox { max-width: none; margin: 0; }

/* Message panes keep the exact #363636 border everywhere. */
.apc-inbox > .apc-panel {
	border: 1px solid #363636;
}

.apc-inbox {
	display: grid;
	grid-template-columns: 340px minmax(0, 1fr);
	gap: 18px;
	align-items: start;
}

.apc-inbox__side,
.apc-inbox__main {
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-width: 0;
}

.apc-inbox__main {
	min-height: 480px;
}

/* Mobile back link — hidden on desktop. */
.apc-inbox__back { display: none; }

/* ===== Side: header + search ===== */
.apc-inbox__head { display: flex; flex-direction: column; gap: 2px; }

.apc-inbox__title {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: var(--apc-text, #f5f5f5);
}

.apc-inbox__nonetitle { margin: 0 0 4px; font-weight: 600; color: var(--apc-text, #f5f5f5); }

.apc-inbox__sub {
	margin: 0;
	font-size: 12.5px;
	color: var(--apc-muted, #f5f5f5bf);
}

.apc-convsearch { position: relative; }

.apc-convsearch input {
	width: 100%;
	box-sizing: border-box;
	background: var(--apc-card-2, #121212);
	border: 1.5px solid var(--apc-border, #363636);
	border-radius: 10px;
	color: var(--apc-text, #f5f5f5);
	font-size: 13px;
	padding: 9px 38px 9px 12px;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.apc-convsearch input::placeholder { color: var(--apc-muted, #f5f5f5bf); }

.apc-convsearch input:focus {
	border-color: var(--apc-red, #e10012);
	box-shadow: 0 0 0 3px rgba(225, 0, 18, 0.18);
}

.apc-convsearch__btn[class] {
	position: absolute;
	right: 4px;
	top: 50%;
	transform: translateY(-50%);
	background: transparent;
	border: 0;
	color: var(--apc-muted, #f5f5f5bf);
	width: 30px;
	height: 30px;
	display: grid;
	place-items: center;
	cursor: pointer;
	border-radius: 8px;
}

.apc-convsearch__btn svg { width: 16px; height: 16px; }
.apc-convsearch__btn[class]:hover { color: var(--apc-text, #f5f5f5); }

/* ===== Side: conversation list ===== */
.apc-conv {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	overflow-y: auto;
	max-height: 560px;
}

.apc-conv__item {
	position: relative;
	display: grid;
	grid-template-columns: 38px minmax(0, 1fr) auto auto;
	gap: 10px;
	align-items: center;
	padding: 10px;
	border-radius: 12px;
	border: 1.5px solid transparent;
	text-decoration: none;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.apc-conv__item:hover { background: rgba(255, 255, 255, 0.04); }

.apc-conv__item.is-active {
	background: var(--apc-card-2, #121212);
	border-color: rgba(225, 0, 18, 0.45);
}

.apc-conv__avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #242424;
	color: var(--apc-text, #f5f5f5);
	display: grid;
	place-items: center;
	font-size: 13px;
	font-weight: 700;
	flex: 0 0 auto;
}

.apc-conv__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.apc-conv__name {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--apc-text, #f5f5f5);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apc-conv__item.is-unread .apc-conv__name { color: #ffffff; }

.apc-conv__job {
	font-style: normal;
	font-size: 11.5px;
	font-weight: 600;
	color: var(--apc-red, #e10012);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apc-conv__preview {
	font-size: 12px;
	color: var(--apc-muted, #f5f5f5bf);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.apc-conv__aside {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
	flex: 0 0 auto;
}

.apc-conv__time { font-size: 11px; color: var(--apc-muted, #f5f5f5bf); font-style: normal; }

.apc-conv__unread {
	font-style: normal;
	background: var(--apc-red, #e10012);
	color: #ffffff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 999px;
	display: grid;
	place-items: center;
	padding: 0 6px;
	box-sizing: border-box;
}

.apc-conv__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	font-size: 12px;
	color: var(--apc-muted, #f5f5f5bf);
}

.apc-conv__nav a {
	color: var(--apc-text, #f5f5f5);
	text-decoration: none;
	padding: 4px 10px;
	border: 1px solid var(--apc-border, #363636);
	border-radius: 8px;
}

.apc-conv__nav a:hover { border-color: var(--apc-red, #e10012); }

.apc-inbox__none { font-size: 13px; color: var(--apc-muted, #f5f5f5bf); }
.apc-inbox__nonehint { font-size: 12.5px; margin: 6px 0 0; }

/* ===== Main: empty state ===== */
.apc-inbox__empty {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	text-align: center;
	padding: 60px 20px;
}

.apc-inbox__emptyicon svg { width: 44px; height: 44px; color: var(--apc-border, #363636); }

.apc-inbox__empty h3 {
	margin: 4px 0 0;
	font-size: 17px;
	color: var(--apc-text, #f5f5f5);
}

.apc-inbox__empty p { margin: 0; font-size: 13px; color: var(--apc-muted, #f5f5f5bf); max-width: 380px; }

/* ===== Thread header ===== */
.apc-thread__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--apc-border, #363636);
}

.apc-thread__who { display: flex; align-items: center; gap: 10px; }

.apc-thread__name { margin: 0; font-size: 15px; color: var(--apc-text, #f5f5f5); }

.apc-thread__role { margin: 0; font-size: 11.5px; color: var(--apc-muted, #f5f5f5bf); }

.apc-thread__jobref {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	flex-wrap: wrap;
}

.apc-thread__jobtitle {
	font-size: 13px;
	color: var(--apc-text, #f5f5f5);
	max-width: 320px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ===== Thread: grouped messages, dividers, jump pill ===== */
.apc-threadwrap {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.apc-thread {
	display: flex;
	flex-direction: column;
	gap: 0;
	overflow-y: auto;
	max-height: 460px;
	padding: 10px 4px 6px;
	scrollbar-width: thin;
	scrollbar-color: #3a3a3a transparent;
	overscroll-behavior: contain;
}

.apc-thread__older,
.apc-thread__latest {
	align-self: center;
	font-size: 12px;
	color: var(--apc-muted, #f5f5f5bf);
	text-decoration: none;
	padding: 4px 12px;
	border-radius: 999px;
	border: 1px solid var(--apc-border, #363636);
}

.apc-thread__older:hover,
.apc-thread__latest:hover { color: var(--apc-text, #f5f5f5); border-color: var(--apc-red, #e10012); }

.apc-thread__none { text-align: center; font-size: 13px; color: var(--apc-muted, #f5f5f5bf); padding: 12px 0; }

/* ===== Grouped messages: avatar + name on the first of a group only ===== */
.apc-msgdate {
	align-self: center;
	margin: 16px 0 4px;
}

.apc-msgdate span {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--apc-muted, #a3a3a3);
	background: rgba(255, 255, 255, 0.045);
	border: 1px solid var(--apc-border, #363636);
	border-radius: 999px;
	padding: 3px 12px;
}

.apc-msg {
	display: flex;
	align-items: flex-end;
	margin-top: 16px;
}

/* Continuation of the same sender: tight 4px gap, no avatar/name. */
.apc-msg--cont { margin-top: 4px; }

.apc-msgdate + .apc-msg { margin-top: 6px; }

.apc-msg--mine { justify-content: flex-end; }

.apc-msg__avatar-slot {
	width: 28px;
	flex: 0 0 auto;
	margin-right: 8px;
	align-self: flex-end;
}

.apc-msg__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: #242424;
	color: var(--apc-text, #f5f5f5);
	display: grid;
	place-items: center;
	font-size: 11px;
	font-weight: 700;
	overflow: hidden;
}

.apc-msg__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.apc-msg__stack {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
	max-width: 76%;
}

.apc-msg__name {
	font-size: 11px;
	font-weight: 700;
	color: var(--apc-muted, #a3a3a3);
	margin: 0 0 1px 2px;
}

.apc-msg__bubble {
	position: relative;
	background: var(--apc-card, #171717);
	border: 1px solid var(--apc-border, #363636);
	border-radius: 14px;
	padding: 8px 12px;
	box-sizing: border-box;
}

/* Group tail: only the last bubble in a group keeps the sharp corner. */
.apc-msg:not(.apc-msg--cont) .apc-msg__bubble { border-bottom-left-radius: 5px; }

.apc-msg--cont .apc-msg__bubble { border-radius: 10px; }

.apc-msg--mine .apc-msg__stack { align-items: flex-end; }

.apc-msg--mine .apc-msg__bubble {
	background: #2c4a6e;
	border-color: #3d5f88;
	border-radius: 14px;
}

.apc-msg--mine:not(.apc-msg--cont) .apc-msg__bubble { border-bottom-right-radius: 5px; }

.apc-msg--mine.apc-msg--cont .apc-msg__bubble { border-radius: 10px; }

.apc-msg__text {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--apc-text, #f5f5f5);
	overflow-wrap: anywhere;
	white-space: normal;
}

.apc-msg--mine .apc-msg__text { color: #f2f6fb; }

/* Exact time on hover only — absolute, so nothing reflows. */
.apc-msg__time {
	position: absolute;
	bottom: 3px;
	font-size: 10.5px;
	color: var(--apc-muted, #a3a3a3);
	font-style: normal;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.12s ease;
}

.apc-msg:not(.apc-msg--mine) .apc-msg__time { left: calc(100% + 8px); }

.apc-msg--mine .apc-msg__time { right: calc(100% + 8px); color: #8fadc9; }

.apc-msg:hover .apc-msg__time,
.apc-msg:focus-within .apc-msg__time { opacity: 1; }

/* Pending (in flight) + failed states */
.apc-msg.is-pending .apc-msg__bubble { opacity: 0.5; }

.apc-msg.is-failed .apc-msg__bubble { border-color: rgba(225, 0, 18, 0.65); }

.apc-msg__fail {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11.5px;
	color: #ff6b74;
	margin: 2px 2px 0;
}

.apc-msg__fail[hidden] { display: none; }

.apc-msg__retry[class] {
	appearance: none !important;
	background: none !important;
	border: 0 !important;
	padding: 0 !important;
	color: #ff6b74 !important;
	font: inherit !important;
	font-size: 11.5px !important;
	font-weight: 700 !important;
	cursor: pointer !important;
	text-decoration: underline !important;
	width: auto !important;
}

.apc-msg__retry[class]:hover { color: #ffffff !important; }

/* ===== "X new messages" jump pill ===== */
.apc-jump[class] {
	position: absolute;
	bottom: 10px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 4;
	display: inline-flex !important;
	align-items: center !important;
	gap: 6px !important;
	background: #1f1f1f !important;
	border: 1px solid var(--apc-border, #363636) !important;
	border-radius: 999px !important;
	color: var(--apc-text, #f5f5f5) !important;
	font: inherit !important;
	font-size: 12px !important;
	font-weight: 600 !important;
	padding: 6px 14px !important;
	cursor: pointer !important;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45) !important;
	width: auto !important;
}

.apc-jump[class]:hover { border-color: var(--apc-red, #e10012) !important; }

.apc-jump[hidden] { display: none !important; }

.apc-jump__arrow { width: 14px; height: 14px; }

/* ===== Composer: compact, grows to 5 lines, then scrolls internally ===== */
.apc-composer {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	gap: 10px;
	border-top: 1px solid var(--apc-border, #363636);
	padding-top: 12px;
}

.apc-composer textarea {
	width: auto;
	flex: 1 1 auto;
	min-width: 0;
	height: 42px;
	min-height: 42px;
	max-height: 124px;
	box-sizing: border-box;
	background: #1b1b1b;
	border: 1px solid #3a3a3a;
	border-radius: 21px;
	color: var(--apc-text, #f5f5f5);
	font-size: 13.5px;
	line-height: 1.45;
	padding: 10px 15px;
	resize: none;
	outline: none;
	overflow-y: hidden;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
	color-scheme: dark;
}

.apc-composer textarea::placeholder { color: #9a9a9a; }

.apc-composer textarea:hover { border-color: #4a4a4a; }

.apc-composer textarea:focus {
	background: #202020;
	border-color: var(--apc-red, #e10012);
	box-shadow: 0 0 0 3px rgba(225, 0, 18, 0.15);
}

.apc-composer__send {
	flex: 0 0 auto;
	white-space: nowrap;
	width: auto !important;
	height: 42px;
}

.apc-composer__send svg { width: 15px; height: 15px; }

.apc-composer__send[disabled] { opacity: 0.6; cursor: wait; }

/* ===== Dedicated Live Support dashboard page ===== */
.apc-support-page {
	background: var(--apc-card, #171717);
	border: 1px solid var(--apc-border, #363636);
	border-radius: 14px;
	padding: 26px 28px 30px;
	max-width: 560px;
}
.apc-support-page h3 { margin: 0 0 8px; font-size: 19px; color: var(--apc-text, #f5f5f5); }
.apc-support-page p { margin: 0 0 18px; color: var(--apc-muted, #f5f5f5bf); font-size: 14px; line-height: 1.6; }
.apc-support-page__hint { margin: 14px 0 0 !important; font-size: 12.5px; color: #9a9a9a; }
.apc-support-page .apc-btn { display: inline-flex; align-items: center; gap: 8px; }
.apc-support-page .apc-btn__ico { width: 15px; height: 15px; flex: none; }

/* ===== Lock / membership panels ===== */
.apc-lockbox {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
	background: var(--apc-card-2, #121212);
	border: 1.5px solid rgba(225, 0, 18, 0.35);
	border-radius: 14px;
	padding: 14px 16px;
}

.apc-lockbox__icon svg { width: 26px; height: 26px; color: var(--apc-red, #e10012); }

.apc-lockbox__body { flex: 1 1 220px; min-width: 0; }

.apc-lockbox__body h4 { margin: 0 0 3px; font-size: 14px; color: var(--apc-text, #f5f5f5); }

.apc-lockbox__body p { margin: 0; font-size: 12.5px; color: var(--apc-muted, #f5f5f5bf); }

/* ===== Sidebar badge (app nav) ===== */
.apc-appnav__badge {
	font-style: normal;
	background: var(--apc-red, #e10012);
	color: #ffffff;
	font-size: 10.5px;
	font-weight: 700;
	min-width: 18px;
	height: 18px;
	border-radius: 999px;
	display: inline-grid;
	place-items: center;
	padding: 0 5px;
	box-sizing: border-box;
}

/* ===== Shared safety ===== */
.apc-inbox .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* ===== Linked chip (My Jobs → Messages) ===== */
.apc-chip--link {
	text-decoration: none;
	color: var(--apc-text, #f5f5f5);
	border: 1px solid var(--apc-border, #363636);
	transition: border-color 0.15s ease, color 0.15s ease;
}

.apc-chip--link:hover { border-color: var(--apc-red, #e10012); color: var(--apc-red, #e10012); }

/* ===== Desktop: panes fill the viewport like the reference ===== */
@media (min-width: 901px) {
	.apc-msgs {
		display: flex;
		flex-direction: column;
	}

	.apc-inbox {
		flex: 1 1 auto;
		height: calc(100vh - 185px);
		min-height: 560px;
		align-items: stretch;
	}

	.apc-inbox > .apc-panel {
		min-height: 0;
		overflow: hidden;
	}

	.apc-conv {
		flex: 1 1 auto;
		max-height: none;
	}

	.apc-threadwrap {
		flex: 1 1 auto;
		min-height: 0;
	}

	.apc-thread {
		flex: 1 1 auto;
		max-height: none;
	}

	.apc-inbox__main .apc-composer,
	.apc-inbox__main .apc-lockbox,
	.apc-inbox__main .apc-thread__head {
		flex: 0 0 auto;
	}
}

/* ===== Responsive: list ⇄ thread ===== */
@media (max-width: 900px) {
	.apc-inbox { grid-template-columns: 1fr; }

	.apc-inbox:not(.apc-inbox--thread) .apc-inbox__main { display: none; }

	.apc-inbox--thread .apc-inbox__side { display: none; }

	.apc-inbox--thread .apc-inbox__back {
		display: inline-block;
		align-self: flex-start;
		font-size: 13px;
		color: var(--apc-muted, #f5f5f5bf);
		text-decoration: none;
		margin-bottom: 2px;
	}

	.apc-inbox--thread .apc-inbox__back:hover { color: var(--apc-text, #f5f5f5); }

	.apc-msg__stack { max-width: 88%; }
}

/* ===== Per-conversation ⋮ menu (delete chat) ===== */
.apc-conv__menu {
	display: none;
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 5;
}

.apc-conv__item:hover .apc-conv__menu,
.apc-conv__item:focus-within .apc-conv__menu {
	display: block;
}

.apc-conv__dots[class] {
	appearance: none !important;
	background: none !important;
	border: 0 !important;
	padding: 2px 7px !important;
	color: var(--apc-muted, #f5f5f5bf) !important;
	font-size: 16px;
	line-height: 1;
	cursor: pointer !important;
	border-radius: 6px !important;
	width: auto !important;
}

.apc-conv__dots[class]:hover,
.apc-conv__dots[class]:focus-visible {
	color: #ffffff !important;
	background: rgba(255, 255, 255, 0.1) !important;
	outline: none !important;
	box-shadow: none !important;
}

.apc-conv__pop {
	position: absolute;
	right: 0;
	top: calc(100% + 4px);
	background: #121212;
	border: 1px solid #363636;
	border-radius: 10px;
	padding: 4px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
	min-width: 150px;
	z-index: 30;
}

.apc-conv__delete[class] {
	appearance: none !important;
	display: block !important;
	width: 100% !important;
	text-align: left !important;
	background: none !important;
	border: 0 !important;
	padding: 8px 10px !important;
	border-radius: 8px !important;
	color: #ff6b74 !important;
	font: inherit !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	cursor: pointer !important;
}

.apc-conv__delete[class]:hover,
.apc-conv__delete[class]:focus-visible {
	background: rgba(225, 0, 18, 0.14) !important;
	color: #ff6b74 !important;
	outline: none !important;
	box-shadow: none !important;
}

/* ===== Optimistic / failed messages (AJAX sends) ===== */
.apc-msg--pending {
	opacity: 0.45;
}

.apc-msg--failed .apc-msg__bubble {
	border: 1px solid rgba(225, 0, 18, 0.65);
}

/* ===== Typing indicator (inside the flow: avatar + three dots) ===== */
.apc-typing {
	display: flex;
	align-items: flex-end;
	margin-top: 6px;
	opacity: 1;
	transition: opacity 0.16s ease;
}

.apc-typing.is-out { opacity: 0; }

/* The author rule above would beat the UA's [hidden] rule — force it. */
.apc-typing[hidden] {
	display: none !important;
}

.apc-typing__bubble {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--apc-card, #171717);
	border: 1px solid var(--apc-border, #363636);
	border-radius: 14px;
	border-bottom-left-radius: 5px;
	padding: 10px 12px;
}

.apc-typing__bubble i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--apc-muted, #a3a3a3);
	animation: apc-typing-blink 1.2s infinite;
}

.apc-typing__bubble i:nth-child(2) {
	animation-delay: 0.2s;
}

.apc-typing__bubble i:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes apc-typing-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

/* ===== Inbox item without the other user's name: job title leads ===== */
.apc-conv__meta .apc-conv__job {
	font-style: normal;
	color: var(--apc-text, #f5f5f5);
	font-weight: 600;
	font-size: 13.5px;
}

.apc-conv__meta .apc-conv__preview {
	color: var(--apc-muted, #f5f5f5bf);
}

.apc-conv__aside .apc-conv__time {
	color: var(--apc-muted, #f5f5f5bf);
}

