/* ═══════════════════════════════════════════════════════════════════
   Pod Shell — Deck-based navigation layout
   Concept: concept/PXA.md, Phase 3 (UX-Modell)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Shell grid ──────────────────────────────────────────────────── */

.pod-shell {
	display: flex;
	min-height: 100vh;
	background: var(--mud-palette-background);
	color: var(--mud-palette-text-primary);
}

.pod-shell__nav {
	width: 220px;
	min-width: 220px;
	display: flex;
	flex-direction: column;
	padding: 16px 12px;
	background: var(--mud-palette-surface);
	border-right: 1px solid var(--mud-palette-divider);
	overflow-y: auto;
}

.pod-shell__pod-name {
	text-align: center;
	padding: 8px 0 16px;
	border-bottom: 1px solid var(--mud-palette-divider);
	margin-bottom: 12px;
}

.pod-shell__content {
	flex: 1;
	position: relative;
	padding: 24px;
	overflow-y: auto;
}

.pod-shell__mobile-header {
	display: none;
}

/* ── Deck navigation ─────────────────────────────────────────────── */

.deck-nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1;
}

/* ── Deck card ───────────────────────────────────────────────────── */

.deck-card {
	cursor: pointer;
	padding: 10px 12px;
	border-radius: 8px;
	transition: background 0.15s ease, transform 0.1s ease;
	user-select: none;
}

.deck-card:hover {
	background: rgba(255, 255, 255, 0.06);
}

.deck-card--active {
	background: rgba(108, 140, 255, 0.15);
	border-left: 3px solid var(--mud-palette-primary);
	padding-left: 9px;
}

.deck-card__content {
	display: flex;
	align-items: center;
	gap: 10px;
}

.deck-card__color-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}

.deck-card__icon {
	width: 24px;
}

.deck-card__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.deck-card__name {
	font-size: 0.875rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.deck-card__subtitle {
	font-size: 0.7rem;
	opacity: 0.55;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Bridge deck: rounded top (ship's bridge) ────────────────────── */

.deck-card--bridge {
	border-radius: 16px 16px 8px 8px;
	margin-bottom: 4px;
}

.deck-card--bridge.deck-card--active {
	border-left: none;
	border-top: 3px solid var(--mud-palette-primary);
	padding-left: 12px;
	padding-top: 7px;
}

/* ── Engine deck: rounded bottom (ship's hull) ───────────────────── */

.deck-card--engine {
	border-radius: 8px 8px 16px 16px;
	margin-top: auto;
}

.deck-card--engine.deck-card--active {
	border-left: none;
	border-bottom: 3px solid var(--mud-palette-primary);
	padding-left: 12px;
}

/* ── Intercom button ─────────────────────────────────────────────── */

.intercom-btn {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--mud-palette-primary);
	color: white;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	transition: transform 0.15s ease, background 0.15s ease;
	z-index: 1001;
}

.intercom-btn:hover {
	transform: scale(1.08);
}

.intercom-btn--recording {
	background: var(--mud-palette-error);
	animation: intercom-pulse 1s ease-in-out infinite;
}

@keyframes intercom-pulse {
	0%, 100% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
	50% { transform: scale(1.12); box-shadow: 0 4px 20px rgba(244, 67, 54, 0.5); }
}

/* ── Intercom overlay ────────────────────────────────────────────── */

.intercom-backdrop {
	position: fixed;
	inset: 0;
	z-index: 998;
}

.intercom-overlay {
	position: fixed;
	bottom: 16px;
	right: 16px;
	width: 480px;
	max-height: calc(100vh - 32px);
	display: flex;
	flex-direction: column;
	background: var(--mud-palette-surface);
	border: 1px solid var(--mud-palette-divider);
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
	z-index: 999;
	transform: translateY(20px);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.intercom-overlay--open {
	transform: translateY(0);
	opacity: 1;
	pointer-events: auto;
}

.intercom-overlay__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid var(--mud-palette-divider);
	flex-shrink: 0;
}

.intercom-overlay__messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 200px;
}

.intercom-overlay__input {
	padding: 8px 12px 12px;
	padding-right: 72px;
	border-top: 1px solid var(--mud-palette-divider);
	flex-shrink: 0;
}

.intercom-msg {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 12px;
	word-break: break-word;
}

.intercom-msg--user {
	align-self: flex-end;
	background: var(--mud-palette-primary);
	color: white;
	border-bottom-right-radius: 4px;
}

.intercom-msg--agent {
	align-self: flex-start;
	background: rgba(255, 255, 255, 0.08);
	border-bottom-left-radius: 4px;
}

.intercom-cursor {
	animation: intercom-blink 0.8s step-end infinite;
	opacity: 1;
	color: var(--mud-palette-primary);
}

@keyframes intercom-blink {
	50% { opacity: 0; }
}

.intercom-overlay__textfield {
	width: 100%;
}

/* ── Canvas frame (sandboxed iframe for agent-generated HTML) ────── */

.canvas-frame {
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--mud-palette-divider);
	margin: 4px 0;
}

.canvas-frame__toolbar {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 2px 8px;
	background: rgba(255, 255, 255, 0.04);
	border-bottom: 1px solid var(--mud-palette-divider);
}

.canvas-frame__label {
	flex: 1;
	opacity: 0.6;
	font-family: 'JetBrains Mono', monospace;
}

.canvas-frame__iframe {
	width: 100%;
	height: 240px;
	border: none;
	background: white;
	display: block;
}

.canvas-frame--expanded .canvas-frame__iframe {
	height: 480px;
}

/* ── Intercom markdown rendering ─────────────────────────────────── */

.intercom-markdown {
	font-size: 0.875rem;
	line-height: 1.5;
	overflow-wrap: break-word;
}

.intercom-markdown p {
	margin: 0 0 0.4em;
}

.intercom-markdown p:last-child {
	margin-bottom: 0;
}

.intercom-markdown h1,
.intercom-markdown h2,
.intercom-markdown h3,
.intercom-markdown h4 {
	margin: 0.6em 0 0.3em;
	font-weight: 600;
	line-height: 1.3;
}

.intercom-markdown h1 { font-size: 1.15em; }
.intercom-markdown h2 { font-size: 1.05em; }
.intercom-markdown h3 { font-size: 0.95em; }
.intercom-markdown h4 { font-size: 0.875em; }

.intercom-markdown code {
	font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
	font-size: 0.85em;
	padding: 0.15em 0.35em;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.1);
}

.intercom-markdown pre {
	margin: 0.5em 0;
	padding: 0.6em 0.8em;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.3);
	overflow-x: auto;
}

.intercom-markdown pre code {
	padding: 0;
	background: transparent;
	font-size: 0.8em;
	white-space: pre;
}

.intercom-markdown ul,
.intercom-markdown ol {
	margin: 0.3em 0;
	padding-left: 1.4em;
}

.intercom-markdown li {
	margin: 0.15em 0;
}

.intercom-markdown blockquote {
	margin: 0.4em 0;
	padding: 0.2em 0.8em;
	border-left: 3px solid var(--mud-palette-primary);
	opacity: 0.85;
}

.intercom-markdown a {
	color: var(--mud-palette-primary);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

.intercom-markdown a:hover {
	opacity: 0.8;
}

.intercom-markdown table {
	border-collapse: collapse;
	margin: 0.4em 0;
	font-size: 0.85em;
	width: 100%;
}

.intercom-markdown th,
.intercom-markdown td {
	border: 1px solid var(--mud-palette-divider);
	padding: 0.3em 0.5em;
	text-align: left;
}

.intercom-markdown th {
	background: rgba(255, 255, 255, 0.06);
	font-weight: 600;
}

.intercom-markdown input[type="checkbox"] {
	margin-right: 0.4em;
	pointer-events: none;
}

/* User messages: adjust code/pre colors for primary background */
.intercom-msg--user .intercom-markdown code {
	background: rgba(255, 255, 255, 0.2);
}

.intercom-msg--user .intercom-markdown pre {
	background: rgba(0, 0, 0, 0.2);
}

.intercom-msg--user .intercom-markdown a {
	color: white;
}

.intercom-msg--user .intercom-markdown blockquote {
	border-left-color: rgba(255, 255, 255, 0.6);
}

/* ── Deck page ───────────────────────────────────────────────────── */

.deck-page__header {
	padding-left: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   Mobile responsive (< 768px)
   Pod fills screen → tap deck → zoom in → pod collapses to hamburger
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
	.pod-shell {
		flex-direction: column;
	}

	/* Nav is hidden by default on mobile, shown when toggled */
	.pod-shell__nav {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 900;
		transform: translateX(-100%);
		transition: transform 0.25s ease;
		border-right: none;
	}

	.pod-shell--nav-open .pod-shell__nav {
		transform: translateX(0);
	}

	.pod-shell__mobile-header {
		display: flex;
		align-items: center;
		padding: 8px 0 16px;
		border-bottom: 1px solid var(--mud-palette-divider);
		margin-bottom: 16px;
	}

	.pod-shell__content {
		padding: 16px;
	}

	.intercom-btn {
		bottom: 12px;
		right: 12px;
		width: 48px;
		height: 48px;
	}

	.intercom-overlay {
		bottom: 8px;
		right: 8px;
		left: 8px;
		width: auto;
		max-height: calc(100vh - 16px);
	}

	.intercom-overlay__input {
		padding-right: 64px;
	}
}
