/* Media Cleanup screen.
 * Builds on admin-ui.css (cards, pill buttons, top bar, hero, inputs), which
 * Scanner::enqueue_assets() loads on this screen without Bootstrap so the
 * WP_List_Table keeps its core styles. This file only adds what the shared
 * stylesheet doesn't have: tabs, stat tiles, progress, usage badges, the
 * duplicate groups and the two dialogs.
 *
 * The usage badges also load on the Media Library list screen, where
 * admin-ui.css isn't loaded, so they use literal colors, not the --iup-*
 * tokens. */

.iu-media-usage .iu-mu-muted {
	margin: 14px 0 0;
	font-size: 13px;
	color: var(--iup-muted);
}

.iu-media-usage .iu-mu-intro {
	margin: 0 0 18px;
	font-size: 14px;
	color: var(--iup-body);
}

/* ---- Tabs (pill segmented control) ---- */
.iu-mu-tabs {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 2px;
	margin: 0 0 18px;
	padding: 4px;
	border: 1px solid var(--iup-input-border);
	border-radius: 999px;
	background: #f4f8fb;
}

.iup-ui .iu-mu-tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 18px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	color: var(--iup-muted);
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.iup-ui .iu-mu-tab:hover,
.iup-ui .iu-mu-tab:focus {
	color: var(--iup-ink);
	box-shadow: none;
}

.iup-ui .iu-mu-tab:focus-visible {
	box-shadow: var(--iup-focus);
	outline: none;
}

.iup-ui .iu-mu-tab.is-active {
	background: #ffffff;
	box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
	color: var(--iup-accent-ink);
}

/* Same specificity as .is-active above and later in the file, so without
   this the active tab's drop shadow replaced its keyboard focus ring. */
.iup-ui .iu-mu-tab.is-active:focus-visible {
	box-shadow: var(--iup-focus);
}

.iu-mu-tab .iup-icon {
	width: 16px;
	height: 16px;
}

/* ---- Hero without the ring visual (enable screens) ---- */
.iu-media-usage .iup-hero__main .iup-btn {
	margin-top: 2px;
}

/* ---- Stat tiles ---- */
.iu-mu-last-scan {
	font-size: 13px;
	color: var(--iup-muted);
}

.iu-mu-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 14px;
}

.iu-mu-stat {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px 18px;
	border: 1px solid var(--iup-border);
	border-radius: var(--iup-radius-panel);
	background: var(--iup-panel);
}

.iu-mu-stat__label {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--iup-muted);
}

.iu-mu-stat__value {
	font-size: 28px;
	font-weight: 800;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	color: var(--iup-ink);
}

.iu-mu-stat__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--iup-faint);
}

.iu-mu-stat--total {
	border-color: #cbe9f7;
	background: linear-gradient(90deg, #e7f6fd 0%, #f4fcfe 100%);
}

.iu-mu-stat--total .iu-mu-stat__value {
	color: var(--iup-accent-ink);
}

.iu-mu-stat.iu-usage-referenced .iu-mu-stat__dot {
	background: #22a06b;
}

.iu-mu-stat.iu-usage-possibly_unused .iu-mu-stat__dot {
	background: var(--iup-orange);
}

/* ---- Controls and progress ---- */
.iu-mu-controls {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 22px;
}

.iu-mu-progress {
	flex-basis: 100%;
	max-width: 560px;
	margin-top: 8px;
}

.iu-mu-progress-bar {
	height: 10px;
	border-radius: 999px;
	background: var(--iup-accent-tile);
	overflow: hidden;
}

.iu-mu-progress-fill {
	display: block;
	width: 0;
	height: 100%;
	border-radius: 999px;
	background: var(--iup-accent);
	transition: width 0.3s ease;
}

.iu-media-usage .iu-mu-progress-msg {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--iup-muted);
}

/* "Keep this tab open" notice (shown when WP-Cron isn't running). */
.iu-media-usage .iu-mu-keepopen {
	margin: 10px 0 0;
	padding: 10px 14px;
	border: 1px solid var(--iup-warning-border);
	border-radius: var(--iup-radius-input);
	background: var(--iup-warning-tint);
	font-size: 13px;
	color: var(--iup-warning);
}

/* ---- Callouts (crawl warning, truncated duplicates) ---- */
.iu-mu-callout {
	margin: 0 0 24px;
	padding: 16px 20px;
	border: 1px solid #cbe9f7;
	border-radius: var(--iup-radius-panel);
	background: var(--iup-accent-tint);
	font-size: 13.5px;
	color: var(--iup-body);
}

.iu-mu-callout p {
	margin: 0 0 8px;
}

.iu-mu-callout p:last-child,
.iu-mu-callout details p {
	margin-bottom: 0;
}

.iu-mu-callout--warning {
	border-color: var(--iup-warning-border);
	background: var(--iup-warning-tint);
}

.iu-media-usage .iu-mu-callout__title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 700;
	color: var(--iup-ink);
}

.iu-mu-callout--warning .iu-mu-callout__title .iup-icon {
	color: var(--iup-orange);
}

.iu-mu-callout summary {
	font-weight: 600;
	color: var(--iup-ink);
	cursor: pointer;
}

.iu-mu-callout ul {
	margin: 8px 0 0 18px;
	list-style: disc;
}

/* ---- List table ---- */
.iu-mu-table-panel .iup-card__body {
	padding: 18px 24px;
}

/* Status filter row ("All (75) | In use | Possibly unused | Unknown"). WP
   renders it as plain blue links with " | " separators; this makes it read
   as a muted segmented control that matches the rest of the admin UI. */
.iu-mu-table-panel .subsubsub {
	margin: 0 0 12px;
	font-size: 13px;
	color: var(--iup-muted);
}

.iu-mu-table-panel .subsubsub a {
	color: var(--iup-muted);
	text-decoration: none;
	font-weight: 500;
}

.iu-mu-table-panel .subsubsub a:hover {
	color: var(--iup-accent-ink);
}

.iu-mu-table-panel .subsubsub a.current {
	color: var(--iup-ink);
	font-weight: 600;
}

.iu-mu-table-panel .wp-list-table {
	border-color: var(--iup-border);
	border-radius: var(--iup-radius-input);
	box-shadow: none;
	overflow: hidden;
}

/* Match the muted uppercase label used in stat tiles and card headers across
   the admin UI; the default black bold heading WP ships read too heavy next
   to the data rows. */
.iu-mu-table-panel .wp-list-table thead th,
.iu-mu-table-panel .wp-list-table tfoot th {
	background: var(--iup-panel);
	color: var(--iup-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.iu-mu-table-panel .wp-list-table thead th a,
.iu-mu-table-panel .wp-list-table tfoot th a {
	color: inherit;
}

.iu-mu-table-panel .wp-list-table thead th a:hover,
.iu-mu-table-panel .wp-list-table tfoot th a:hover {
	color: var(--iup-ink);
}

/* Rows: drop the zebra stripe (which fights the panel background) and use a
   soft divider plus a subtle hover tint instead. */
.iu-mu-table-panel .wp-list-table.striped > tbody > :nth-child(odd) {
	background: transparent;
}

.iu-mu-table-panel .wp-list-table tbody tr {
	border-bottom: 1px solid var(--iup-divider);
}

.iu-mu-table-panel .wp-list-table tbody tr:last-child {
	border-bottom: none;
}

.iu-mu-table-panel .wp-list-table tbody tr:hover {
	background: var(--iup-accent-tint);
}

.iu-mu-table-panel .search-box input[type="search"],
.iu-mu-table-panel .tablenav select {
	border-color: var(--iup-input-border);
	border-radius: var(--iup-radius-input);
}

/* Pagination numbers / arrows (default WP button styling clashes with the
   softer card around it). */
.iu-mu-table-panel .tablenav-pages .pagination-links .button,
.iu-mu-table-panel .tablenav-pages .pagination-links .tablenav-pages-navspan {
	border-color: var(--iup-input-border);
	border-radius: var(--iup-radius-input);
	color: var(--iup-body);
}

.iu-mu-table-panel .tablenav-pages .pagination-links .button:hover:not(:disabled) {
	border-color: var(--iup-accent);
	color: var(--iup-accent-ink);
}

.column-iu_media_usage {
	width: 12%;
}

/* The list table is table-layout: fixed with no column widths, so all seven
   columns came out equal and "In use (32 places)" ran into Last scanned below
   ~1200px. Size the short columns and give Usage room for its badge; File
   takes what's left. */
.iu-mu-table-panel .wp-list-table .column-thumbnail,
.iu-mu-table-panel .wp-list-table .column-attachment_id {
	width: 64px;
}

.iu-mu-table-panel .wp-list-table .column-file_type {
	width: 110px;
}

.iu-mu-table-panel .wp-list-table .column-file_size {
	width: 80px;
}

.iu-mu-table-panel .wp-list-table .column-usage_status {
	width: 170px;
}

.iu-mu-table-panel .wp-list-table .column-last_scanned_at {
	width: 120px;
}

/* ---- Usage badges (this screen and the Media Library "Usage" column) ---- */
.iu-usage-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: #f1f5f9;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.5;
	color: #7c8a99;
	white-space: nowrap;
}

.iu-usage-badge.iu-usage-referenced {
	background: #eff9f4;
	color: #0f6b45;
}

.iu-usage-badge.iu-usage-possibly_unused {
	background: #fdf1e7;
	color: #a24f08;
}

.iu-usage-badge.iu-usage-unknown {
	background: #f1f5f9;
	color: #5b6b7b;
}

.iu-usage-badge.iu-usage-broken {
	background: #fdf3f2;
	color: #96231f;
}

.iu-usage-badge.iu-usage-ignored,
.iu-usage-badge.iu-usage-unscanned {
	background: #f1f5f9;
	color: #a8b6c5;
}

/* ---- Report a problem + footer ---- */
.iu-mu-support {
	margin-top: 4px;
	text-align: center;
}

.iu-media-usage .iu-mu-footer {
	max-width: none;
	text-align: center;
}

/* ---- Dialogs ----
 * #iu-mu-detail is ID-scoped, not the .iu-mu-detail class: that class is also
 * on the list table's inline "Found references" row-action links. */
#iu-mu-detail,
.iu-mu-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(16, 24, 40, 0.5);
}

.iu-mu-detail-inner,
.iu-mu-modal-inner {
	position: relative;
	width: 100%;
	max-height: 82vh;
	padding: 28px;
	border-radius: var(--iup-radius-card);
	background: #ffffff;
	box-shadow: var(--iup-shadow-modal);
	overflow: auto;
}

.iu-mu-detail-inner {
	max-width: 780px;
}

.iu-mu-modal-inner {
	max-width: 520px;
}

.iu-media-usage .iu-mu-detail-inner h2,
.iu-media-usage .iu-mu-modal-inner h2 {
	margin: 0 32px 14px 0;
	padding: 0;
	font-size: 19px;
	font-weight: 700;
	color: var(--iup-ink);
}

.iu-media-usage .iu-mu-modal-inner p {
	margin: 0 0 14px;
	color: var(--iup-body);
}

.iu-mu-detail-close,
.iu-mu-modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f1f5f9;
	color: var(--iup-muted);
	cursor: pointer;
}

.iu-mu-detail-close:hover,
.iu-mu-modal-close:hover {
	background: var(--iup-accent-tint);
	color: var(--iup-accent-ink);
}

.iu-mu-detail-close .iup-icon,
.iu-mu-modal-close .iup-icon {
	width: 16px;
	height: 16px;
}

.iu-mu-detail-inner .widefat {
	border-color: var(--iup-border);
	border-radius: var(--iup-radius-input);
	overflow: hidden;
}

.iu-mu-bugreport-form {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
}

.iup-ui .iu-mu-bugreport-note {
	max-width: none;
	font-size: 13px;
	resize: vertical;
}

.iu-media-usage .iu-mu-modal-inner .iu-mu-bugreport-send {
	margin: 16px 0 0;
	font-size: 13px;
}

/* ---- Duplicate groups ---- */
.iu-dup-group {
	padding: 18px 24px;
}

.iu-dup-group.iu-dup-ignored {
	opacity: 0.7;
}

.iu-dup-group-head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 14px;
}

.iu-dup-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}

.iu-dup-likely {
	background: var(--iup-success-tint);
	color: var(--iup-success);
}

.iu-dup-possible {
	background: var(--iup-accent-tint);
	color: var(--iup-accent-ink);
}

.iu-dup-needs_review {
	background: var(--iup-orange-tint);
	color: var(--iup-warning);
}

.iu-dup-weak {
	background: #f1f5f9;
	color: var(--iup-body);
}

.iu-dup-reason {
	flex: 1 1 240px;
	font-size: 13px;
	color: var(--iup-muted);
}

.iu-dup-ignored-tag {
	padding: 2px 8px;
	border-radius: 999px;
	background: #f1f5f9;
	font-size: 11px;
	font-weight: 600;
	color: var(--iup-faint);
}

.iu-dup-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.iu-dup-verify-result {
	margin: 0 0 14px;
	padding: 8px 12px;
	border-radius: var(--iup-radius-input);
	background: #f1f5f9;
	font-size: 13px;
	color: var(--iup-body);
}

.iu-dup-verify-result[data-result="exact"] {
	background: var(--iup-success-tint);
	color: var(--iup-success);
}

.iu-dup-verify-result[data-result="similar"] {
	background: var(--iup-orange-tint);
	color: var(--iup-warning);
}

.iu-dup-members {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.iu-dup-member {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1 1 280px;
	min-width: 240px;
	padding: 10px 12px;
	border: 1px solid var(--iup-border);
	border-radius: var(--iup-radius-panel);
	background: var(--iup-panel);
}

.iu-dup-thumb img {
	display: block;
	width: 56px;
	height: 56px;
	border-radius: var(--iup-radius-input);
	object-fit: cover;
}

.iu-dup-meta {
	min-width: 0;
}

.iu-dup-meta strong {
	display: block;
	color: var(--iup-ink);
	word-break: break-word;
}

.iu-dup-sub {
	font-size: 12px;
	color: var(--iup-muted);
}

/* ---- Duplicate detection settings ---- */
/* Chrome ignores flex on <details>; keep it a block. */
.iu-dup-settings.iup-card {
	display: block;
}

.iu-dup-settings summary {
	list-style: none;
}

.iu-dup-settings summary::-webkit-details-marker {
	display: none;
}

.iu-dup-settings summary::after {
	content: "";
	width: 8px;
	height: 8px;
	margin-left: auto;
	border-right: 2px solid var(--iup-muted);
	border-bottom: 2px solid var(--iup-muted);
	transform: rotate(45deg);
	transition: transform 0.15s ease;
}

.iu-dup-settings[open] summary::after {
	transform: rotate(-135deg);
}

.iu-dup-settings summary {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 18px 24px;
	font-size: 15px;
	font-weight: 700;
	color: var(--iup-ink);
	cursor: pointer;
}

.iu-dup-settings summary .iup-icon {
	width: 18px;
	height: 18px;
	color: var(--iup-accent);
}

.iu-dup-settings__body {
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 4px 24px 22px;
	border-top: 1px solid var(--iup-divider);
	padding-top: 18px;
}

.iu-dup-settings__actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.iu-dup-saved {
	color: var(--iup-success);
}

/* ---- Responsive ---- */
@media (max-width: 782px) {
	.iu-mu-tabs {
		display: flex;
		border-radius: var(--iup-radius-panel);
	}

	.iup-ui .iu-mu-tab {
		flex: 1 1 auto;
		justify-content: center;
	}

	.iu-mu-table-panel .iup-card__body,
	.iu-dup-group {
		padding: 16px;
	}
}
