/* ============================================================
   TRAILSIQ — Settings Page  (tqs-* namespace)
   Mirrors AttentIQ ags-* layout; uses orange design tokens.
   ============================================================ */

/* ── Layout ───────────────────────────────────────────────── */
.tqs-layout {
	display: grid;
	grid-template-columns: 1fr 280px;
	gap: 20px;
	align-items: start;
	max-width: 1100px;
}

.tqs-main {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.tqs-sidebar {
	display: flex;
	flex-direction: column;
	gap: 16px;
	position: sticky;
	top: 32px;
	align-self: start;
}

/* ── Cards ────────────────────────────────────────────────── */
.tqs-card {
	background: var(--tiq-surface);
	border: 1px solid var(--tiq-border);
	border-radius: 12px;
	overflow: hidden;
}

.tqs-card-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--tiq-border-soft);
	background: var(--tiq-bg);
}

.tqs-card-icon {
	width: 36px;
	height: 36px;
	border-radius: 8px;
	background: var(--tiq-primary-soft);
	color: var(--tiq-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.tqs-card-title {
	font-size: 14px;
	font-weight: 700;
	color: var(--tiq-text);
	margin-bottom: 2px;
}

.tqs-card-desc {
	font-size: 12px;
	color: var(--tiq-text-3);
	line-height: 1.4;
}

.tqs-card-body {
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ── Collapsible card (<details>) ─────────────────────────── */
.tqs-card--collapsible > summary.tqs-card-header {
	list-style: none;
	cursor: pointer;
	user-select: none;
}
.tqs-card--collapsible > summary.tqs-card-header::-webkit-details-marker { display: none; }
.tqs-card--collapsible > summary.tqs-card-header:hover { background: var(--tiq-bg-2, #f3f4f6); }
.tqs-card--collapsible:not([open]) > summary.tqs-card-header {
	/* When closed, the card has no body — remove the header's bottom border. */
	border-bottom: 0;
}
.tqs-card-chevron {
	flex-shrink: 0;
	color: var(--tiq-text-3);
	transition: transform 0.15s ease;
}
.tqs-card--collapsible[open] > summary .tqs-card-chevron {
	transform: rotate(180deg);
}

/* ── Fields ───────────────────────────────────────────────── */
.tqs-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.tqs-field-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 16px;
}

.tqs-field-label {
	font-size: 13px;
	font-weight: 700;
	color: var(--tiq-text);
}

.tqs-field-desc {
	font-size: 12px;
	color: var(--tiq-text-3);
	line-height: 1.6;
}

.tqs-divider {
	height: 1px;
	background: var(--tiq-border-soft);
	margin: 4px 0;
}

/* ── App promo cards (Mobile Apps settings card) ─────────────
   Two side-by-side mini-cards promoting the TrailsIQ Field +
   Report iOS apps and their web shells. Stacks on narrow
   viewports. */
.tiq-app-promo-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 12px;
}
.tiq-app-promo {
	display: flex;
	gap: 12px;
	padding: 14px;
	border: 1px solid var(--tiq-border-soft);
	border-radius: 8px;
	background: var(--tiq-bg-soft, #fafafa);
}
.tiq-app-promo__icon {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	background: #1b2e1a;
	color: #fff;
}
.tiq-app-promo__body {
	min-width: 0;
	flex: 1;
}
.tiq-app-promo__title {
	font-size: 14px;
	font-weight: 600;
	color: var(--tiq-text-1, #1b2e1a);
	margin-bottom: 4px;
}
.tiq-app-promo__desc {
	font-size: 12px;
	line-height: 1.5;
	color: var(--tiq-text-3);
	margin-bottom: 10px;
}
.tiq-app-promo__links {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.tiq-app-promo__links .button {
	font-size: 12px;
}

/* App-store / Google-Play badge row. Both badges keep their
   stock SVG aspect ratio and are sized by height so they match
   visually regardless of intrinsic width. */
.tiq-app-promo__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}
.tiq-app-badge {
	display: inline-flex;
	transition: opacity 0.15s, transform 0.15s;
}
.tiq-app-badge:hover,
.tiq-app-badge:focus {
	opacity: 0.85;
	transform: translateY(-1px);
}
.tiq-app-badge img {
	display: block;
	height: 40px;
	width: auto;
}

/* Coming-soon variant — used on a <span> stand-in (no <a>) when
   the store listing isn't live yet. Greys the badge image and
   overlays a small "Coming soon" pill so operators understand
   the placement is reserved. No hover lift, no pointer cursor. */
.tiq-app-badge--coming-soon {
	position: relative;
	cursor: default;
}
.tiq-app-badge--coming-soon:hover,
.tiq-app-badge--coming-soon:focus {
	opacity: 1;
	transform: none;
}
.tiq-app-badge--coming-soon img {
	filter: grayscale(100%);
	opacity: 0.45;
}
.tiq-app-badge__overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(15, 23, 42, 0.85);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 3px 8px;
	border-radius: 999px;
	white-space: nowrap;
	pointer-events: none;
}

/* Inline notice/callout used at the top of cards (e.g. Mobile
   Apps when the registry isn't connected). Soft-tinted box with
   an icon column. */
.tqs-callout {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 13px;
	line-height: 1.45;
}
.tqs-callout svg {
	flex-shrink: 0;
	margin-top: 2px;
}
.tqs-callout--warn {
	background: rgba(221,156,53,0.12);
	border: 1px solid rgba(221,156,53,0.35);
	color: #6a4c12;
}
.tqs-callout--warn a {
	color: inherit;
	text-decoration: underline;
}

/* ── Advanced disclosure (<details>) ──────────────────────── */
.tqs-advanced[open] .tqs-advanced-chevron {
	transform: rotate(90deg);
}
.tqs-advanced-summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
	color: var(--tiq-text-3);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	list-style: none;
	user-select: none;
	padding: 2px 0;
}
.tqs-advanced-summary::-webkit-details-marker { display: none; }
.tqs-advanced-summary:hover { color: var(--tiq-text); }
.tqs-advanced-chevron {
	flex-shrink: 0;
	transition: transform 0.15s ease;
	color: currentColor;
}

/* ── Inputs ───────────────────────────────────────────────── */
.tqs-input,
.tqs-select {
	font-size: 13px;
	font-family: inherit;
	color: var(--tiq-text);
	background: var(--tiq-surface);
	border: 1px solid var(--tiq-border);
	border-radius: 7px;
	padding: 8px 12px;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
	width: 100%;
	box-sizing: border-box;
}

.tqs-input:focus,
.tqs-select:focus {
	border-color: rgba(228,84,25,0.45);
	box-shadow: 0 0 0 3px rgba(228,84,25,0.08);
}

.tqs-input-group {
	display: flex;
	align-items: center;
	border: 1px solid var(--tiq-border);
	border-radius: 7px;
	overflow: hidden;
	background: var(--tiq-surface);
	transition: border-color 0.15s, box-shadow 0.15s;
}

.tqs-input-group:focus-within {
	border-color: rgba(228,84,25,0.45);
	box-shadow: 0 0 0 3px rgba(228,84,25,0.08);
}

.tqs-input-group .tqs-input {
	border: none;
	border-radius: 0;
	box-shadow: none;
	flex: 1;
	min-width: 0;
}

.tqs-input-group .tqs-input:focus {
	border: none;
	box-shadow: none;
}

.tqs-input-unit {
	padding: 0 10px;
	font-size: 12px;
	color: var(--tiq-text-3);
	background: var(--tiq-bg);
	border-left: 1px solid var(--tiq-border);
	display: flex;
	align-items: center;
	height: 100%;
	white-space: nowrap;
	min-height: 38px;
	font-family: inherit;
	flex-shrink: 0;
}

.tqs-input-unit:first-child {
	border-left: none;
	border-right: 1px solid var(--tiq-border);
}

/* ── Notice ───────────────────────────────────────────────── */
.tqs-notice {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px 14px;
	border-radius: 7px;
	font-size: 12px;
	line-height: 1.6;
	border: 1px solid;
}

.tqs-notice--info {
	background: var(--tiq-primary-soft);
	border-color: rgba(228,84,25,0.25);
	color: var(--tiq-primary-text);
}

.tqs-notice svg { flex-shrink: 0; margin-top: 2px; }

/* ── Save button ──────────────────────────────────────────── */
.tqs-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 20px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	border: 1px solid var(--tiq-border);
	background: var(--tiq-surface);
	color: var(--tiq-text);
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s;
}

.tqs-btn:hover {
	background: var(--tiq-surface-soft);
	border-color: rgba(228,84,25,0.25);
}

.tqs-btn--primary {
	background: var(--tiq-primary);
	color: #fff !important;
	border-color: var(--tiq-primary);
}

.tqs-btn--primary:hover {
	background: var(--tiq-primary-dark);
	border-color: var(--tiq-primary-dark);
	color: #fff;
}

/* ── Form inside card body ────────────────────────────────── */
/* Settings page fields are direct children of .tqs-card-body (flex col, gap 16px).
   Trail/network edit pages wrap fields in a <form> — make the form behave the same. */
.tqs-card-body form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ── Default Map View picker ──────────────────────────────── */
.tiq-mapview-picker {
	width: 100%;
	height: 320px;
	border-radius: 10px;
	border: 1px solid var(--tiq-border);
	overflow: hidden;
	cursor: crosshair;
	background: #f3f4f6;
}

.tiq-mapview-picker .maplibregl-canvas {
	cursor: crosshair;
}

/* ── Form footer ──────────────────────────────────────────── */
.tqs-form-footer {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding-top: 4px;
}

/* ── Sidebar info card ────────────────────────────────────── */
.tqs-info-card {
	background: var(--tiq-surface);
	border: 1px solid var(--tiq-border);
	border-radius: 12px;
	padding: 16px 18px;
}

.tqs-info-title {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 700;
	color: var(--tiq-text-3);
	text-transform: uppercase;
	letter-spacing: 0.07em;
	margin-bottom: 10px;
}

.tqs-info-body {
	font-size: 12px;
	color: var(--tiq-text-3);
	line-height: 1.6;
}

.tqs-info-body p { margin: 0 0 10px; }
.tqs-info-body p:last-child { margin-bottom: 0; }
.tqs-info-body strong { color: var(--tiq-text-2); }
.tqs-info-body a { color: var(--tiq-primary-text); text-decoration: none; }
.tqs-info-body a:hover { text-decoration: underline; }

.tqs-info-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 0;
	border-bottom: 1px solid var(--tiq-border-soft);
	font-size: 12px;
}

.tqs-info-row:last-child { border-bottom: none; }
.tqs-info-row-label { color: var(--tiq-text-3); }
.tqs-info-row-value { font-weight: 600; color: var(--tiq-text); }

/* ── Colour palette controls ──────────────────────────────── */
.tqs-color-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 12px 20px;
}

.tqs-field--color .tqs-field-label {
	margin-bottom: 6px;
}

.tqs-color-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.tqs-color-input {
	width: 44px;
	height: 34px;
	border: 1px solid var(--tiq-border);
	border-radius: 6px;
	padding: 2px;
	cursor: pointer;
	background: none;
	flex-shrink: 0;
}

.tqs-color-reset {
	font-size: 11px !important;
	padding: 2px 8px !important;
	height: 26px !important;
	line-height: 22px !important;
}

/* ── Button variants ──────────────────────────────────────── */
.tqs-btn--secondary {
	background: var(--tiq-surface);
	color: var(--tiq-text);
	border-color: var(--tiq-border);
}

.tqs-btn--secondary:hover {
	background: var(--tiq-surface-soft);
	border-color: rgba(228,84,25,0.35);
	color: var(--tiq-primary);
}

.tqs-btn--danger {
	background: var(--tiq-surface);
	color: #dc2626;
	border-color: #fca5a5;
}

.tqs-btn--danger:hover {
	background: #fef2f2;
	border-color: #dc2626;
	color: #dc2626;
}

/* ── Stat rows (trail & network edit sidebars) ────────────── */
.tiq-stat-section {
	padding: 0 20px;
	border-bottom: 1px solid var(--tiq-border-soft);
}

.tiq-stat-section:last-child {
	border-bottom: none;
}

.tiq-stat-section-label {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--tiq-text-3);
	padding: 12px 0 6px;
}

.tiq-stat-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	padding: 5px 0;
	border-bottom: 1px solid var(--tiq-border-soft);
	font-size: 12px;
}

.tiq-stat-section .tiq-stat-row:last-child {
	border-bottom: none;
	padding-bottom: 12px;
}

.tiq-stat-key {
	color: var(--tiq-text-3);
}

.tiq-stat-val {
	font-weight: 600;
	color: var(--tiq-text);
	text-align: right;
}

.tiq-stat-unit {
	font-weight: 400;
	color: var(--tiq-text-3);
	font-size: 11px;
}

/* ── Trail list (network edit) ────────────────────────────── */
.tiq-trail-search-bar {
	display: flex;
	gap: 8px;
	align-items: center;
}

.tiq-search-results-dropdown {
	border: 1px solid var(--tiq-border);
	border-radius: 8px;
	max-height: 200px;
	overflow-y: auto;
	margin-top: 4px;
}

.tiq-trail-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tiq-trail-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 4px;
	border-bottom: 1px solid var(--tiq-border-soft);
	font-size: 13px;
}

.tiq-trail-item:last-child {
	border-bottom: none;
}

.tiq-trail-drag {
	cursor: grab;
	color: var(--tiq-text-3);
	font-size: 14px;
	flex-shrink: 0;
}

.tiq-trail-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
}

.tiq-trail-item-name {
	flex: 1;
	font-weight: 500;
}

.tiq-trail-item-name a {
	color: var(--tiq-text);
	text-decoration: none;
}

.tiq-trail-item-name a:hover {
	color: var(--tiq-primary);
	text-decoration: underline;
}

.tiq-detach-trail {
	flex-shrink: 0;
	background: none;
	border: 1px solid #fca5a5;
	color: #dc2626;
	border-radius: 4px;
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 14px;
	line-height: 1;
	padding: 0;
}

.tiq-detach-trail:hover {
	background: #fef2f2;
	border-color: #dc2626;
}

.tiq-search-row {
	padding: 8px 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	border-bottom: 1px solid var(--tiq-border-soft);
}

.tiq-search-row:hover {
	background: var(--tiq-bg);
}

.tiq-search-row:last-child {
	border-bottom: none;
}

.tiq-search-empty {
	padding: 12px;
	color: var(--tiq-text-3);
	font-size: 13px;
}

/* ── Difficulty breakdown bar ─────────────────────────────── */
.tiq-diff-bar {
	display: flex;
	height: 10px;
	border-radius: 5px;
	overflow: hidden;
	margin-bottom: 10px;
}

.tiq-diff-bar-segment {
	min-width: 4px;
}

.tiq-diff-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* ── Diff badges ──────────────────────────────────────────── */
.tiq-diff-badge {
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	padding: 2px 7px;
	border-radius: 20px;
	color: #fff;
}

.tiq-diff-easy     { background: var(--tiq-trail-difficulty-easy); }
.tiq-diff-moderate { background: var(--tiq-trail-difficulty-moderate); }
.tiq-diff-hard     { background: var(--tiq-trail-difficulty-hard); }
.tiq-diff-expert   { background: var(--tiq-trail-difficulty-expert); }

/* ── Network checkbox labels (trail edit sidebar) ─────────── */
.tiq-network-check-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--tiq-text);
	cursor: pointer;
	padding: 4px 0;
}

.tiq-network-check-label input[type="checkbox"] {
	margin: 0;
	flex-shrink: 0;
	accent-color: var(--tiq-primary);
	width: 15px;
	height: 15px;
	cursor: pointer;
}

.tiq-network-check-label span {
	line-height: 1.3;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 960px) {
	.tqs-layout {
		grid-template-columns: 1fr;
	}

	.tqs-sidebar {
		position: static;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.tqs-sidebar > * {
		flex: 1;
		min-width: 260px;
	}
}

/* ── Toggle switch ────────────────────────────────────────────────── */

.tqs-toggle {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
}
.tqs-toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.tqs-toggle-switch {
	position: relative;
	width: 40px;
	height: 22px;
	background: #d1d5db;
	border-radius: 11px;
	flex-shrink: 0;
	transition: background 0.2s;
}
.tqs-toggle-switch::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.2s;
	box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.tqs-toggle input:checked + .tqs-toggle-switch { background: #2d6a4f; }
.tqs-toggle input:checked + .tqs-toggle-switch::after { transform: translateX(18px); }
.tqs-toggle-label { font-size: 14px; font-weight: 500; color: var(--tiq-text); }

@media (max-width: 600px) {
	.tqs-field-row {
		grid-template-columns: 1fr;
	}

	.tqs-sidebar {
		flex-direction: column;
	}
}
