/* Visitor Management — Frontend styles (mobile-first) */

.vm-app {
	--vm-brand: #2563eb;
	--vm-bg: #f3f4f6;
	--vm-card-bg: #ffffff;
	--vm-text: #1f2937;
	--vm-muted: #6b7280;
	--vm-border: #e5e7eb;
	--vm-success: #16a34a;
	--vm-danger: #dc2626;
	--vm-warning: #d97706;

	box-sizing: border-box;
	max-width: 520px;
	margin: 0 auto;
	padding: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--vm-text);
	background: var(--vm-bg);
	min-height: 100vh;
}

.vm-app *,
.vm-app *::before,
.vm-app *::after {
	box-sizing: border-box;
}

/*
 * Several elements below (buttons, the camera placeholder, etc.) set an
 * explicit `display` value of their own, which — being an author rule —
 * takes priority over the browser's built-in `[hidden] { display: none }`
 * default. Without this override, setting `.hidden = true` in JS on a
 * `.vm-btn` or similar element would silently fail to actually hide it.
 * `!important` here guarantees `hidden` always wins, everywhere in the app.
 */
.vm-app [hidden] {
	display: none !important;
}

.vm-app.vm-reception {
	max-width: 900px;
	padding: 0;
	display: flex;
	flex-direction: column;
	background: var(--vm-bg);
}

.vm-app-shell {
	min-height: 100vh;
}

.vm-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 4px 20px;
	flex-wrap: wrap;
}

.vm-appbar {
	position: sticky;
	top: 0;
	z-index: 20;
	background: var(--vm-brand);
	color: #fff;
	padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 16px;
	margin: 0;
	flex-wrap: nowrap;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.vm-appbar .vm-header-text h1 {
	font-size: 16px;
	color: #fff;
}

.vm-appbar .vm-tagline {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.85);
}

.vm-appbar .vm-logo {
	background: #fff;
	padding: 4px;
	border-radius: 8px;
	max-height: 34px;
}

.vm-reception-body {
	flex: 1;
	padding: 0 16px calc(28px + env(safe-area-inset-bottom, 0px));
	max-width: 900px;
	margin: 0 auto;
	width: 100%;
}

.vm-filters-sticky {
	padding: 16px 0 12px;
	margin-bottom: 0;
	overflow-x: auto;
	flex-wrap: nowrap;
	-ms-overflow-style: none;
	scrollbar-width: none;
}

.vm-filters-sticky::-webkit-scrollbar {
	display: none;
}

.vm-icon-btn {
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	text-decoration: none;
	font-size: 16px;
	flex-shrink: 0;
}

.vm-appbar .vm-pending-badge {
	background: rgba(255, 255, 255, 0.25);
	color: #fff;
}

.vm-logo {
	max-height: 48px;
	max-width: 140px;
	object-fit: contain;
}

.vm-header-text h1 {
	font-size: 19px;
	margin: 0;
	line-height: 1.25;
}

.vm-tagline {
	margin: 2px 0 0;
	font-size: 13px;
	color: var(--vm-muted);
}

.vm-header-actions {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	flex-wrap: wrap;
}

.vm-pending-badge {
	background: var(--vm-brand);
	color: #fff;
	font-weight: 700;
	font-size: 12px;
	min-width: 22px;
	height: 22px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
}

.vm-card {
	background: var(--vm-card-bg);
	border-radius: 16px;
	padding: 20px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
	border: 1px solid var(--vm-border);
}

.vm-center-card {
	text-align: center;
}

.vm-login-card {
	max-width: 360px;
	margin: 0 auto;
}

.vm-login-card form p {
	margin-bottom: 14px;
}

.vm-login-card input[type="text"],
.vm-login-card input[type="password"] {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--vm-border);
	border-radius: 10px;
	font-size: 15px;
}

.vm-login-card input[type="submit"] {
	width: 100%;
	background: var(--vm-brand);
	color: #fff;
	border: none;
	padding: 13px;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.vm-step-title {
	margin: 0 0 16px;
	font-size: 17px;
	text-align: center;
}

.vm-photo-box {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	background: #111827;
	border-radius: 12px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 12px;
}

.vm-camera-video,
.vm-photo-preview {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.vm-camera-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	color: #9ca3af;
	font-size: 13px;
	text-align: center;
	padding: 20px;
}

.vm-icon {
	font-size: 32px;
}

.vm-photo-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-bottom: 20px;
}

.vm-field {
	margin-bottom: 16px;
}

.vm-field label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 6px;
	color: var(--vm-text);
}

.vm-req {
	color: var(--vm-danger);
}

.vm-field input[type="text"],
.vm-field input[type="tel"],
.vm-field input[type="email"] {
	width: 100%;
	padding: 13px 14px;
	border: 1px solid var(--vm-border);
	border-radius: 10px;
	font-size: 16px;
	background: #fff;
}

.vm-field input:focus {
	outline: none;
	border-color: var(--vm-brand);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--vm-brand) 20%, transparent);
}

.vm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 18px;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 600;
	border: none;
	cursor: pointer;
	text-decoration: none;
	line-height: 1.3;
	transition: transform 0.06s ease, opacity 0.15s ease;
}

.vm-btn:active {
	transform: scale(0.98);
}

.vm-btn-primary {
	background: var(--vm-brand);
	color: #fff;
}

.vm-btn-secondary {
	background: #eef2f7;
	color: var(--vm-text);
}

.vm-btn-link {
	background: transparent;
	color: var(--vm-brand);
	padding: 12px 6px;
	text-decoration: underline;
}

.vm-btn-block {
	display: flex;
	width: 100%;
}

.vm-btn-small {
	padding: 6px 12px;
	font-size: 12px;
}

.vm-btn[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
	transform: none !important;
}

.vm-error {
	color: var(--vm-danger);
	background: #fef2f2;
	border: 1px solid #fecaca;
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 13px;
	margin: 0 0 16px;
}

.vm-step-status {
	text-align: center;
	padding: 30px 10px;
}

.vm-status-icon {
	font-size: 48px;
	margin-bottom: 8px;
}

.vm-status-status--approved .vm-status-icon,
.vm-status-name {
	color: var(--vm-muted);
	font-size: 14px;
	margin: 4px 0 20px;
}

.vm-spinner {
	width: 30px;
	height: 30px;
	margin: 10px auto;
	border-radius: 50%;
	border: 3px solid var(--vm-border);
	border-top-color: var(--vm-brand);
	animation: vm-spin 0.8s linear infinite;
}

@keyframes vm-spin {
	to {
		transform: rotate(360deg);
	}
}

.vm-footer {
	text-align: center;
	font-size: 11px;
	color: var(--vm-muted);
	padding: 20px 10px 10px;
}

.vm-footer a {
	color: var(--vm-brand);
	text-decoration: none;
}

/* Status theme classes toggled via JS */
.vm-status-approved .vm-status-icon { color: var(--vm-success); }
.vm-status-rejected .vm-status-icon { color: var(--vm-danger); }
.vm-status-pending .vm-status-icon { color: var(--vm-warning); }

/* ---------------- Reception ---------------- */

.vm-filters {
	display: flex;
	gap: 8px;
	flex-wrap: nowrap;
	margin-bottom: 0;
}

.vm-filter-btn {
	background: #fff;
	border: 1px solid var(--vm-border);
	border-radius: 999px;
	padding: 9px 18px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	color: var(--vm-text);
	white-space: nowrap;
	flex-shrink: 0;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.vm-filter-btn.is-active {
	background: var(--vm-brand);
	border-color: var(--vm-brand);
	color: #fff;
}

.vm-visitor-list {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.vm-empty {
	text-align: center;
	color: var(--vm-muted);
	padding: 48px 20px;
	background: #fff;
	border-radius: 16px;
	border: 1px dashed var(--vm-border);
	font-size: 14px;
}

.vm-visitor-card {
	background: #fff;
	border-radius: 18px;
	border: 1px solid var(--vm-border);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.04);
	padding: 14px;
	display: flex;
	gap: 14px;
	align-items: flex-start;
	flex-wrap: wrap;
	-webkit-tap-highlight-color: transparent;
	transition: opacity 0.15s ease;
}

.vm-visitor-photo {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
	background: #f3f4f6;
	flex-shrink: 0;
	border: 2px solid var(--vm-border);
}

.vm-visitor-info {
	flex: 1 1 180px;
	min-width: 160px;
}

.vm-visitor-name {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 700;
}

.vm-visitor-meta {
	margin: 0 0 2px;
	font-size: 12.5px;
	color: var(--vm-muted);
}

.vm-status-pill {
	display: inline-block;
	margin-top: 6px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	padding: 3px 10px;
	border-radius: 999px;
}

.vm-status-pill.pending {
	background: #fef9c3;
	color: #854d0e;
}

.vm-status-pill.approved {
	background: #dcfce7;
	color: #166534;
}

.vm-status-pill.rejected {
	background: #fee2e2;
	color: #991b1b;
}

.vm-visitor-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	width: 100%;
}

.vm-visitor-actions .vm-btn {
	flex: 1 1 auto;
	white-space: nowrap;
	border-radius: 12px;
	font-weight: 700;
	padding: 12px 14px;
}

.vm-btn-approve {
	background: var(--vm-success);
	color: #fff;
}

.vm-btn-reject {
	background: #fff;
	color: var(--vm-danger);
	border: 1px solid #fca5a5;
}

.vm-btn-whatsapp {
	background: #25d366;
	color: #fff;
	gap: 6px;
}

.vm-btn-whatsapp.is-sending {
	opacity: 0.7;
	pointer-events: none;
}

.vm-btn-whatsapp.is-sent {
	background: #128c43;
}

@media (min-width: 600px) {
	.vm-app:not(.vm-reception) {
		padding: 24px;
	}

	.vm-visitor-actions {
		width: auto;
		flex-direction: column;
		align-self: stretch;
	}

	.vm-visitor-card {
		flex-wrap: nowrap;
	}
}

@media (min-width: 782px) {
	.vm-visitor-list {
		grid-template-columns: 1fr 1fr;
	}
}

/* ---------------- Frontend Records screen ---------------- */

.vm-records-filters {
	background: #fff;
	border: 1px solid var(--vm-border);
	border-radius: 16px;
	padding: 14px;
	margin: 16px 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.vm-records-filters #vm-rec-search {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--vm-border);
	border-radius: 10px;
	font-size: 15px;
}

.vm-records-filter-row {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.vm-records-filter-row label {
	flex: 1 1 120px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: var(--vm-muted);
	font-weight: 600;
}

.vm-records-filter-row input[type="date"] {
	padding: 10px 12px;
	border: 1px solid var(--vm-border);
	border-radius: 10px;
	font-size: 14px;
}

.vm-records-actions {
	display: flex;
	gap: 8px;
}

.vm-records-actions .vm-btn {
	flex: 1;
}

.vm-record-card {
	cursor: default;
}

.vm-records-load-more-wrap {
	margin-top: 14px;
}
