/**
 * Electronic Compliance Agreement - Public Form Styling
 * Matches the suite's existing front-end theme (aie-frontend.css):
 * Primary: #12285b (Gauteng Navy) / Accent: #d1a53e (Gauteng Gold)
 */

/* NOTE on font-family: this is intentionally NOT set on .eca-container.
   This form is usually embedded inside a page-builder text module (e.g. a
   Divi Text Module) whose own typography settings should apply to any
   plain text we don't explicitly style - most importantly the pasted
   Agreement Text content (.eca-agreement-text below), which has no fixed
   look of its own and should visually match whatever module it's dropped
   into. CSS inheritance can't "skip" an ancestor's explicit font-family,
   so instead of setting it once here (which would block that content from
   ever picking up the embedding module's font), every other "chrome"
   selector below (headings, labels, buttons, badges, etc.) declares this
   same font stack explicitly, keeping the plugin's own Open Sans look
   everywhere except the agreement text itself. */
/* Width is NOT capped here: the form fills whatever page-builder module
   it's embedded in, so its width is set in Divi (Text module -> Design ->
   Sizing -> Max Width) rather than being fixed by the plugin. */
.eca-container {
	max-width: none;
	margin: 20px auto;
	color: #0f172a;
}

.eca-card {
	background: #ffffff;
	border-radius: 12px;
	border: 1px solid #e2e8f0;
	box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
	padding: 32px;
}

.eca-card-header h2 {
	margin: 0 0 6px 0;
	font-size: 24px;
	font-weight: 700;
	color: #12285b;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-card-header p {
	margin: 0 0 24px 0;
	color: #64748b;
	font-size: 14.5px;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-group-box {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 22px;
	margin-bottom: 24px;
}

.eca-group-title {
	font-size: 16px;
	font-weight: 700;
	color: #12285b;
	margin: 0 0 16px 0;
	padding-bottom: 8px;
	border-bottom: 1px solid #cbd5e1;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px 20px;
}

.eca-field-group {
	display: flex;
	flex-direction: column;
}

.eca-field-group.full-width {
	grid-column: 1 / -1;
}

.eca-field-group label {
	font-size: 13.5px;
	font-weight: 700;
	color: #1e293b;
	margin-bottom: 6px;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-field-group label span.required {
	color: #dc2626;
}

.eca-field-group .description {
	margin: 6px 0 0 0;
	font-size: 12.5px;
	color: #64748b;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-field-group input[type="text"],
.eca-field-group input[type="email"],
.eca-field-group input[type="number"],
.eca-field-group input[type="date"],
.eca-field-group select,
.eca-field-group textarea {
	padding: 10px 14px;
	border: 2px solid #64748b;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.4;
	color: #0f172a;
	background: #ffffff;
	box-sizing: border-box;
	width: 100%;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.eca-field-group input[type="text"],
.eca-field-group input[type="email"],
.eca-field-group input[type="number"],
.eca-field-group input[type="date"],
.eca-field-group select {
	height: 44px;
}

.eca-field-group textarea {
	resize: vertical;
}

.eca-field-group select {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 12px;
	padding-right: 36px;
}

.eca-field-group input:focus,
.eca-field-group select:focus,
.eca-field-group textarea:focus {
	outline: none;
	border-color: #12285b;
	box-shadow: 0 0 0 3px rgba(18, 40, 91, 0.15);
}

/* ── Chess SA subsection ──────────────────────────────────────────────── */
.eca-subsection {
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	margin-bottom: 18px;
	background: #ffffff;
}

.eca-subsection-header {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	padding: 12px 16px;
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
	border-radius: 9px 9px 0 0;
}

.eca-subsection-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: #1e293b;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-subsection-body {
	padding: 16px 16px 8px;
}

.eca-toggle-wrapper {
	margin-top: 2px;
}

.eca-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	user-select: none;
}

.eca-toggle input[type="checkbox"] {
	display: none;
}

.eca-toggle-slider {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	background: #cbd5e1;
	border-radius: 12px;
	transition: background 0.2s;
	flex-shrink: 0;
}

.eca-toggle-slider::after {
	content: '';
	position: absolute;
	width: 20px;
	height: 20px;
	background: #fff;
	border-radius: 50%;
	top: 2px;
	left: 2px;
	transition: transform 0.2s;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.eca-toggle input:checked + .eca-toggle-slider {
	background: #22c55e;
}

.eca-toggle input:checked + .eca-toggle-slider::after {
	transform: translateX(20px);
}

.eca-toggle-label {
	font-size: 11.5px;
	font-weight: 600;
	color: #64748b;
	min-width: 38px;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-readonly-badge,
.eca-optional-badge {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	color: #94a3b8;
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 4px;
	padding: 1px 5px;
	margin-left: 4px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	vertical-align: middle;
	white-space: nowrap;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-readonly-field,
input[readonly].eca-readonly-field,
input[readonly] {
	background: #f8fafc !important;
	color: #94a3b8 !important;
	border-color: #cbd5e1 !important;
	cursor: default !important;
}

select:disabled,
select.eca-readonly-field {
	background: #f8fafc !important;
	color: #475569 !important;
	border-color: #cbd5e1 !important;
	cursor: not-allowed !important;
	opacity: 1 !important;
}

.eca-locked-notice {
	margin-bottom: 12px;
	padding: 8px 14px;
	background: #f0fdf4;
	border: 1px solid #86efac;
	border-radius: 6px;
	font-size: 12.5px;
	color: #166534;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-no-csa-id-note {
	margin-bottom: 12px;
	padding: 8px 14px;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	border-radius: 6px;
	font-size: 12.5px;
	color: #1e40af;
	line-height: 1.5;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-link-btn {
	background: none;
	border: none;
	color: #2563eb;
	cursor: pointer;
	font-size: 12.5px;
	font-weight: 600;
	text-decoration: underline;
	padding: 0;
	line-height: 1;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-link-btn:hover {
	color: #1d4ed8;
}

/* ── Live search dropdown ─────────────────────────────────────────────── */
.eca-search-wrapper {
	position: relative;
	margin-bottom: 16px;
}

/* This input sits outside .eca-field-group, so it doesn't pick up that
   selector's border/padding styling - without its own rule it renders with
   no visible border at all beyond the bare browser default, which made it
   hard to tell it was a text box (flagged by the user). Styled to match
   the rest of the form's text inputs. */
.eca-search-wrapper input[type="text"] {
	padding: 10px 14px;
	border: 2px solid #64748b;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.4;
	color: #0f172a;
	background: #ffffff;
	box-sizing: border-box;
	width: 100%;
	height: 44px;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.eca-search-wrapper input[type="text"]:focus {
	outline: none;
	border-color: #12285b;
	box-shadow: 0 0 0 3px rgba(18, 40, 91, 0.15);
}

.eca-search-spinner {
	display: none;
	width: 20px;
	height: 20px;
	border: 2.5px solid #cbd5e1;
	border-top-color: #12285b;
	border-radius: 50%;
	animation: eca-search-spin 0.6s linear infinite;
	position: absolute;
	right: 14px;
	top: 56px;
	pointer-events: none;
	z-index: 10;
}

@keyframes eca-search-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.eca-search-spinner-lg {
	display: inline-block;
	vertical-align: middle;
	width: 20px;
	height: 20px;
	margin-right: 8px;
	border: 3px solid #cfe0fb;
	border-top-color: #0284c7;
	border-radius: 50%;
	animation: eca-search-spin 0.6s linear infinite;
}

.eca-search-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #ffffff;
	border: 2px solid #94a3b8;
	border-radius: 8px;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
	max-height: 280px;
	overflow-y: auto;
	z-index: 1000;
	margin-top: 4px;
}

.eca-search-item {
	padding: 11px 15px;
	border-bottom: 1px solid #f1f5f9;
	cursor: pointer;
	font-size: 13px;
	transition: background 0.15s ease;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: #0f172a;
}

.eca-search-item:hover {
	background: #eff6ff;
	color: #12285b;
}

.eca-search-item .eca-item-rating {
	float: right;
	font-weight: 700;
	color: #d1a53e;
}

/* ── Agreement text block ─────────────────────────────────────────────── */
/* font-size, line-height and font-family are deliberately NOT set here.
   This box holds admin-pasted Agreement Text (not plugin chrome), so when
   it's embedded inside a page-builder text module (e.g. a Divi Text
   Module), its typography should inherit from that module rather than
   being forced to a plugin-defined look - fixes the heading/paragraph
   text clashing with the surrounding module's configured styling. Color
   is still pinned for contrast/readability regardless of what other
   modules on the page are doing. */
.eca-agreement-text {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 18px 20px;
	max-height: 340px;
	overflow-y: auto;
	color: #334155;
}

.eca-agreement-text p {
	margin: 0 0 12px 0;
}

.eca-agreement-text p:last-child {
	margin-bottom: 0;
}

/* ── Checkbox rows (minor toggle, agree-to-terms) ─────────────────────── */
.eca-check-item {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	background: #ffffff;
	border: 2px solid #cbd5e1;
	border-radius: 8px;
	padding: 12px 16px;
	cursor: pointer;
	font-size: 13.5px;
	font-weight: 600;
	color: #334155;
	transition: background 0.15s ease, border-color 0.15s ease;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-check-item:hover {
	background: #eff6ff;
	border-color: #12285b;
}

.eca-check-item input[type="checkbox"] {
	width: 20px;
	height: 20px;
	accent-color: #12285b;
	cursor: pointer;
	flex: 0 0 auto;
	margin-top: 1px;
}

.eca-check-item span.required {
	color: #dc2626;
}

/* ── Messages / notices ───────────────────────────────────────────────── */
.eca-message {
	padding: 14px 16px;
	border-radius: 6px;
	margin-bottom: 20px;
	font-size: 14px;
	font-weight: 700;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-message.success {
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
	color: #15803d;
}

.eca-message.error {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
}

.eca-warning-box {
	background: #fffbeb;
	border-left: 4px solid #f59e0b;
	color: #b45309;
	padding: 14px 16px;
	border-radius: 6px;
	font-size: 14px;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Submit button ─────────────────────────────────────────────────────── */
.eca-form-actions {
	display: flex;
	justify-content: flex-end;
}

.eca-btn {
	padding: 0.8em 1.8em;
	font-size: 15px;
	font-weight: 700;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	border: none;
	background: #12285b;
	color: #ffffff;
	box-shadow: 0 4px 14px rgba(18, 40, 91, 0.3);
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-btn:not(:disabled):hover {
	background: #1a367c;
	box-shadow: 0 6px 18px rgba(18, 40, 91, 0.4);
	transform: translateY(-1px);
}

.eca-btn:disabled {
	opacity: 0.65;
	cursor: not-allowed;
	box-shadow: none;
	transform: none;
}

/* ── Success panel (replaces the form after a successful submit) ─────── */
.eca-success-panel {
	text-align: center;
	padding: 40px 20px;
}

.eca-success-icon {
	font-size: 48px;
	margin-bottom: 12px;
}

.eca-success-panel h3 {
	color: #15803d;
	font-size: 19px;
	margin: 0 0 10px 0;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-success-panel p {
	color: #475569;
	font-size: 14.5px;
	max-width: 480px;
	margin: 0 auto;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (max-width: 600px) {
	.eca-card {
		padding: 20px;
	}
}

/* ------------------------------------------------------------------
   Public compliance roster - [gauteng_compliance_roster]
   Wider than the signing form: the entry list can have many columns.
   ------------------------------------------------------------------ */
.eca-container.eca-roster {
	max-width: none;
}

.eca-roster-summary,
.eca-roster-filters,
.eca-roster-table,
.eca-roster-note {
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-roster-summary {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 20px;
	align-items: baseline;
	margin-bottom: 14px;
	font-size: 16px;
	font-weight: 600;
}

.eca-roster-count.done { color: #15803d; }
.eca-roster-count.todo { color: #b91c1c; }
.eca-roster-count.total { color: #64748b; font-weight: 400; }

.eca-roster-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 24px;
	align-items: center;
	margin-bottom: 14px;
	font-size: 14px;
	color: #12285b;
}

.eca-roster-filters select {
	margin-left: 6px;
	padding: 6px 10px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	font-size: 14px;
}

.eca-roster-toggle {
	display: inline-flex;
	gap: 6px;
	align-items: center;
	cursor: pointer;
}

.eca-roster-scroll {
	overflow-x: auto;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	background: #ffffff;
}

.eca-roster-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	margin: 0;
}

.eca-roster-table th {
	background: #12285b;
	color: #ffffff;
	text-align: left;
	font-weight: 600;
	padding: 10px 12px;
	white-space: nowrap;
}

.eca-roster-table td {
	padding: 9px 12px;
	border-top: 1px solid #e2e8f0;
	white-space: nowrap;
	color: #0f172a;
}

.eca-roster-table tr.is-todo td {
	background: #fef2f2;
}

.eca-roster-badge {
	font-weight: 600;
}

.eca-roster-badge.done { color: #15803d; }
.eca-roster-badge.todo { color: #b91c1c; }

.eca-roster-note {
	margin-top: 10px;
	font-size: 13px;
	color: #64748b;
}

.eca-roster-table td.eca-roster-view a {
	color: #12285b;
	font-weight: 600;
	text-decoration: none;
}

.eca-roster-table td.eca-roster-view a:hover {
	text-decoration: underline;
}

.eca-roster-admin-only {
	font-weight: 400;
	font-size: 11px;
	opacity: 0.75;
}

/* ── "Read the full agreement" button + pop-up ───────────────────────── */
.eca-agreement-toolbar {
	display: flex;
	justify-content: flex-end;
	margin: -4px 0 10px 0;
}

.eca-read-full-btn {
	background: #ffffff;
	color: #12285b;
	border: 2px solid #12285b;
	border-radius: 8px;
	padding: 8px 14px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	transition: background 0.2s ease, color 0.2s ease;
}

.eca-read-full-btn:hover,
.eca-read-full-btn:focus-visible {
	background: #12285b;
	color: #ffffff;
}

html.eca-modal-open,
html.eca-modal-open body {
	overflow: hidden;
}

.eca-modal {
	position: fixed;
	inset: 0;
	z-index: 1000000; /* above Divi's fixed header (99999) */
	background: rgba(15, 23, 42, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.eca-modal[hidden] {
	display: none;
}

.eca-modal-dialog {
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
	width: 100%;
	max-width: 1000px;
	height: 100%;
	max-height: calc(100vh - 48px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.eca-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 24px;
	border-bottom: 1px solid #e2e8f0;
}

.eca-modal-header h3 {
	margin: 0;
	padding: 0;
	font-size: 18px;
	font-weight: 700;
	color: #12285b;
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.eca-modal-close {
	background: none;
	border: none;
	font-size: 30px;
	line-height: 1;
	color: #64748b;
	cursor: pointer;
	padding: 0 4px;
}

.eca-modal-close:hover {
	color: #12285b;
}

.eca-modal-body {
	flex: 1;
	overflow-y: auto;
	padding: 24px 32px;
	color: #334155;
}

.eca-modal-body p {
	margin: 0 0 14px 0;
}

/* Agreement headings in the pop-up. eca-frontend.js copies the inline
   box's heading typography (font, size, weight, colour) onto these when
   the pop-up opens; the sizes below are only a fallback for when that
   isn't available. Spacing is always set here: under <body> the theme's
   own heading rules gave these no margin at all. */
.eca-modal-body h1,
.eca-modal-body h2,
.eca-modal-body h3,
.eca-modal-body h4,
.eca-modal-body h5,
.eca-modal-body h6 {
	margin: 1.1em 0 0.45em 0;
	padding: 0;
	line-height: 1.3;
	font-weight: 600;
	color: #1e293b;
}

.eca-modal-body h2 { font-size: 1.45em; }
.eca-modal-body h3 { font-size: 1.25em; }
.eca-modal-body h4 { font-size: 1.1em; }

.eca-modal-body > :first-child {
	margin-top: 0;
}

.eca-modal-footer {
	padding: 14px 24px;
	border-top: 1px solid #e2e8f0;
	text-align: right;
}

@media (max-width: 600px) {
	.eca-modal {
		padding: 0;
	}

	.eca-modal-dialog {
		max-height: none;
		border-radius: 0;
	}

	.eca-modal-body {
		padding: 18px;
	}

	.eca-agreement-toolbar {
		justify-content: stretch;
	}

	.eca-read-full-btn {
		width: 100%;
	}
}
