/* Image Picker Modal */
.image-picker-overlay {
	position: fixed;
	top: 0; left: 0; width: 100%; height: 100%;
	background: rgba(0, 0, 0, 0.7);
	z-index: 15000;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.image-picker-modal {
	background: #1e1e2e;
	color: #cdd6f4;
	border-radius: 12px;
	width: 90%;
	max-width: 1100px;
	height: 80vh;
	max-height: 700px;
	display: flex;
	flex-direction: column;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
	border: 1px solid #45475a;
	overflow: hidden;
}

.image-picker-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid #45475a;
	flex-shrink: 0;
}

.image-picker-header h2 {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 600;
}

.image-picker-close {
	background: none;
	border: none;
	color: #cdd6f4;
	font-size: 1.5rem;
	cursor: pointer;
	padding: 0 4px;
	line-height: 1;
	opacity: 0.7;
}
.image-picker-close:hover { opacity: 1; }

.image-picker-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 16px;
	border-bottom: 1px solid #313244;
	flex-shrink: 0;
}

.image-picker-folder-filter {
	background: #313244;
	border: 1px solid #45475a;
	color: #cdd6f4;
	padding: 6px 8px;
	border-radius: 6px;
	font-size: 0.85rem;
	outline: none;
	max-width: 180px;
	cursor: pointer;
}
.image-picker-folder-filter:focus { border-color: #89b4fa; }

.image-picker-search {
	flex: 1;
	background: #313244;
	border: 1px solid #45475a;
	color: #cdd6f4;
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 0.85rem;
	outline: none;
}
.image-picker-search:focus { border-color: #89b4fa; }

.image-picker-count {
	color: #a6adc8;
	font-size: 0.8rem;
	white-space: nowrap;
}

.image-picker-body {
	display: flex;
	flex: 1;
	overflow: hidden;
}

/* Image Grid */
.image-picker-grid {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
	align-content: start;
}

.image-picker-item {
	background: #313244;
	border: 2px solid transparent;
	border-radius: 8px;
	cursor: pointer;
	transition: border-color 0.15s, transform 0.1s;
	overflow: hidden;
}
.image-picker-item:hover {
	border-color: #585b70;
	transform: translateY(-1px);
}
.image-picker-item.selected {
	border-color: #89b4fa;
	box-shadow: 0 0 0 1px #89b4fa;
}

.image-picker-thumb {
	width: 100%;
	height: 100px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #1e1e2e;
}
.image-picker-thumb img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}
.image-picker-thumb-loading {
	color: #585b70;
	font-size: 0.8rem;
}
.image-picker-thumb-error {
	color: #f38ba8;
	font-size: 1.2rem;
}

.image-picker-item-name {
	padding: 4px 6px;
	font-size: 0.7rem;
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
	color: #a6adc8;
	text-align: center;
}

.image-picker-loading,
.image-picker-empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 2rem;
	color: #a6adc8;
}

/* Sidebar */
.image-picker-sidebar {
	width: 280px;
	border-left: 1px solid #45475a;
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
}

.image-picker-preview {
	height: 180px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #11111b;
	border-bottom: 1px solid #313244;
}
.image-picker-preview img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}
.image-picker-no-selection {
	color: #585b70;
	font-size: 0.85rem;
}

.image-picker-settings {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.image-picker-settings label {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 0.8rem;
	color: #a6adc8;
}

.image-picker-settings select,
.image-picker-settings input[type="text"] {
	background: #313244;
	border: 1px solid #45475a;
	color: #cdd6f4;
	padding: 5px 8px;
	border-radius: 4px;
	font-size: 0.8rem;
}
.image-picker-settings select:focus,
.image-picker-settings input[type="text"]:focus {
	border-color: #89b4fa;
	outline: none;
}

.image-picker-checkbox-label {
	flex-direction: row !important;
	align-items: center;
	gap: 6px !important;
}
.image-picker-checkbox-label input[type="checkbox"] {
	accent-color: #89b4fa;
}

.image-picker-custom-width {
	padding-left: 0;
}

.image-picker-actions {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #45475a;
}

.image-picker-insert-btn,
.image-picker-cancel-btn {
	flex: 1;
	padding: 8px 16px;
	border: none;
	border-radius: 6px;
	font-size: 0.85rem;
	cursor: pointer;
	font-weight: 500;
}

.image-picker-insert-btn {
	background: #89b4fa;
	color: #1e1e2e;
}
.image-picker-insert-btn:hover:not(:disabled) {
	background: #74c7ec;
}
.image-picker-insert-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.image-picker-cancel-btn {
	background: #45475a;
	color: #cdd6f4;
}
.image-picker-cancel-btn:hover {
	background: #585b70;
}
