/*
Theme Name:        Apartment Intercom Theme
Description:       App-style interface for the Apartment Intercom plugin: a full-screen lobby kiosk, an installable resident app, branded login and a manager dashboard. Light and dark mode.
Version:           1.8.0
Requires at least: 6.0
Requires PHP:      7.4
Author:            Raul Vasquez
License:           GPL-2.0-or-later
Text Domain:       apartment-intercom-theme
*/

/* ---------- Tokens (light default; dark via device setting or data-aic-theme) ---------- */

:root {
	--ait-accent: #2563eb;
	--ait-bg: #f5f7fb;
	--ait-surface: #ffffff;
	--ait-surface-2: #eef2f7;
	--ait-border: #e3e8ef;
	--ait-text: #0f172a;
	--ait-muted: #64748b;
	--ait-ok: #16a34a;
	--ait-ok-soft: #dcfce7;
	--ait-danger: #dc2626;
	--ait-danger-soft: #fee2e2;
	--ait-warn: #d97706;
	--ait-warn-soft: #fef3c7;
	--ait-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
	--ait-radius: 20px;
	--ait-nav-h: 68px;
	--ait-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	html:not([data-aic-theme="light"]) {
		--ait-bg: #0b1120;
		--ait-surface: #111a2e;
		--ait-surface-2: #1b2640;
		--ait-border: #26324d;
		--ait-text: #eef2f8;
		--ait-muted: #93a1bb;
		--ait-ok: #22c55e;
		--ait-ok-soft: rgba(34, 197, 94, .15);
		--ait-danger: #ef4444;
		--ait-danger-soft: rgba(239, 68, 68, .15);
		--ait-warn: #f59e0b;
		--ait-warn-soft: rgba(245, 158, 11, .15);
		--ait-shadow: 0 1px 2px rgba(0, 0, 0, .3);
		color-scheme: dark;
	}
}
html[data-aic-theme="dark"] {
	--ait-bg: #0b1120;
	--ait-surface: #111a2e;
	--ait-surface-2: #1b2640;
	--ait-border: #26324d;
	--ait-text: #eef2f8;
	--ait-muted: #93a1bb;
	--ait-ok: #22c55e;
	--ait-ok-soft: rgba(34, 197, 94, .15);
	--ait-danger: #ef4444;
	--ait-danger-soft: rgba(239, 68, 68, .15);
	--ait-warn: #f59e0b;
	--ait-warn-soft: rgba(245, 158, 11, .15);
	--ait-shadow: 0 1px 2px rgba(0, 0, 0, .3);
	color-scheme: dark;
}

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

html, body {
	margin: 0;
	min-height: 100%;
	background: var(--ait-bg);
	color: var(--ait-text);
	font-family: var(--ait-font);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--ait-accent); }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--ait-accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
}

.ait-icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- Shared components ---------- */

.ait-card {
	background: var(--ait-surface);
	border: 1px solid var(--ait-border);
	border-radius: var(--ait-radius);
	box-shadow: var(--ait-shadow);
}

.ait-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--ait-surface-2);
	color: var(--ait-text);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}
.ait-btn-primary { background: var(--ait-accent); color: #fff; }
.ait-btn-sm { min-height: 36px; padding: 0 14px; font-size: .9rem; }

.ait-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ait-text); text-decoration: none; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; min-width: 0; }
.ait-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ait-brand img { max-height: 36px; width: auto; }
.ait-brand-mark { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--ait-accent); color: #fff; flex: none; }
.ait-brand-mark .ait-icon { width: 20px; height: 20px; }

.ait-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--ait-surface-2); color: var(--ait-muted); white-space: nowrap; }
.ait-pill-ok { background: var(--ait-ok-soft); color: var(--ait-ok); }
.ait-pill-danger { background: var(--ait-danger-soft); color: var(--ait-danger); }
.ait-pill-warn { background: var(--ait-warn-soft); color: var(--ait-warn); }

.ait-notice { background: var(--ait-warn-soft); color: var(--ait-warn); border-radius: 14px; padding: 14px 16px; margin: 16px; font-weight: 600; }

/* ---------- Generic pages ---------- */

.ait-site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--ait-border); background: var(--ait-surface); }
.ait-site-header nav { display: flex; gap: 6px; }
.ait-content { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.ait-content h1, .ait-content h2 { line-height: 1.25; }
.ait-site-footer { text-align: center; color: var(--ait-muted); font-size: .85rem; padding: 24px; }

/* ---------- Sign in ---------- */

.ait-center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.ait-login { width: 100%; max-width: 420px; padding: 36px 28px 28px; text-align: center; }
.ait-login .ait-logo { margin: 0 auto 16px; display: block; max-height: 72px; width: auto; }
.ait-login-mark { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: var(--ait-accent); color: #fff; }
.ait-login-mark .ait-icon { width: 32px; height: 32px; }
.ait-login h1 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -.02em; }
.ait-login p.ait-sub { margin: 0 0 24px; color: var(--ait-muted); }
.ait-login form { text-align: left; }
.ait-login form p { margin: 0 0 16px; }
.ait-login label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.ait-login input[type="text"],
.ait-login input[type="password"] {
	width: 100%;
	min-height: 52px;
	padding: 0 16px;
	border-radius: 12px;
	border: 2px solid var(--ait-border);
	background: var(--ait-surface);
	color: var(--ait-text);
	font-size: 1rem;
}
.ait-login input[type="text"]:focus, .ait-login input[type="password"]:focus { border-color: var(--ait-accent); outline: none; }
.ait-login .login-remember label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ait-muted); }
.ait-login input[type="submit"] { width: 100%; min-height: 52px; border: 0; border-radius: 999px; background: var(--ait-accent); color: #fff; font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer; }
.ait-login .ait-forgot { display: inline-block; margin-top: 18px; font-size: .9rem; }

/* ---------- Manager dashboard ---------- */

.ait-topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 20px;
	padding: 12px 24px;
	background: color-mix(in srgb, var(--ait-surface) 88%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--ait-border);
}
.ait-topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.ait-topnav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; color: var(--ait-muted); text-decoration: none; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.ait-topnav a:hover { background: var(--ait-surface-2); color: var(--ait-text); }
.ait-topnav a[aria-current="page"] { background: var(--ait-surface-2); color: var(--ait-text); }
.ait-user { display: flex; align-items: center; gap: 10px; flex: none; }
.ait-avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--ait-accent); color: #fff; font-weight: 700; font-size: .9rem; flex: none; }

.ait-dash { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; display: flex; flex-direction: column; gap: 24px; }
.ait-greeting h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -.02em; }
.ait-greeting p { margin: 4px 0 0; color: var(--ait-muted); }
.ait-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ait-section-head h2 { margin: 0; font-size: 1.15rem; }
.ait-section-head a { font-size: .9rem; font-weight: 600; text-decoration: none; }

.ait-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.ait-stat { padding: 18px; display: flex; align-items: center; gap: 14px; }
.ait-stat-icon { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--ait-surface-2); color: var(--ait-accent); flex: none; }
.ait-stat strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.ait-stat span { color: var(--ait-muted); font-size: .88rem; }
.ait-stat-warn .ait-stat-icon { background: var(--ait-danger-soft); color: var(--ait-danger); }
.ait-stat-warn strong { color: var(--ait-danger); }
.ait-stat-ok .ait-stat-icon { background: var(--ait-ok-soft); color: var(--ait-ok); }

.ait-dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: start; }
.ait-building-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ait-building { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ait-building-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ait-building-head strong { display: block; font-size: 1.1rem; }
.ait-building-head span { color: var(--ait-muted); font-size: .88rem; }
.ait-mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.ait-mini-stats div { padding: 8px 4px; border-radius: 12px; background: var(--ait-surface-2); }
.ait-mini-stats b { display: block; font-size: 1.15rem; }
.ait-mini-stats small { color: var(--ait-muted); font-size: .72rem; }
.ait-mini-stats .is-warn b { color: var(--ait-danger); }
.ait-building-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ait-feed { padding: 6px 0; }
.ait-feed-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; }
.ait-feed-row + .ait-feed-row { border-top: 1px solid var(--ait-border); }
.ait-feed-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--ait-surface-2); color: var(--ait-muted); flex: none; }
.ait-feed-icon.is-ok { background: var(--ait-ok-soft); color: var(--ait-ok); }
.ait-feed-icon.is-missed { background: var(--ait-danger-soft); color: var(--ait-danger); }
.ait-feed-text { flex: 1; min-width: 0; }
.ait-feed-text strong { display: block; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ait-feed-text span { color: var(--ait-muted); font-size: .82rem; }
.ait-empty { padding: 28px 18px; text-align: center; color: var(--ait-muted); }

.ait-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.ait-quick a { padding: 16px; display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ait-text); transition: border-color .15s ease, transform .15s ease; }
.ait-quick a:hover { border-color: var(--ait-accent); transform: translateY(-1px); }
.ait-quick strong { display: block; }
.ait-quick span { color: var(--ait-muted); font-size: .85rem; }

/* ---------- Lobby kiosk ---------- */

.ait-kiosk { min-height: 100vh; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; background: var(--ait-bg); }
.ait-kiosk-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; }
.ait-kiosk-bar .ait-brand { font-size: 1.3rem; }
.ait-kiosk-clock { text-align: right; line-height: 1.2; }
.ait-kiosk-clock .ait-time { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ait-kiosk-clock .ait-date { color: var(--ait-muted); font-size: .95rem; }
.ait-kiosk-main { flex: 1; padding: 0 32px 32px; }
.ait-kiosk.ait-hide-cursor, .ait-kiosk.ait-hide-cursor * { cursor: none !important; }
/* The kiosk bar already names the building, so the welcome line becomes the headline. */
.ait-kiosk .aic-home .aic-hero h1 { display: none; }
.ait-kiosk .aic-home .aic-hero p { margin: 0; font-size: clamp(1.4rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; color: var(--ait-text); }
.ait-fullscreen-btn { position: fixed; right: 16px; bottom: 16px; opacity: .6; z-index: 10; min-height: 40px; font-size: .85rem; }

/* ---------- Resident app ---------- */

.ait-resident { min-height: 100vh; padding-bottom: calc(var(--ait-nav-h) + env(safe-area-inset-bottom) + 12px); }
.ait-appbar {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
	background: color-mix(in srgb, var(--ait-bg) 88%, transparent);
	backdrop-filter: blur(10px);
}
.ait-units-badge { flex: none; }
.ait-view { max-width: 560px; margin: 0 auto; padding: 8px 16px 16px; }
.ait-hello { margin: 4px 4px 16px; }
.ait-hello h1 { margin: 0; font-size: 1.7rem; letter-spacing: -.02em; }
.ait-hello p { margin: 2px 0 0; color: var(--ait-muted); }

.ait-profile { padding: 22px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.ait-profile .ait-avatar { width: 56px; height: 56px; font-size: 1.3rem; }
.ait-profile strong { display: block; font-size: 1.15rem; }
.ait-profile span { color: var(--ait-muted); font-size: .9rem; }
.ait-menu { padding: 4px 0; margin-bottom: 16px; }
.ait-menu-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 18px; border: 0; background: none; color: var(--ait-text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.ait-menu-row + .ait-menu-row { border-top: 1px solid var(--ait-border); }
.ait-menu-icon { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--ait-surface-2); color: var(--ait-accent); flex: none; }
.ait-menu-text { flex: 1; min-width: 0; }
.ait-menu-text strong { display: block; font-weight: 600; }
.ait-menu-text span { color: var(--ait-muted); font-size: .85rem; }
.ait-menu-row .ait-chevron { color: var(--ait-muted); }
.ait-menu-row.is-danger, .ait-menu-row.is-danger .ait-menu-icon { color: var(--ait-danger); }
.ait-menu-row.is-danger .ait-menu-icon { background: var(--ait-danger-soft); }
.ait-tip { display: flex; gap: 10px; color: var(--ait-muted); font-size: .9rem; padding: 0 6px; }

.ait-tabbar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 5;
	display: flex;
	justify-content: center;
	gap: 8px;
	height: calc(var(--ait-nav-h) + env(safe-area-inset-bottom));
	padding: 8px 16px env(safe-area-inset-bottom);
	background: color-mix(in srgb, var(--ait-surface) 92%, transparent);
	backdrop-filter: blur(10px);
	border-top: 1px solid var(--ait-border);
}
.ait-tabbar a {
	flex: 1;
	max-width: 200px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	border-radius: 16px;
	color: var(--ait-muted);
	text-decoration: none;
	font-size: .78rem;
	font-weight: 600;
}
.ait-tabbar a .ait-icon { width: 24px; height: 24px; }
.ait-tabbar a[aria-current="page"] { color: var(--ait-accent); background: color-mix(in srgb, var(--ait-accent) 10%, transparent); }

@media (max-width: 1100px) {
	.ait-user .ait-user-name { display: none; }
}
@media (max-width: 960px) {
	/* Navigation gets its own row instead of being cut off. */
	.ait-topbar { flex-wrap: wrap; justify-content: space-between; row-gap: 8px; }
	.ait-topnav { order: 3; flex-basis: 100%; }
}
@media (max-width: 900px) {
	.ait-dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
	.ait-topbar { padding: 10px 14px; gap: 10px; }
	.ait-dash { padding: 20px 14px 48px; }
	.ait-kiosk-bar, .ait-kiosk-main { padding-left: 16px; padding-right: 16px; }
	.ait-kiosk-clock .ait-time { font-size: 1.4rem; }
}

/* ---------- Client panel page ---------- */
.ait-client-wrap { width: min(1240px, 100% - 32px); margin: 0 auto; padding: 24px 0 40px; }
@media (max-width: 900px) { .ait-client-wrap { padding-top: 12px; } }
