/*
 * Admin-screen styles.
 *
 * Consolidated from former inline <style> blocks (CodeCanyon: no raw
 * inline styles). Loaded on every wp-admin page; every rule is scoped
 * to a body class so it is inert on unrelated screens.
 */

/* Listing editor: hide the core Preview button + the Publish-box rows
   the React listing form replaces. Was inline in classes/admin/admin.php
   and classes/listings/listings_manager.php. */
body.w2dc-listing-edit #preview-action { display: none; }
body.w2dc-listing-edit #submitdiv #major-publishing-actions #publishing-action { display: none !important; }
body.w2dc-listing-edit #submitdiv #save-action { display: none !important; }

/* Publish metabox layout - the React-injected status message
 * (`#w2dc-publish-messages`) sits on its OWN full-width row on top
 * (and collapses when empty), with the action buttons + "Move to Trash"
 * clustered together on the row below. (Previously a single flex row
 * where the empty message grew via `flex:1 1 auto` and shoved the
 * buttons sideways.) */
body.w2dc-listing-edit #submitdiv #major-publishing-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions > .clear {
	display: none; /* WP's float-clear no-op once the parent is flex */
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions #w2dc-publish-messages {
	flex: 0 0 100%; /* own full-width row */
	min-width: 0;
	order: 0;       /* on top, above the action buttons */
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions #w2dc-publish-messages:empty {
	display: none;  /* collapse when there is no message (no sideways shove) */
}
/* The React `SubmitBar`'s inline success/error banner carries an 8 px
 * bottom margin tuned for the stacked (column) layout - in the new
 * single-row flex container that bottom margin throws off `align-
 * items: center`, leaving the banner visually higher than the
 * buttons. Zero it specifically for the admin portal mount. */
body.w2dc-listing-edit #submitdiv #major-publishing-actions #w2dc-publish-messages > div {
	margin: 0 !important;
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions .w2dc-publish-actions {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 6px;
	margin: 0;
	order: 1; /* buttons cluster, under the message row */
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions .w2dc-publish-actions__btn {
	width: auto; /* was 100% from the old inline style - collapses to
	                button-natural width in the row layout */
	margin: 0;
}
body.w2dc-listing-edit #submitdiv #major-publishing-actions #delete-action {
	float: none;
	line-height: 1;
	margin: 0;
	order: 2; /* Move-to-Trash right after the buttons (same side) */
}

/* Listing-history metabox. Was inline in classes/listings/listing_log.php. */
#w2dc_listing_history .w2dc-log__list { list-style: none; margin: 0; padding: 0; }
#w2dc_listing_history .w2dc-log__item { padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
#w2dc_listing_history .w2dc-log__item:last-child { border-bottom: 0; }
#w2dc_listing_history .w2dc-log__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#w2dc_listing_history .w2dc-log__when { color: #6b7280; font-size: 11px; white-space: nowrap; }
#w2dc_listing_history .w2dc-log__meta { margin-top: 2px; color: #475569; font-size: 11px; line-height: 1.4; }
#w2dc_listing_history .w2dc-log__badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #e5e7eb; color: #1f2937; }
#w2dc_listing_history .w2dc-log__event--created { background: #dbeafe; color: #1e40af; }
#w2dc_listing_history .w2dc-log__event--activated { background: #dcfce7; color: #166534; }
#w2dc_listing_history .w2dc-log__event--renewed { background: #ccfbf1; color: #0f766e; }
#w2dc_listing_history .w2dc-log__event--expired { background: #fee2e2; color: #991b1b; }
#w2dc_listing_history .w2dc-log__event--expiration_changed { background: #fef3c7; color: #92400e; }
#w2dc_listing_history .w2dc-log__empty { color: #6b7280; margin: 0; font-style: italic; }

/* Maps Debug page. Was inline in templates/debug.tpl.php. */
.w2dc-debug { max-width: 960px; }
.w2dc-debug h2 { margin: 24px 0 4px; }
.w2dc-debug h3 { margin: 24px 0 8px; font-size: 14px; text-transform: uppercase; color: #475569; letter-spacing: .03em; }
.w2dc-debug table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e8f0; }
.w2dc-debug th, .w2dc-debug td { text-align: left; padding: 6px 10px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: top; }
.w2dc-debug th { width: 220px; color: #64748b; font-weight: 500; }
.w2dc-debug td code { background: #f1f5f9; padding: 1px 6px; border-radius: 3px; font-size: 12px; }
.w2dc-debug .ok { color: #166534; }
.w2dc-debug .err { color: #991b1b; }
.w2dc-debug .warn { color: #92400e; }
.w2dc-debug .muted { color: #94a3b8; font-style: italic; }
.w2dc-debug .diag-block { background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; padding: 12px; margin-top: 8px; }
.w2dc-debug .diag-loading { color: #64748b; }
.w2dc-debug details { background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; margin-top: 8px; padding: 8px 12px; }
.w2dc-debug details summary { cursor: pointer; font-weight: 500; color: #334155; }
.w2dc-debug details textarea { width: 100%; height: 400px; margin-top: 8px; font-family: Consolas, Monaco, monospace; font-size: 11px; }

/* Search-index rebuild widget. Was inline in classes/migration/migrate_search_index.php. */
.w2dc-search-index-rebuild .w2dc-sri-status { font-weight: 600; margin: 0 0 8px 0; }
.w2dc-search-index-rebuild .w2dc-sri-bar { width: 100%; max-width: 480px; height: 14px; background: #e5e5e5; border-radius: 3px; overflow: hidden; margin: 0 0 12px 0; }
.w2dc-search-index-rebuild .w2dc-sri-bar > span { display: block; height: 100%; width: 0; background: #2271b1; transition: width .25s ease; }
.w2dc-search-index-rebuild .w2dc-sri-actions .button { margin-right: 8px; }
.w2dc-search-index-rebuild .w2dc-sri-msg { color: #50575e; margin-top: 8px; font-style: italic; }
.w2dc-search-index-rebuild .w2dc-sri-msg.error { color: #b32d2e; font-style: normal; }

/* License support-status line (rendered by updater.php support_checker_response) */
.w2dc-license-support-checker-active  { color: #1a7f37; font-weight: 600; }
.w2dc-license-support-checker-expired { color: #b32d2e; font-weight: 600; }

/* In-flight save on the Publish-metabox proxy buttons — SubmitBar toggles
   `updating-message` (+ disabled) while the REST save runs. Own spinner ring:
   core's .updating-message dashicon styling isn't guaranteed outside the
   plugin-update screens, so the class alone rendered nothing here. */
body.w2dc-listing-edit .w2dc-publish-actions__btn.updating-message {
	pointer-events: none;
	opacity: 0.85;
}
body.w2dc-listing-edit .w2dc-publish-actions__btn.updating-message::before {
	content: "";
	display: inline-block;
	width: 12px;
	height: 12px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	margin-right: 6px;
	vertical-align: -2px;
	animation: w2dc-admin-btn-spin 0.6s linear infinite;
}
@keyframes w2dc-admin-btn-spin {
	to { transform: rotate(360deg); }
}
