/* ============================================================
 * DigitOne Media Folders — wp.media modal integration
 * ============================================================ */

/* ---------- Dropdown fallback ---------- */

.dmf-modal-folder-filter {
	display: inline-block;
	margin-right: 10px;
	vertical-align: middle;
}

.dmf-modal-folder-filter select.attachment-filters {
	max-width: 240px;
	min-width: 160px;
	padding: 0 24px 0 8px;
	height: 30px;
	line-height: 28px;
	font-size: 13px;
	background-color: #fff;
	border: 1px solid #7e8993;
	border-radius: 3px;
	vertical-align: middle;
}

.dmf-modal-folder-filter select.attachment-filters:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
	outline: none;
}

/* ---------- Sidebar ----------
 *
 * wp.media modal layout (left-to-right):
 *   .media-frame-menu     ← Breakdance/WP router with "Upload Media" / "Insert from URL"
 *   .media-frame-router   ← tab bar with "Upload files / Media Library"
 *   .media-frame-content  ← grid + toolbar
 *
 * Standard wp.media reserves ~200px on the left for .media-frame-menu.
 * Our sidebar goes BETWEEN that menu and the content area.
 */

.dmf-has-sidebar .media-frame-content,
.dmf-has-sidebar .media-frame-toolbar,
.dmf-has-sidebar .media-frame-router {
	left: 440px; /* 200px menu + 240px sidebar */
}

.dmf-modal-sidebar {
	position: absolute;
	left: 200px;   /* sits right of the .media-frame-menu */
	top: 50px;
	bottom: 0;
	width: 240px;
	background: #f6f7f7;
	border-right: 1px solid #dcdcde;
	overflow-y: auto;
	box-sizing: border-box;
	padding: 14px 0;
	z-index: 5;
}

/* If the menu is not present (some modals don't have it), pin to left. */
.dmf-modal-sidebar.dmf-no-menu {
	left: 0;
}

.dmf-has-sidebar.dmf-no-menu .media-frame-content,
.dmf-has-sidebar.dmf-no-menu .media-frame-toolbar,
.dmf-has-sidebar.dmf-no-menu .media-frame-router {
	left: 240px;
}

.dmf-modal-sidebar-header {
	padding: 0 14px 10px;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	color: #1d2327;
	letter-spacing: 0.6px;
	border-bottom: 1px solid #dcdcde;
	margin-bottom: 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.dmf-modal-newfolder-btn {
	font-size: 11px !important;
	padding: 2px 8px !important;
	height: auto !important;
	min-height: 0 !important;
	line-height: 1.6 !important;
	text-transform: none;
	letter-spacing: 0;
}

.dmf-modal-quick,
.dmf-modal-tree,
.dmf-modal-folder-children {
	list-style: none;
	margin: 0;
	padding: 0;
}

.dmf-modal-quick {
	border-bottom: 1px solid #dcdcde;
	margin-bottom: 10px;
	padding-bottom: 10px;
}

.dmf-modal-folder {
	position: relative;
}

.dmf-modal-folder-row {
	display: flex;
	align-items: center;
	padding: 8px 12px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	color: #1d2327;
	user-select: none;
	transition: background 0.1s;
	line-height: 1.4;
}

.dmf-modal-folder-row:hover {
	background: #e9eaea;
}

.dmf-modal-folder-row.is-active,
.dmf-modal-folder.is-active > .dmf-modal-folder-row {
	background: #2271b1;
	color: #fff;
}

.dmf-modal-folder-row.is-active .dashicons,
.dmf-modal-folder-row.is-active .dmf-modal-folder-count,
.dmf-modal-folder.is-active > .dmf-modal-folder-row .dashicons,
.dmf-modal-folder.is-active > .dmf-modal-folder-row .dmf-modal-folder-count {
	color: #fff;
}

.dmf-modal-folder-row .dashicons {
	margin-right: 8px;
	color: #2271b1;
	font-size: 20px;
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

.dmf-modal-folder-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.dmf-modal-folder-count {
	color: #646970;
	font-size: 12px;
	font-weight: 500;
	margin-left: 8px;
	flex-shrink: 0;
}

/* Hover actions (subfolder, color, rename, delete) */
.dmf-modal-folder-actions {
	display: none;
	margin-left: 8px;
	gap: 4px;
}

.dmf-modal-folder-row:hover .dmf-modal-folder-actions,
.dmf-modal-folder-row.is-active .dmf-modal-folder-actions {
	display: inline-flex;
}

.dmf-modal-folder-actions a {
	text-decoration: none;
	color: inherit;
	opacity: 0.65;
	transition: opacity 0.1s;
}

.dmf-modal-folder-actions a:hover {
	opacity: 1;
}

.dmf-modal-folder-actions .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	margin: 0;
	color: inherit;
}

/* Drag-over highlight */
.dmf-modal-folder-row.dmf-modal-drag-over {
	background: #d5e7f5 !important;
	outline: 2px dashed #2271b1;
	outline-offset: -2px;
}

/* Color picker popup (reusable across admin + modal) */
.dmf-color-popup {
	position: absolute;
	z-index: 999999;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	padding: 10px;
	display: grid;
	grid-template-columns: repeat(6, 22px);
	gap: 6px;
}

.dmf-color-swatch {
	width: 22px;
	height: 22px;
	border-radius: 4px;
	cursor: pointer;
	border: 2px solid transparent;
	transition: transform 0.1s, border-color 0.1s;
	position: relative;
}

.dmf-color-swatch:hover {
	transform: scale(1.15);
	border-color: #1d2327;
}

.dmf-color-swatch.is-default {
	background: #f0f0f1;
	border: 2px dashed #8c8f94;
}

.dmf-color-swatch.is-default::after {
	content: '×';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 14px;
	color: #50575e;
	font-weight: bold;
	line-height: 1;
}

/* Narrow viewport fallback */
@media screen and (max-width: 900px) {
	.dmf-modal-sidebar {
		display: none;
	}

	.dmf-has-sidebar .media-frame-content,
	.dmf-has-sidebar .media-frame-toolbar,
	.dmf-has-sidebar .media-frame-router {
		left: 200px; /* keep menu offset only */
	}

	.dmf-has-sidebar.dmf-no-menu .media-frame-content,
	.dmf-has-sidebar.dmf-no-menu .media-frame-toolbar,
	.dmf-has-sidebar.dmf-no-menu .media-frame-router {
		left: 0;
	}
}

/* Suppress Plupload "Drop files to upload" overlay during internal drag
 * inside the modal (folder reparent or attachment reassign). The JS-based
 * hide handles the primary case; this is the CSS belt-and-braces fallback. */
body.dmf-dragging .uploader-window,
body.dmf-dragging .uploader-window-content,
body.dmf-dragging .upload-ui,
body.dmf-dragging .moxie-shim,
body.dmf-dragging #drag-drop-area,
body.dmf-dragging .media-frame-uploader,
body.dmf-dragging .media-modal .uploader-inline,
body.dmf-dragging .media-modal .uploader-inline-content {
	display: none !important;
	pointer-events: none !important;
	visibility: hidden !important;
}

/* Visual cue: folder rows look grabbable */
.dmf-modal-folder-row[draggable="true"] {
	cursor: grab;
}

.dmf-modal-folder-row[draggable="true"]:active {
	cursor: grabbing;
}

/* Attachment thumbnails in modal — show grab cursor when draggable */
.media-modal .attachment[draggable="true"] {
	cursor: grab;
}

.media-modal .attachment[draggable="true"]:active {
	cursor: grabbing;
}
