/* ============================================================
   TMS Message System — chat board styles (admin + shortcode)
   ============================================================ */

.tmsg-board,
.tmsg-board * {
	box-sizing: border-box;
}
.tmsg-board {
	max-width: 460px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 8px;
	padding: 12px;
}

/* ---- Header ---- */
.tmsg-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 2px 10px;
	border-bottom: 1px solid #eee;
	margin-bottom: 10px;
}
.tmsg-header-title {
	display: flex;
	align-items: center;
	gap: 8px;
}
.tmsg-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: #e6f1fb;
	color: #185fa5;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	flex-shrink: 0;
}
.tmsg-owner-name {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
}
.tmsg-board-label {
	margin: 0;
	font-size: 12px;
	color: #666;
}
.tmsg-filter-toggle {
	background: #fff !important;
	border: 1px solid #bbb !important;
	border-radius: 4px;
	padding: 4px 10px;
	font-size: 12px;
	cursor: pointer;
	color: #444 !important;
}
.tmsg-filter-toggle:hover,
.tmsg-filter-toggle-active {
	background: #f0f0f0 !important;
	border-color: #999 !important;
}

/* ---- Filter panel ---- */
.tmsg-filter-panel {
	background: #f8f8f8;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 12px;
	margin-bottom: 12px;
}
.tmsg-filter-hint {
	font-size: 11px;
	color: #888;
	margin: 0 0 8px;
}
.tmsg-filter-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 8px;
}
.tmsg-filter-field label {
	display: block;
	font-size: 11px;
	color: #666;
	margin-bottom: 3px;
}
.tmsg-filter-field-full {
	margin-bottom: 10px;
}

/* ---- Custom closed multi-select dropdown ----
 * The real <select multiple> stays in the DOM (hidden) as the single
 * source of truth — this is a visual/interaction layer on top of it, not
 * a replacement for it, so existing read/write logic (state.filter.*,
 * applyFilterInputs(), clearFilterInputs()) needs no data-model changes.
 */
.tmsg-custom-select {
	position: relative;
}
.tmsg-custom-select-trigger {
	width: 100%;
	text-align: left;
	background: #fff !important;
	border: 1px solid #bbb !important;
	color: #333 !important;
	border-radius: 4px;
	padding: 5px 8px;
	font-size: 12px;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tmsg-custom-select-trigger:after {
	content: '▾';
	float: right;
	color: #999;
	margin-left: 4px;
}
.tmsg-custom-select-panel {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 20;
	margin-top: 2px;
	background: #fff;
	border: 1px solid #bbb;
	border-radius: 4px;
	max-height: 160px;
	overflow-y: auto;
	box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.tmsg-custom-select.tmsg-open .tmsg-custom-select-panel {
	display: block;
}
.tmsg-custom-select-option {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 5px 8px;
	font-size: 12px;
	cursor: pointer;
}
.tmsg-custom-select-option:hover {
	background: #f4f7fb;
}
.tmsg-custom-select-option input {
	margin: 0;
	flex-shrink: 0;
}
.tmsg-custom-select-empty {
	padding: 6px 8px;
	font-size: 12px;
	color: #999;
	font-style: italic;
}
.tmsg-filter-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}
.tmsg-filter-actions button {
	font-size: 12px;
	padding: 4px 10px;
	border-radius: 4px;
	border: 1px solid #bbb !important;
	background: #fff !important;
	color: #444 !important;
	cursor: pointer;
}
.tmsg-filter-apply {
	background: #e6f1fb !important;
	color: #185fa5 !important;
	border-color: #85b7eb !important;
}

/* ---- Thread ---- */
.tmsg-thread {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 360px;
	overflow-y: auto;
	padding: 2px 4px;
	margin-bottom: 10px;
}
.tmsg-thread-loading,
.tmsg-thread-empty {
	text-align: center;
	color: #888;
	font-size: 12px;
	padding: 10px 0;
}

.tmsg-bubble-wrap {
	align-self: flex-start;
	max-width: 78%;
}
.tmsg-bubble-wrap.tmsg-own {
	align-self: flex-end;
	text-align: right;
}
.tmsg-bubble-meta {
	font-size: 11px;
	color: #999;
	margin-bottom: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tmsg-bubble {
	background: #f1f1f1;
	border: 1px solid #e0e0e0;
	border-radius: 12px;
	border-bottom-left-radius: 2px;
	padding: 8px 12px;
	font-size: 13px;
	text-align: left;
	display: inline-block;
	white-space: pre-wrap;
	word-break: break-word;
}
.tmsg-own .tmsg-bubble {
	background: #e6f1fb;
	color: #185fa5;
	border: none;
	border-radius: 12px;
	border-bottom-right-radius: 2px;
}

/* Filtered-out message placeholder */
.tmsg-dot-wrap {
	align-self: center;
}
.tmsg-dot {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #f1f1f1;
	border: 1px solid #ddd;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	line-height: 1;
	color: #999;
	cursor: pointer;
}
.tmsg-dot:hover {
	background: #e6e6e6;
}
.tmsg-dot-tooltip {
	position: relative;
}
.tmsg-dot-tooltip-content {
	display: none;
	position: absolute;
	bottom: 28px;
	left: 50%;
	transform: translateX(-50%);
	background: #222;
	color: #fff;
	font-size: 11px;
	padding: 6px 10px;
	border-radius: 4px;
	white-space: nowrap;
	max-width: 220px;
	white-space: normal;
	z-index: 10;
}
.tmsg-dot-tooltip:hover .tmsg-dot-tooltip-content {
	display: block;
}

/* ---- Typing indicator ---- */
.tmsg-typing-indicator {
	font-size: 11px;
	font-style: italic;
	color: #999;
	padding: 2px 4px 4px;
}

/* ---- Compose ---- */
.tmsg-compose {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding-top: 10px;
	border-top: 1px solid #eee;
}
.tmsg-compose-input {
	flex: 1;
	resize: none;
	min-height: 36px;
	max-height: 120px;
	line-height: 1.4;
	font-family: inherit;
	overflow-y: auto;
}
.tmsg-compose-send {
	min-width: 64px;
	height: 36px;
	padding: 0 16px;
	white-space: nowrap;
	flex-shrink: 0;
	background: #185fa5 !important;
	color: #fff !important;
	border: 1px solid #0c447c !important;
}

/* ---- Open button (mode=button) + popup ---- */
/* Use "body" prefix for specificity (beats theme's bare `button` rule)
   without !important, so the button-type inline style attribute can win. */
body .tmsg-open-btn {
	position: relative;
	background: #fff;
	border: 1px solid #bbb !important;
	border-radius: 4px;
	padding: 6px 14px;
	font-size: 13px;
	cursor: pointer;
	color: #333;
}
.tmsg-unread-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #e04040;
	margin-left: 6px;
	vertical-align: middle;
}
.tmsg-popup-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.55);
	z-index: 100000;
}
/*
 * Positioned via inline style (top/left/width/height) by chat.js, not CSS —
 * geometry is either restored from a saved position or computed as a
 * centered default on open. resize:both gives a native bottom-right resize
 * handle with no extra JS; ResizeObserver in chat.js persists the result.
 */
.tmsg-popup-box {
	position: fixed;
	min-width: 320px;
	min-height: 260px;
	max-width: 95vw;
	max-height: 95vh;
	resize: both;
	overflow: hidden;
	background: #fff;
	border-radius: 8px;
	display: flex;
	flex-direction: column;
}
.tmsg-popup-box .tmsg-board {
	max-width: none;
	flex: 1 1 auto;
	min-height: 0;
	border: none;
	border-radius: 0;
	display: flex;
	flex-direction: column;
}
.tmsg-popup-box .tmsg-thread {
	flex: 1 1 auto;
	max-height: none;
}
.tmsg-popup-titlebar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 8px;
	background: #f6f7f7;
	border-bottom: 1px solid #ddd;
	border-radius: 8px 8px 0 0;
	flex-shrink: 0;
}
.tmsg-popup-drag-handle {
	flex: 1;
	min-width: 0;
	cursor: move;
	color: #999;
	letter-spacing: 2px;
	font-size: 13px;
	line-height: 1;
	padding: 4px;
	user-select: none;
	overflow: hidden;
}
.tmsg-popup-reset,
.tmsg-popup-close {
	background: #fff !important;
	border: 1px solid #bbb !important;
	border-radius: 4px;
	cursor: pointer;
	line-height: 1;
	flex-shrink: 0;
	white-space: nowrap;
	color: #444 !important;
}
.tmsg-popup-reset {
	font-size: 11px;
	padding: 4px 8px;
}
.tmsg-popup-close {
	width: 24px;
	height: 24px;
	font-size: 16px;
	color: #666 !important;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

/* Admin page */
.tmsg-controls {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 16px 0;
}
.tmsg-controls select {
	min-width: 220px;
}
.tmsg-placeholder {
	color: #666;
	font-style: italic;
}
