/* Project pages: event / quote / material */

:root {
	--ios-blue: #007aff;
	--ios-red: #ff3b30;
	--ios-bg: #f2f2f7;
	--ios-surface: #ffffff;
	--ios-border: rgba(200, 200, 200, .16);
	--ios-muted: rgba(60, 60, 67, .6);
	--ios-shadow: 0 8px 22px rgba(0, 0, 0, .06);
	--lagex-header-h: 3.6rem;
	--ios-radius: 16px;
	--ios-radius-lg: 20px;
	--ios-tap-bg: rgba(120, 120, 128, .10);
}

@media (prefers-color-scheme: dark) {
	:root {
		--ios-bg: #000000;
		--ios-surface: #1c1c1e;
		--ios-border: rgba(84, 84, 88, .65);
		--ios-muted: rgba(235, 235, 245, .6);
		--ios-shadow: 0 8px 22px rgba(0, 0, 0, .35);
	}
}

body {
	background: var(--ios-bg);
	color: var(--text);
	-webkit-tap-highlight-color: transparent;
	scroll-behavior: smooth;
}

.proj-wrap {
	padding: 1rem;
	max-width: 720px;
	margin: 0 auto;
}

/* Tab panels for merged page */
.proj-tabpanel {
	display: none;
}

/* Detail table for services/materials (full table) */
.proj-detail-table {
	width: 100%;
	margin-top: .35rem;
	border-collapse: collapse;
	border: 1px solid var(--ios-border);
	border-radius: 4px;
	overflow: hidden;
	background: var(--ios-surface);
}

.proj-detail-table th,
.proj-detail-table td {
	padding: .35rem .6rem;
	font-size: 12px;
	border-top: 1px solid var(--ios-border);
	vertical-align: top;
}

.proj-detail-table thead th {
	background: rgba(120, 120, 128, .08);
	color: var(--text);
}

.proj-detail-table tr:first-child th,
.proj-detail-table tr:first-child td {
	border-top: none;
}

.proj-detail-table th {
	width: 92px;
	text-align: left;
	color: var(--ios-muted);
	font-weight: 600;
	white-space: nowrap;
}

.proj-detail-table td {
	color: var(--text);
	word-break: break-word;
}

.proj-detail-table.is-multi {
	table-layout: fixed;
}

.proj-detail-table.is-multi th,
.proj-detail-table.is-multi td {
	white-space: normal;
	word-break: break-word;
}

.proj-detail-table.is-multi th {
	width: auto;
}

.proj-tabpanel.is-active {
	display: block;
}

.proj-tabpanel.is-enter {
	animation: projTabEnter 220ms ease both;
}

.proj-tabpanel.is-leave {
	animation: projTabLeave 180ms ease both;
}

@keyframes projTabEnter {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes projTabLeave {
	from { opacity: 1; transform: translateY(0); }
	to { opacity: 0; transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
	.proj-tabpanel,
	.proj-tabpanel.is-active {
		animation: none;
	}
}

/* Anchor jump offset for fixed header */
.proj-anchor {
	scroll-margin-top: calc(var(--lagex-header-h) + env(safe-area-inset-top) + 1rem);
}

/* ===== Stronger iOS-like components ===== */

.ios-sticky {
	position: sticky;
	top: calc(var(--lagex-header-h) + env(safe-area-inset-top) + .35rem);
	z-index: 40;
}

.ios-seg {
	position: relative;
	display: flex;
	gap: 4px;
	padding: 4px;
	border-radius: 40px;
	border: 1px solid var(--ios-border);
	background: rgba(120, 120, 128, .14);
	backdrop-filter: saturate(180%) blur(16px);
}

/* Sliding active indicator (enabled by JS: add .is-enhanced + set --seg-x/--seg-w) */
.ios-seg.is-enhanced::before {
	content: '';
	position: absolute;
	top: 4px;
	bottom: 4px;
	left: 0;
	width: var(--seg-w, 0px);
	transform: translateX(var(--seg-x, 0px));
	background: var(--ios-surface);
	border-radius: 40px;
	box-shadow: 0 1px 2px rgba(0,0,0,.12);
	transition:
		transform 260ms cubic-bezier(.2,.8,.2,1),
		width 260ms cubic-bezier(.2,.8,.2,1);
}


/* ===== Admin top tabs (proj-tabs) ===== */
.proj-tabs {
	position: sticky;
	top: calc(var(--lagex-header-h) + env(safe-area-inset-top) + .35rem);
	z-index: 40;
	display: flex;
	gap: 4px;
	padding: 4px;
	margin-top: .75rem;
	border-radius: 40px;
	border: 1px solid var(--ios-border);
	background: rgba(120, 120, 128, .14);
	backdrop-filter: saturate(180%) blur(18px);
}

.proj-tab {
	flex: 1 1 0;
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	padding: .55rem .65rem;
	border: 0;
	border-radius: 40px;
	color: var(--ios-muted);
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	user-select: none;
	-webkit-user-select: none;
	transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.proj-tab:active {
	transform: scale(.99);
}

.proj-tab.is-active {
	color: var(--text);
	background: var(--ios-surface);
	box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.proj-tabs.is-enhanced::before {
	content: '';
	position: absolute;
	top: 4px;
	bottom: 4px;
	left: 0;
	width: var(--seg-w, 0px);
	transform: translateX(var(--seg-x, 0px));
	background: var(--ios-surface);
	border-radius: 40px;
	box-shadow: 0 1px 2px rgba(0,0,0,.12);
	transition:
		transform 260ms cubic-bezier(.2,.8,.2,1),
		width 260ms cubic-bezier(.2,.8,.2,1);
}

.proj-tabs.is-enhanced .proj-tab {
	position: relative;
	z-index: 1;
}

.proj-tabs.is-enhanced .proj-tab.is-active {
	background: transparent;
	box-shadow: none;
}

/* ===== Admin helper blocks ===== */
.proj-admin-sum {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
}

.proj-pre {
	white-space: pre-wrap;
	word-break: break-word;
	background: rgba(2, 6, 23, .03);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: .6rem;
	font-size: 12px;
	margin: .5rem 0 0;
}

@media (prefers-color-scheme: dark) {
	.proj-pre {
		background: rgba(255, 255, 255, .04);
	}
}

.proj-form-row {
	display: flex;
	gap: .5rem;
	flex-wrap: wrap;
	align-items: center;
}

.proj-form-row .cfg-input,
.proj-form-row .cfg-select {
	min-width: 180px;
}

.proj-hr {
	border: none;
	border-top: 1px solid var(--border);
	margin: .75rem 0;
}

.proj-req-actions {
	display: flex;
	gap: .5rem;
	align-items: center;
	flex-wrap: wrap;
	justify-content: flex-end;
	min-width: 120px;
}

.proj-req-panel {
	margin-top: .75rem;
	padding-top: .75rem;
	border-top: 1px solid var(--border);
}

.ios-seg a {
	flex: 1 1 0;
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	border-radius: 40px;
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	color: var(--ios-muted);
	user-select: none;
	-webkit-user-select: none;
	transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.ios-seg a:active {
	transform: scale(.99);
}

.ios-seg a.is-active {
	color: var(--text);
	background: var(--ios-surface);
	box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.ios-seg.is-enhanced a.is-active {
	background: transparent;
	box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
	.ios-seg.is-enhanced::before {
		transition: none;
	}

	.proj-tabs.is-enhanced::before {
		transition: none;
	}
}

/* ===== Progress segmented bar (for "进度" cards) ===== */
.proj-progress {
	--prog-color: rgba(0, 122, 255, .55);
	display: flex;
	gap: 6px;
	margin-top: .55rem;
}

.proj-progress .seg {
	flex: 1 1 0;
	height: 7px;
	border-radius: 999px;
	background: rgba(120, 120, 128, .18);
}

.proj-progress .seg.is-on {
	background: var(--prog-color);
}

.proj-progress .seg.is-cur {
	filter: saturate(120%);
}

.proj-progress.is-new { --prog-color: rgba(14, 165, 233, .55); }
.proj-progress.is-acc { --prog-color: rgba(139, 92, 246, .55); }
.proj-progress.is-prog { --prog-color: rgba(245, 158, 11, .6); }
.proj-progress.is-done { --prog-color: rgba(34, 197, 94, .6); }
.proj-progress.is-unpaid { --prog-color: rgba(239, 68, 68, .62); }
.proj-progress.is-closed { --prog-color: rgba(148, 163, 184, .6); }

/* Inset grouped list (optional helper) */
.ios-group {
	overflow: hidden;
}

/* iOS-like card styling for cfg components */
.proj-wrap .cfg-card {
	border-radius: var(--ios-radius);
	border: 1px solid var(--ios-border);
	background: var(--ios-surface);
	box-shadow: var(--ios-shadow);
	padding: 1rem;
}

.proj-wrap .cfg-section {
	border-top: none;
	padding-top: .75rem;
	margin-top: .75rem;
}

.proj-wrap .cfg-input,
.proj-wrap .cfg-select,
.proj-wrap .cfg-textarea {
	border-radius: 12px;
	border: 1px solid var(--ios-border);
	background: rgba(120, 120, 128, .08);
	font-size: 16px; /* avoid iOS zoom */
	padding: .7rem .9rem;
}

.proj-wrap .cfg-input:focus,
.proj-wrap .cfg-select:focus,
.proj-wrap .cfg-textarea:focus {
	border-color: var(--ios-blue);
}

@media (prefers-color-scheme: dark) {
	.proj-wrap .cfg-input,
	.proj-wrap .cfg-select,
	.proj-wrap .cfg-textarea {
		background: rgba(120, 120, 128, .16);
	}
}

.proj-wrap .cfg-textarea {
	min-height: 120px;
}

.proj-wrap .cfg-btn {
	display: inline-flex;
	align-items: center;
    justify-content: center;
    gap: 6px;
	border-radius: 12px;
	min-height: 44px;
	padding: .65rem 1rem;
	border-color: var(--ios-border);
	background: rgba(120, 120, 128, .10);
}

.proj-wrap .cfg-btn:active {
	transform: scale(.99);
}

.proj-wrap .cfg-btn.cfg-btn-primary {
	background: var(--ios-blue);
	border-color: rgba(0, 122, 255, .25);
	color: #fff;
}

.proj-wrap .cfg-btn.cfg-btn-primary:hover {
	background: var(--ios-blue);
}

.proj-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
}

.proj-title {
	font-size: 20px;
	font-weight: 600;
	color: var(--text);
}

.proj-sub {
	margin-top: .25rem;
	font-size: 12px;
	color: var(--ios-muted);
	white-space: nowrap;
}

.proj-mini {
	font-size: 12px;
	color: var(--muted);
}

.proj-badge {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	padding: .15rem .5rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	font-size: 12px;
	color: var(--muted);
}

.proj-badge.is-new {
	color: #0ea5e9;
	border-color: rgba(14, 165, 233, .35);
	background: rgba(14, 165, 233, .08);
}

.proj-badge.is-prog {
	color: #f59e0b;
	border-color: rgba(245, 158, 11, .35);
	background: rgba(245, 158, 11, .08);
}

.proj-badge.is-done {
	color: #22c55e;
	border-color: rgba(34, 197, 94, .35);
	background: rgba(34, 197, 94, .08);
}

.proj-badge.is-acc {
	color: #8b5cf6;
	border-color: rgba(139, 92, 246, .35);
	background: rgba(139, 92, 246, .08);
}

.proj-badge.is-closed {
	color: #94a3b8;
	border-color: rgba(148, 163, 184, .35);
	background: rgba(148, 163, 184, .08);
}

.proj-badge.is-unpaid {
	color: #ef4444;
	border-color: rgba(239, 68, 68, .35);
	background: rgba(239, 68, 68, .08);
}

.proj-kv {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: .5rem .75rem;
	font-size: 13px;
	margin: .5rem 0 0;
}

.proj-kv .k {
	color: var(--muted);
}

.proj-row {
	display: grid;
	grid-template-columns: 1fr;
	gap: .45rem;
	align-items: start;
	margin-bottom: .75rem;
}

.proj-row .proj-label {
	font-size: 13px;
	color: var(--ios-muted);
	padding-top: 0;
}

.proj-actions {
	display: flex;
	gap: .5rem;
	align-items: center;
	justify-content: flex-end;
	margin-top: .75rem;
}

/* Sticky bottom action bar (opt-in by adding class) */
.proj-actions.ios-bottom-bar {
	position: sticky;
	bottom: 0;
	z-index: 35;
	margin: .75rem -1rem -1rem;
	padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
	border-top: 1px solid var(--ios-border);
	background: rgba(242, 242, 247, .82);
	backdrop-filter: saturate(180%) blur(18px);
	border-radius: 0 0 var(--ios-radius) var(--ios-radius);
}

@media (prefers-color-scheme: dark) {
	.proj-actions.ios-bottom-bar {
		background: rgba(28, 28, 30, .72);
	}
}

.proj-msg {
	margin-top: .75rem;
	font-size: 13px;
	color: var(--ios-muted);
}

.proj-msg.is-ok {
	color: rgba(43, 189, 86, 1);
}

.proj-msg.is-err {
	color: rgba(255, 21, 21, .95);
}

.proj-mat-list {
	display: flex;
	flex-direction: column;
	gap: .5rem;
}

.proj-mat-item {
	display: grid;
	grid-template-columns: 1.2fr .8fr .8fr;
	gap: .5rem;
	align-items: center;
	border: 1px solid var(--ios-border);
	border-radius: 6px;
	padding: .75rem;
	background: var(--ios-surface);
	box-shadow: 0 1px 0 rgba(0,0,0,.02);
	transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

/* Service options in booking form: title only */
.proj-svc-opt {
	grid-template-columns: 1fr;
	cursor: pointer;
}

.proj-svc-opt__main {
	display: flex;
	align-items: center;
	gap: .6rem;
	flex-wrap: wrap;
}

.proj-svc-opt input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--ios-blue);
}

.proj-svc-opt__title {
	font-size: 14px;
	font-weight: 600;
}

.proj-mat-item:active {
	transform: scale(.995);
	background: var(--ios-tap-bg);
}

.proj-mat-item .muted {
	color: var(--ios-muted);
	font-size: 12px;
}

.proj-mat-item code, .proj-mat-left code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 13px;
	font-weight: 800;
}

/* Material list card with optional thumbnail */
.proj-mat-item--material {
	grid-template-columns: 1fr auto;
	align-items: start;
}

.proj-mat-item--material.has-thumb {
	grid-template-columns: 72px 1fr auto;
}

.proj-mat-thumb {
	width: 72px;
	height: 72px;
	border-radius: 14px;
	border: 1px solid var(--ios-border);
	object-fit: cover;
	background: rgba(120, 120, 128, .08);
}

.proj-mat-main {
	min-width: 0;
}

.proj-mat-side {
	text-align: right;
	white-space: nowrap;
}

/* Front material rows (compact list) */
.proj-mat-row {
	padding: 8px 0;
	border-bottom: 1px solid var(--ios-border);
}

.proj-mat-row__left {
	display: flex;
	align-items: center;
	gap: .65rem;
	min-width: 0;
}

.proj-mat-row__thumb {
	height: 70px;
	border-radius: 12px;
	border: 1px solid var(--ios-border);
	object-fit: cover;
	background: rgba(120, 120, 128, .08);
	flex: 0 0 auto;
}

.proj-mat-row__text {
	min-width: 0;
	display: flex;
    flex-direction: column;
    gap: 2px;
}

.proj-mat-row__name {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.proj-mat-row__desc {
	font-size: 12px;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}


.proj-taglist {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
}

.proj-tag {
	font-size: 10px;
	line-height: 1;
	padding: .25rem .55rem;
	border-radius: 999px;
	border: 1px solid var(--ios-border);
	background: rgba(120, 120, 128, .08);
	color: var(--ios-muted);
	white-space: nowrap;
}

.proj-mat-left {
	text-align: left;
	white-space: nowrap;
	font-size: 12px;
}

/* Material category filters (multi-select chips) */
.proj-chipbar {
	display: flex;
	flex-wrap: nowrap;
	gap: .35rem;
	margin: .6rem 0 .2rem;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 2px;
}

.proj-chipbar::-webkit-scrollbar { height: 6px; }
.proj-chipbar::-webkit-scrollbar-thumb {
	background: rgba(120, 120, 128, .25);
	border-radius: 999px;
}
.proj-chipbar::-webkit-scrollbar-track { background: transparent; }

.proj-chip {
	appearance: none;
	border: 1px solid var(--ios-border);
	background: var(--ios-surface);
	color: var(--text);
	border-radius: 4px;
	padding: .45rem 1rem;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	user-select: none;
	flex: 0 0 auto;
}

.proj-chip:active {
	background: var(--ios-tap-bg);
}

.proj-chip.is-active {
	border-color: rgba(0, 122, 255, .35);
	background: rgba(0, 122, 255, .12);
	color: var(--ios-blue);
}

/* When showing ALL categories, hide group titles for a cleaner list */
[data-mat-section].is-all [data-mat-group-title] {
	display: none;
}

/* Admin upload preview */
.proj-upload-preview {
	display: none;
	max-width: 180px;
	max-height: 180px;
	border-radius: 12px;
	border: 1px solid var(--ios-border);
	object-fit: cover;
	background: rgba(120, 120, 128, .08);
}

.proj-upload-preview.is-visible {
	display: block;
}

.proj-upload-preview.is-pending {
	outline: 2px dashed rgba(0, 122, 255, .45);
	outline-offset: 2px;
}

/* Custom file input */
.proj-file {
	display: flex;
	align-items: center;
	gap: .55rem;
	flex-wrap: wrap;
}

.proj-file__input {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.proj-file__btn {
	border-radius: 12px;
}

.proj-file__name {
	font-size: 12px;
	color: rgba(0, 0, 0, .55);
	max-width: 100%;
	word-break: break-all;
}

/* Category picker stack */
.proj-field-stack {
	display: flex;
	flex-direction: column;
	gap: .35rem;
}

.proj-total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: .75rem;
	padding: .75rem;
	border: 1px solid var(--ios-border);
	border-radius: 14px;
	background: var(--ios-surface);
	box-shadow: 0 1px 0 rgba(0,0,0,.02);
}

.proj-total b {
	color: var(--text);
}

@media (prefers-color-scheme: dark) {
	.proj-mat-item,
	.proj-total {
		background: var(--ios-surface);
	}
}

@media (max-width: 860px) {
	.proj-wrap { padding: .5rem; }

	.proj-mat-item {
		grid-template-columns: 1fr;
	}

	.proj-mat-item--material,
	.proj-mat-item--material.has-thumb {
		grid-template-columns: 1fr;
	}

	.proj-mat-thumb {
		width: 100%;
		height: 180px;
	}

	.proj-actions .cfg-btn {
		width: 100%;
	}

	.proj-title {
		font-size: 22px;
		letter-spacing: -.01em;
	}

	.ios-seg a {
		min-height: 34px;
		font-size: 13.5px;
	}
}
