/**
 * TrailsIQ — Structure App CSS
 * Mobile-first, theme-free styles for the standalone structure inventory PWA.
 */

/* ── Reset / Base ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #1b2e1a; }

.tiq-sa-body {
	height: 100dvh;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: #1b2e1a;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	background: #1b2e1a;
	overflow: hidden;
}

/* ── App shell ──────────────────────────────────────────────────────── */

#tiq-sa-app {
	position: fixed;
	top: calc(54px + env(safe-area-inset-top, 0px));
	right: 0;
	bottom: 0;
	left: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: #f5f7f4;
}

/* ── Loading screen ─────────────────────────────────────────────────── */

#tiq-sa-loading {
	position: fixed;
	inset: 0;
	z-index: 999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #1b2e1a;
}
#tiq-sa-loading[hidden] { display: none; }

.tiq-sa-spinner {
	width: 44px;
	height: 44px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: #fff;
	border-radius: 50%;
	animation: tiq-sa-spin 0.75s linear infinite;
}
@keyframes tiq-sa-spin { to { transform: rotate(360deg); } }

/* ── Login screen ────────────────────────────────────────────────────── */

/* The login is rendered into #tiq-sa-app; the wrapper sets the dark bg */
#tiq-sa-app > #tiq-sa-login-inner {
	background: #1b2e1a;
}

.tiq-sa-login-card {
	width: 100%;
	max-width: 360px;
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
	padding: 40px 32px 36px;
}

.tiq-sa-login-logo {
	width: 60px;
	height: 60px;
	margin: 0 auto 20px;
	background: #1b2e1a;
	border-radius: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.tiq-sa-login-logo img { display: block; }

.tiq-sa-login-title {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.02em;
	text-align: center;
	color: #1b2e1a;
	margin-bottom: 4px;
}
.tiq-sa-login-subtitle {
	font-size: 13px;
	color: #9ca3af;
	text-align: center;
	margin-bottom: 30px;
}

.tiq-sa-login-field { margin-bottom: 12px; }

.tiq-sa-login-input {
	width: 100%;
	padding: 14px 16px;
	border: 1.5px solid #e5e7eb;
	border-radius: 12px;
	font-size: 16px;
	font-family: inherit;
	color: #1b2e1a;
	background: #f9fafb;
	outline: none;
	transition: border-color 0.15s, background 0.15s;
	-webkit-appearance: none;
}
.tiq-sa-login-input:focus {
	border-color: #1b2e1a;
	background: #fff;
}

.tiq-sa-login-err {
	font-size: 13px;
	color: #dc2626;
	margin-bottom: 12px;
	padding: 10px 14px;
	background: #fef2f2;
	border-radius: 10px;
	border-left: 3px solid #dc2626;
	line-height: 1.4;
}
.tiq-sa-login-err[hidden] { display: none; }

.tiq-sa-login-btn {
	width: 100%;
	padding: 15px;
	margin-top: 4px;
	background: #1b2e1a;
	color: #fff;
	border: none;
	border-radius: 12px;
	font-size: 16px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	letter-spacing: -0.01em;
	transition: opacity 0.15s;
	-webkit-tap-highlight-color: transparent;
}
.tiq-sa-login-btn:disabled        { opacity: 0.6; cursor: default; }
.tiq-sa-login-btn:not(:disabled):active { opacity: 0.82; }

.tiq-sa-btn-primary {
	width: 100%;
	padding: 15px 20px;
	background: #4a8c3f;
	border: none;
	border-radius: 12px;
	color: #fff;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: opacity 0.15s;
}
.tiq-sa-btn-primary:disabled { opacity: 0.6; }
.tiq-sa-btn-primary:active   { opacity: 0.85; }

/* ── Step screens ────────────────────────────────────────────────────── */

.tiq-sa-screen {
	display: none;
	flex-direction: column;
	height: 100%;
}
.tiq-sa-screen.is-active { display: flex; }

/* ── Pending offline banner ──────────────────────────────────────────── */

.tiq-sa-pending-banner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	margin-bottom: 14px;
	background: #fff8e6;
	border: 1px solid #f0c76b;
	border-radius: 10px;
	font-size: 13px;
	color: #7a5c00;
	line-height: 1.4;
}
.tiq-sa-pending-banner[hidden] { display: none; }
.tiq-sa-pending-banner > svg { flex-shrink: 0; color: #c28a00; }
.tiq-sa-pending-banner > span { flex: 1; font-weight: 600; }

.tiq-sa-sync-btn {
	flex-shrink: 0;
	padding: 5px 12px;
	background: #c28a00;
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: opacity 0.15s;
}
.tiq-sa-sync-btn:disabled { opacity: 0.6; cursor: default; }

/* ── Step 1: Type selection ──────────────────────────────────────────── */

.tiq-sa-type-screen {
	padding: 24px 20px;
	gap: 16px;
	overflow-y: auto;
	background: #f5f7f4;
}

.tiq-sa-section-title {
	font-size: 18px;
	font-weight: 700;
	color: #1b2e1a;
	letter-spacing: -0.02em;
}

.tiq-sa-type-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}

.tiq-sa-type-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 20px 12px;
	background: #fff;
	border: 2px solid #e0e4db;
	border-radius: 16px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.15s, background 0.15s;
	text-align: center;
}
.tiq-sa-type-btn:active,
.tiq-sa-type-btn.is-selected {
	border-color: #1b2e1a;
	background: #f0f4ee;
}

.tiq-sa-type-icon {
	font-size: 28px;
	line-height: 1;
}
.tiq-sa-type-prefix {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	color: #fff;
	background: #1b2e1a;
	padding: 2px 7px;
	border-radius: 20px;
}
.tiq-sa-type-label {
	font-size: 14px;
	font-weight: 600;
	color: #1b2e1a;
}

/* ── Step 2: Map + form ──────────────────────────────────────────────── */

.tiq-sa-map-screen { overflow: hidden; }

#tiq-sa-map {
	flex: none;
	height: 40dvh;
	position: relative;
	background: #2a3e28;
	transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expanded form: shrink map to give the form more room */
.tiq-sa-map-screen.tiq-form-expanded #tiq-sa-map { height: 20dvh; }

#tiq-sa-map .maplibregl-canvas-container { height: 100%; }

/* Form drag handle */
.tiq-sa-form-handle {
	flex-shrink: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 10px 0 6px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	background: #f5f7f4;
}
.tiq-sa-form-handle-bar {
	width: 36px;
	height: 4px;
	background: #d1d5db;
	border-radius: 2px;
	transition: background 0.15s;
}
.tiq-sa-form-handle:hover .tiq-sa-form-handle-bar,
.tiq-sa-form-handle:focus .tiq-sa-form-handle-bar { background: #9ca3af; }

.tiq-sa-form-body {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 4px 20px 20px;
	gap: 14px;
	display: flex;
	flex-direction: column;
	background: #f5f7f4;
}

.tiq-sa-back-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: none;
	color: #4a8c3f;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	padding: 0 0 4px;
	-webkit-tap-highlight-color: transparent;
}

.tiq-sa-code-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: #1b2e1a;
	color: #fff;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.05em;
}

.tiq-sa-field { display: flex; flex-direction: column; gap: 6px; }

.tiq-sa-label {
	font-size: 12px;
	font-weight: 700;
	color: #4a5e47;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.tiq-sa-field-input,
.tiq-sa-field-textarea,
.tiq-sa-field-select {
	width: 100%;
	padding: 12px 14px;
	background: #fff;
	border: 1px solid #d4d9d0;
	border-radius: 10px;
	font-size: 15px;
	color: #1b2e1a;
	outline: none;
	font-family: inherit;
	-webkit-appearance: none;
}
.tiq-sa-field-input:focus,
.tiq-sa-field-textarea:focus,
.tiq-sa-field-select:focus { border-color: #4a8c3f; }
.tiq-sa-field-textarea { resize: vertical; min-height: 90px; }

/* Trail + network selectors (same as report-issue) */
.tiq-sa-trail-row {
	display: flex;
	gap: 8px;
}
.tiq-sa-trail-row .tiq-sa-field-select { flex: 1; }

/* Location status pill */
.tiq-sa-loc-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 600;
}
.tiq-sa-loc-pill--waiting  { background: #f3f4f0; color: #5a6b57; }
.tiq-sa-loc-pill--gps      { background: #e3f0e0; color: #2a5e27; }
.tiq-sa-loc-pill--manual   { background: #fef3e2; color: #7c5e1e; }
.tiq-sa-loc-pill--error    { background: #fee2e2; color: #991b1b; }

/* Trail proximity notice */
.tiq-sa-trail-notice {
	margin-top: 8px;
	padding: 8px 12px;
	border-radius: 10px;
	font-size: 13px;
	line-height: 1.4;
}
.tiq-sa-trail-notice[hidden] { display: none; }
.tiq-sa-trail-notice--on  { background: #e3f0e0; color: #1e4a1c; border-left: 3px solid #3a7a36; }
.tiq-sa-trail-notice--off { background: #fef9e7; color: #7c5e1e; border-left: 3px solid #e6a817; }

/* ── Photo upload ────────────────────────────────────────────────────── */

.tiq-sa-photo-label {
	cursor: pointer;
	display: inline-flex;
}

.tiq-sa-photo-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border: 1.5px dashed #c4cdc0;
	border-radius: 10px;
	font-size: 13px;
	color: #4a5e47;
	background: #fff;
	transition: border-color 0.15s, color 0.15s;
}
.tiq-sa-photo-label:hover .tiq-sa-photo-btn,
.tiq-sa-photo-label:active .tiq-sa-photo-btn {
	border-color: #4a8c3f;
	color: #4a8c3f;
}

.tiq-sa-photo-preview {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-top: 8px;
}
.tiq-sa-photo-preview[hidden] { display: none; }

.tiq-sa-photo-thumb {
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 10px;
	border: 1px solid #d4d9d0;
}

.tiq-sa-photo-remove {
	background: #fff;
	border: 1px solid #d4d9d0;
	border-radius: 50%;
	width: 26px;
	height: 26px;
	cursor: pointer;
	font-size: 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	flex-shrink: 0;
	-webkit-tap-highlight-color: transparent;
}

/* ── Submit bar ──────────────────────────────────────────────────────── */

.tiq-sa-submit-bar {
	padding: 16px 20px;
	padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	background: #f5f7f4;
	border-top: 1px solid #e0e4db;
	display: flex;
	gap: 10px;
}

.tiq-sa-submit-bar .tiq-sa-btn-primary { flex: 1; padding: 14px 20px; }

/* ── Success screen ──────────────────────────────────────────────────── */

#tiq-sa-success {
	position: fixed;
	inset: 0;
	z-index: 80;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f5f7f4;
	padding: 24px;
	text-align: center;
	flex-direction: column;
	gap: 16px;
}
#tiq-sa-success[hidden] { display: none; }

.tiq-sa-success-icon {
	font-size: 56px;
	line-height: 1;
}
.tiq-sa-success-code {
	font-size: 28px;
	font-weight: 800;
	color: #1b2e1a;
	letter-spacing: -0.03em;
}
.tiq-sa-success-msg {
	font-size: 16px;
	color: #4a5e47;
}
.tiq-sa-success-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
	max-width: 320px;
	margin-top: 8px;
}
.tiq-sa-btn-ghost {
	padding: 14px 20px;
	background: none;
	border: 2px solid #1b2e1a;
	border-radius: 12px;
	color: #1b2e1a;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
