/**
 * Admin styles for Sidocode Shipping Goal Tracker.
 *
 * Loaded only on the plugin's own settings page via SSGT_Admin::enqueue_assets().
 * Prefix all selectors with .ssgt- to avoid conflicts.
 *
 * The live preview reuses .ssgt-bar-wrap markup from bar.php. Because
 * ssgt-public.css must not load on admin pages (CLAUDE.md), the structural
 * bar styles needed for the preview are included here, scoped to
 * .ssgt-preview-outer so they cannot affect the surrounding admin UI.
 *
 * @package ShippingThresholdTracker
 * @since   1.0.0
 */

/* ==========================================================================
	Page wrapper
	========================================================================== */

.ssgt-settings-wrap {
	max-width: 900px;
}

.ssgt-settings-wrap > h1 {
	margin-bottom: 12px;
}

/* ==========================================================================
	Navigation tabs
	========================================================================== */

.ssgt-nav-tab-wrapper {
	border-bottom: 1px solid #c3c4c7;
	margin-bottom: 0;
	padding-top: 9px;
}

.ssgt-nav-tab-wrapper .nav-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* ==========================================================================
	PRO badge
	========================================================================== */

.ssgt-pro-badge {
	display: inline-block;
	font-size: 9px;
	font-weight: 700;
	line-height: 1;
	padding: 2px 5px;
	border-radius: 3px;
	background: #8a8a8a;
	color: #fff;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	vertical-align: middle;
}

/* ==========================================================================
	Tab panels
	========================================================================== */

.ssgt-tab-panels {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-top: 0;
	padding: 4px 24px 12px;
	box-sizing: border-box;
}

.ssgt-tab-panel {
	display: none;
}

.ssgt-tab-panel--active {
	display: block;
}

/* ==========================================================================
	Section headings within tabs
	========================================================================== */

.ssgt-section-heading {
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	border-bottom: 1px solid #e0e0e0;
	padding-bottom: 8px;
	margin: 24px 0 0;
}

.ssgt-tab-panel > .ssgt-section-heading:first-of-type,
.ssgt-design-subpanel > .ssgt-section-heading:first-of-type {
	margin-top: 16px;
}

/* ==========================================================================
	Design inner sub-tabs — Bar / Upsells
	========================================================================== */

.ssgt-design-subtab-nav {
	display: flex;
	gap: 2px;
	margin-top: 16px;
	border-bottom: 1px solid #c3c4c7;
}

.ssgt-design-subtab-btn {
	padding: 6px 18px;
	font-size: 13px;
	font-weight: 500;
	color: #50575e;
	background: none;
	border: 1px solid transparent;
	border-bottom: none;
	border-radius: 3px 3px 0 0;
	cursor: pointer;
	line-height: 1.4;
	margin-bottom: -1px;
	transition: color 0.15s ease;
}

.ssgt-design-subtab-btn:hover {
	color: #1d2327;
}

.ssgt-design-subtab-btn--active {
	color: #1d2327;
	background: #fff;
	border-color: #c3c4c7;
	border-bottom-color: #fff;
}

.ssgt-design-subpanel {
	display: none;
}

.ssgt-design-subpanel--active {
	display: block;
}

/* ==========================================================================
	Form table — WordPress-standard two-column layout
	========================================================================== */

.ssgt-tab-panel .form-table th {
	width: 200px;
	padding: 14px 10px 14px 0;
	font-weight: 400;
	vertical-align: top;
}

.ssgt-tab-panel .form-table td {
	padding: 10px 10px 10px 0;
	vertical-align: top;
}

/* Per-option description text indented under each radio label */
.ssgt-option-desc {
	margin: 2px 0 8px 20px !important;
}

/* ==========================================================================
	Toggle switch — checkbox as a pill toggle
	========================================================================== */

.ssgt-toggle-field label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	line-height: 1.4;
}

.ssgt-toggle-field input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	flex-shrink: 0;
	width: 44px;
	height: 24px;
	background: #c3c4c7;
	border-radius: 12px;
	border: none;
	outline: none;
	cursor: pointer;
	transition: background 0.2s ease;
	vertical-align: middle;
}

.ssgt-toggle-field input[type="checkbox"]::after {
	content: '';
	position: absolute;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	top: 3px;
	left: 3px;
	transition: left 0.2s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ssgt-toggle-field input[type="checkbox"]::before {
	content: '';
}

.ssgt-toggle-field input[type="checkbox"]:checked {
	background: #22a94f;
}

.ssgt-toggle-field input[type="checkbox"]:checked::after {
	left: 23px;
}

.ssgt-toggle-field input[type="checkbox"]:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* ==========================================================================
	Number inputs
	========================================================================== */

.ssgt-input-number {
	width: 72px !important;
	text-align: right;
}

.ssgt-unit,
.ssgt-currency {
	margin-left: 4px;
	color: #50575e;
}

/* ==========================================================================
	Button Group
	========================================================================== */

.ssgt-button-group {
	display: inline-flex;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	overflow: hidden;
}

.ssgt-button-group label {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 6px 16px;
	background: #f6f7f7;
	color: #3c434a;
	font-weight: 500;
	cursor: pointer;
	border-right: 1px solid #c3c4c7;
	transition: all 0.2s ease;
	line-height: 1.4;
	margin: 0;
}

.ssgt-button-group label:last-child {
	border-right: none;
}

.ssgt-button-group label:hover {
	background: #f0f0f1;
}

.ssgt-button-group input[type="radio"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.ssgt-button-group input[type="radio"]:focus-visible + label {
	outline: 2px solid #2271b1;
	outline-offset: -2px;
	z-index: 1;
}

.ssgt-button-group input[type="radio"]:checked + label {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
}

/* ==========================================================================
	Icon picker — visual grid of selectable icon thumbnails
	========================================================================== */

.ssgt-icon-picker {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-width: 560px;
}

.ssgt-icon-option {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

/* Radio is visually hidden; the thumb provides the selection affordance. */
.ssgt-icon-option input[type="radio"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.ssgt-icon-thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	box-sizing: border-box;
	border: 2px solid #dcdcde;
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s ease;
	color: #333;
}

.ssgt-icon-thumb .ssgt-svg-icon,
.ssgt-icon-thumb .ssgt-svg-icon * {
	height: 50px;
	width: 50px;
}

.ssgt-icon-option:hover .ssgt-icon-thumb,
.ssgt-icon-option--active .ssgt-icon-thumb {
	border-color: #2271b1;
	background: #f0f6fc;
}

.ssgt-icon-option--active .ssgt-icon-thumb {
	border-width: 2px;
}

/* ==========================================================================
	Shortcode helper
	========================================================================== */

.ssgt-shortcode-helper {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ssgt-shortcode-helper .code {
	font-family: Consolas, "Courier New", monospace;
	max-width: 160px;
}

/* ==========================================================================
	Live preview section
	========================================================================== */

.ssgt-preview-outer {
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	padding: 16px 20px;
	margin: 12px 0 20px;
}

.ssgt-preview-label {
	font-size: 12px;
	font-style: italic;
	color: #787c82;
	margin: 0 0 12px;
}

/* ==========================================================================
	Preview bar — structural styles
	(ssgt-public.css must not load on admin; these duplicate the minimum needed)
	========================================================================== */

.ssgt-preview-outer .ssgt-bar-wrap {
	position: relative;
	padding: 14px 16px;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	color: var(--ssgt-text, #333);
	border-radius: var(--ssgt-wrap-radius, 0);
	background-color: var(--ssgt-wrap-bg, transparent);
	margin: var(--ssgt-margin-top, 5px) auto var(--ssgt-margin-bottom, 5px);
}

.ssgt-preview-outer .ssgt-bar-row {
	display: flex;
	align-items: center;
	gap: 10px;
	width: var(--ssgt-bar-row-w-desktop, 100%);
	max-width: 100%;
}

.ssgt-preview-outer .ssgt-bar-track {
	flex: 1;
	min-width: 0;
	height: var(--ssgt-height, 12px);
	background-color: var(--ssgt-bg, #c7cbce);
	border-radius: var(--ssgt-radius, 50px);
	overflow: hidden;
}

.ssgt-preview-outer .ssgt-bar-fill {
	height: 100%;
	width: 0;
	background-color: var(--ssgt-bar, #22a94f);
	border-radius: var(--ssgt-radius, 50px);
}

.ssgt-preview-outer .ssgt-bar-label {
	flex-shrink: 0;
	font-size: 0.85em;
	white-space: nowrap;
	color: var(--ssgt-text, #333);
}

.ssgt-preview-outer .ssgt-bar-message {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	font-size: 0.9375em;
	color: var(--ssgt-text, #333);
	line-height: 1.4;
}

.ssgt-preview-outer .ssgt-bar-icon {
	flex-shrink: 0;
	display: flex;
	align-items: center;
}

.ssgt-preview-outer .ssgt-bar-icon svg {
	display: block;
}

.ssgt-preview-outer .ssgt-bar-text {
	min-width: 0;
}

/* Mirror the text-alignment rules from ssgt-public.css inside the preview */
.ssgt-preview-outer [data-ssgt-align="center"] .ssgt-bar-message {
	justify-content: center;
}

.ssgt-preview-outer [data-ssgt-align="center"] .ssgt-bar-row {
	margin: 0 auto;
}

/* Mirror border / shadow override rules */
.ssgt-preview-outer .ssgt-bar-wrap[data-ssgt-border="1"] {
	border: 1px solid var(--ssgt-border-color, #e0e0e0);
}

.ssgt-preview-outer .ssgt-bar-wrap[data-ssgt-border="0"] {
	border: none;
}

.ssgt-preview-outer .ssgt-bar-wrap[data-ssgt-shadow="1"] {
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.ssgt-preview-outer .ssgt-bar-wrap[data-ssgt-shadow="0"] {
	box-shadow: none;
}

/* Mirror typography custom properties */
.ssgt-preview-outer .ssgt-bar-title   { font-size: var(--ssgt-title-fs, 14px); }
.ssgt-preview-outer .ssgt-bar-message { font-size: var(--ssgt-msg-fs,   15px); }

/* Mirror icon visibility */
.ssgt-preview-outer [data-ssgt-show-icon="0"] .ssgt-bar-icon { display: none; }

/* Mirror icon colour */
.ssgt-preview-outer .ssgt-bar-icon {
	color: var(--ssgt-icon-color, var(--ssgt-text, #333));
}

.ssgt-preview-outer .ssgt-bar-icon .ssgt-svg-icon [fill]:not([fill="none"]) { fill: currentColor; }
.ssgt-preview-outer .ssgt-bar-icon .ssgt-svg-icon [stroke]:not([stroke="none"]) { stroke: currentColor; }

/* Mirror content order — flexbox reorder for preview illustration */
.ssgt-preview-outer [data-ssgt-content-order="message_first"] {
	display: flex;
	flex-direction: column;
}

.ssgt-preview-outer [data-ssgt-content-order="message_first"] .ssgt-bar-message {
	order: -1;
}

/* ==========================================================================
	Threshold auto-detect info panel
	========================================================================== */

.ssgt-threshold-auto-info {
	margin-top: 8px;
}

.ssgt-threshold-auto-info p {
	margin: 0;
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 13px;
	line-height: 1.5;
}

.ssgt-auto-detected {
	background: #edfaef;
	border: 1px solid #b7e4bd;
	color: #1a6b2e;
}

.ssgt-auto-not-found {
	background: #fef9e7;
	border: 1px solid #f5d97e;
	color: #7a5a00;
}

/* ==========================================================================
	Location zones info panel
	========================================================================== */

.ssgt-location-zones-info {
	margin-top: 10px;
}

.ssgt-location-zones-table {
	max-width: 420px;
	border: 1px solid #ebebeb !important;
	border-radius: 5px;
	margin-bottom: 12px;
}

#ssgt-location-zones-info .ssgt-location-zones-table th {
	text-align: left;
	padding: 10px 10px;
	font-weight: 600;
}

#ssgt-location-zones-info .ssgt-location-zones-table td {
	padding: 10px 10px;
}

#ssgt-location-zones-info .ssgt-location-zones-note {
	margin-top: 6px !important;
}

.ssgt-zone-disabled-badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
	padding: 2px 6px;
	border-radius: 3px;
	background: #f0f0f1;
	color: #787c82;
	border: 1px solid #c3c4c7;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	vertical-align: middle;
	margin-left: 6px;
}

/* ==========================================================================
	Submit button spacing
	========================================================================== */

.ssgt-settings-wrap .submit {
	padding-left: 0;
	margin-top: 12px;
}

/* ==========================================================================
	Responsive — single column below 768px
	========================================================================== */

@media ( max-width: 768px ) {

	.ssgt-tab-panels {
		padding: 4px 16px 12px;
	}

	.ssgt-tab-panel .form-table th,
	.ssgt-tab-panel .form-table td {
		display: block;
		width: auto;
		padding-right: 0;
	}

	.ssgt-tab-panel .form-table th {
		padding-bottom: 4px;
		font-weight: 600;
	}

}
