/**
 * EARA Field Worker App — Premium Styles
 * Matches the survey tool's premium design language.
 */

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

.eara-field-app {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	max-width: 720px;
	margin: 0 auto;
	padding-bottom: 60px;
}

/* ── Header banner ───────────────────────────────────────────────────────── */

.eara-field-app__header {
	background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
	border-radius: 16px;
	padding: 24px 20px;
	margin-bottom: 20px;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
}

/* ── Sync badge (shared style with survey page) ──────────────────────────── */

#eara-field-sync-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	background: rgba(255,255,255,.15);
	border: 1px solid rgba(255,255,255,.3);
	border-radius: 20px;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	color: #fff;
	white-space: nowrap;
}

/* Manual sync/refresh buttons in header */
.eara-conn-action-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: rgba(255,255,255,.12);
	border: 1.5px solid rgba(255,255,255,.25);
	border-radius: 18px;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s, border-color .15s;
}
.eara-conn-action-btn:hover {
	background: rgba(255,255,255,.22);
	border-color: rgba(255,255,255,.45);
}
.eara-conn-action-btn:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.eara-field-app__header-inner {
	display: flex;
	align-items: center;
	gap: 16px;
}

.eara-field-app__header-icon {
	font-size: 40px;
	flex-shrink: 0;
}

.eara-field-app__title {
	font-size: 22px;
	font-weight: 700;
	margin: 0 0 4px;
	color: #fff;
}

.eara-field-app__intro {
	font-size: 13px;
	margin: 0;
	opacity: 0.85;
	color: #fff;
}

/* ── Campaign progress panel ─────────────────────────────────────────────── */

.eara-campaign-progress {
	margin-bottom: 20px;
}

.eara-progress-panel {
	background: #f0f9ff;
	border: 1px solid #bae6fd;
	border-radius: 12px;
	padding: 16px 18px;
	box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.eara-progress-panel__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 6px;
	font-size: 14px;
	font-weight: 600;
	color: #1e3a5f;
}

.eara-progress-panel__pct {
	font-weight: 700;
	color: #1e40af;
	font-size: 20px;
}

.eara-coverage-bar {
	background: #e5e7eb;
	border-radius: 6px;
	height: 10px;
	overflow: hidden;
	margin-bottom: 10px;
}

.eara-coverage-bar__fill {
	height: 100%;
	background: linear-gradient(90deg, #1e3a5f, #2563eb);
	border-radius: 6px;
	transition: width 0.5s ease;
}

.eara-coverage-summary__stats {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	font-size: 12px;
}

.eara-stat {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: 600;
}

.eara-stat--green { color: #065f46; }
.eara-stat--amber { color: #92400e; }
.eara-stat--red   { color: #991b1b; }
.eara-stat--pct   { color: #1e40af; }

/* Street breakdown */

.eara-street-breakdown summary {
	cursor: pointer;
	user-select: none;
	font-size: 12px;
	color: #64748b;
}

.eara-street-breakdown__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-top: 10px;
}

@media (max-width: 480px) {
	.eara-street-breakdown__grid { grid-template-columns: 1fr; }
}

.eara-street-row { font-size: 12px; }

.eara-street-row__name {
	color: #374151;
	margin-bottom: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.eara-street-row__bar {
	display: flex;
	align-items: center;
	gap: 6px;
}

.eara-street-row__bar .eara-coverage-bar { flex: 1; margin: 0; }

.eara-street-row__pct {
	color: #6b7280;
	font-size: 11px;
	white-space: nowrap;
}

.eara-street-row--complete .eara-street-row__name {
	color: #15803d;
	font-weight: 600;
}

/* ── Controls card ───────────────────────────────────────────────────────── */

.eara-field-app__controls {
	background: #fff;
	border: 2px solid #e2e8f0;
	border-radius: 12px;
	padding: 20px;
	margin-bottom: 20px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.eara-field-app__controls-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 15px;
	font-weight: 600;
	color: #1e3a5f;
	margin: 0 0 14px;
}

.eara-field-app__step-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	background: #2563eb;
	color: #fff;
	border-radius: 50%;
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
}

.eara-field-app__select-row {
	display: flex;
	gap: 10px;
	align-items: stretch;
	flex-wrap: wrap;
}

.eara-field-app__select-row .eara-input {
	flex: 1;
	min-width: 200px;
	height: 46px;
	font-size: 15px;
}

/* Load Street button — matches survey Start Survey button */
#eara-load-street {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: linear-gradient(135deg, #1e3a5f, #2563eb);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 12px 22px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: opacity 0.2s, transform 0.1s;
	white-space: nowrap;
}

#eara-load-street:hover  { opacity: 0.9; transform: translateY(-1px); }
#eara-load-street:active { transform: translateY(0); }

/* ── Coverage summary card ───────────────────────────────────────────────── */

.eara-coverage-summary {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 16px 18px;
	margin-bottom: 14px;
	box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.eara-coverage-summary__title {
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 6px;
	color: #1e3a5f;
}

/* ── Coverage list ───────────────────────────────────────────────────────── */

.eara-coverage-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.eara-coverage-row {
	background: #fff;
	border: 2px solid #e2e8f0;
	border-radius: 10px;
	overflow: hidden;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.eara-coverage-row:hover {
	box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.eara-coverage-row--updated { border-color: #86efac; background: #f0fdf4; }
.eara-coverage-row--pending { border-color: #fde68a; background: #fffbeb; }
.eara-coverage-row--missing { border-color: #fca5a5; background: #fff5f5; }

.eara-coverage-row__summary {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	flex-wrap: wrap;
}

/* Status dot */
.eara-status-dot {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	font-size: 13px;
	font-weight: 700;
	flex-shrink: 0;
}

.eara-status-dot--green { background: #dcfce7; color: #15803d; }
.eara-status-dot--amber { background: #fef3c7; color: #b45309; }
.eara-status-dot--red   { background: #fee2e2; color: #dc2626; }

.eara-coverage-row__address {
	flex: 1;
	font-size: 14px;
	font-weight: 600;
	color: #1a1a2e;
}

.eara-coverage-row__postcode {
	font-size: 12px;
	color: #64748b;
	font-weight: 400;
	margin-left: 4px;
}

.eara-coverage-row__name {
	font-size: 12px;
	color: #64748b;
	font-style: italic;
}

/* Resident count badge */
.eara-resident-count {
	font-size: 11px;
	background: #e0f2fe;
	color: #0369a1;
	padding: 3px 10px;
	border-radius: 10px;
	font-weight: 600;
	white-space: nowrap;
}

/* Add Resident button */
.eara-btn--add-resident {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #f0fdf4;
	color: #15803d;
	border: 1px solid #86efac;
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	margin-left: auto;
	transition: background 0.15s;
	white-space: nowrap;
}

.eara-btn--add-resident:hover { background: #dcfce7; }

/* Red missing button */
.eara-btn--red {
	background: #fff5f5;
	color: #b91c1c;
	border: 1px solid #fca5a5;
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;
}

.eara-btn--red:hover { background: #fee2e2; }

/* ── Multiple residents sub-list ─────────────────────────────────────────── */

.eara-property-residents {
	list-style: none;
	margin: 0;
	padding: 0 14px 10px 50px;
	border-top: 1px solid #f1f5f9;
}

.eara-resident-subrow {
	padding: 8px 0;
	border-bottom: 1px solid #f1f5f9;
}

.eara-resident-subrow:last-child { border-bottom: none; }

.eara-resident-subrow__summary {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.eara-resident-subrow__name {
	font-size: 13px;
	font-weight: 600;
	color: #1a1a2e;
	flex: 1;
}

/* Badges */
.eara-badge {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 700;
}

.eara-badge--green { background: #dcfce7; color: #15803d; }
.eara-badge--amber { background: #fef3c7; color: #b45309; }

/* ── Inline forms ────────────────────────────────────────────────────────── */

.eara-resident-card__form {
	padding: 16px;
	border-top: 1px solid #e2e8f0;
	background: #f8fafc;
	border-radius: 0 0 8px 8px;
}

/* Add resident panel */
.eara-add-resident-panel {
	margin: 0;
	padding: 16px 16px 16px 50px;
	border-top: 1px solid #e2e8f0;
	background: #f0fdf4;
}

/* Verify & Update button on sub-row */
.eara-toggle-update-form {
	font-size: 12px;
	padding: 4px 10px;
	background: #eff6ff;
	color: #1d4ed8;
	border: 1px solid #bfdbfe;
	border-radius: 6px;
	cursor: pointer;
	font-weight: 600;
	transition: background 0.15s;
}

.eara-toggle-update-form:hover { background: #dbeafe; }

/* ── Inline form messages ────────────────────────────────────────────────── */

.eara-inline-msg { font-size: 13px; margin-left: 4px; }
.eara-inline-msg--error   { color: #b91c1c; }
.eara-inline-msg--success { color: #15803d; }
.eara-inline-msg--warning { color: #92400e; }

/* ── Placeholder ─────────────────────────────────────────────────────────── */

.eara-field-app__placeholder {
	background: #f8fafc;
	border: 2px dashed #e2e8f0;
	border-radius: 12px;
	padding: 32px 24px;
	text-align: center;
	color: #94a3b8;
	font-size: 14px;
	font-style: italic;
}

/* Loading */
.eara-loading {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 20px;
	color: #64748b;
	font-size: 14px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
	.eara-field-app__header { padding: 18px 16px; }
	.eara-field-app__title  { font-size: 18px; }
	.eara-coverage-row__summary { gap: 7px; }
	#eara-load-street { width: 100%; justify-content: center; }
}

/* ── Team Presence Panel ─────────────────────────────────────────────────── */

.eara-presence-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	background: #eff6ff;
	border: 1.5px solid #bfdbfe;
	border-radius: 10px;
	padding: 10px 16px;
	margin-bottom: 14px;
	font-size: 13px;
	color: #1e40af;
	font-weight: 500;
	flex-wrap: wrap;
}

.eara-presence-bar__icon {
	font-size: 18px;
	flex-shrink: 0;
}

.eara-presence-bar__label {
	flex: 1;
	min-width: 0;
}

.eara-presence-bar__avatars {
	display: flex;
	gap: 5px;
	flex-shrink: 0;
}

.eara-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 11px;
	font-weight: 800;
	color: #fff;
	border: 2px solid #fff;
	box-shadow: 0 1px 4px rgba(0,0,0,.2);
	letter-spacing: .03em;
	cursor: default;
}

/* ── Property row left column (status dot + recent badge stacked) ─────────── */

.eara-coverage-row__left {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	flex-shrink: 0;
	min-width: 38px;
}

/* ── Recently Actioned Badge ─────────────────────────────────────────────── */

.eara-recent-action {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	font-size: 10px;
	color: #6b7280;
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 1px 6px;
	white-space: nowrap;
	cursor: default;
	font-weight: 600;
	letter-spacing: .01em;
}

.eara-recent-action__dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9ca3af;
	flex-shrink: 0;
}

/* ── Conflict Resolution Modal ──────────────────────────────────────────── */

.eara-conflict-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 36, 68, .72);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	backdrop-filter: blur(3px);
}

.eara-conflict-modal {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 24px 64px rgba(0,0,0,.28);
	max-width: 640px;
	width: 100%;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.eara-conflict-modal__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 20px 24px 0;
}

.eara-conflict-modal__icon {
	font-size: 28px;
	flex-shrink: 0;
}

.eara-conflict-modal__title {
	font-size: 17px;
	font-weight: 700;
	color: #0f2444;
	margin: 0;
}

.eara-conflict-modal__intro {
	font-size: 13px;
	color: #64748b;
	padding: 10px 24px 0;
	margin: 0;
	line-height: 1.6;
}

.eara-conflict-modal__table-wrap {
	overflow-y: auto;
	flex: 1;
	padding: 16px 24px;
}

.eara-conflict-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.eara-conflict-table th {
	background: #f1f5f9;
	padding: 8px 12px;
	text-align: left;
	font-weight: 700;
	color: #374151;
	border-bottom: 2px solid #e2e8f0;
}

.eara-conflict-table td {
	padding: 8px 12px;
	border-bottom: 1px solid #f1f5f9;
	vertical-align: middle;
}

.eara-conflict__label {
	font-weight: 600;
	color: #374151;
	white-space: nowrap;
}

.eara-conflict__row--diff td {
	background: #fffbeb;
}

.eara-conflict__val--changed {
	font-weight: 700;
}

.eara-conflict__badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 7px;
	border-radius: 10px;
	margin-left: 6px;
	vertical-align: middle;
}

.eara-conflict__badge--theirs {
	background: #fee2e2;
	color: #991b1b;
}

.eara-conflict__badge--mine {
	background: #dbeafe;
	color: #1e40af;
}

.eara-conflict-modal__actions {
	display: flex;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid #e2e8f0;
	flex-wrap: wrap;
}

.eara-conflict-keep-theirs {
	background: #f1f5f9;
	color: #374151;
	border-color: #cbd5e1;
	flex: 1;
}
.eara-conflict-keep-theirs:hover {
	background: #e2e8f0;
}

.eara-conflict-keep-mine {
	flex: 1;
}
