/* TSO Link Inspector – Admin Styles
   Compatible amb WordPress 6.0+
   ============================================================ */

/* ── Layout ─────────────────────────────────────────────────── */
.tsoliin-wrap {
	max-width: min(1400px, 100%);
	margin: 0 auto;
	box-sizing: border-box;
}

.tsoliin-title-icon {
	color: #2271b1;
	font-size: 28px;
	vertical-align: middle;
	margin-right: 6px;
}

.tsoliin-page-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 16px;
	margin-bottom: 0;
}

.tsoliin-page-head .wp-heading-inline,
.tsoliin-page-head h1 {
	margin: 0;
	flex: 1 1 auto;
}

.tsoliin-donate-btn {
	display: inline-flex;
	align-items: center;
	padding: 6px 14px;
	border-radius: 999px;
	border: 1px solid #c07000;
	background: #fff8e6;
	color: #6b3800;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
	flex-shrink: 0;
}

.tsoliin-donate-btn:hover,
.tsoliin-donate-btn:focus {
	background: #ffefb8;
	color: #6b3800;
	border-color: #a85f00;
	box-shadow: none;
}

/* ── Stats cards ─────────────────────────────────────────────── */
.tsoliin-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin: 20px 0 10px;
}

.tsoliin-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 110px;
	padding: 14px 18px;
	border-radius: 6px;
	background: #fff;
	border: 1px solid #c3c4c7;
	box-shadow: 0 1px 3px rgba(0,0,0,.05);
	text-align: center;
}

.tsoliin-stat__number {
	font-size: 28px;
	font-weight: 700;
	line-height: 1.1;
	color: #1d2327;
}

.tsoliin-stat__label {
	margin-top: 4px;
	font-size: 12px;
	color: #646970;
	text-transform: uppercase;
	letter-spacing: .04em;
}

.tsoliin-stat--broken .tsoliin-stat__number   { color: #cc1818; }
.tsoliin-stat--redirect .tsoliin-stat__number { color: #b45309; }
.tsoliin-stat--ok .tsoliin-stat__number       { color: #0a7d33; }
.tsoliin-stat--unchecked .tsoliin-stat__number{ color: #646970; }

.tsoliin-last-scan {
	font-size: 13px;
	color: #646970;
	margin-bottom: 16px;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.tsoliin-toolbar {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 14px 0;
}

.tsoliin-toolbar .button .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	vertical-align: sub;
	margin-right: 4px;
}

/* Keep consistent gap below bulk actions across empty/non-empty lists. */
.tsoliin-wrap .tablenav.top {
	min-height: 40px;
	margin-bottom: 10px;
}

.tsoliin-wrap .tablenav.top .bulkactions {
	margin-bottom: 10px;
}

.tsoliin-wrap .wp-list-table {
	margin-top: 10px;
}

/* ── Progress bar ────────────────────────────────────────────── */
.tsoliin-progress {
	position: relative;
	width: 300px;
	height: 22px;
	background: #e0e0e0;
	border-radius: 11px;
	overflow: hidden;
	border: 1px solid #c3c4c7;
}

.tsoliin-progress__bar {
	height: 100%;
	background: linear-gradient(90deg, #2271b1, #72aee6);
	border-radius: 11px;
	transition: width .3s ease;
	width: 0%;
}

.tsoliin-progress__label {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 600;
	color: #fff;
	text-shadow: 0 0 3px rgba(0,0,0,.5);
}

/* ── Filter tabs ─────────────────────────────────────────────── */
.tsoliin-filter-tabs {
	margin-bottom: 10px;
}

.tsoliin-filter-tabs a {
	display: inline-block;
	padding: 4px 12px;
	margin-right: 4px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	background: #f0f0f1;
	color: #2271b1;
	text-decoration: none;
	font-size: 13px;
	transition: background .15s, color .15s;
}

.tsoliin-filter-tabs a:hover {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
}

.tsoliin-filter-tabs a.current {
	background: #2271b1;
	color: #fff;
	border-color: #135e96;
	font-weight: 600;
}

/* ── Status badges ───────────────────────────────────────────── */
.tsoliin-status {
	display: inline-block;
	padding: 3px 9px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.35;
	white-space: nowrap;
}

.wp-list-table td.column-status_code .tsoliin-status {
	white-space: normal;
	word-break: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
}

.tsoliin-status--ok       { background: #d1fae5; color: #065f46; }
.tsoliin-status--broken   { background: #fee2e2; color: #7f1d1d; }
.tsoliin-status--redirect { background: #fef3c7; color: #78350f; }
.tsoliin-status--unknown  { background: #f3f4f6; color: #374151; }

.tsoliin-redirect-to {
	display: block;
	margin-top: 3px;
	color: #646970;
	font-size: 11px;
}

/* ── Table tweaks ────────────────────────────────────────────── */
.wp-list-table .column-cb            { width: 2.2em; }
.wp-list-table .column-status_code   { width: 220px; min-width: 180px; }
.wp-list-table .column-last_checked  { width: 130px; white-space: nowrap; }
.wp-list-table .column-anchor_text   { width: 130px; }
.wp-list-table .column-post_title    { width: 200px; }

.wp-list-table td.column-status_code {
	vertical-align: top;
	line-height: 1.4;
}

/* Avoid duplicate header row at the bottom in short/empty tables. */
.tsoliin-wrap .wp-list-table tfoot {
	display: none;
}

.tsoliin-url {
	word-break: break-all;
	font-size: 13px;
}

/* Row action spinner */
.tsoliin-row-spinner {
	display: inline-block;
	vertical-align: middle;
	margin-left: 6px;
}

/* ── Modal ───────────────────────────────────────────────────── */
.tsoliin-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
}

.tsoliin-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.55);
}

.tsoliin-modal__content {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: #fff;
	border-radius: 8px;
	padding: 28px 32px;
	width: 90%;
	max-width: 520px;
	box-shadow: 0 10px 40px rgba(0,0,0,.25);
	z-index: 1;
}

.tsoliin-modal__content h2 {
	margin-top: 0;
	font-size: 18px;
	color: #1d2327;
	border-bottom: 1px solid #e0e0e0;
	padding-bottom: 12px;
	margin-bottom: 16px;
}

.tsoliin-modal__content label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
	color: #1d2327;
}

.tsoliin-modal__content code {
	display: block;
	word-break: break-all;
	background: #f0f0f1;
	padding: 6px 10px;
	border-radius: 4px;
	font-size: 13px;
	color: #cc1818;
}

.tsoliin-modal__content input[type="url"] {
	width: 100%;
	margin-top: 4px;
	font-size: 14px;
}

.tsoliin-modal__actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 20px;
}

.tsoliin-modal__spinner {
	display: none;
}

.tsoliin-modal__spinner.is-active {
	display: inline-block;
	float: none;
	margin: 0;
}

.tsoliin-modal__feedback {
	margin-top: 10px;
	font-size: 13px;
}

.tsoliin-modal__feedback.is-error   { color: #cc1818; }
.tsoliin-modal__feedback.is-success { color: #0a7d33; }

/* ── Responsive ──────────────────────────────────────────────── */
@media screen and (max-width: 782px) {
	.tsoliin-stats {
		gap: 8px;
	}
	.tsoliin-stat {
		min-width: 80px;
		padding: 10px 12px;
	}
	.tsoliin-stat__number {
		font-size: 22px;
	}
	.tsoliin-progress {
		width: 200px;
	}
}

/* ── Diagnostic panel ────────────────────────────────────────── */
.tsoliin-diagnose-panel {
	margin: 10px 0 16px;
	padding: 14px 18px;
	background: #f0f6fc;
	border: 1px solid #c3d9f0;
	border-radius: 6px;
	font-size: 13px;
	line-height: 1.7;
}

.tsoliin-diagnose-panel code {
	background: transparent;
	font-size: 12.5px;
	font-family: monospace;
}

.tsoliin-toolbar .button .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	vertical-align: sub;
	margin-right: 4px;
}

/* ── Check progress bar (green) ──────────────────────────────── */
.tsoliin-progress--check .tsoliin-progress__bar {
	background: linear-gradient(90deg, #00a32a, #00e05a);
}

/* ── Check button ────────────────────────────────────────────── */
#tsoliin-start-check {
	background: #00a32a;
	border-color: #008a20;
	color: #fff;
}
#tsoliin-start-check:hover,
#tsoliin-start-check:focus {
	background: #007a1e;
	border-color: #006618;
	color: #fff;
}
#tsoliin-start-check:disabled {
	background: #6dc08a;
	border-color: #5aa876;
}

/* ── Warning badge (403/401/429 – bot block, probably not broken) ── */
.tsoliin-status--skipped {
	background: #e5e7eb;
	color: #4b5563;
}

.tsoliin-status--warning {
	background: #fff3cd;
	color: #856404;
	border: 1px solid #ffc107;
	font-weight: 600;
}

/* ── Context column ──────────────────────────────────────────── */
.wp-list-table .column-context { width: 200px; }

.tsoliin-context {
	display: block;
	font-size: 12px;
	color: #646970;
	font-style: italic;
	cursor: help;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	max-width: 200px;
}

/* ── Check button ────────────────────────────────────────────── */
.tsoliin-btn-check {
	background: #00a32a !important;
	border-color: #008a20 !important;
	color: #fff !important;
}
.tsoliin-btn-check:hover,
.tsoliin-btn-check:focus {
	background: #007a1e !important;
}
.tsoliin-btn-check:disabled {
	background: #6dc08a !important;
	border-color: #5aa876 !important;
	opacity: 0.7;
}

/* ── Notice ──────────────────────────────────────────────────── */
.tsoliin-notice {
	margin: 10px 0 !important;
}

/* ── Settings back button ────────────────────────────────────── */
.tsoliin-back-link {
	color: #2271b1;
	text-decoration: none;
	font-size: 18px;
	font-weight: 600;
}
.tsoliin-back-link:hover { color: #135e96; text-decoration: underline; }
.tsoliin-back-link .dashicons { vertical-align: middle; font-size: 20px; }
.tsoliin-breadcrumb-sep { color: #646970; margin: 0 6px; font-size: 16px; }

/* ── Type icons ──────────────────────────────────────────────── */
.wp-list-table .column-link_type { width: 70px; text-align: center; }

.tsoliin-type-icon {
	font-size: 18px;
	width: 18px;
	height: 18px;
	vertical-align: middle;
}
.tsoliin-type--link    .tsoliin-type-icon, .tsoliin-type--link    { color: #2271b1; }
.tsoliin-type--image   { color: #00a32a; }
.tsoliin-type--iframe  { color: #cc1818; }
.tsoliin-type--comment { color: #b45309; }

/* ── Smart Suggest panel ─────────────────────────────────────── */
.tsoliin-suggest-row td {
	background: #fffbeb;
	border-top: 2px solid #fbbf24;
	padding: 12px 16px !important;
}

.tsoliin-suggest-list {
	margin: 8px 0 0;
	padding: 0;
	list-style: none;
}

.tsoliin-suggest-list li {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 8px;
	padding: 8px 10px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 5px;
}

.tsoliin-suggest-list a {
	word-break: break-all;
	font-size: 13px;
	font-weight: 500;
}

.tsoliin-suggest-close {
	float: right;
	margin-top: -4px;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	padding: 4px 10px;
	min-width: 32px;
	min-height: 32px;
	color: #646970;
	text-decoration: none;
}

.tsoliin-suggest-close:hover,
.tsoliin-suggest-close:focus {
	color: #b32d2e;
}

/* ── Settings meta keys textarea fix ────────────────────────── */
.tsoliin-meta-keys {
	box-sizing: border-box;
	width: 100%;
	max-width: 400px;
	font-size: 12px;
}

/* ── Not-broken resolved row ─────────────────────────────────── */
.tsoliin-row--broken {
	background: #fef2f2 !important;
}
.tsoliin-row--broken:hover {
	background: #fee2e2 !important;
}
.tsoliin-row--resolved {
	opacity: 0.6;
	background: #f0fdf4 !important;
	transition: opacity .4s;
}
.tsoliin-row--resolved:hover { opacity: 1; }

/* ── Not-broken action link ──────────────────────────────────── */
.row-actions .tsoliin-not-broken { color: #0a7d33; font-weight: 600; }
.row-actions .tsoliin-not-broken:hover { color: #065f46; }

/* ── URL column wider ─────────────────────────────────────────── */
.wp-list-table .column-link_url {
	min-width: 420px;
	max-width: 680px;
	width: 35%;
	word-break: break-word;
	overflow-wrap: break-word;
}
.wp-list-table .column-link_url .tsoliin-url a {
	word-break: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
	display: inline-block;
}


/* ── HTTP insecure stat card ──────────────────────────────────── */
.tsoliin-stat--http-insecure { border-top-color: #b45309; }
.tsoliin-stat--http-insecure .tsoliin-stat__number { color: #b45309; }

/* ── Secondary action bar ─────────────────────────────────────── */
.tsoliin-action-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 8px 0 4px;
	gap: 8px;
	flex-wrap: wrap;
}
.tsoliin-action-bar__left  { display: flex; gap: 6px; flex-wrap: wrap; }
.tsoliin-action-bar__right { display: flex; align-items: center; }

.tsoliin-search-input {
	min-width: 260px;
	height: 30px;
	padding: 0 8px;
	border: 1px solid #8c8f94;
	border-radius: 3px 0 0 3px;
	border-right: none;
}
.tsoliin-search-input:focus { border-color: #2271b1; outline: none; box-shadow: 0 0 0 1px #2271b1; }
.tsoliin-action-bar__right .button {
	border-radius: 0 3px 3px 0;
	height: 30px;
}

/* ── Post title icon buttons ──────────────────────────────────── */
.tsoliin-post-icons { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 4px; }

.tsoliin-post-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 4px;
	color: #2271b1;
	text-decoration: none;
	transition: background .15s, color .15s;
}
.tsoliin-post-icon .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}
.tsoliin-post-icon:hover { background: #e8f0fb; color: #135e96; }

/* List-view icon */
.tsoliin-post-icon--list { color: #2271b1; }
.tsoliin-post-icon--list:hover { background: #e8f0fb; }

/* Back icon — orange/accent so it stands out */
.tsoliin-post-icon--back {
	color: #fff;
	background: #d63638;
	border-radius: 4px;
}
.tsoliin-post-icon--back:hover { background: #b32d2e; color: #fff; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — viewport ≤ 782px (WP admin breakpoint)
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — WordPress admin mobile breakpoint (≤ 782px)
   ═══════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 782px) {

	/* ── Contain plugin screens (no horizontal pan to read) ───── */
	.tsoliin-wrap,
	body.tools_page_tso-link-inspector .wrap,
	body.tools_page_tso-link-inspector-settings .wrap,
	body.admin_page_tso-link-inspector-settings .wrap {
		max-width: 100%;
		min-width: 0;
		box-sizing: border-box;
	}

	/* WordPress wraps list tables; keep within viewport */
	.tsoliin-wrap .wp-list-table-wrapper,
	body.tools_page_tso-link-inspector .wp-list-table-wrapper {
		max-width: 100%;
		overflow-x: hidden;
	}

	/* Desktop URL column min-width must not apply on small screens */
	.wp-list-table .column-link_url {
		min-width: 0 !important;
		max-width: 100% !important;
		width: auto !important;
	}

	.wp-list-table {
		width: 100% !important;
		max-width: 100%;
		table-layout: fixed;
		box-sizing: border-box;
	}

	.tsoliin-context {
		max-width: 100%;
		white-space: normal;
	}

	/* Settings: fields use full content width */
	body.tools_page_tso-link-inspector-settings .form-table textarea,
	body.tools_page_tso-link-inspector-settings .form-table input.large-text,
	body.tools_page_tso-link-inspector-settings .form-table input.regular-text,
	body.tools_page_tso-link-inspector-settings .form-table input[type="email"],
	body.tools_page_tso-link-inspector-settings .form-table select,
	body.admin_page_tso-link-inspector-settings .form-table textarea,
	body.admin_page_tso-link-inspector-settings .form-table input.large-text,
	body.admin_page_tso-link-inspector-settings .form-table input.regular-text,
	body.admin_page_tso-link-inspector-settings .form-table input[type="email"],
	body.admin_page_tso-link-inspector-settings .form-table select,
	.tsoliin-meta-keys {
		max-width: 100% !important;
		width: 100% !important;
	}

	/* ── Stat cards ─────────────────────────────────────────────── */
	.tsoliin-stats {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;
	}
	.tsoliin-stat        { padding: 8px; min-width: 0; }
	.tsoliin-stat__number{ font-size: 1.5em; }
	.tsoliin-stat__label { font-size: 0.68em; }

	/* ── Toolbar buttons ────────────────────────────────────────── */
	.tsoliin-toolbar { flex-wrap: wrap; gap: 4px; }
	.tsoliin-toolbar .button { font-size: 12px; padding: 3px 8px; height: auto; }

	/* ── Action bar ─────────────────────────────────────────────── */
	.tsoliin-action-bar { flex-direction: column; align-items: stretch; }
	.tsoliin-action-bar__left  { flex-wrap: wrap; gap: 4px; }
	.tsoliin-action-bar__right { width: 100%; }
	.tsoliin-search-input      { min-width: 0; flex: 1; }

	/* ── LIST TABLE: card layout instead of columns ─────────────── */
	/* Hide table header */
	.wp-list-table thead,
	.wp-list-table tfoot { display: none; }

	/* Keep empty-state row as a normal table row (no "card" look). */
	.wp-list-table tbody tr.no-items {
		display: table-row;
		border: none;
		border-radius: 0;
		margin-bottom: 0;
		padding: 0;
		background: transparent;
	}
	.wp-list-table tbody tr.no-items td {
		display: table-cell;
		padding: 8px 10px;
	}

	/* Each row becomes a card */
	.wp-list-table tbody tr {
		display: block;
		border: 1px solid #dcdcde;
		border-radius: 4px;
		margin-bottom: 10px;
		padding: 8px 12px 10px;
		background: #fff;
		box-sizing: border-box;
		max-width: 100%;
	}

	/* Each cell becomes a block */
	.wp-list-table tbody td {
		display: block;
		border: none;
		padding: 3px 0;
		width: 100% !important;
		max-width: 100% !important;
		min-width: 0 !important;
		box-sizing: border-box;
	}

	/* Type icon: inline with URL */
	.wp-list-table td.column-link_type {
		display: inline-block;
		width: auto !important;
		vertical-align: middle;
		margin-right: 4px;
	}

	/* URL cell */
	.wp-list-table td.column-link_url {
		font-size: 13px;
		word-break: break-word;
		overflow-wrap: break-word;
	}
	.wp-list-table td.column-link_url .tsoliin-url a {
		word-break: break-word;
		overflow-wrap: break-word;
	}

	/* Status badge */
	.wp-list-table td.column-status_code {
		margin: 2px 0;
		min-width: 140px;
	}
	.wp-list-table td.column-status_code .tsoliin-status {
		font-size: 11px;
		max-width: 100%;
	}

	/* Hide less important columns */
	.wp-list-table td.column-anchor_text,
	.wp-list-table td.column-last_checked { display: none; }

	/* Article column: smaller */
	.wp-list-table td.column-post_title {
		font-size: 12px;
		color: #646970;
		word-break: break-word;
		overflow-wrap: anywhere;
	}
	.wp-list-table td.column-post_title a {
		word-break: break-word;
		overflow-wrap: anywhere;
	}

	/* Row actions: always visible + wrap on narrow screens */
	.wp-list-table .row-actions {
		position: static;
		visibility: visible;
		opacity: 1;
		padding-top: 4px;
		font-size: 12px;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 4px 8px;
	}

	/* Checkbox */
	.wp-list-table td.check-column {
		float: right;
		width: auto !important;
		padding: 0;
	}

	/* Select all row */
	.wp-list-table tbody .check-column input { margin-top: 2px; }

	/* Bulk actions bar */
	.tablenav .actions { flex-wrap: wrap; gap: 4px; }
	.tablenav .actions select { max-width: 140px; }

	/* Filter tabs */
	.subsubsub { font-size: 11px; }
	.subsubsub li { display: inline-block; }

	.tsoliin-filter-tabs {
		display: flex;
		flex-wrap: wrap;
		gap: 6px 8px;
		max-width: 100%;
	}
	.tsoliin-filter-tabs a {
		margin-right: 0;
		margin-bottom: 0;
		max-width: 100%;
		box-sizing: border-box;
		word-break: break-word;
	}
}

/* ── Very narrow (≤ 480px) ──────────────────────────────────────── */
@media screen and (max-width: 480px) {
	.tsoliin-toolbar .button .dashicons { display: none; }
	.tsoliin-stats { grid-template-columns: 1fr 1fr; }
}
