/* ==========================================================================
   Project Estimator – Frontend Styles (Phase 7 polish)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. DESIGN TOKENS (CSS Custom Properties)
   -------------------------------------------------------------------------- */
:root {
	--pe-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
	--pe-primary: #2271b1;
	--pe-primary-dark: #135e96;
	--pe-primary-light: rgba(34, 113, 177, 0.08);
	--pe-primary-ring: rgba(34, 113, 177, 0.18);
	--pe-success: #00a32a;
	--pe-success-light: rgba(0, 163, 42, 0.08);
	--pe-danger: #d63638;
	--pe-text: #1d2327;
	--pe-text-muted: rgba(29, 35, 39, 0.62);
	--pe-text-soft: rgba(29, 35, 39, 0.75);
	--pe-border: rgba(29, 35, 39, 0.14);
	--pe-border-hover: rgba(29, 35, 39, 0.28);
	--pe-bg: #fff;
	--pe-bg-subtle: rgba(29, 35, 39, 0.025);
	--pe-radius-sm: 8px;
	--pe-radius-md: 12px;
	--pe-radius-lg: 16px;
	--pe-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
	--pe-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
	--pe-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.10);
	--pe-transition-fast: 160ms ease;
	--pe-transition-normal: 260ms cubic-bezier(0.4, 0, 0.2, 1);
	--pe-transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   1. BASE RESET
   -------------------------------------------------------------------------- */
.pe-app {
	box-sizing: border-box;
	font-family: var(--pe-font);
}

.pe-app *,
.pe-app *::before,
.pe-app *::after {
	box-sizing: inherit;
}

/* --------------------------------------------------------------------------
   2. SHELL
   -------------------------------------------------------------------------- */
.pe-shell {
	border: 1px solid var(--pe-border);
	border-radius: var(--pe-radius-lg);
	padding: 28px 24px;
	background: var(--pe-bg);
	max-width: 740px;
	margin: 24px auto;
	box-shadow: var(--pe-shadow-sm);
}

/* --------------------------------------------------------------------------
   3. WIZARD HEADER
   -------------------------------------------------------------------------- */
.pe-wizard__header {
	margin-bottom: 20px;
}

.pe-wizard__title {
	margin: 0 0 6px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--pe-text);
	letter-spacing: -0.01em;
}

.pe-wizard__subtitle {
	margin: 0;
	font-size: 14px;
	line-height: 1.55;
	color: var(--pe-text-soft);
}

.pe-noscript {
	margin: 0;
	font-size: 16px;
	line-height: 1.5;
	color: var(--pe-text);
}

/* --------------------------------------------------------------------------
   4. PROGRESS BAR (animated + gradient)
   -------------------------------------------------------------------------- */
.pe-progress {
	margin: 16px 0 24px;
}

.pe-progress__meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
	font-size: 13px;
	font-weight: 500;
	color: var(--pe-text-soft);
}

.pe-progress__track {
	width: 100%;
	height: 8px;
	border-radius: 999px;
	background: rgba(29, 35, 39, 0.08);
	overflow: hidden;
	position: relative;
}

.pe-progress__bar {
	height: 100%;
	width: 0%;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--pe-primary), #3a9edb);
	transition: width var(--pe-transition-slow);
	position: relative;
}

.pe-progress__bar::after {
	content: '';
	position: absolute;
	top: 0;
	inset-inline-end: 0;
	width: 24px;
	height: 100%;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.35);
	filter: blur(3px);
	opacity: 0;
	transition: opacity var(--pe-transition-normal);
}

.pe-progress__bar[style*="width"]:not([style*="width: 0"]) .pe-progress__bar::after,
.pe-progress__bar:not([style*="0%"])::after {
	opacity: 1;
}

/* --------------------------------------------------------------------------
   5. STEP TRANSITIONS (fade + slide)
   -------------------------------------------------------------------------- */
.pe-step {
	margin: 0;
	animation: pe-step-enter var(--pe-transition-slow) both;
}

.pe-step__header {
	margin-bottom: 16px;
}

.pe-step__meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.pe-step__num {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 999px;
	border: 1px solid var(--pe-border);
	background: var(--pe-bg-subtle);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--pe-text-muted);
}

.pe-step__progress {
	font-size: 13px;
	font-weight: 500;
	color: var(--pe-text-soft);
}

@keyframes pe-step-enter {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.pe-step__title {
	margin: 0 0 16px;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--pe-text);
}

.pe-step__header .pe-step__title {
	margin: 0;
}

.pe-step__subtitle {
	margin: 10px 0 0;
	font-size: 14px;
	line-height: 1.55;
	color: var(--pe-text-soft);
}

.pe-required {
	color: var(--pe-danger);
	margin-inline-start: 3px;
	font-weight: 400;
}

.pe-step__hint {
	margin-top: 12px;
	min-height: 1.3em;
	font-size: 13px;
	line-height: 1.4;
	color: var(--pe-danger);
	transition: opacity var(--pe-transition-fast);
}

/* --------------------------------------------------------------------------
   6. SERVICE CARDS (rich hover + selected)
   -------------------------------------------------------------------------- */
.pe-cards {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}

.pe-card__button {
	width: 100%;
	text-align: start;
	display: flex;
	flex-direction: column;
	border: 1.5px solid var(--pe-border);
	border-radius: var(--pe-radius-md);
	padding: 18px 16px;
	background: var(--pe-bg);
	cursor: pointer;
	position: relative;
	transition:
		border-color var(--pe-transition-fast),
		box-shadow var(--pe-transition-fast),
		transform var(--pe-transition-fast),
		background-color var(--pe-transition-fast);
}

.pe-card__media {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: 10px;
	overflow: hidden;
	background: rgba(29, 35, 39, 0.06);
	margin-bottom: 12px;
}

.pe-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pe-card__button:hover {
	border-color: var(--pe-border-hover);
	box-shadow: var(--pe-shadow-md);
	transform: translateY(-2px);
	background: var(--pe-bg-subtle);
}

.pe-card__button:active {
	transform: translateY(0);
	box-shadow: var(--pe-shadow-sm);
}

.pe-card__button.is-selected {
	border-color: var(--pe-primary);
	background: var(--pe-primary-light);
	box-shadow: 0 0 0 3px var(--pe-primary-ring), var(--pe-shadow-sm);
}

.pe-card__button.is-selected::after {
	content: '✓';
	position: absolute;
	top: 10px;
	inset-inline-end: 12px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--pe-primary);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	animation: pe-check-pop 280ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pe-check-pop {
	from {
		transform: scale(0);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

.pe-card__title {
	display: block;
	font-weight: 600;
	font-size: 15px;
	line-height: 1.3;
	color: var(--pe-text);
	margin-bottom: 6px;
}

.pe-card__desc {
	display: block;
	font-size: 13px;
	line-height: 1.5;
	color: var(--pe-text-muted);
}

/* --------------------------------------------------------------------------
   6b. STEP GROUP QUESTIONS (multi-question steps)
   -------------------------------------------------------------------------- */
.pe-questions {
	display: grid;
	gap: 16px;
}

.pe-question {
	border: 1.5px solid var(--pe-border);
	border-radius: var(--pe-radius-md);
	padding: 14px 14px 12px;
	background: var(--pe-bg);
}

.pe-question__title {
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 650;
	line-height: 1.35;
	color: var(--pe-text);
}

/* --------------------------------------------------------------------------
   7. QUESTION CHOICES (radio / checkbox cards)
   -------------------------------------------------------------------------- */
.pe-fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	display: grid;
	gap: 10px;
}

.pe-choice {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 16px;
	border: 1.5px solid var(--pe-border);
	border-radius: var(--pe-radius-sm);
	background: var(--pe-bg);
	cursor: pointer;
	transition:
		border-color var(--pe-transition-fast),
		background-color var(--pe-transition-fast),
		box-shadow var(--pe-transition-fast);
}

.pe-choice:hover {
	border-color: var(--pe-border-hover);
	background: var(--pe-bg-subtle);
}

.pe-choice:has(input:checked) {
	border-color: var(--pe-primary);
	background: var(--pe-primary-light);
	box-shadow: 0 0 0 2px var(--pe-primary-ring);
}

.pe-choice input {
	margin-top: 2px;
	accent-color: var(--pe-primary);
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

.pe-choice__label {
	font-size: 14px;
	line-height: 1.4;
	color: var(--pe-text);
}

/* --------------------------------------------------------------------------
   8. CONTACT FORM
   -------------------------------------------------------------------------- */
.pe-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.pe-grid .pe-field:last-child {
	grid-column: 1 / -1;
}

.pe-label {
	display: block;
	margin: 0 0 6px;
	font-size: 13px;
	font-weight: 500;
	color: var(--pe-text-soft);
}

.pe-input {
	width: 100%;
	padding: 11px 14px;
	border: 1.5px solid var(--pe-border);
	border-radius: var(--pe-radius-sm);
	font-size: 14px;
	line-height: 1.4;
	color: var(--pe-text);
	background: var(--pe-bg);
	transition: border-color var(--pe-transition-fast), box-shadow var(--pe-transition-fast);
}

.pe-input:focus {
	outline: none;
	border-color: var(--pe-primary);
	box-shadow: 0 0 0 3px var(--pe-primary-ring);
}

.pe-input::placeholder {
	color: var(--pe-text-muted);
}

/* --------------------------------------------------------------------------
   9. SUBMITTING STATE
   -------------------------------------------------------------------------- */
.pe-wizard.is-submitting {
	opacity: 0.85;
	pointer-events: none;
}

.pe-wizard.is-submitting .pe-btn {
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   10. NAVIGATION
   -------------------------------------------------------------------------- */
.pe-nav {
	margin-top: 24px;
	display: flex;
	justify-content: space-between;
	gap: 12px;
}

/* --------------------------------------------------------------------------
   11. BUTTONS (consistent + loading + hover)
   -------------------------------------------------------------------------- */
.pe-btn {
	border-radius: var(--pe-radius-sm);
	padding: 11px 20px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	border: 1.5px solid transparent;
	cursor: pointer;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition:
		background-color var(--pe-transition-fast),
		border-color var(--pe-transition-fast),
		box-shadow var(--pe-transition-fast),
		transform var(--pe-transition-fast),
		opacity var(--pe-transition-fast);
}

.pe-btn:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: var(--pe-shadow-sm);
}

.pe-btn:active:not(:disabled) {
	transform: translateY(0);
	box-shadow: none;
}

.pe-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
}

.pe-btn--primary {
	background: var(--pe-primary);
	border-color: var(--pe-primary);
	color: #fff;
}

.pe-btn--primary:hover:not(:disabled) {
	background: var(--pe-primary-dark);
	border-color: var(--pe-primary-dark);
}

.pe-btn--ghost {
	background: var(--pe-bg);
	border-color: var(--pe-border);
	color: var(--pe-text);
}

.pe-btn--ghost:hover:not(:disabled) {
	border-color: var(--pe-border-hover);
	background: var(--pe-bg-subtle);
}

/* Loading spinner (added/removed by JS) */
.pe-btn.is-loading {
	color: transparent;
	pointer-events: none;
}

.pe-btn.is-loading::after {
	content: '';
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: pe-spin 600ms linear infinite;
}

.pe-btn--ghost.is-loading::after {
	border-color: rgba(29, 35, 39, 0.15);
	border-top-color: var(--pe-text);
}

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

/* --------------------------------------------------------------------------
   12. EMPTY STATE
   -------------------------------------------------------------------------- */
.pe-empty {
	padding: 20px;
	border: 1.5px dashed var(--pe-border);
	border-radius: var(--pe-radius-md);
	background: var(--pe-bg-subtle);
	text-align: center;
}

.pe-empty__title {
	margin: 0 0 6px;
	font-weight: 600;
	font-size: 15px;
	color: var(--pe-text);
}

.pe-empty__body {
	margin: 0;
	font-size: 14px;
	color: var(--pe-text-muted);
}

/* --------------------------------------------------------------------------
   13. SUCCESS SCREEN (polished)
   -------------------------------------------------------------------------- */
.pe-success {
	padding-top: 8px;
	animation: pe-step-enter var(--pe-transition-slow) both;
}

.pe-success__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--pe-success-light);
	margin-bottom: 18px;
	animation: pe-check-pop 450ms cubic-bezier(0.34, 1.56, 0.64, 1) 200ms both;
}

.pe-success__icon svg {
	width: 28px;
	height: 28px;
	stroke: var(--pe-success);
	fill: none;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.pe-success__title {
	margin: 0 0 8px;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--pe-text);
	letter-spacing: -0.01em;
}

.pe-success__lead {
	margin: 0 0 20px;
	font-size: 15px;
	line-height: 1.55;
	color: var(--pe-text-soft);
}

/* --------------------------------------------------------------------------
   14. SUMMARY (success screen)
   -------------------------------------------------------------------------- */
.pe-summary {
	border: 1.5px solid var(--pe-border);
	border-radius: var(--pe-radius-md);
	padding: 4px 16px;
	background: var(--pe-bg-subtle);
	margin-bottom: 20px;
}

.pe-summary__row {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 12px;
	padding: 14px 0;
	border-bottom: 1px solid var(--pe-border);
}

.pe-summary__row:last-child {
	border-bottom: 0;
}

.pe-summary__label {
	font-size: 13px;
	font-weight: 500;
	color: var(--pe-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.pe-summary__value {
	font-size: 14px;
	line-height: 1.5;
	color: var(--pe-text);
}

.pe-summary__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.pe-summary__item {
	padding: 3px 0;
	position: relative;
	padding-inline-start: 16px;
}

.pe-summary__item::before {
	content: '•';
	position: absolute;
	inset-inline-start: 0;
	color: var(--pe-primary);
	font-weight: 700;
}

/* --------------------------------------------------------------------------
   15. RTL (Arabic-first)
   -------------------------------------------------------------------------- */
.pe-shell[dir="rtl"] {
	direction: rtl;
	text-align: start;
}

.pe-shell[dir="rtl"] .pe-step__num,
.pe-shell[dir="rtl"] .pe-summary__label {
	text-transform: none;
	letter-spacing: 0;
}

.pe-shell[dir="rtl"] .pe-progress__bar {
	/* Fill from the right edge in RTL. */
	margin-inline-end: auto;
	margin-inline-start: 0;
	background: linear-gradient(-90deg, var(--pe-primary), #3a9edb);
}

/* --------------------------------------------------------------------------
   16. RESPONSIVE (mobile-first polish)
   -------------------------------------------------------------------------- */
@media (max-width: 520px) {
	.pe-shell {
		padding: 20px 16px;
		margin: 12px 8px;
		border-radius: var(--pe-radius-md);
	}

	.pe-wizard__title {
		font-size: 19px;
	}

	.pe-cards {
		grid-template-columns: 1fr;
	}

	.pe-card__button {
		padding: 16px 14px;
	}

	.pe-grid {
		grid-template-columns: 1fr;
	}

	.pe-grid .pe-field:last-child {
		grid-column: auto;
	}

	.pe-choice {
		padding: 14px;
	}

	.pe-summary__row {
		grid-template-columns: 1fr;
		gap: 4px;
	}

	.pe-nav {
		flex-direction: column-reverse;
	}

	.pe-btn {
		width: 100%;
		padding: 13px 20px;
		min-height: 48px;
	}

	.pe-success__icon {
		width: 48px;
		height: 48px;
	}

	.pe-success__icon svg {
		width: 24px;
		height: 24px;
	}
}

/* Larger tap targets for touch */
@media (pointer: coarse) {
	.pe-card__button {
		min-height: 64px;
	}

	.pe-choice {
		min-height: 52px;
	}

	.pe-btn {
		min-height: 48px;
	}

	.pe-input {
		min-height: 48px;
		font-size: 16px; /* prevent iOS zoom */
	}
}
