/**
 * Customer file list portal styles.
 *
 * The viewer deliberately imitates Windows File Explorer's details view, since
 * that is what customers recognise from their own machine: navigation pane on
 * the left, address bar across the top, Name / Date modified / Type / Size
 * columns, and a status bar.
 *
 * Everything is scoped under .rmfd-portal / .rmfd-explorer so it neither leaks
 * into the surrounding theme nor picks up theme styling, and so the identical
 * viewer can be dropped into the admin preview screen.
 */

/* --- Shared ------------------------------------------------------------- */

.rmfd-portal {
	--rmfd-blue: #2271b1;
	--rmfd-border: #dcdcde;
	--rmfd-muted: #646970;
	font-size: 15px;
	color: #1d2327;
}

.rmfd-portal * {
	box-sizing: border-box;
}

/* --- Login / expired cards ---------------------------------------------- */

.rmfd-portal-card {
	max-width: 440px;
	margin: 40px auto;
	padding: 32px 36px;
	background: #fff;
	border: 1px solid var(--rmfd-border);
	border-radius: 8px;
	box-shadow: 0 2px 10px rgba( 0, 0, 0, .06 );
}

.rmfd-portal-card h2 {
	margin: 0 0 12px;
	font-size: 22px;
}

.rmfd-portal-intro {
	margin: 0 0 22px;
	color: var(--rmfd-muted);
}

.rmfd-portal-field {
	margin: 0 0 18px;
}

.rmfd-portal-field label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	font-size: 14px;
}

.rmfd-portal-field input {
	width: 100%;
	padding: 10px 12px;
	font-size: 15px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
}

.rmfd-portal-field input:focus {
	border-color: var(--rmfd-blue);
	outline: 2px solid rgba( 34, 113, 177, .25 );
}

.rmfd-portal-button {
	width: 100%;
	padding: 12px 20px;
	background: var(--rmfd-blue);
	color: #fff;
	border: 0;
	border-radius: 4px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.rmfd-portal-button:hover:not( :disabled ) {
	background: #135e96;
}

.rmfd-portal-button:disabled {
	opacity: .6;
	cursor: default;
}

.rmfd-portal-error {
	min-height: 20px;
	margin: 0 0 12px;
	color: #b32d2e;
	font-size: 14px;
}

.rmfd-portal-help,
.rmfd-portal-contact {
	margin: 20px 0 0;
	color: var(--rmfd-muted);
	font-size: 13px;
	line-height: 1.6;
}

/* --- Page header above the Explorer window ------------------------------ */

.rmfd-portal-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: flex-end;
	justify-content: space-between;
	padding-bottom: 12px;
}

.rmfd-portal-bar h2 {
	margin: 0;
	font-size: 21px;
}

.rmfd-portal-meta {
	margin: 4px 0 0;
	color: var(--rmfd-muted);
	font-size: 13px;
}

.rmfd-portal-logout {
	color: var(--rmfd-muted);
	font-size: 13px;
	text-decoration: underline;
	white-space: nowrap;
}

/* --- Payment banner ------------------------------------------------------
   Sits above the expiry notice so the amount due is the first thing read,
   and stacks on narrow screens rather than squeezing the Pay button. */

.rmfd-portal-invoice {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 20px;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 12px;
	padding: 14px 18px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 4px;
}

.rmfd-portal-invoice--paid {
	background: #edfaef;
	border-color: #b8e6c1;
}

.rmfd-portal-invoice-head {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
}

.rmfd-portal-invoice--paid .rmfd-portal-invoice-head {
	color: #007017;
}

.rmfd-portal-invoice-sub {
	margin: 2px 0 0;
	color: var(--rmfd-muted);
	font-size: 13px;
}

.rmfd-portal-pay {
	flex: none;
	padding: 11px 26px;
	background: #ffc439;
	border-radius: 4px;
	color: #111;
	font-size: 15px;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
}

.rmfd-portal-pay:hover,
.rmfd-portal-pay:focus {
	background: #f0b429;
	color: #111;
}

.rmfd-portal-expiry-notice {
	margin: 0 0 12px;
	padding: 8px 14px;
	background: #fcf9e8;
	border-left: 4px solid #dba617;
	font-size: 13px;
}

.rmfd-portal-loading {
	padding: 40px 0;
	color: var(--rmfd-muted);
	text-align: center;
}

/* Break out of the theme's content column so the file list gets 80% of the
   window. Themes typically constrain content to 600-800px, which is far too
   narrow for a four column details view. The negative margins are relative to
   the parent's width, so this centres an 80vw block whatever the parent is. */
@media screen and ( min-width: 900px ) {
	.rmfd-portal-viewer-wrap {
		width: 80vw;
		max-width: 80vw;
		margin-right: calc( 50% - 40vw );
		margin-left: calc( 50% - 40vw );
	}
}

/* --- Explorer window ---------------------------------------------------- */

.rmfd-explorer {
	display: flex;
	flex-direction: column;
	height: 680px;
	max-height: 82vh;
	overflow: hidden;
	background: #fff;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, .08 );
	font-family: "Segoe UI", "Segoe UI Variable", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	font-size: 13px;
	color: #1b1b1b;
}

/* Repeated rather than inherited from .rmfd-portal: the admin preview screen
   renders this same markup outside the portal wrapper. */
.rmfd-explorer,
.rmfd-explorer * {
	box-sizing: border-box;
}

.rmfd-explorer svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* --- Toolbar: address bar + search -------------------------------------- */

.rmfd-toolbar {
	display: flex;
	flex: 0 0 auto;
	gap: 8px;
	align-items: center;
	padding: 8px 10px;
	background: #f3f3f3;
	border-bottom: 1px solid #e0e0e0;
}

.rmfd-address {
	display: flex;
	flex: 1 1 auto;
	gap: 1px;
	align-items: center;
	min-width: 0;
	height: 30px;
	padding: 0 8px;
	overflow: hidden;
	background: #fff;
	border: 1px solid #d6d6d6;
	border-radius: 4px;
}

.rmfd-address-icon {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin-right: 6px;
}

.rmfd-crumb {
	flex: 0 0 auto;
	max-width: 220px;
	padding: 3px 6px;
	overflow: hidden;
	background: none;
	border: 0;
	border-radius: 3px;
	color: #1b1b1b;
	font: inherit;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
}

.rmfd-crumb:hover:not( .is-current ) {
	background: #e8e8e8;
}

.rmfd-crumb.is-current {
	cursor: default;
}

.rmfd-crumb-sep {
	flex: 0 0 auto;
	width: 11px;
	height: 11px;
	color: #6b6b6b;
}

.rmfd-address .rmfd-crumb-sep:last-child {
	display: none;
}

/* --- Copy path button --------------------------------------------------- */

.rmfd-copy-path {
	display: flex;
	flex: 0 0 auto;
	gap: 6px;
	align-items: center;
	height: 30px;
	padding: 0 11px;
	background: #fff;
	border: 1px solid #d6d6d6;
	border-radius: 4px;
	color: #1b1b1b;
	font: inherit;
	white-space: nowrap;
	cursor: pointer;
}

.rmfd-copy-path:hover:not( :disabled ) {
	background: #f0f6fd;
	border-color: #9ac3ea;
}

.rmfd-copy-path:disabled {
	opacity: .45;
	cursor: default;
}

.rmfd-copy-path.is-copied {
	background: #dff3e3;
	border-color: #8bc99a;
	color: #14622a;
}

.rmfd-copy-path.is-failed {
	background: #fdf0f0;
	border-color: #e0a3a3;
	color: #8a2020;
}

.rmfd-copy-icon {
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	color: #5a5a5a;
}

.rmfd-copy-path.is-copied .rmfd-copy-icon,
.rmfd-copy-path.is-failed .rmfd-copy-icon {
	color: inherit;
}

.rmfd-copy-label {
	min-width: 62px;
	text-align: left;
}

.rmfd-search-wrap {
	flex: 0 0 auto;
}

.rmfd-search {
	width: 210px;
	height: 30px;
	padding: 0 10px;
	background: #fff;
	border: 1px solid #d6d6d6;
	border-radius: 4px;
	font: inherit;
	color: #1b1b1b;
}

.rmfd-search:focus {
	border-color: #0067c0;
	outline: 1px solid #0067c0;
}

/* --- Panes -------------------------------------------------------------- */

.rmfd-panes {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
}

.rmfd-nav {
	flex: 0 0 250px;
	padding: 6px 0 12px;
	overflow: auto;
	background: #fafafa;
	border-right: 1px solid #e6e6e6;
}

.rmfd-main {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.rmfd-main-scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
}

@media screen and ( max-width: 782px ) {
	.rmfd-explorer {
		height: auto;
		max-height: none;
	}

	.rmfd-panes {
		flex-direction: column;
	}

	.rmfd-nav {
		flex: 0 0 auto;
		max-height: 190px;
		border-right: 0;
		border-bottom: 1px solid #e6e6e6;
	}

	.rmfd-main-scroll {
		max-height: 460px;
	}

	/* Type is the least useful column on a phone, and dropping it lets the
	   table floor come down so Name still gets a workable share. */
	.rmfd-col-type,
	.rmfd-cell-type {
		display: none;
	}

	.rmfd-file-table {
		min-width: 480px;
	}

	/* Toolbar gets tight on a phone; the copy button keeps its icon only. */
	.rmfd-copy-label {
		display: none;
	}

	.rmfd-copy-path {
		padding: 0 8px;
	}

	.rmfd-search {
		width: 130px;
	}
}

/* --- Navigation tree ---------------------------------------------------- */

.rmfd-tree,
.rmfd-tree-children {
	margin: 0;
	padding: 0;
	list-style: none;
}

.rmfd-tree-row {
	display: flex;
	gap: 4px;
	align-items: center;
	height: 26px;
	padding-right: 8px;
	cursor: pointer;
	user-select: none;
}

.rmfd-tree-row:hover {
	background: #ebebeb;
}

.rmfd-tree-item.is-active > .rmfd-tree-row {
	background: #cfe4fa;
}

.rmfd-tree-toggle {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	padding: 0;
	background: none;
	border: 0;
	color: #5a5a5a;
	cursor: pointer;
}

.rmfd-tree-toggle:disabled {
	cursor: default;
	visibility: hidden;
}

.rmfd-chevron {
	display: block;
	width: 11px;
	height: 11px;
	transition: transform .12s ease;
}

.rmfd-tree-item.is-open > .rmfd-tree-row .rmfd-chevron {
	transform: rotate( 90deg );
}

.rmfd-tree-icon {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
}

.rmfd-tree-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* --- Details view ------------------------------------------------------- */

/*
 * min-width is load-bearing. With table-layout: fixed the Name column takes
 * whatever is left after the fixed columns (150 + 180 + 96 = 426px), so in a
 * container narrower than that it resolves to zero and filenames vanish
 * entirely. The floor guarantees Name always has ~230px, and the surrounding
 * .rmfd-main-scroll provides horizontal scrolling if the window really is
 * that cramped.
 */
.rmfd-file-table {
	width: 100%;
	min-width: 660px;
	border-collapse: collapse;
	table-layout: fixed;
}

.rmfd-file-table th {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 0;
	background: #fff;
	border-bottom: 1px solid #e6e6e6;
	font-weight: 400;
	text-align: left;
}

.rmfd-file-table th + th {
	border-left: 1px solid #ededed;
}

.rmfd-sort {
	position: relative;
	width: 100%;
	padding: 7px 20px 7px 10px;
	background: none;
	border: 0;
	color: #444;
	font: inherit;
	text-align: left;
	white-space: nowrap;
	cursor: pointer;
}

.rmfd-sort:hover {
	background: #f0f0f0;
}

/* Sort arrow sits at the trailing edge of the header, clear of the label. */
.rmfd-file-table th.is-sorted-asc .rmfd-sort::after,
.rmfd-file-table th.is-sorted-desc .rmfd-sort::after {
	position: absolute;
	top: 50%;
	right: 7px;
	color: #0067c0;
	font-size: 8px;
	line-height: 1;
	transform: translateY( -50% );
	content: "▲";
}

.rmfd-file-table th.is-sorted-desc .rmfd-sort::after {
	content: "▼";
}

.rmfd-col-name { width: auto; min-width: 230px; }
.rmfd-col-path { width: 22%; }
.rmfd-col-date { width: 150px; }
.rmfd-col-type { width: 180px; }
.rmfd-col-size { width: 96px; }

/* Right aligned like Explorer, but with room kept for the sort arrow. */
.rmfd-col-size .rmfd-sort {
	padding-right: 20px;
	text-align: right;
}

.rmfd-row {
	height: 24px;
	cursor: default;
	user-select: none;
}

.rmfd-row:hover {
	background: #f0f6fd;
}

.rmfd-row.is-selected {
	background: #cfe4fa;
}

.rmfd-row:focus-visible {
	outline: 1px solid #0067c0;
	outline-offset: -1px;
}

.rmfd-file-table td {
	padding: 3px 10px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rmfd-cell-name {
	display: flex;
	gap: 8px;
	align-items: center;
}

.rmfd-icon {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
}

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

.rmfd-row-dir .rmfd-name-text {
	font-weight: 600;
}

.rmfd-cell-date,
.rmfd-cell-type,
.rmfd-cell-path {
	color: #4a4a4a;
}

.rmfd-cell-size {
	color: #4a4a4a;
	text-align: right;
}

.rmfd-empty-row td {
	padding: 36px 12px;
	color: #6b6b6b;
	text-align: center;
}

.rmfd-sentinel td {
	padding: 10px;
	text-align: center;
}

.rmfd-load-more {
	padding: 6px 16px;
	background: #fbfbfb;
	border: 1px solid #d6d6d6;
	border-radius: 4px;
	color: #0067c0;
	font: inherit;
	cursor: pointer;
}

.rmfd-load-more:hover {
	background: #f0f0f0;
}

/* --- Status bar --------------------------------------------------------- */

.rmfd-statusbar {
	display: flex;
	flex: 0 0 auto;
	gap: 16px;
	align-items: center;
	justify-content: space-between;
	height: 26px;
	padding: 0 12px;
	background: #f3f3f3;
	border-top: 1px solid #e0e0e0;
	color: #444;
	font-size: 12px;
	white-space: nowrap;
}

.rmfd-status-note {
	overflow: hidden;
	color: #8a6d1f;
	text-overflow: ellipsis;
}

/* --- Admin preview ------------------------------------------------------ */

/* No max-width: on the portal the 80vw wrapper already sets the size, and in
   wp-admin the preview should simply fill the content column. */
.rmfd-portal-viewer.rmfd-explorer {
	margin-top: 10px;
}

/* -------------------------------------------------------------------------
 * View switcher and the Large icons grid.
 *
 * The grid is a sibling of the details table rather than a restyled tbody.
 * The table depends on table-layout:fixed, sticky headers and colspan
 * sentinels, and display:grid fights all three.
 * ---------------------------------------------------------------------- */

.rmfd-view-switch {
	display: flex;
	flex: 0 0 auto;
	border: 1px solid #c4c4c4;
	border-radius: 3px;
	overflow: hidden;
	background: #fff;
}

.rmfd-view-button {
	border: 0;
	border-right: 1px solid #e0e0e0;
	background: #fff;
	color: #1a1a1a;
	font: inherit;
	height: 28px;
	padding: 0 10px;
	cursor: pointer;
	white-space: nowrap;
}

.rmfd-view-button:last-child {
	border-right: 0;
}

.rmfd-view-button:hover {
	background: #eaf3fb;
}

.rmfd-view-button.is-active {
	background: #cfe4fa;
	font-weight: 600;
}

.rmfd-icon-sort {
	flex: 0 0 auto;
	height: 30px;
	border: 1px solid #c4c4c4;
	border-radius: 3px;
	background: #fff;
	font: inherit;
	padding: 0 6px;
}

.rmfd-icon-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 140px, 1fr ) );
	gap: 10px;
	padding: 12px;
	align-content: start;
}

.rmfd-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 8px 6px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: none;
	font: inherit;
	color: inherit;
	cursor: pointer;
	text-align: center;
	min-width: 0;
}

.rmfd-tile:hover {
	background: #f0f6fc;
	border-color: #cfe4fa;
}

.rmfd-tile.is-selected {
	background: #cfe4fa;
	border-color: #99c9f0;
}

.rmfd-tile:focus-visible {
	outline: 1px solid #0067c0;
	outline-offset: -1px;
}

/* Fixed box so tiles line up regardless of each photo's aspect ratio. 256px
   thumbnails rendered into 128px stay crisp on a 2x display. */
.rmfd-tile-img {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 128px;
	height: 128px;
	background: #fafafa;
	border: 1px solid #e6e6e6;
	overflow: hidden;
}

.rmfd-tile-img img {
	max-width: 100%;
	max-height: 100%;
	display: block;
}

.rmfd-tile-folder {
	width: 64px;
	height: 64px;
}

.rmfd-tile-fallback {
	width: 48px;
	height: 48px;
}

.rmfd-tile-label {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	overflow-wrap: anywhere;
	line-height: 1.3;
	max-width: 100%;
}

.rmfd-tile-dir .rmfd-tile-label {
	font-weight: 600;
}

.rmfd-tile-path {
	color: #666;
	font-size: 11px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
}

.rmfd-grid-empty {
	grid-column: 1 / -1;
	color: #666;
	padding: 20px;
	text-align: center;
}

.rmfd-icon-grid .rmfd-load-more {
	grid-column: 1 / -1;
	justify-self: center;
}

@media screen and ( max-width: 782px ) {
	.rmfd-icon-grid {
		grid-template-columns: repeat( auto-fill, minmax( 100px, 1fr ) );
	}

	.rmfd-tile-img {
		width: 96px;
		height: 96px;
	}

	.rmfd-view-button {
		padding: 0 7px;
	}
}
