/*
 * Mobile primitives shared by EpTeam.App and EpTeam.Web.
 * Tokens only (see theme.css); no literal colours. Mockups: docs/mobile-mockups.html,
 * plan: docs/MobileRedesignPlan.md.
 */

/* ── Pressed state, everywhere something is tappable ─────────────── */
.pressable,
a.card,
.app-launcher-tile,
.app-shift-card,
.menu-button-item,
.app-tab,
.btn,
.chip-btn,
.mobile-row {
	transition: transform 120ms ease, background-color 150ms ease, color 150ms ease;
}

.pressable:active,
a.card:active,
.app-launcher-tile:active,
.btn:active:not(:disabled),
.mobile-row:active {
	transform: scale(0.98);
}

.mobile-row:active,
.menu-button-item:active {
	background: var(--color-bg-raised);
}

.app-tab:active .icon,
.app-tab:active .app-tab-fab {
	transform: scale(0.88);
}

.app-tab .icon,
.app-tab .app-tab-fab {
	transition: transform 120ms ease;
}

/* ── Page entrance ───────────────────────────────────────────────── */
@keyframes page-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

@keyframes sheet-up {
	from { transform: translateY(100%); }
	to   { transform: none; }
}

@keyframes scrim-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.app-content > * {
	animation: page-in 220ms ease-out backwards;
}

/* ── App shell: bell in the top bar, centre action in the tab bar ── */
.app-topbar-spacer {
	flex: 1;
}

.app-topbar-bell {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin-right: -6px;
	border-radius: var(--radius-pill);
	color: var(--color-text);
	text-decoration: none;
}

.app-topbar-bell:active {
	background: var(--color-bg-hover);
}

.app-topbar-bell .icon {
	width: 22px;
	height: 22px;
}

.app-topbar-bell .app-tab-badge {
	top: 2px;
	right: 0;
}

.app-tab.app-tab-center {
	color: var(--color-text);
	overflow: visible;
}

.app-tab-fab {
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	margin-top: -28px;
	border-radius: 50%;
	background: var(--color-primary);
	color: var(--color-on-primary);
	box-shadow: 0 10px 22px -4px rgba(var(--color-primary-rgb), 0.6), 0 0 0 6px var(--color-bg-elevated);
}

.app-tab-fab .icon {
	width: 26px;
	height: 26px;
}

/* ── Large collapsing-style title on phones ──────────────────────── */
@media (max-width: 767.98px) {
	.page-header-title h1 {
		font-size: 26px;
		line-height: 1.15;
		letter-spacing: -0.3px;
	}
}

/* ── Touch sizing on phones ──────────────────────────────────────── */
@media (max-width: 767.98px) {
	:root {
		--control-height: 46px;
		--control-height-sm: 40px;
	}

	.form-control,
	.form-select,
	.login-input,
	.modal-body .form-control,
	.modal-body .form-select,
	.modal-body input,
	.modal-body select,
	.modal-body textarea {
		font-size: 16px;
	}

	.btn:not(.btn-sm):not(.btn-icon):not(.btn-close) {
		min-height: 44px;
	}
}

/* ── Modals become bottom sheets on phones ───────────────────────── */
@media (max-width: 767.98px) {
	.modal.show.d-block,
	.modal.d-block {
		animation: scrim-in 200ms ease-out;
	}

	.modal-dialog,
	.modal-dialog.modal-dialog-centered,
	.modal-dialog.modal-dialog-scrollable {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		width: 100%;
		max-width: none !important;
		margin: 0 !important;
		min-height: 0;
		height: auto;
		display: flex;
		align-items: flex-end;
		animation: sheet-up 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.modal-content {
		width: 100%;
		max-height: 92vh;
		border-radius: 24px 24px 0 0 !important;
		border-bottom: 0 !important;
		padding-bottom: env(safe-area-inset-bottom);
	}

	.modal-header {
		position: relative;
		padding-top: 22px;
		border-top-left-radius: 24px;
		border-top-right-radius: 24px;
	}

	.modal-header::before {
		content: "";
		position: absolute;
		top: 8px;
		left: 50%;
		width: 40px;
		height: 5px;
		margin-left: -20px;
		border-radius: 3px;
		background: var(--color-border-strong);
	}

	.modal-body {
		padding: var(--space-4);
		overflow-y: auto;
		min-height: 0;
	}

	.modal-footer {
		gap: var(--space-2);
	}

	.modal-footer > .btn {
		flex: 1 1 0;
	}

	.rz-dialog-wrapper .rz-dialog {
		position: fixed !important;
		left: 0 !important;
		right: 0 !important;
		top: auto !important;
		bottom: 0 !important;
		width: 100% !important;
		max-width: none !important;
		max-height: 92vh;
		margin: 0 !important;
		border-radius: 24px 24px 0 0 !important;
		padding-bottom: env(safe-area-inset-bottom);
		animation: sheet-up 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
	}
}

/* ── Sheet component ─────────────────────────────────────────────── */
.sheet-scrim {
	position: fixed;
	inset: 0;
	z-index: var(--z-popover);
	background: rgba(0, 0, 0, 0.55);
	animation: scrim-in 200ms ease-out;
}

.sheet-panel {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: calc(var(--z-popover) + 1);
	display: flex;
	flex-direction: column;
	max-height: 88vh;
	background: var(--color-bg-elevated);
	border: 1px solid var(--color-border-strong);
	border-bottom: 0;
	border-radius: 24px 24px 0 0;
	box-shadow: var(--shadow-pop);
	padding-bottom: env(safe-area-inset-bottom);
	animation: sheet-up 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
	touch-action: none;
}

.sheet-panel.is-dragging {
	animation: none;
	transition: none;
}

.sheet-panel.is-closing {
	transform: translateY(100%);
	transition: transform 220ms ease-in;
}

.sheet-grab {
	flex: 0 0 auto;
	width: 40px;
	height: 5px;
	margin: 10px auto 6px;
	border-radius: 3px;
	background: var(--color-border-strong);
}

.sheet-title {
	padding: 4px 18px 8px;
	font-family: var(--font-heading);
	font-size: var(--text-lg);
	font-weight: 600;
}

.sheet-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 4px 16px 16px;
	touch-action: pan-y;
}

@media (min-width: 768px) {
	.sheet-panel {
		left: 50%;
		right: auto;
		width: 480px;
		margin-left: -240px;
		bottom: 24px;
		border-bottom: 1px solid var(--color-border-strong);
		border-radius: 24px;
	}
}

/* ── Account page: grouped list ──────────────────────────────────── */
.account-profile {
	display: flex;
	align-items: center;
	gap: var(--space-4);
	padding: var(--space-4);
	margin-bottom: var(--space-4);
	color: inherit;
	text-decoration: none;
}

.account-avatar {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--color-primary-soft);
	color: var(--color-primary);
	font-family: var(--font-heading);
	font-size: 22px;
	font-weight: 600;
}

.account-profile-name {
	font-family: var(--font-heading);
	font-size: 17px;
	font-weight: 600;
}

.group-label {
	padding: 0 var(--space-4) 7px;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--color-text-subtle);
}

.group-list {
	margin-bottom: var(--space-5);
	overflow: hidden;
	padding: 0;
}

.group-row {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	min-height: 54px;
	padding: 0 var(--space-4);
	border: 0;
	border-bottom: 1px solid var(--color-border-soft);
	background: none;
	color: var(--color-text);
	font-family: inherit;
	font-size: 14.5px;
	font-weight: 500;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
}

.group-row:last-child {
	border-bottom: 0;
}

.group-row:active {
	background: var(--color-bg-raised);
}

.group-row-icon {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 9px;
	background: var(--color-tone-neutral-soft);
	color: var(--color-tone-neutral);
}

.group-row-icon.tone-info { background: var(--color-tone-info-soft); color: var(--color-tone-info); }
.group-row-icon.tone-healthy { background: var(--color-tone-healthy-soft); color: var(--color-tone-healthy); }
.group-row-icon.tone-at-risk { background: var(--color-tone-at-risk-soft); color: var(--color-tone-at-risk); }
.group-row-icon.tone-critical { background: var(--color-tone-critical-soft); color: var(--color-tone-critical); }

.group-row-icon .icon {
	width: 18px;
	height: 18px;
}

.group-row-label {
	flex: 1 1 auto;
}

.group-row-value {
	color: var(--color-text-muted);
	font-size: 13px;
}

.group-row-chevron {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	color: var(--color-text-subtle);
}

.group-row.is-danger {
	color: var(--color-tone-critical);
}

/* ── Manage / quick action tiles inside a sheet ──────────────────── */
.sheet-tiles {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.sheet-tile {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: var(--space-3);
	min-height: 104px;
	padding: 14px;
	border: 1px solid var(--color-border);
	border-radius: 16px;
	background: var(--color-bg-raised);
	color: var(--color-text);
	text-decoration: none;
	text-align: left;
	font-family: inherit;
	cursor: pointer;
}

.sheet-tile:active {
	transform: scale(0.97);
	background: var(--color-bg-subtle);
}

.sheet-tile-top {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
}

.sheet-tile-title {
	display: block;
	font-size: 14px;
	font-weight: 600;
}

.sheet-tiles-compact {
	grid-template-columns: repeat(3, 1fr);
}

.sheet-tiles-compact .sheet-tile {
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 86px;
	padding: 12px 6px;
	text-align: center;
}

.sheet-tiles-compact .sheet-tile-title {
	font-size: 12.5px;
}

.sheet-tile-hint {
	display: block;
	font-size: 12px;
	color: var(--color-text-muted);
}

/* ── Pull to refresh and swipe rows ──────────────────────────────── */
.ptr {
	position: relative;
}

.ptr-indicator {
	position: absolute;
	left: 0;
	right: 0;
	top: -8px;
	display: flex;
	justify-content: center;
	height: 0;
	overflow: visible;
	pointer-events: none;
	z-index: 2;
}

.ptr-indicator span {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	margin-top: -38px;
	border-radius: 50%;
	background: var(--color-bg-elevated);
	border: 1px solid var(--color-border-strong);
	color: var(--color-primary);
	box-shadow: var(--shadow-md);
	opacity: 0;
	transform: translateY(0);
}

.ptr.is-pulling .ptr-indicator span,
.ptr.is-refreshing .ptr-indicator span {
	opacity: 1;
}

.ptr.is-refreshing .ptr-indicator .icon {
	animation: epteam-spin 800ms linear infinite;
}

.swipe-row {
	position: relative;
	margin-bottom: 10px;
	border-radius: 16px;
	overflow: hidden;
	touch-action: pan-y;
}

.swipe-row-actions {
	position: absolute;
	inset: 0;
	display: flex;
	justify-content: space-between;
	align-items: stretch;
	font-size: 13px;
	font-weight: 700;
}

.swipe-row-actions > div {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 50%;
	padding: 0 20px;
}

.swipe-row-right {
	background: var(--color-tone-healthy);
	color: var(--color-bg);
}

.swipe-row-left {
	justify-content: flex-end;
	background: var(--color-danger);
	color: var(--color-danger-on);
}

.swipe-row-face {
	position: relative;
	background: var(--color-bg-elevated);
	border: 1px solid var(--color-border);
	border-radius: 16px;
	transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.swipe-row-face.is-dragging {
	transition: none;
}

@media (prefers-reduced-motion: reduce) {
	.app-content > *,
	.modal-dialog,
	.sheet-panel,
	.rz-dialog-wrapper .rz-dialog {
		animation: none !important;
	}
}

/* ── Home hero: the next shift and one action ────────────────────── */
.home-hero {
	position: relative;
	margin-bottom: var(--space-4);
	padding: 18px;
	overflow: hidden;
	border: 1px solid var(--color-primary);
	border-radius: 22px;
	background: linear-gradient(160deg, color-mix(in srgb, var(--color-primary) 55%, var(--color-bg)) 0%, color-mix(in srgb, var(--color-primary) 22%, var(--color-bg)) 70%, var(--color-bg-elevated) 100%);
	color: var(--color-text);
}

.home-hero::after {
	content: "";
	position: absolute;
	right: -40px;
	top: -40px;
	width: 160px;
	height: 160px;
	border-radius: 50%;
	background: var(--color-primary-soft);
	pointer-events: none;
}

.home-hero-title {
	position: relative;
	margin: 8px 0 2px;
	font-family: var(--font-heading);
	font-size: 21px;
	font-weight: 600;
}

.home-hero-meta {
	position: relative;
	font-size: 13.5px;
	color: var(--color-text-muted);
}

.home-hero-count {
	position: relative;
	margin: 14px 0;
	font-family: var(--font-heading);
	font-size: 30px;
	font-weight: 600;
	letter-spacing: -0.5px;
}

.home-hero-actions {
	position: relative;
	display: flex;
	gap: var(--space-2);
}

.home-hero-primary {
	flex: 2 1 0;
	min-height: 50px;
	border: 0;
	border-radius: 14px;
	background: var(--color-text);
	color: var(--color-bg);
	font-size: 16px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

.home-hero-secondary {
	flex: 1 1 0;
	min-height: 50px;
	border: 1px solid var(--color-border-strong);
	border-radius: 14px;
	background: transparent;
	color: var(--color-text);
	font-weight: 600;
}

/* ── Search bar with filter button and removable chips ───────────── */
.app-searchbar {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	margin-bottom: var(--space-3);
}

.app-searchbar-field {
	flex: 1 1 auto;
	min-width: 0;
}

.app-filter-btn {
	position: relative;
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
	border: 1px solid var(--color-border);
	border-radius: 14px;
	background: var(--color-bg-subtle);
	color: var(--color-text);
}

.app-filter-btn:active {
	transform: scale(0.92);
}

.app-filter-count {
	position: absolute;
	top: -5px;
	right: -5px;
	display: grid;
	place-items: center;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	border-radius: 9px;
	background: var(--color-primary);
	color: var(--color-on-primary);
	font-size: 10px;
	font-weight: 700;
}

.app-chip-scroll {
	display: flex;
	gap: var(--space-2);
	margin: 0 calc(-1 * var(--space-4)) var(--space-3);
	padding: 0 var(--space-4);
	overflow-x: auto;
	scrollbar-width: none;
}

.app-chip-scroll::-webkit-scrollbar {
	display: none;
}

.app-chip {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	gap: 6px;
	height: 36px;
	padding: 0 14px;
	border: 1px solid var(--color-border-strong);
	border-radius: var(--radius-pill);
	background: transparent;
	color: var(--color-text);
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 600;
	white-space: nowrap;
}

.app-chip.is-on {
	border-color: var(--color-primary);
	background: var(--color-primary-soft);
}

.app-chip .icon {
	width: 14px;
	height: 14px;
}

.swipe-row-face > .card {
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.app-btn-hero {
	min-height: 54px;
	border-radius: 14px;
	font-size: 16px;
	font-weight: 700;
}
