/*
Copyright (c) 2026, Cognosys (Pty) Ltd : eugene.parsons@cognosys.co
License: GNU General Public License v3. See license.txt
*/

/*
BEM naming					: .pess-block__element--modifier
CSS variables				: Use Frappe theme variables and fallbacks, eg (var(--x, fallback))
WCAG contrast				: Ensure light and dark theme have sufficient contrast on background and foreground fallback/default colours
Responsive breakpoints		: Mobile-first with 640px and 480px breakpoints
Accessibility audit			: Run through WAVE or Lighthouse
*/

/* ====	RESPONSIVE === */

@media (min-width: 640px) {
	.pess-modal {
		max-width: 500px;
		max-height: 80vh;
		margin: auto;
		border-radius: 16px;
	}
	.pess-modal-overlay {
		align-items: center;
	}
}

@media (max-width: 480px) {
	.pess-actions-row {
		flex-direction: column;
	}
	.pess-btn {
		width: 100%;
	}
	.pess-stats-row {
		gap: 8px;
	}
	.pess-stat-card {
		padding: 6px 10px;
	}
}

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

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* === FF Overrides === */
/* Open DevTools > Inspect the element > Computed tab > search for the CSS > Source file will show you exactly which FF CSS file applies */

.pess-section-title {
	margin-top: 0;				/* website.bundle.css : h2 {font-size: 2.5rem; margin-top: 4rem;} where 4rem ~ 64px */
}

/* === PESS Colours === */

:root {
	--pess-primary: #274e81;
	--pess-primary-light: #3972aa;
	--pess-success: #10b981;
	--pess-danger: #ef4444;
	--pess-warning: #f59e0b;
	--pess-section-upcoming: #cf804a;
	--pess-section-active: #4a9acf;
	--pess-section-completed: #4acf91;
	--pess-card-bg: #cfd0d3;
	--pess-btn-bg-dark: #686f77;
	--pess-btn-bg-light: #78808a;
	--status-dispatched-bg: #fef3c7;
	--status-dispatched-text: #92400e;
	--status-assessed-bg: #dbeafe;
	--status-assessed-text: #1e40af;
	--status-quoted-bg: #e9d5ff;
	--status-quoted-text: #6b21a8;
	--status-customeraccepted-bg: #d1fae5;
	--status-customeraccepted-text: #065f46;
	--status-default-bg: #fee2e2;
	--status-default-text: #991b1b;
}

/* === DARK MODE === */

@media (prefers-color-scheme: dark) {
	:root {
		--status-dispatched-bg: #fac6a9;
		--status-dispatched-text: #4f433c;
		--status-assessed-bg: #b0c4fc;
		--status-assessed-text: #3f4a57;
		--status-quoted-bg: #dbb6ff;
		--status-quoted-text: #5f4f70;
		--status-customeraccepted-bg: #b5fdd8;
		--status-customeraccepted-text: #5a7e6b;
	}

	svg.pess-icon {
		stroke: currentColor;
	}
}

/* === ICON SYSTEM === */

.pess-icon,
svg.pess-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	vertical-align: middle;
	box-sizing: border-box;
}

.pess-icon--sm,
svg.pess-icon--sm {
	width: 18px;
	height: 18px;
}

.pess-icon--md,
svg.pess-icon--md {
	width: 24px;
	height: 24px;
}

.pess-icon--lg,
svg.pess-icon--lg {
	width: 28px;
	height: 28px;
}

.pess-icon--xl,
svg.pess-icon--xl {
	width: 32px;
	height: 32px;
}

/* Font Awesome specific */
.pess-icon.fa {
	font-size: 18px;
	line-height: 1;
}

.pess-icon.fa.pess-icon--sm { font-size: 14px; }
.pess-icon.fa.pess-icon--md { font-size: 18px; }
.pess-icon.fa.pess-icon--lg { font-size: 24px; }
.pess-icon.fa.pess-icon--xl { font-size: 32px; }

/* Lucide SVG specific */
svg.pess-icon {
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	fill: none;
}

/* Icon color utilities */
.pess-icon--primary { color: var(--pess-primary); }
.pess-icon--muted { color: var(--text-muted, #666); }
.pess-icon--white { color: #fff; }
.pess-icon--success { color: var(--pess-success); }

/* === LAYOUT === */

.pess-portal-container {
	max-width: 600px;
	min-height: 100vh;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: var(--bg-color, #f8f9fa);
	margin: 0 auto;
	padding: 0;
	/* padding-left: 1rem; */
	/* padding-right: 1rem; */
}

/* === DASHBOARD HEADER === */

.pess-upcoming {
	border: 2px solid var(--pess-section-upcoming);
}
.pess-active {
	border: 2px solid var(--pess-section-active);
}
.pess-completed {
	border: 2px solid var(--pess-section-completed);
}

.pess-dashboard-header {
	background: var(--card-bg, #fff);
	/* background: linear-gradient(135deg, var(--pess-primary) 0%, var(--pess-primary-light) 100%); */
	/* background: var(--pess-card-bg, #fff); */
	color: var(--text-color, #1f2937);
	/* color: white; */
	box-shadow: 0 2px 8px rgba(0,0,0,0.08);
	margin-bottom: 20px;
	border: 2px solid var(--pess-primary, #1e3a5f);
	border-radius: 12px;
	padding: 20px;
}

.pess-dashboard-header__logo {
	height: 48px;
	width: auto;
	object-fit: contain;
	margin-right: 8px;
	vertical-align: middle;
}

.pess-dashboard-header__title {
	color: var(--pess-primary, #1e3a5f);
	font-size: 1.3em;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 5px 0;
}

.pess-dashboard-header__subtitle {
	color: var(--text-muted, #666);
	opacity: 0.85;
	font-size: 0.95em;
	text-align: center;
}

.pess-dashboard-header__name {
	color: var(--pess-primary);
	opacity: 1;
	font-size: 1.05em;
	font-weight: 700;
	text-align: center;
}

.pess-stats-row {
	display: flex;
	gap: 15px;
	margin-top: 15px;
}

.pess-stat-card {
	/* background: rgba(255, 255, 255, 0.15); */
	background: var(--gray-100, #f3f4f6);
	color: var(--text-color, #1f2937);
	text-align: center;
	flex: 1;
	backdrop-filter: blur(4px);
	/* backdrop-filter: none; */
	border-radius: 8px;
	padding: 8px 16px;
}

.pess-stat-card__value {
	font-size: 1.3em;
	font-weight: 700;
}

.pess-stat-card__label {
	font-size: 0.65em;
	opacity: 0.8;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* === COLLAPSIBLE === */

.pess-collapsible {
	margin-bottom: 8px;
}

.pess-collapsible > summary {
	cursor: pointer;
	user-select: none;
	display: flex;
	align-items: center;
	gap: 6px;
}

.pess-collapsible > summary::marker {
	color: var(--text-muted, #666);
}

.pess-collapsible__count {
	margin-left: auto;
	background: var(--gray-100, #f3f4f6);
	color: var(--text-muted, #666);
	font-size: 0.95em;
	padding: 2px 8px;
	border-radius: 12px;
	font-weight: 600;
}

.pess-collapsible__content {
	padding-top: 4px;
}

/* === SECTIONS === */

.pess-section--upcoming {
	margin-top: 10px;
	margin-bottom: 20px;
	border: 2px solid var(--pess-section-upcoming);
	border-radius: 12px;
	padding-top: 0;
	padding-bottom: 0;
}

.pess-section--active {
	margin-top: 10px;
	margin-bottom: 20px;
	border: 2px solid var(--pess-section-active);
	border-radius: 12px;
	padding-top: 0;
	padding-bottom: 0;
}

.pess-section--completed {
	margin-top: 10px;
	margin-bottom: 20px;
	border: 2px solid var(--pess-section-completed);
	border-radius: 12px;
	padding-top: 0;
	padding-bottom: 0;
}

.pess-section-title {
	font-size: 0.8em;
	font-weight: 600;
	color: var(--text-muted, #666);
	text-transform: uppercase;
	letter-spacing: 0.5px;
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 0;
	padding: 10px;
}

/* === SERVICE CARDS === */

.pess-service-card {
	background: var(--card-bg, #fff);
	box-shadow: 0 1px 3px rgba(0,0,0,0.05);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
	margin-bottom: 12px;
	border: 1px solid var(--border-color, #e5e7eb);
	border-radius: 12px;
	padding: 16px;
}

.pess-service-card:hover {
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
	transform: translateY(-1px);
}

.pess-service-card:focus-visible {
	outline: 2px solid var(--pess-primary);
	outline-offset: 2px;
}

.pess-service-card--completed {
	opacity: 0.7;
}

.pess-service-card__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

.pess-service-card__id {
	font-weight: 600;
	color: var(--pess-primary);
	font-size: 1.0em;
}

.pess-service-card__id--completed {
	color: var(--text-muted, #666);
}

/* Status Badges */
.pess-status-badge {
	font-size: 0.75em;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
	border-radius: 20px;
	padding: 4px 10px;
}

.pess-status-badge--dispatched {
	background: var(--status-dispatched-bg);
	color: var(--status-dispatched-text);
}

.pess-status-badge--assessed {
	background: var(--status-assessed-bg);
	color: var(--status-assessed-text);
}

.pess-status-badge--quoted {
	background: var(--status-quoted-bg);
	color: var(--status-quoted-text);
}

.pess-status-badge--customeraccepted {
	background: var(--status-customeraccepted-bg);
	color: var(--status-customeraccepted-text);
}

.pess-status-badge--completed {
	background: var(--gray-100, #f3f4f6);
	color: var(--text-muted, #666);
}

.pess-status-badge--default {
	background: var(--status-default-bg);
	color: var(--status-default-text);
}

/* Card Content */
.pess-service-card__customer {
	font-size: 1.1em;
	font-weight: 600;
	color: var(--text-color, #1f2937);
	margin-bottom: 6px;
}

.pess-service-card__equipment {
	color: var(--text-muted, #666);
	font-size: 0.9em;
	margin-bottom: 5px;
}

.pess-service-card__reg-number {
	font-family: monospace;
	font-size: 0.85em;
	background: var(--gray-100, #f3f4f6);
	margin-left: 4px;
	border-radius: 4px;
	padding: 2px 8px;
}

.pess-service-card__meta {
	font-size: 0.85em;
	color: var(--text-muted, #666);
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-top: 10px;
}

.pess-service-card__meta-item {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* === ACTION BUTTONS === */

.pess-actions-row {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

.pess-btn {
	flex: 1;
	cursor: pointer;
	font-size: 0.95em;
	font-weight: 500;
	text-align: center;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	transition: all 0.2s ease;
	outline: none;
	border: none;
	border-radius: 8px;
	padding: 10px;
}

.pess-btn:focus-visible {
	box-shadow: 0 0 0 2px var(--pess-primary), 0 0 0 4px rgba(30, 58, 95, 0.2);
}

.pess-btn--primary {
	background: #2563eb;
	color: white;
}

.pess-btn--primary:hover {
	background: #1d4ed8;
}

.pess-btn--secondary {
	background: var(--gray-100, #f3f4f6);
	color: var(--text-color, #374151);
	border: 1px solid var(--border-color, #ddd);
}

.pess-btn--secondary:hover {
	background: var(--gray-200, #e5e7eb);
}

.pess-btn--success {
	background: var(--pess-success);
	color: white;
}

.pess-btn--success:hover {
	background: #059669;
}

.pess-btn--view {
	background: var(--pess-btn-bg-light);
	color: white;
}

.pess-btn--view:hover {
	background: var(--pess-btn-bg-dark);
}

.pess-btn--go {
	background: var(--pess-btn-bg-light);
	color: white;
}

.pess-btn--go:hover {
	background: var(--pess-btn-bg-dark);
}

.pess-btn--assess {
	background: var(--pess-btn-bg-light);
	color: white;
}

.pess-btn--assess:hover {
	background: var(--pess-btn-bg-dark);
}

.pess-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* === EMPTY STATE === */

.pess-empty-state {
	text-align: center;
	color: var(--text-muted, #666);
	padding: 60px 20px;
}

.pess-empty-state__icon {
	width: 64px;
	height: 64px;
	color: var(--text-muted, #999);
	margin: 0 auto 16px auto;
}

.pess-empty-state__icon svg {
	stroke-width: 1.5;
}

.pess-empty-state__title {
	font-size: 1.25em;
	font-weight: 600;
	color: var(--text-color, #374151);
	margin-bottom: 8px;
}

.pess-empty-state__text {
	font-size: 0.95em;
}

/* === MODALS === */

.pess-modal-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 200;
	align-items: flex-end;
	justify-content: center;
}

.pess-modal-overlay--active {
	display: flex;
}

.pess-modal {
	background: var(--card-bg, #fff);
	width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	animation: slideUp 0.3s ease;
	border-radius: 20px 20px 0 0;
	padding: 24px;
}

@keyframes slideUp {
	from { transform: translateY(100%); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

.pess-modal__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.pess-modal__title {
	font-size: 1.25em;
	font-weight: 600;
	color: var(--text-color, #1f2937);
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
}

.pess-modal__close {
	background: none;
	font-size: 1.8em;
	cursor: pointer;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-muted, #666);
	transition: background 0.2s;
	border: none;
	border-radius: 8px;
	padding: 0;
}

.pess-modal__close:hover {
	background: var(--gray-100, #f3f4f6);
}

.pess-modal__close:focus-visible {
	box-shadow: 0 0 0 2px var(--pess-primary);
	border-radius: 8px;
}

.pess-modal__content {
	color: var(--text-color, #374151);
	line-height: 1.6;
}

.pess-modal__content p {
	margin: 8px 0;
}

.pess-modal__content strong {
	color: var(--text-color, #1f2937);
}

.pess-modal__divider {
	margin: 16px 0;
	border: none;
	border-top: 1px solid var(--border-color, #eee);
}

.pess-modal__list {
	margin: 8px 0;
	padding-left: 20px;
}

.pess-modal__list li {
	margin-bottom: 4px;
}

/* === FORM ELEMENTS === */

.pess-form-group {
	margin-bottom: 16px;
}

.pess-form-label {
	display: block;
	font-size: 0.85em;
	font-weight: 600;
	color: var(--text-color, #374151);
	display: flex;
	align-items: center;
	gap: 4px;
	margin-bottom: 6px;
}

.pess-form-textarea {
	width: 100%;
	min-height: 100px;
	font-family: inherit;
	font-size: 0.95em;
	resize: vertical;
	background: var(--card-bg, #fff);
	color: var(--text-color, #374151);
	transition: border-color 0.2s, box-shadow 0.2s;
	border: 1px solid var(--border-color, #d1d5db);
	border-radius: 10px;
	padding: 12px;
}

.pess-form-textarea:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
	border-color: #2563eb;
}

.pess-form-file {
	width: 100%;
	background: var(--card-bg, #fff);
	color: var(--text-color, #374151);
	font-size: 0.9em;
	border: 1px solid var(--border-color, #d1d5db);
	border-radius: 10px;
	padding: 12px;
}

.pess-form-file:focus {
	outline: none;
	border-color: #2563eb;
}

/* === AUDIO === */

.pess-voice-recorder {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.pess-voice-timer {
	font-family: monospace;
	font-size: 0.9em;
	color: var(--pess-danger, #ef4444);
	font-weight: 600;
}

.pess-voice-recorder .pess-btn--recording {
	background: var(--pess-danger, #ef4444);
	color: white;
	border-color: var(--pess-danger, #ef4444);
}

.pess-voice-recorder .pess-btn--recording:hover {
	background: #dc2626;
}