.wpmfs-app {
	display: flex;
	gap: 20px;
	border: 1px solid #e2e4e7;
	border-radius: 8px;
	overflow: hidden;
	min-height: 360px;
	font-size: 14px;
}

.wpmfs-sidebar {
	flex: 0 0 280px;
	max-width: 40%;
	background: #f6f7f7;
	border-right: 1px solid #e2e4e7;
	padding: 12px;
	overflow: auto;
}

.wpmfs-main {
	flex: 1 1 auto;
	padding: 16px;
	overflow: auto;
}

/* Tree */
.wpmfs-tree,
.wpmfs-children {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wpmfs-children {
	margin-left: 18px;
	display: none;
}

.wpmfs-node.open > .wpmfs-children {
	display: block;
}

.wpmfs-folder {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 5px 6px;
	border-radius: 4px;
	cursor: pointer;
	user-select: none;
}

.wpmfs-folder:hover {
	background: #eaecee;
}

.wpmfs-folder.active {
	background: #2271b1;
	color: #fff;
}

.wpmfs-toggle {
	width: 14px;
	text-align: center;
	font-size: 11px;
	color: inherit;
	flex: 0 0 14px;
}

.wpmfs-folder-name {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Access badge next to tagged folders */
.wpmfs-badge {
	flex: 0 0 auto;
	margin-left: auto;
	font-size: 12px;
	line-height: 1;
	padding: 2px 5px;
	border-radius: 10px;
	cursor: default;
}

.wpmfs-badge--board {
	background: #fcf3d6;
}

.wpmfs-badge--guild {
	background: #e1ecf7;
}

/* Keep badges readable when the row is selected. */
.wpmfs-folder.active .wpmfs-badge {
	background: rgba( 255, 255, 255, 0.25 );
}

/* Files */
.wpmfs-placeholder {
	color: #888;
	margin: 8px 0;
}

.wpmfs-file-table {
	width: 100%;
	border-collapse: collapse;
}

.wpmfs-file-table td {
	padding: 8px 10px;
	border-bottom: 1px solid #eee;
	vertical-align: middle;
}

.wpmfs-file-name {
	font-weight: 500;
}

.wpmfs-file-size,
.wpmfs-file-date {
	color: #777;
	white-space: nowrap;
	width: 1%;
}

.wpmfs-dl-btn {
	display: inline-block;
	padding: 4px 12px;
	background: #2271b1;
	color: #fff !important;
	text-decoration: none;
	border-radius: 4px;
	font-size: 13px;
	white-space: nowrap;
}

.wpmfs-dl-btn:hover {
	background: #135e96;
}

.wpmfs-upload-form {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid #eee;
	flex-wrap: wrap;
}

.wpmfs-upload-form .wpmfs-dl-btn {
	border: 0;
	cursor: pointer;
}

.wpmfs-upload-form .wpmfs-dl-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.wpmfs-upload-status {
	color: #777;
	font-size: 13px;
}

.wpmfs-notice {
	padding: 16px;
	background: #f6f7f7;
	border: 1px solid #e2e4e7;
	border-radius: 8px;
	color: #555;
}

/* ---------- Document library (block / shortcode / Elementor) ---------- */
.wpmfs-doclib {
	font-size: 14px;
}

.wpmfs-doclib-title {
	margin: 0 0 12px;
}

.wpmfs-breadcrumb {
	margin-bottom: 12px;
	color: #555;
}

.wpmfs-breadcrumb .wpmfs-crumb {
	color: #2271b1;
	text-decoration: none;
}

.wpmfs-breadcrumb .wpmfs-crumb--current {
	color: #555;
	font-weight: 600;
}

.wpmfs-breadcrumb .wpmfs-sep {
	margin: 0 6px;
	color: #aaa;
}

.wpmfs-subfolders {
	list-style: none;
	margin: 0 0 16px;
	padding: 0;
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
	gap: 8px;
}

.wpmfs-subfolder {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	border: 1px solid #e2e4e7;
	border-radius: 6px;
	text-decoration: none;
	color: #1d2327;
	background: #fff;
}

.wpmfs-subfolder:hover {
	background: #f6f7f7;
}

.wpmfs-sf-name {
	flex: 1 1 auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wpmfs-sf-count {
	flex: 0 0 auto;
	font-size: 12px;
	color: #777;
	background: #f0f0f1;
	border-radius: 10px;
	padding: 1px 7px;
}

/* Files — grid */
.wpmfs-files-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat( var( --wpmfs-columns, 4 ), 1fr );
	gap: 12px;
	max-width: 100%;
}

/*
 * Grid tracks default to minmax(auto, 1fr): a long unbreakable file name can
 * force a track wider than the container and push the whole grid past the
 * right edge of the screen (most visible on mobile). min-width: 0 lets cards
 * shrink below their content size so the text wraps instead.
 */
.wpmfs-files-grid > .wpmfs-file {
	min-width: 0;
}

.wpmfs-file-open,
.wpmfs-file-link {
	overflow-wrap: anywhere;
}

.wpmfs-file-link {
	display: flex;
	flex-direction: column;
	gap: 4px;
	height: 100%;
	padding: 14px;
	border: 1px solid #e2e4e7;
	border-radius: 8px;
	text-decoration: none;
	color: #1d2327;
	background: #fff;
	transition: box-shadow 0.15s ease;
}

.wpmfs-file-link:hover {
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.08 );
}

/*
 * File-type badge: a colored rounded tile showing the extension (PDF, DOCX…).
 * The color group class (wpmfs-ext-*) is set server-side from the extension.
 */
.wpmfs-file-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	min-width: 42px;
	height: 42px;
	padding: 0 7px;
	border-radius: 8px;
	background: #6b7280;         /* generic fallback */
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.03em;
	line-height: 1;
	flex-shrink: 0;
}

.wpmfs-ext-pdf     { background: #d63638; }
.wpmfs-ext-word    { background: #2b579a; }
.wpmfs-ext-excel   { background: #217346; }
.wpmfs-ext-ppt     { background: #d24726; }
.wpmfs-ext-image   { background: #7c3aed; }
.wpmfs-ext-video   { background: #0e7fc0; }
.wpmfs-ext-audio   { background: #b45309; }
.wpmfs-ext-zip     { background: #4d4d4d; }
.wpmfs-ext-text    { background: #64748b; }
.wpmfs-ext-generic { background: #6b7280; }

.wpmfs-file-title {
	font-weight: 500;
	word-break: break-word;
}

.wpmfs-file-meta {
	font-size: 12px;
	color: #777;
	margin-top: auto;
}

/* Files — list layout */
.wpmfs-layout-list .wpmfs-files-grid {
	grid-template-columns: 1fr;
}

.wpmfs-layout-list .wpmfs-file-link {
	flex-direction: row;
	align-items: center;
	gap: 12px;
}

.wpmfs-layout-list .wpmfs-file-icon {
	align-self: center;
	min-width: 36px;
	height: 30px;
	font-size: 10px;
}

.wpmfs-layout-list .wpmfs-file-meta {
	margin-top: 0;
	margin-left: auto;
	white-space: nowrap;
}

/*
 * Responsive defaults for block/shortcode instances. Elementor widgets emit
 * their own per-breakpoint rules (higher specificity), so per-device values
 * chosen in the Elementor editor override these.
 */
@media ( max-width: 1024px ) {
	.wpmfs-files-grid {
		grid-template-columns: repeat( min( var( --wpmfs-columns, 4 ), 3 ), 1fr );
	}
}

@media ( max-width: 600px ) {
	.wpmfs-files-grid {
		grid-template-columns: repeat( 2, 1fr );
		gap: 8px;
	}

	.wpmfs-layout-list .wpmfs-file-meta {
		white-space: normal;   /* nowrap meta can overflow narrow screens */
	}

	/* Tighter type + padding so names fit two-up on small screens. */
	.wpmfs-file-open,
	.wpmfs-file-link {
		padding: 10px;
	}

	.wpmfs-file-title {
		font-size: 0.8em;
	}

	.wpmfs-file-meta {
		font-size: 11px;
	}

	.wpmfs-file-icon {
		min-width: 34px;
		height: 32px;
		font-size: 10px;
	}
}

@media ( max-width: 400px ) {
	.wpmfs-files-grid {
		grid-template-columns: 1fr;
	}
}

/* File card: preview button + separate download button */
.wpmfs-file {
	position: relative;
	overflow: hidden;          /* hard guarantee: nothing bleeds past the card */
}

/*
 * Wrap rules directly on the text spans (not just inherited from the card):
 * break anywhere when a name has no natural break point, scale the title down
 * a touch relative to the theme font, and never exceed the card width.
 */
.wpmfs-file-title,
.wpmfs-file-meta,
.wpmfs-sf-name,
.wpmfs-crumb {
	overflow-wrap: anywhere;
	word-break: break-word;
	min-width: 0;
	max-width: 100%;
}

.wpmfs-file-title {
	font-size: 0.9em;
	line-height: 1.35;
}

.wpmfs-file-open {
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: 100%;
	height: 100%;
	min-width: 0;
	max-width: 100%;
	padding: 14px;
	text-align: left;
	border: 1px solid #e2e4e7;
	border-radius: 8px;
	background: #fff;
	color: #1d2327;
	cursor: pointer;
	transition: box-shadow 0.15s ease;
}

.wpmfs-file-open:hover {
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.08 );
}

.wpmfs-file-dl {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 6px;
	background: #2271b1;
	color: #fff !important;
	text-decoration: none;
	font-size: 15px;
	line-height: 1;
}

.wpmfs-file-dl:hover {
	background: #135e96;
}

.wpmfs-layout-list .wpmfs-file-open {
	flex-direction: row;
	align-items: center;
	gap: 12px;
	padding-right: 50px;
}

.wpmfs-layout-list .wpmfs-file-meta {
	margin-left: auto;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	white-space: nowrap;
}

/* Generic button (upload, lightbox) */
.wpmfs-btn {
	display: inline-block;
	padding: 7px 14px;
	background: #2271b1;
	color: #fff !important;
	border: 0;
	border-radius: 5px;
	font-size: 13px;
	text-decoration: none;
	cursor: pointer;
}

.wpmfs-btn:hover {
	background: #135e96;
}

/* Upload form */
.wpmfs-upload-form {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid #eee;
}

.wpmfs-upload-status {
	font-size: 13px;
	color: #777;
}

.wpmfs-upload-hint {
	flex-basis: 100%;
	font-size: 12px;
	color: #888;
}

/* Lightbox */
.wpmfs-lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 100000;
	align-items: center;
	justify-content: center;
}

.wpmfs-lightbox.is-open {
	display: flex;
}

.wpmfs-lb-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.8 );
}

.wpmfs-lb-dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	max-width: 90vw;
	max-height: 90vh;
	background: #fff;
	border-radius: 8px;
	overflow: hidden;
}

.wpmfs-lb-close {
	position: absolute;
	top: 6px;
	right: 8px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;         /* themes set global button padding (e.g. .5rem 1rem), pushing the × off-center */
	border: 0;
	border-radius: 50%;
	background: rgba( 0, 0, 0, 0.55 );
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.wpmfs-lb-content {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #111;
	min-width: 320px;
	min-height: 200px;
	max-height: 80vh;
	overflow: auto;
}

.wpmfs-lb-img {
	max-width: 90vw;
	max-height: 80vh;
	display: block;
}

.wpmfs-lb-frame {
	width: 80vw;
	height: 80vh;
	border: 0;
	background: #fff;
}

.wpmfs-lb-media {
	max-width: 90vw;
}

.wpmfs-lb-noprev {
	color: #ddd;
	padding: 48px 32px;
	text-align: center;
}

.wpmfs-lb-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	background: #fff;
}

.wpmfs-lb-caption {
	flex: 1 1 auto;
	font-weight: 500;
	word-break: break-word;
}

body.wpmfs-lb-lock {
	overflow: hidden;
}

@media ( max-width: 600px ) {
	.wpmfs-app {
		flex-direction: column;
	}
	.wpmfs-sidebar {
		flex-basis: auto;
		max-width: none;
		border-right: none;
		border-bottom: 1px solid #e2e4e7;
	}
}
