/* ================================================================
 *  sidebar-assets.css — Right Assets Sidebar
 *
 *  Element: <aside class="ii-assets-sidebar" id="iiAssetsSidebar">
 *  Always visible on desktop; right edge of .ii-app flex row.
 *  Hidden on mobile (≤768px) — bottom Drawer handles assets there.
 * ================================================================ */

/* ── Layout ── */
.ii-assets-sidebar {
	width: var(--ii-assets-sidebar-width, 260px);
	min-width: var(--ii-assets-sidebar-width, 260px);
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	background: var(--ii-surface-white);
	border-left: 1px solid var(--ii-border);
	overflow: hidden;
	position: relative;
	z-index: 15;
}

[data-theme='dark'] .ii-assets-sidebar {
	background: var(--ii-dk-surface-1);
	border-left-color: var(--ii-dk-border);
}

/* ── Header (Selected count + Clear all) ── */
.ii-assets-sidebar-header {
	padding: 10px 15px;
	border-bottom: 1px solid var(--ii-border);
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
	height: var(--header-sidebar-height, 3rem);
	background: var(--ii-surface-white);
	box-sizing: border-box;
}

[data-theme='dark'] .ii-assets-sidebar-header {
	background: var(--ii-dk-surface-1);
	border-bottom-color: var(--ii-dk-border);
}

.ii-assets-sidebar-title {
	font-weight: 600;
	font-size: 14px;
	color: var(--ii-text-secondary);
	margin: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}

/* ── Actions row in header ── */
.ii-assets-sidebar-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* ── Body (scrollable asset sections) ── */
.ii-assets-sidebar-body {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
	box-sizing: border-box;
	width: var(--ii-assets-sidebar-width, 260px);
	min-width: var(--ii-assets-sidebar-width, 260px);
}

@supports (-moz-appearance: none) {
	.ii-assets-sidebar-body {
		scrollbar-width: thin;
		scrollbar-color: var(--ii-bg-active) transparent;
	}
}

.ii-assets-sidebar.is-delete-mode .ii-assets-sidebar-body {
	padding-bottom: 49px;
}

/* ── Scrollbar — Chrome/Safari/Edge ── */
.ii-assets-sidebar-body::-webkit-scrollbar {
	width: 4px;
}

.ii-assets-sidebar-body::-webkit-scrollbar-button {
	display: none !important;
	width: 0 !important;
	height: 0 !important;
}

.ii-assets-sidebar-body::-webkit-scrollbar-track {
	background: transparent;
}

.ii-assets-sidebar-body::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.18);
	border-radius: 999px;
}

.ii-assets-sidebar-body:hover::-webkit-scrollbar-thumb,
.ii-assets-sidebar-body:active::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.28);
}

.ii-assets-sidebar-body::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] .ii-assets-sidebar-body::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.18);
}

[data-theme='dark'] .ii-assets-sidebar-body:hover::-webkit-scrollbar-thumb,
[data-theme='dark'] .ii-assets-sidebar-body:active::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.28);
}

[data-theme='dark'] .ii-assets-sidebar-body::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.45);
}

/* ── Hidden modifier (for future conditional use) ── */
.ii-assets-sidebar.ii-assets-sidebar--hidden {
	display: none;
}

/* ── Mobile: hidden — bottom Drawer handles assets ── */
@media (max-width: 768px) {
	.ii-assets-sidebar {
		display: none !important;
	}
}

/* ════════════════════════════════════════════════════════════════
 *  Header Skeleton — shown while app is hydrating (before .is-loaded)
 * ════════════════════════════════════════════════════════════════ */

.ii-app:not(.is-loaded) .ii-assets-sidebar-header {
	pointer-events: none;
}

/* Title: replace text with shimmer pill */
.ii-app:not(.is-loaded) .ii-assets-sidebar-title {
	color: transparent;
	width: 72px;
	height: 13px;
	border-radius: 8px;
	background: linear-gradient(
		90deg,
		var(--ii-bg-secondary, #f3f4f6) 25%,
		var(--ii-bg-hover, #e5e7eb) 50%,
		var(--ii-bg-secondary, #f3f4f6) 75%
	);
	background-size: 200% 100%;
	animation: iiSkeletonShimmer 1.8s infinite linear;
}

.ii-app:not(.is-loaded) .ii-assets-sidebar-title * {
	visibility: hidden;
}

/* Clear-all + bulk-toggle buttons: replace with shimmer squares */
.ii-app:not(.is-loaded) .ii-sidebar-clear-btn,
.ii-app:not(.is-loaded) .ii-bulk-toggle-btn {
	color: transparent;
	width: 32px;
	height: 32px;
	border-radius: 6px;
	background: linear-gradient(
		90deg,
		var(--ii-bg-secondary, #f3f4f6) 25%,
		var(--ii-bg-hover, #e5e7eb) 50%,
		var(--ii-bg-secondary, #f3f4f6) 75%
	);
	background-size: 200% 100%;
	animation: iiSkeletonShimmer 1.8s infinite linear;
	pointer-events: none;
}

/* === MOVED FROM sidebar-left.css === */
/* ── 1. Title row layout ──────────────────────────────────────────── */

/* Direct-child title rows on both section types */
.ii-assets-section > .ii-assets-section-title,
.collection-section > .ii-assets-section-title {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 5px 6px 5px 2px;
	cursor: pointer;
	user-select: none;
	border-radius: var(--ii-radius-md, 12px);
	transition: background 0.15s ease;
}

.ii-assets-section > .ii-assets-section-title:hover,
.collection-section > .ii-assets-section-title:hover {
	background: var(--ii-bg-hover, rgba(0 0 0 / 0.04));
}

/* Label text fills the space between chevron and ⋯ */
.ii-assets-section-title > span:not([class]) {
	flex: 1 1 0;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ── 2. Collapse chevron — LEFT of title, always visible ─────────── */

.ii-section-collapse-btn {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
	/* Visible at rest — uses a slightly muted but clear colour */
	color: var(--ii-text-secondary, #6b7280);
	border-radius: var(--ii-radius-sm);
	transition:
		color 0.15s ease,
		background 0.15s ease;
}

.ii-section-collapse-btn:hover {
	color: var(--ii-text-primary, #111827);
	background: var(--ii-bg-active, rgba(0 0 0 / 0.07));
}

.ii-section-chevron {
	display: block;
	flex-shrink: 0;
	/* Points DOWN (expanded) — "6 9 12 15 18 9" polyline is a down-chevron */
	transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
	transform: rotate(0deg);
}

/* Collapsed: rotate UP */
.ii-section-collapsed > .ii-assets-section-title .ii-section-chevron {
	transform: rotate(-180deg);
}

/* ── 3. Section ⋯ options button — far right, ALWAYS VISIBLE ─────── */

.ii-section-options-btn {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	/* Always visible — no opacity:0 hiding */
	background: none;
	cursor: pointer;
	color: var(--ii-text-tertiary, #9ca3af);
	border-radius: var(--ii-radius-xs, 4px);
	transition:
		color 0.15s ease,
		background 0.15s ease;
}

.ii-section-options-btn:hover {
	color: var(--ii-text-primary, #111827);
	background: var(--ii-bg-active, rgba(0 0 0 / 0.07));
}

/* Active state when popper is open */
.ii-section-options-btn[aria-expanded='true'],
.ii-section-options-btn.is-active {
	color: var(--ii-text-primary, #111827);
	background: var(--ii-bg-active, rgba(0 0 0 / 0.07));
}

/* ── 4. Collapsible content ───────────────────────────────────────── */

/*
 * Target the direct card containers that follow the title row.
 * Using max-height for CSS-only animation without JS height measurement.
 */
.ii-assets-section > .ii-collection-images,
.ii-assets-section > .ii-collection-images-wrapper,
.collection-section > .ii-collection-images,
.collection-section > .ii-collection-images-wrapper {
	overflow: hidden;
	max-height: 9999px;
	/* large ceiling — never clips real content */
	opacity: 1;
	transition:
		max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1),
		padding 0.26s cubic-bezier(0.4, 0, 0.2, 1),
		opacity 0.2s ease;
}

.ii-section-collapsed > .ii-collection-images,
.ii-section-collapsed > .ii-collection-images-wrapper {
	max-height: 0 !important;
	opacity: 0;
	pointer-events: none;
}

/* ── 6. Tombstone: remove old "Show All" overlay ─────────────────── */
/* Stale server-rendered HTML may still contain these — hide them safely */

.ii-sidebar-show-all-overlay,
.ii-sidebar-show-all-overlay-btn {
	display: none !important;
}

/* Also undo old overflow clamping class if it got applied */
.ii-sidebar-assets-overflow {
	overflow: visible !important;
	max-height: none !important;
}

[data-theme='dark'] .ii-assets-section > .ii-assets-section-title:hover,
[data-theme='dark'] .collection-section > .ii-assets-section-title:hover {
	/* background: rgba(255 255 255 / 0.06); */
}

[data-theme='dark'] .ii-section-collapse-btn {
	color: var(--ii-text-secondary-dark, rgba(255 255 255 / 0.55));
}

[data-theme='dark'] .ii-section-collapse-btn:hover {
	color: var(--ii-text-primary-dark, #f3f4f6);
	background: rgba(255 255 255 / 0.08);
}

[data-theme='dark'] .ii-section-options-btn {
	color: var(--ii-text-tertiary-dark, rgba(255 255 255 / 0.38));
}

[data-theme='dark'] .ii-section-options-btn:hover,
[data-theme='dark'] .ii-section-options-btn[aria-expanded='true'],
[data-theme='dark'] .ii-section-options-btn.is-active {
	color: var(--ii-text-primary-dark, #f3f4f6);
	/* background: rgba(255 255 255 / 0.08); */
}

@media (max-width: 1336px) {
	:root {
		--ii-assets-sidebar-width: 240px;
	}
}

@media (max-width: 768px) {
	.ii-assets-sidebar {
		display: none !important;
	}
}

@media (max-width: 480px) {
	.ii-collection-images {
		gap: 5px;
		padding: 0 6px 6px;
	}
}
