/* ============================================================
   Generation Queue Panel
   ============================================================ */

/* ── Panel container ─────────────────────────────────────── */
.ii-queue-panel {
	position: fixed;
	z-index: 6001;
	width: 320px;
	background: var(--ii-surface-white);
	border: 1px solid var(--ii-border);
	border-radius: var(--ii-radius-lg);
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.12),
		0 2px 8px rgba(0, 0, 0, 0.06);
	display: none;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom left;
	will-change: transform, opacity;
}

.ii-queue-panel.is-open {
	display: flex;
}

.ii-queue-panel.is-animating-in {
	animation: iiQueueSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ii-queue-panel.is-animating-out {
	animation: iiQueueSlideOut 0.16s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes iiQueueSlideIn {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(4px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

@keyframes iiQueueSlideOut {
	from {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
	to {
		opacity: 0;
		transform: scale(0.95) translateY(4px);
	}
}

/* ── Header ──────────────────────────────────────────────── */
.ii-queue-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px 10px;
	border-bottom: 1px solid var(--ii-border);
	flex-shrink: 0;
}

.ii-queue-header-left {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ii-queue-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--ii-text-primary);
	line-height: 1;
}

.ii-queue-count-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	background: var(--ii-accent-dim);
	color: var(--ii-accent);
	font-size: 10px;
	font-weight: 700;
	border-radius: 999px;
	line-height: 1;
}

.ii-queue-count-pill.is-hidden {
	display: none;
}

.ii-queue-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border: none;
	background: none;
	cursor: pointer;
	color: var(--ii-text-tertiary);
	border-radius: var(--ii-radius-sm);
	transition:
		background 0.15s,
		color 0.15s;
	flex-shrink: 0;
}

.ii-queue-close:hover {
	background: var(--ii-bg-hover);
	color: var(--ii-text-primary);
}

/* ── Body ────────────────────────────────────────────────── */
.ii-queue-body {
	overflow-y: auto;
	max-height: 380px;
	overscroll-behavior: contain;
}

/* ── Empty state ─────────────────────────────────────────── */
.ii-queue-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 32px 20px;
	text-align: center;
}

.ii-queue-empty-icon {
	color: var(--ii-text-tertiary);
	opacity: 0.5;
}

.ii-queue-empty-text {
	font-size: 13px;
	color: var(--ii-text-tertiary);
	line-height: 1.4;
}

/* ── Skeleton ────────────────────────────────────────────── */
.ii-queue-skeleton {
	padding: 8px 0;
}

.ii-queue-skeleton-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 14px;
}

.ii-queue-skeleton-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--ii-bg-active);
	flex-shrink: 0;
}

.ii-queue-skeleton-thumb {
	width: 32px;
	height: 32px;
	border-radius: var(--ii-radius-sm);
	flex-shrink: 0;
}

.ii-queue-skeleton-text {
	flex: 1;
	height: 10px;
	border-radius: 4px;
}

/* ── Item list — single vertical timeline line ───────────── */
.ii-queue-list {
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	position: relative;
}

/* Single vertical line running through all dots */
.ii-queue-list::before {
	content: '';
	position: absolute;
	left: 23px; /* list padding-left (8px) + half timeline-col width (16px) */
	top: 8px;
	bottom: 8px;
	width: 1.5px;
	background: var(--ii-border);
	pointer-events: none;
}

/* ── Individual item ─────────────────────────────────────── */
.ii-queue-item {
	display: flex;
	align-items: center;
	gap: 0;
	padding: 0;
	cursor: default;
	position: relative;
	border-radius: var(--ii-radius-md);
	transition: background 0.35s ease;
}

.ii-queue-item.is-completed {
	cursor: pointer;
	background: rgba(22, 163, 74, 0.05);
}

.ii-queue-item.is-completed:hover {
	background: rgba(22, 163, 74, 0.09);
}

.ii-queue-item.is-failed {
	background: rgba(239, 68, 68, 0.05);
}

/* ── Timeline column — dot only, no per-item line ───────── */
.ii-queue-timeline {
	width: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	align-self: stretch;
}

/* Status dot */
.ii-queue-timeline-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	position: relative;
	z-index: 1;
	background: var(--ii-surface-white);
}

.is-processing .ii-queue-timeline-dot {
	background: var(--ii-text-tertiary);
	animation: iiQueueDotPulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.is-completed .ii-queue-timeline-dot {
	background: #16a34a;
}

.is-failed .ii-queue-timeline-dot {
	background: rgb(239, 68, 68);
}

@keyframes iiQueueDotPulse {
	0%,
	100% {
		opacity: 1;
		box-shadow: 0 0 0 0 rgba(156, 163, 175, 0.6);
	}
	50% {
		opacity: 0.7;
		box-shadow: 0 0 0 5px rgba(156, 163, 175, 0);
	}
}

/* ── Item content area ───────────────────────────────────── */
.ii-queue-item-content {
	flex: 1;
	min-width: 0;
	padding: 8px 10px 8px 0;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

/* ── Item top row (media + prompt) ───────────────────────── */
.ii-queue-item-row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

/* ── Media (spinner / thumbnail / x-icon) ───────────────── */
.ii-queue-media {
	width: 32px;
	height: 32px;
	border-radius: var(--ii-radius-sm);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

/* Spinner for processing */
.ii-queue-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--ii-border);
	border-top-color: var(--ii-accent);
	border-radius: 50%;
	animation: iiQueueSpin 0.7s linear infinite;
	flex-shrink: 0;
}

@keyframes iiQueueSpin {
	to {
		transform: rotate(360deg);
	}
}

/* Thumbnail for completed */
.ii-queue-thumb {
	width: 32px;
	height: 32px;
	object-fit: cover;
	border-radius: var(--ii-radius-sm);
	display: block;
}

/* X icon container for failed */
.ii-queue-fail-icon {
	width: 32px;
	height: 32px;
	border-radius: var(--ii-radius-sm);
	background: rgba(239, 68, 68, 0.1);
	display: flex;
	align-items: center;
	justify-content: center;
	color: rgb(239, 68, 68);
	flex-shrink: 0;
}

/* ── Prompt marquee ──────────────────────────────────────── */
.ii-queue-prompt {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	position: relative;
}

.ii-queue-prompt.is-marquee {
	mask-image: linear-gradient(
		to right,
		transparent 0%,
		black 8%,
		black 92%,
		transparent 100%
	);
	-webkit-mask-image: linear-gradient(
		to right,
		transparent 0%,
		black 8%,
		black 92%,
		transparent 100%
	);
}

.ii-queue-prompt-text {
	font-size: 0.875rem;
	color: var(--ii-text-primary);
	white-space: nowrap;
	line-height: 1.4;
	display: block;
}

/* When marquee is active — duplicate content for seamless loop */
/* Duration is set inline by JS (textWidth / 60px·s⁻¹) for constant perceived speed */
.ii-queue-prompt.is-marquee .ii-queue-prompt-inner {
	display: flex;
	width: max-content;
	animation: iiQueueMarquee var(--ii-marquee-duration, 12s) linear infinite;
}

.ii-queue-prompt.is-marquee:hover .ii-queue-prompt-inner {
	animation-play-state: paused;
}

.ii-queue-prompt.is-marquee .ii-queue-prompt-text {
	padding-right: 40px; /* gap between repeat */
}

@keyframes iiQueueMarquee {
	0% {
		transform: translateX(0);
	}
	100% {
		transform: translateX(-50%);
	}
}

/* ── Sidebar footer queue button badge ───────────────────── */
.ii-sfooter-queue-btn {
	position: relative;
}

.ii-queue-badge {
	position: absolute;
	top: -2px;
	right: -4px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	background: var(--ii-accent);
	color: #fff;
	font-size: 9px;
	font-weight: 700;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	pointer-events: none;
	box-shadow: 0 0 0 2px var(--ii-surface-white);
	transition:
		transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
		opacity 0.15s;
	transform: scale(1);
}

.ii-queue-badge.is-hidden {
	opacity: 0;
	transform: scale(0.5);
	pointer-events: none;
}

/* ── Dark mode adjustments ───────────────────────────────── */
[data-theme='dark'] .ii-queue-panel {
	background: var(--ii-dk-surface-1, #13131a);
	border-color: var(--ii-dk-border, rgba(255, 255, 255, 0.08));
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.4),
		0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme='dark'] .ii-queue-timeline-dot {
	background: var(--ii-dk-surface-1, #13131a);
}

[data-theme='dark'] .is-processing .ii-queue-timeline-dot {
	background: var(--ii-text-tertiary);
}

[data-theme='dark'] .is-completed .ii-queue-timeline-dot {
	background: #16a34a;
}

[data-theme='dark'] .is-failed .ii-queue-timeline-dot {
	background: rgb(239, 68, 68);
}

[data-theme='dark'] .ii-queue-item.is-completed {
	background: rgba(22, 163, 74, 0.08);
}

[data-theme='dark'] .ii-queue-item.is-completed:hover {
	background: rgba(22, 163, 74, 0.12);
}

[data-theme='dark'] .ii-queue-item.is-failed {
	background: rgba(239, 68, 68, 0.08);
}

[data-theme='dark'] .ii-queue-fail-icon {
	background: rgba(239, 68, 68, 0.15);
}

[data-theme='dark'] .ii-queue-badge {
	box-shadow: 0 0 0 2px var(--ii-dk-surface-1, #13131a);
}

[data-theme='dark'] .ii-queue-count-pill {
	background: rgba(37, 99, 235, 0.2);
}

/* fade-in for newly added items */
@keyframes iiQueueItemIn {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ii-queue-item.is-new {
	animation: iiQueueItemIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
