/* ─── Edit Layout Link ─── */
.db-edit-link {
	transition: color 0.2s ease;
}
.db-edit-link:hover {
	color: var(--dashboard) !important;
}

/* ─── Dashboard Grid ─── */
.db-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 1rem;
	padding: 1rem;
	width: 100%;
	min-height: calc(100vh - 120px);
	align-content: start;
}

/* ─── Widget Container ─── */
.db-widget {
	background: var(--white);
	border-radius: 8px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
	min-width: 0;
	overflow: hidden;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
	display: flex;
	flex-direction: column;
}
.db-widget:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ─── Widget Header ─── */
.db-widget-header {
	display: flex;
	align-items: center;
	padding: 8px 12px;
	gap: 8px;
	min-height: 42px;
}
.db-widget-drag {
	cursor: grab;
	display: none;
	align-items: center;
}
.db-editing .db-widget-drag {
	display: flex;
}
.db-widget-resize,
.db-widget-remove {
	display: none;
}
.db-editing .db-widget-resize,
.db-editing .db-widget-remove {
	display: inline;
}
.db-widget-title {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
}
.db-widget-title h4 {
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.db-widget-controls {
	display: flex;
	align-items: center;
	gap: 10px;
	opacity: 0;
	transition: opacity 0.2s ease;
}
.db-widget:hover .db-widget-controls,
.db-editing .db-widget-controls {
	opacity: 1;
}
.db-widget-controls i {
	font-size: 0.85rem;
	transition: transform 0.2s ease;
}
.db-widget-controls i:hover {
	transform: scale(1.2);
}

/* ─── Widget Body ─── */
.db-widget-body {
	padding: 8px 12px 12px;
	flex: 1;
	overflow-y: auto;
	max-height: 400px;
	transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

/* ─── Collapsed State ─── */
.db-collapsed .db-widget-body {
	max-height: 0;
	padding: 0 12px;
	opacity: 0;
	overflow: hidden;
}

/* ─── Edit Mode ─── */
.db-editing .db-widget {
	outline: 2px dashed var(--dashboardl);
	outline-offset: -2px;
}
.db-editing .db-widget-drag {
	opacity: 1;
	cursor: grab;
}
.db-editing .db-widget-controls {
	opacity: 1;
}

/* ─── Drag States ─── */
.db-widget.db-dragging {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	transform: rotate(1deg);
	z-index: 100 !important;
	opacity: 0.9;
	pointer-events: none;
}

/* ─── Drop Ghost ─── */
#db-drop-ghost {
	display: none;
	background: var(--dashboardl);
	opacity: 0.3;
	border-radius: 8px;
	border: 2px dashed var(--dashboard);
	min-height: 80px;
	pointer-events: none;
}
#db-drop-ghost.db-ghost-insert {
	background: var(--dashboard);
	opacity: 0.7;
	border: none;
	border-radius: 4px;
	min-height: 0;
	width: 4px;
	justify-self: start;
}

/* ─── Resize Handle ─── */
.db-resize-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 200;
	background: rgba(0, 0, 0, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
}
.db-resize-panel {
	background: var(--white);
	border-radius: 12px;
	padding: 24px;
	min-width: 300px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.db-resize-panel h3 {
	margin-bottom: 16px;
}
.db-resize-options {
	display: flex;
	gap: 12px;
	justify-content: center;
}
.db-resize-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 12px 16px;
	border: 2px solid var(--light);
	border-radius: 8px;
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
}
.db-resize-option:hover,
.db-resize-option.active {
	border-color: var(--dashboard);
	background: var(--dashboardl);
}
.db-resize-option h4 {
	margin-top: 8px;
}
.db-resize-preview {
	display: flex;
	gap: 3px;
	height: 24px;
}
.db-resize-preview span {
	width: 20px;
	border-radius: 3px;
	background: var(--dashboardl);
}
.db-resize-option.active .db-resize-preview span.filled,
.db-resize-option:hover .db-resize-preview span.filled {
	background: var(--dashboard);
}
.db-resize-preview span.filled {
	background: var(--dashboardl);
}

/* ─── Widget Picker ─── */
.db-picker-hidden {
	display: none;
}
.db-picker-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.4);
	z-index: 10;
}
.db-picker-panel {
	position: fixed;
	top: 0;
	right: -400px;
	width: 380px;
	height: 100vh;
	background: var(--white);
	z-index: 110;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
	overflow-y: auto;
	transition: right 0.3s ease;
}
.db-picker-open .db-picker-panel {
	right: 0;
}
.db-picker-grid {
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.db-picker-item {
	border: 2px solid var(--light);
	border-radius: 8px;
	padding: 8px;
	transition: border-color 0.2s ease, background 0.2s ease;
}
.db-picker-item:not(.db-picker-disabled):hover {
	border-color: var(--dashboard);
	background: rgba(242, 75, 120, 0.05);
}
.db-picker-disabled {
	opacity: 0.4;
	cursor: default;
}
.db-picker-group-label {
	padding: 8px 4px 2px;
	border-bottom: 1px solid var(--light);
	margin-top: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 1200px) {
	.db-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	.db-widget {
		grid-column: auto !important;
		grid-row: auto !important;
	}
}
@media (max-width: 680px) {
	.db-grid {
		grid-template-columns: 1fr;
	}
}
