/**
 * @ownership community
 * DSP community live chat.
 *
 * community.css
 * ----------------
 * Allowed selectors:
 *   .dsp-main--community
 *   .dsp-community*
 *
 * Forbidden:
 *   body
 *   html
 *   main
 *   .dsp-product-card*
 *   .dsp-home*
 *   .dsp-shop*
 *   .dsp-dashboard*
 */
.dsp-main--community {
	padding-block: 0;
	background-color: var(--dsp-color-bg-base);
}

.dsp-community {
	width: 100%;
	max-width: none;
	min-height: calc(100vh - var(--dsp-header-height, 4rem));
}

/* Welcome (guests) */
.dsp-community__welcome {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: calc(100vh - var(--dsp-header-height, 4rem) - var(--dsp-space-16));
	padding: var(--dsp-space-8) var(--dsp-space-4);
}

.dsp-community__welcome-inner {
	max-width: 36rem;
	text-align: center;
}

.dsp-community__welcome-title {
	margin: 0 0 var(--dsp-space-4);
	font-family: var(--dsp-font-family-display);
	font-size: var(--dsp-font-size-3xl);
	font-weight: var(--dsp-font-weight-bold);
	color: var(--dsp-color-text-primary);
}

.dsp-community__welcome-text {
	margin: 0 0 var(--dsp-space-8);
	font-size: var(--dsp-font-size-md);
	line-height: var(--dsp-line-height-relaxed);
	color: var(--dsp-color-text-secondary);
}

.dsp-community__welcome-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--dsp-space-3);
	justify-content: center;
}

/* Three-column chat layout */
.dsp-community__layout {
	display: grid;
	grid-template-columns: minmax(12rem, 14rem) minmax(0, 1fr) minmax(10rem, 12rem);
	grid-template-rows: minmax(calc(100vh - var(--dsp-header-height, 4rem)), 32rem);
	height: calc(100vh - var(--dsp-header-height, 4rem));
	border-top: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__rooms,
.dsp-community__users {
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--dsp-color-bg-surface);
	border-inline-end: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__users {
	border-inline-end: 0;
	border-inline-start: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__rooms-header,
.dsp-community__chat-header,
.dsp-community__users-title {
	flex-shrink: 0;
}

.dsp-community__rooms-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--dsp-space-4);
	border-bottom: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__rooms-title,
.dsp-community__users-title {
	margin: 0;
	padding: var(--dsp-space-4);
	font-size: var(--dsp-font-size-sm);
	font-weight: var(--dsp-font-weight-semibold);
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--dsp-color-text-secondary);
}

.dsp-community__users-title {
	border-bottom: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__rooms-close,
.dsp-community__menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: var(--dsp-radius-md);
	background: transparent;
	color: var(--dsp-color-text-primary);
	cursor: pointer;
}

.dsp-community__rooms-close:hover,
.dsp-community__menu-toggle:hover {
	background: var(--dsp-color-bg-muted);
}

.dsp-community__room-list,
.dsp-community__user-list {
	flex: 1;
	min-height: 0;
	margin: 0;
	padding: var(--dsp-space-2);
	overflow-y: auto;
	list-style: none;
}

.dsp-community__room-item {
	margin: 0;
}

.dsp-community__room-btn,
.dsp-community__user-btn {
	display: flex;
	align-items: center;
	gap: var(--dsp-space-2);
	width: 100%;
	padding: var(--dsp-space-2) var(--dsp-space-3);
	border: 0;
	border-radius: var(--dsp-radius-md);
	background: transparent;
	font: inherit;
	font-size: var(--dsp-font-size-sm);
	color: var(--dsp-color-text-primary);
	text-align: start;
	cursor: pointer;
}

.dsp-community__room-btn:hover,
.dsp-community__user-btn:hover {
	background: var(--dsp-color-bg-muted);
}

.dsp-community__room-item.is-active .dsp-community__room-btn {
	background: var(--dsp-color-accent-soft, rgba(59, 130, 246, 0.12));
	color: var(--dsp-color-accent, #2563eb);
	font-weight: var(--dsp-font-weight-semibold);
}

.dsp-community__room-emoji {
	font-size: 1.1em;
	line-height: 1;
}

.dsp-community__user-empty {
	padding: var(--dsp-space-3);
	font-size: var(--dsp-font-size-sm);
	color: var(--dsp-color-text-tertiary);
}

/* Chat column */
.dsp-community__chat {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	background: var(--dsp-color-bg-base);
}

.dsp-community__chat-header {
	display: flex;
	align-items: center;
	gap: var(--dsp-space-3);
	padding: var(--dsp-space-3) var(--dsp-space-4);
	border-bottom: 1px solid var(--dsp-color-border-subtle);
	background: var(--dsp-color-bg-surface);
}

.dsp-community__chat-title-wrap {
	display: flex;
	flex-direction: column;
	gap: var(--dsp-space-1);
	min-width: 0;
}

.dsp-community__chat-title {
	margin: 0;
	font-size: var(--dsp-font-size-lg);
	font-weight: var(--dsp-font-weight-semibold);
	color: var(--dsp-color-text-primary);
}

.dsp-community__status {
	font-size: var(--dsp-font-size-xs);
	color: var(--dsp-color-text-tertiary);
}

.dsp-community__status--connected {
	color: var(--dsp-color-success, #16a34a);
}

.dsp-community__messages-wrap {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.dsp-community__load-older {
	flex-shrink: 0;
	margin: var(--dsp-space-2) auto 0;
	padding: var(--dsp-space-1) var(--dsp-space-3);
	border: 1px solid var(--dsp-color-border-subtle);
	border-radius: var(--dsp-radius-full);
	background: var(--dsp-color-bg-surface);
	font-size: var(--dsp-font-size-xs);
	color: var(--dsp-color-text-secondary);
	cursor: pointer;
}

.dsp-community__load-older[hidden] {
	display: none !important;
}

.dsp-community__load-older:hover {
	border-color: var(--dsp-color-border-strong);
	color: var(--dsp-color-text-primary);
}

.dsp-community__messages {
	flex: 1;
	min-height: 0;
	padding: var(--dsp-space-4);
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: var(--dsp-space-3);
}

.dsp-community__empty,
.dsp-community__error {
	margin: auto;
	max-width: 24rem;
	padding: var(--dsp-space-6) var(--dsp-space-4);
	text-align: center;
	font-size: var(--dsp-font-size-sm);
	color: var(--dsp-color-text-secondary);
}

.dsp-community__error {
	color: var(--dsp-color-danger, #dc2626);
}

.dsp-community__retry {
	margin-top: var(--dsp-space-3);
}

.dsp-community__message {
	max-width: 85%;
	padding: var(--dsp-space-2) var(--dsp-space-3);
	border-radius: var(--dsp-radius-lg);
	background: var(--dsp-color-bg-surface);
	border: 1px solid var(--dsp-color-border-subtle);
}

.dsp-community__message--mine {
	align-self: flex-end;
	background: var(--dsp-color-accent-soft, rgba(59, 130, 246, 0.1));
	border-color: transparent;
}

.dsp-community__message-header {
	display: flex;
	align-items: baseline;
	gap: var(--dsp-space-2);
	margin-bottom: var(--dsp-space-1);
}

.dsp-community__message-author {
	padding: 0;
	border: 0;
	background: none;
	font-size: var(--dsp-font-size-xs);
	font-weight: var(--dsp-font-weight-semibold);
	color: var(--dsp-color-accent, #2563eb);
	cursor: pointer;
}

.dsp-community__message-author:hover {
	text-decoration: underline;
}

.dsp-community__message-time {
	font-size: var(--dsp-font-size-xs);
	color: var(--dsp-color-text-tertiary);
}

.dsp-community__message-body {
	margin: 0;
	font-size: var(--dsp-font-size-sm);
	line-height: var(--dsp-line-height-relaxed);
	color: var(--dsp-color-text-primary);
	word-break: break-word;
}

.dsp-community__message-actions {
	margin-top: var(--dsp-space-1);
}

.dsp-community__message-delete {
	padding: 0;
	border: 0;
	background: none;
	font-size: var(--dsp-font-size-xs);
	color: var(--dsp-color-danger, #dc2626);
	cursor: pointer;
}

.dsp-community__composer {
	display: flex;
	flex-wrap: wrap;
	gap: var(--dsp-space-2);
	align-items: center;
	padding: var(--dsp-space-3) var(--dsp-space-4);
	border-top: 1px solid var(--dsp-color-border-subtle);
	background: var(--dsp-color-bg-surface);
}

.dsp-community__composer-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.dsp-community__input {
	flex: 1;
	min-width: 12rem;
	padding: var(--dsp-space-2) var(--dsp-space-3);
	border: 1px solid var(--dsp-color-border-subtle);
	border-radius: var(--dsp-radius-md);
	font: inherit;
	font-size: var(--dsp-font-size-sm);
	background: var(--dsp-color-bg-base);
	color: var(--dsp-color-text-primary);
}

.dsp-community__input:focus {
	outline: 2px solid var(--dsp-color-accent, #2563eb);
	outline-offset: 1px;
	border-color: transparent;
}

/* Badges */
.dsp-community__badge {
	display: inline-flex;
	align-items: center;
	padding: 0.1em 0.45em;
	border-radius: var(--dsp-radius-sm);
	font-size: var(--dsp-font-size-xs);
	font-weight: var(--dsp-font-weight-semibold);
	line-height: 1.4;
}

.dsp-community__badge--pro {
	background: var(--dsp-color-accent-soft, rgba(59, 130, 246, 0.15));
	color: var(--dsp-color-accent, #2563eb);
}

.dsp-community__badge--free {
	background: var(--dsp-color-bg-muted);
	color: var(--dsp-color-text-secondary);
}

/* Profile modal content */
.dsp-community__profile-body {
	display: grid;
	gap: var(--dsp-space-3);
}

.dsp-community__profile-name {
	margin: 0;
	font-size: var(--dsp-font-size-xl);
	font-weight: var(--dsp-font-weight-semibold);
}

.dsp-community__profile-row {
	margin: 0;
	font-size: var(--dsp-font-size-sm);
	color: var(--dsp-color-text-secondary);
}

/* Tablet */
@media (max-width: 1024px) {
	.dsp-community__layout {
		grid-template-columns: minmax(11rem, 12rem) minmax(0, 1fr);
	}

	.dsp-community__users {
		display: none;
	}
}

/* Mobile — rooms drawer */
@media (max-width: 768px) {
	.dsp-community__layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.dsp-community__menu-toggle {
		display: inline-flex;
	}

	.dsp-community__rooms {
		position: fixed;
		inset: 0 auto 0 0;
		z-index: var(--dsp-z-sidebar, 120);
		width: min(18rem, 85vw);
		transform: translateX(-100%);
		transition: transform 0.25s ease;
		box-shadow: var(--dsp-shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.12));
	}

	.dsp-community__rooms-close {
		display: inline-flex;
	}

	.dsp-community--rooms-open .dsp-community__rooms {
		transform: translateX(0);
	}

	.dsp-community--rooms-open::before {
		content: '';
		position: fixed;
		inset: 0;
		z-index: calc(var(--dsp-z-sidebar, 120) - 1);
		background: rgba(0, 0, 0, 0.35);
	}

	.dsp-community__message {
		max-width: 92%;
	}
}
