/**
 * TrustLens Admin Settings Styles
 *
 * @package TrustLens
 */

/* ==========================================================================
   Settings
   ========================================================================== */

/* Full-width single-column layout. Cards stack uniformly (a multi-column grid
   made tabs ragged — short cards left dead space beside tall ones). Forms use
   display:contents so their cards/submit buttons participate directly; hidden
   inputs are pulled out so they never add stray gaps. */
.wstl-settings {
	color: #1a2433;
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
	align-items: start;
}
.wstl-settings form { display: contents; }
.wstl-settings input[type="hidden"] { display: none; }

/* Brand toggle switches for settings on/off checkboxes (no markup change).
   Hardened against WP core's native checkbox border / dashicon checkmark so it
   renders identically to the .wstl-toggle switch (42x24, 18px knob). */
.wstl-settings .form-table input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	flex: none;
	width: 42px;
	min-width: 42px;
	height: 24px;
	margin: 0 10px 0 0;
	padding: 0;
	border: 0;
	box-shadow: none;
	border-radius: 999px;
	background: #cfd8e3;
	position: relative;
	cursor: pointer;
	vertical-align: middle;
	transition: background-color 0.2s ease;
}
.wstl-settings .form-table input[type="checkbox"]::before,
.wstl-settings .form-table input[type="checkbox"]:checked::before {
	content: "" !important;
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s ease;
}
.wstl-settings .form-table input[type="checkbox"]:checked {
	background: #3377EE;
	border: 0;
}
.wstl-settings .form-table input[type="checkbox"]:checked::before { transform: translateX(18px); }
.wstl-settings .form-table input[type="checkbox"]:focus-visible {
	outline: 2px solid #3377EE;
	outline-offset: 2px;
}

/* Multi-select chip groups — opt these checkbox groups OUT of the toggle skin
   above so they read as "pick several from a set" rather than on/off switches.
   The native checkbox is visually hidden (still focusable); the <label> becomes
   a selectable pill with a checkbox tick that fills on :checked via :has(). */
.wstl-settings .form-table .wstl-choice-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 4px;
	padding: 0;
	border: 0;
}
.wstl-settings .form-table .wstl-choice-chips input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	min-width: 0;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	background: none;
	box-shadow: none;
}
.wstl-settings .form-table .wstl-choice-chips input[type="checkbox"]::before {
	content: none;
}
.wstl-settings .form-table .wstl-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 14px 6px 11px;
	border: 1px solid #d5dde7;
	border-radius: 999px;
	background: #fff;
	font-size: 13px;
	line-height: 1;
	color: #46586b;
	cursor: pointer;
	user-select: none;
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.wstl-settings .form-table .wstl-chip:hover {
	border-color: #b9c6d6;
}
/* Dev-facing gateway id, shown muted after the human label. */
.wstl-settings .form-table .wstl-chip .wstl-chip-id {
	font-size: 11px;
	color: #8493a3;
	font-family: Menlo, Consolas, monospace;
}
.wstl-settings .form-table .wstl-chip:has(input:checked) .wstl-chip-id {
	color: #5a7bb5;
}
/* The faux checkbox tick. */
.wstl-settings .form-table .wstl-chip::before {
	content: "";
	flex: none;
	width: 15px;
	height: 15px;
	border: 1.5px solid #c0cbd9;
	border-radius: 4px;
	background: #fff center/10px 10px no-repeat;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}
.wstl-settings .form-table .wstl-chip:has(input:checked) {
	border-color: #3377EE;
	background: #eef4ff;
	color: #1a2433;
}
.wstl-settings .form-table .wstl-chip:has(input:checked)::before {
	border-color: #3377EE;
	background-color: #3377EE;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.3l2.3 2.3 4.7-5'/%3E%3C/svg%3E");
}
.wstl-settings .form-table .wstl-chip:has(input:focus-visible) {
	outline: 2px solid #3377EE;
	outline-offset: 2px;
}

/* Email token (tag) inputs — progressive-enhanced from a comma-separated text
   field by admin.js (initTokenInputs). Reads as one input holding removable
   pills. Scoped under .form-table so it outranks WP core's input[type=text]. */
.wstl-settings .form-table .wstl-token-field {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-height: 38px;
	max-width: 480px;
	padding: 5px 8px;
	border: 1px solid #c0cbd9;
	border-radius: 8px;
	background: #fff;
	cursor: text;
}
.wstl-settings .form-table .wstl-token-field:focus-within {
	border-color: #3377EE;
	box-shadow: 0 0 0 1px #3377EE;
}
.wstl-settings .form-table .wstl-token {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 4px 3px 10px;
	border-radius: 999px;
	background: #eef4ff;
	border: 1px solid #cfe0ff;
	color: #1a2433;
	font-size: 12.5px;
	line-height: 1.6;
}
.wstl-settings .form-table .wstl-token.is-invalid {
	background: #fdecea;
	border-color: #f3c2c2;
	color: #8a1c1c;
}
.wstl-settings .form-table .wstl-token-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #5a7bb5;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}
.wstl-settings .form-table .wstl-token-remove:hover {
	background: rgba(20, 40, 67, 0.1);
	color: #1a2433;
}
.wstl-settings .form-table .wstl-token.is-invalid .wstl-token-remove { color: #8a1c1c; }
.wstl-settings .form-table .wstl-token-entry {
	flex: 1 1 90px;
	min-width: 90px;
	height: 26px;
	min-height: 0;
	margin: 0;
	padding: 0 2px;
	border: 0;
	background: transparent;
	box-shadow: none;
	font-size: 13px;
	color: #1a2433;
}
.wstl-settings .form-table .wstl-token-entry:focus {
	border: 0;
	outline: none;
	box-shadow: none;
}

/* Section cards — flat, hairline, generous */
.wstl-settings .wstl-card {
	background: #fff;
	border: 1px solid #e7ecf3;
	border-radius: 12px;
	box-shadow: none;
	padding: 22px 24px;
	margin: 0;
}
.wstl-settings .wstl-card:hover { box-shadow: none; }

.wstl-settings .wstl-card h2 {
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: #1a2433;
	margin: 0 0 4px;
	padding: 0;
	border: 0;
}
.wstl-settings .wstl-card > p.description,
.wstl-settings .wstl-card > .description {
	color: #6b7a8d;
	font-size: 13px;
	line-height: 1.55;
	max-width: 640px;
	margin: 0;
}

/* Form table — airy rows with hairline dividers */
.wstl-settings .form-table { margin-top: 6px; }
.wstl-settings .form-table th {
	width: 230px;
	font-weight: 600;
	font-size: 13px;
	color: #33415a;
	padding: 16px 12px 16px 0;
	vertical-align: top;
}
.wstl-settings .form-table td { padding: 14px 10px; }
.wstl-settings .form-table > tbody > tr { border-top: 1px solid #f1f4f8; }
.wstl-settings .form-table > tbody > tr:first-child { border-top: 0; }
.wstl-settings .form-table .description {
	color: #7a8896;
	font-size: 12.5px;
	line-height: 1.5;
	margin-top: 6px;
	max-width: 540px;
}
.wstl-settings .form-table input[type="text"],
.wstl-settings .form-table input[type="url"],
.wstl-settings .form-table input[type="email"],
.wstl-settings .form-table input[type="number"],
.wstl-settings .form-table select {
	border-radius: 8px;
	border-color: #d3dde9;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.wstl-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100000;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
}

.wstl-modal.is-open {
	display: flex;
}

.wstl-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(20, 40, 62, 0.45);
	backdrop-filter: blur(4px);
}

.wstl-modal-content {
	--wstl-modal-bg: #ffffff;
	--wstl-modal-border: #d5e0eb;
	--wstl-modal-shadow: 0 14px 34px rgba(16, 42, 67, 0.08), 0 8px 20px rgba(16, 42, 67, 0.06);
	--wstl-modal-accent: linear-gradient(135deg, #635bff 0%, #3377EE 100%);
	position: relative;
	background: var(--wstl-modal-bg);
	border: 1px solid var(--wstl-modal-border);
	border-radius: 14px;
	box-shadow: var(--wstl-modal-shadow);
	max-width: 600px;
	width: 90%;
	max-height: 85vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.wstl-modal-content::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: var(--wstl-modal-accent);
	border-radius: 14px 14px 0 0;
	pointer-events: none;
}

.wstl-modal-content .form-table,
.wstl-modal-content form {
	flex: 1;
	overflow: auto;
}

.wstl-modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px 24px;
	background: #ffffff;
	border-bottom: 1px solid var(--wstl-modal-border, #d5e0eb);
	border-radius: 14px 14px 0 0;
	flex-shrink: 0;
}

.wstl-modal-header h2 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	color: #14283e;
	letter-spacing: -0.02em;
}

/* Form fills the shell; body/footer handle their own padding (see :has rule). */
.wstl-modal-content > form {
	padding: 20px 24px 24px;
}

.wstl-modal-close {
	background: rgba(20, 40, 62, 0.06);
	border: none;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	font-size: 20px;
	line-height: 1;
	color: #5b6d80;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	flex-shrink: 0;
}

.wstl-modal-close:hover {
	background: rgba(20, 40, 62, 0.12);
	color: #14283e;
}

.wstl-modal-body {
	padding: 20px 24px 24px;
	overflow: auto;
	color: #14283e;
}

.wstl-modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 24px 20px;
	border-top: 1px solid var(--wstl-modal-border, #d5e0eb);
	background: #f8fafc;
	border-radius: 0 0 14px 14px;
	flex-shrink: 0;
}
.wstl-modal-footer .button { min-height: 36px; border-radius: 8px; }
.wstl-modal-footer .button-primary {
	background: #3377EE;
	border-color: #2b6fe0;
	color: #fff;
	box-shadow: none;
}
.wstl-modal-footer .button-primary:hover,
.wstl-modal-footer .button-primary:focus {
	background: #2b6fe0;
	border-color: #245fc4;
	color: #fff;
}

/* Modal form fields — stacked, modern (webhook + schedule modals). */
.wstl-modal-content > form:has(.wstl-modal-body) { padding: 0; }
.wstl-modal-body .wstl-field { margin-bottom: 18px; }
.wstl-modal-body .wstl-field:last-child { margin-bottom: 0; }
.wstl-field > label {
	display: block;
	margin-bottom: 6px;
	font-size: 13px;
	font-weight: 600;
	color: #1a2433;
}
.wstl-field-optional {
	margin-left: 6px;
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #9aa7b6;
}
.wstl-field input[type="url"],
.wstl-field input[type="text"],
.wstl-field input[type="time"],
.wstl-field select {
	width: 100%;
	height: 38px;
	padding: 0 12px;
	border: 1px solid #dbe3ec;
	border-radius: 8px;
	background: #fff;
	font-size: 13px;
	line-height: 1.4;
	box-shadow: none;
	box-sizing: border-box;
}
.wstl-field select {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 32px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6d80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 14px;
}
.wstl-field input[type="url"]:focus,
.wstl-field input[type="text"]:focus,
.wstl-field input[type="time"]:focus,
.wstl-field select:focus {
	border-color: #3377EE;
	box-shadow: 0 0 0 3px rgba(51, 119, 238, 0.12);
	outline: none;
}
.wstl-field-hint {
	margin: 7px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: #8493a3;
}
.wstl-field-inline {
	display: flex;
	align-items: center;
	gap: 11px;
}
.wstl-field-inline-label { font-size: 13px; color: #46586b; }

/* Two fields side by side (e.g. Frequency + Time). */
.wstl-field-row {
	display: flex;
	gap: 14px;
	margin-bottom: 18px;
}
.wstl-field-row .wstl-field { flex: 1; min-width: 0; margin-bottom: 0; }
@media (max-width: 480px) {
	.wstl-field-row { flex-direction: column; gap: 18px; }
}

/* ==========================================================================
   Settings Tabs
   ========================================================================== */

.wstl-settings-tabs {
	margin: 20px 0;
}

.wstl-settings-tabs .nav-tab-wrapper {
	margin-bottom: 20px;
}

.wstl-settings-tab-content {
	display: none;
}

.wstl-settings-tab-content.active {
	display: block;
}

/* ==========================================================================
   Form Enhancements
   ========================================================================== */

.wstl-form-group {
	margin-bottom: 15px;
}

.wstl-form-group label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.wstl-form-group input[type="text"],
.wstl-form-group input[type="url"],
.wstl-form-group input[type="email"],
.wstl-form-group select,
.wstl-form-group textarea {
	width: 100%;
}

.wstl-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wstl-checkbox-group label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: normal;
}

/* ==========================================================================
   Webhook & Automation Tables
   ========================================================================== */

.wstl-settings-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 15px;
}

.wstl-settings-table th,
.wstl-settings-table td {
	padding: 12px;
	text-align: left;
	border-bottom: 1px solid #eee;
}

.wstl-settings-table th {
	background: #f9f9f9;
	font-weight: 600;
}

.wstl-settings-table .actions {
	white-space: nowrap;
}

.wstl-settings-table .actions a,
.wstl-settings-table .actions button {
	margin-right: 5px;
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.wstl-status {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
}

.wstl-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #ccc;
}

.wstl-status-enabled .wstl-status-dot {
	background: #1E7A46;
}

.wstl-status-disabled .wstl-status-dot {
	background: #B23A48;
}

/* ==========================================================================
   API Documentation
   ========================================================================== */

.wstl-api-docs code {
	background: #f1f1f1;
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 12px;
}

.wstl-api-endpoint {
	background: #f9f9f9;
	padding: 15px;
	border-left: 3px solid #0073aa;
	margin-bottom: 15px;
	font-family: monospace;
}

.wstl-api-method {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 3px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	margin-right: 8px;
}

.wstl-api-method-get { background: #28a745; color: #fff; }
.wstl-api-method-post { background: #0073aa; color: #fff; }
.wstl-api-method-put { background: #ffc107; color: #212529; }
.wstl-api-method-delete { background: #dc3545; color: #fff; }

/* ==========================================================================
   Danger Zone
   ========================================================================== */

.wstl-card-danger {
	border-left: 3px solid #B23A48;
}

.wstl-card-danger h2 {
	color: #B23A48;
}

/* ==========================================================================
   Data / Sync settings (views)
   ========================================================================== */

.wstl-card-dev {
	border-left: 3px solid #635bff;
	background: #faf9ff;
}

.wstl-sync-status {
	padding: 15px;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
}

.wstl-sync-status .wstl-progress-bar {
	margin: 10px 0;
}

.wstl-test-data-success {
	color: #46b450;
	font-weight: 500;
}

.wstl-test-data-error {
	color: #dc3545;
	font-weight: 500;
}

/* ==========================================================================
   Automation rules (condition rows)
   ========================================================================== */

.wstl-condition-row {
	display: flex;
	gap: 8px;
	margin-bottom: 8px;
	align-items: center;
}

.wstl-condition-row select,
.wstl-condition-row input {
	margin: 0;
}

.wstl-remove-condition {
	color: #a00;
	border-color: #a00;
}

/* ==========================================================================
   Modules tab — responsive card grid of status lights
   ========================================================================== */
/* Cards lay out in a responsive grid (1 col on narrow screens, 2-3 when wide).
   Default stretch keeps each row's cards equal height, so a card with extra
   inline config doesn't leave dead space beside the shorter ones. */
.wstl-module-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 16px;
}

.wstl-module-top {
	display: flex;
	align-items: center;
	gap: 14px;
}
.wstl-module-icon {
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: #e9f4ee;
	color: #1E7A46;
	box-shadow: inset 0 0 0 1px rgba(30, 122, 70, 0.12);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.wstl-module-icon svg { width: 20px; height: 20px; display: block; }

/* Status-light treatment: the icon glows emerald when the module is armed and
   goes grey when off (a toggleable card unchecked, or the Card-Testing link
   card reading Off), so the page's protection state is scannable at a glance. */
.wstl-module-card:has(.wstl-module-toggle:not(:checked)) .wstl-module-icon,
.wstl-module-card-link:has(.wstl-module-status.is-off) .wstl-module-icon {
	background: #eef1f5;
	color: #97a4b4;
	box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.14);
}
/* On the modules page the switch reads emerald (armed) to match its icon. */
.wstl-module-card .wstl-toggle input:checked + .wstl-toggle-slider { background-color: #1E7A46; }
.wstl-module-card .wstl-toggle input:focus-visible + .wstl-toggle-slider { outline-color: #1E7A46; }

.wstl-module-meta { flex: 1; min-width: 0; }
.wstl-module-name {
	margin: 0 0 2px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: #1a2433;
	transition: color 0.16s ease;
}
/* Quiet the title when the module is off, reinforcing the armed/off read. */
.wstl-module-card:has(.wstl-module-toggle:not(:checked)) .wstl-module-name,
.wstl-module-card-link:has(.wstl-module-status.is-off) .wstl-module-name {
	color: #6b7a8d;
}
.wstl-module-desc {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: #6b7a8d;
}
.wstl-module-top .wstl-toggle,
.wstl-module-top .wstl-module-status { flex: none; }

/* Config aligned under the title (clears the icon); dims when module is off. */
.wstl-module-config {
	margin: 14px 0 0 54px;
	padding-top: 14px;
	border-top: 1px solid #eef2f7;
	display: flex;
	flex-direction: column;
	gap: 12px;
	transition: opacity 0.16s ease;
}
.wstl-module-card:has(.wstl-module-toggle:not(:checked)) .wstl-module-config {
	opacity: 0.45;
}

.wstl-module-config-row {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	font-size: 12.5px;
	color: #46586b;
}
.wstl-module-config-row label { font-weight: 600; color: #1a2433; }
.wstl-module-config-row .small-text { width: 64px; border-radius: 6px; }
.wstl-module-config-hint { color: #8493a3; }

/* Pro sub-feature: label + brand switch, dashed divider above. */
.wstl-module-subrow {
	display: flex;
	align-items: center;
	gap: 14px;
	padding-top: 12px;
	border-top: 1px dashed #e7ecf3;
}
.wstl-module-subrow-label {
	flex: 1;
	font-size: 12.5px;
	line-height: 1.45;
	color: #46586b;
}

.wstl-module-pro-line {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding-top: 12px;
	border-top: 1px dashed #e7ecf3;
	font-size: 12.5px;
	line-height: 1.45;
	color: #8493a3;
}
.wstl-module-pro-line .wstl-badge-pro { vertical-align: middle; margin-left: auto; }

.wstl-module-card-link .wstl-module-config { flex-direction: row; align-items: center; }
.wstl-module-card-link .button { font-size: 12.5px; }
