/* Cares Intake — front-end form.
 *
 * Matches Divi's native form styling, which is what the old CF7 form inherited
 * (the CF7 Styler module was set to "default" and applied no overrides of its
 * own). Divi's defaults: no border, #eeeeee fill, #666 text, 16px padding, 3px
 * radius, body font — here Manrope.
 *
 * Colours are driven by CSS custom properties so the plugin's Appearance
 * settings can re-theme the form without touching this file. The fallbacks
 * below are Divi's stock values.
 */

.cares-intake-form {
	--ci-accent:        #2ea3f2;   /* Divi default accent */
	--ci-field-bg:      #eeeeee;   /* Divi default input background */
	--ci-field-text:    #666666;
	--ci-field-border:  transparent;
	--ci-radius:        3px;
	--ci-label:         #333333;
	--ci-heading:       #333333;
	--ci-error:         #e53e3e;
	--ci-font-size:     14px;

	max-width: 100%;
	font-size: var(--ci-font-size);
	line-height: 1.7em;
	color: var(--ci-field-text);
}

.cares-intake-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 18px 20px;
}

.cares-field { grid-column: span 4; min-width: 0; }
.cares-w-full    { grid-column: span 4; }
.cares-w-half    { grid-column: span 2; }
.cares-w-third   { grid-column: span 2; }
.cares-w-quarter { grid-column: span 1; }

@media (max-width: 980px) {
	.cares-w-third { grid-column: span 2; }
}

@media (max-width: 780px) {
	.cares-w-half,
	.cares-w-third,
	.cares-w-quarter { grid-column: span 4; }
}

/* Section headings — Divi h2 proportions. */
.cares-heading { margin-top: 22px; }

.cares-heading h2 {
	margin: 0;
	padding-bottom: 6px;
	border-bottom: 1px solid rgba(0, 0, 0, .1);
	color: var(--ci-heading);
	font-size: 1.6em;
	font-weight: 500;
	line-height: 1.3em;
}

/* Rows and cells — reproduce the old form's [dipe_row] / [dipe_one_half]
   structure. A row spans the grid; its cells divide the width; several fields
   inside one cell sit side by side (e.g. DOB + Age + Gender in a half cell). */
.cares-row {
	grid-column: span 4;
	display: flex;
	flex-wrap: wrap;
	gap: 14px 20px;
	align-items: flex-end;
}

.cares-cell {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 14px;
	align-items: flex-end;
	min-width: 0;
}

.cares-cell-full    { flex: 1 1 100%; }
.cares-cell-half    { flex: 1 1 calc(50% - 10px); }
.cares-cell-third   { flex: 1 1 calc(33.333% - 14px); }
.cares-cell-quarter { flex: 1 1 calc(25% - 15px); }

/* Fields inside a cell size to their content rather than the grid. */
.cares-in-cell {
	flex: 1 1 auto;
	min-width: 0;
}

/* A lone field fills its cell; siblings share the space. */
.cares-cell > .cares-in-cell:only-child { flex: 1 1 100%; }

/* Compact controls keep their natural width beside a text input. */
.cares-in-cell.cares-type-number { flex: 0 1 90px; }
.cares-in-cell.cares-type-date   { flex: 1 1 150px; }
.cares-in-cell.cares-type-select { flex: 1 1 130px; }

/* Inline yes/no choices sit next to the input they qualify. */
.cares-in-cell.cares-type-checkbox,
.cares-in-cell.cares-type-radio { flex: 0 1 auto; }

@media (max-width: 780px) {
	.cares-cell-half,
	.cares-cell-third,
	.cares-cell-quarter { flex: 1 1 100%; }

	.cares-in-cell { flex: 1 1 100% !important; }
}

/* Tables — reproduce the old form's Family Mental Health History layout:
   a header row of column names above rows of "condition | Yes/No | who". */
.cares-table {
	grid-column: span 4;
	margin: 4px 0 8px;
}

.cares-table-caption {
	margin-bottom: 8px;
	color: var(--ci-heading);
	font-weight: 600;
}

.cares-table-head {
	display: flex;
	flex-wrap: nowrap;
	gap: 14px 20px;
	padding: 0 0 6px;
	border-bottom: 1px solid rgba(0, 0, 0, .25);
	margin-bottom: 10px;
}

.cares-table-head .cares-th {
	flex: 1 1 25%;
	min-width: 0;
	color: var(--ci-label);
	font-weight: 600;
	text-align: center;
}

/* First heading is the row-name column, left aligned and usually blank. */
.cares-table-head .cares-th:first-child { text-align: left; }

/* Rows inside a table align to the header columns. */
.cares-table .cares-row {
	gap: 14px 20px;
	align-items: center;
	padding: 4px 0;
}

.cares-table .cares-row + .cares-row {
	border-top: 1px solid rgba(0, 0, 0, .07);
}

.cares-table .cares-cell-quarter { flex: 1 1 25%; }

/* Match the original's compact controls rather than filling the column. */
.cares-table .cares-row select { max-width: 235px; }
.cares-table .cares-row input[type="text"] { max-width: 235px; }

.cares-rowname {
	display: block;
	padding-right: 8px;
	line-height: 1.4em;
}

/* Labels are redundant inside a table but kept for screen readers. */
.cares-label-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 780px) {
	/* Stack the table on small screens; headings would not line up. */
	.cares-table-head { display: none; }

	.cares-table .cares-row {
		display: block;
		padding: 10px 0;
	}

	.cares-table .cares-cell-quarter { flex: 1 1 100%; }

	.cares-rowname {
		margin-bottom: 6px;
		font-weight: 600;
	}

	/* Restore visible labels once the header row is hidden. */
	.cares-table .cares-label-sr {
		position: static !important;
		width: auto;
		height: auto;
		margin: 0 0 4px;
		clip: auto;
		overflow: visible;
		white-space: normal;
		font-size: .88em;
		opacity: .8;
	}
}

/* Shaded group box — reproduces the old CF7 form's grey panel around the
   minor/guardian section (inline background-color:#d9d9d9 in the source).
   Holds its own nested grid so fields inside keep their column widths. */
.cares-group {
	padding: 20px;
	border-radius: var(--ci-radius);
	background-color: var(--ci-group-bg, #d9d9d9);
}

/* Fields sit on a shaded background, so lift them to white for contrast. */
.cares-group input[type="text"],
.cares-group input[type="email"],
.cares-group input[type="tel"],
.cares-group input[type="number"],
.cares-group input[type="date"],
.cares-group select,
.cares-group textarea {
	background-color: #fff;
}

.cares-group .cares-heading { margin-top: 0; }

.cares-group .cares-heading h2 {
	border-bottom-color: rgba(0, 0, 0, .18);
}

/* Policy / explanatory prose. */
.cares-static {
	line-height: 1.7em;
}

.cares-static p { margin-bottom: 1em; }
.cares-static ul { margin: 0 0 1em 1.4em; list-style: disc; }
.cares-static li { margin-bottom: .35em; }
.cares-static i, .cares-static em { color: #777; }

.cares-label {
	display: block;
	margin-bottom: 6px;
	color: var(--ci-label);
	font-weight: 600;
	line-height: 1.4em;
}

.cares-req { color: var(--ci-error); }

/* Labels the original form showed in bold. */
.cares-label-strong { font-weight: 700; }

/* Section dividers carried over from the source's <hr> rules. */
.cares-static hr {
	margin: 6px 0;
	border: 0;
	border-top: 1px solid rgba(0, 0, 0, .18);
}

/* Divi's form controls: filled, borderless, generous padding. */
.cares-intake-form input[type="text"],
.cares-intake-form input[type="email"],
.cares-intake-form input[type="tel"],
.cares-intake-form input[type="number"],
.cares-intake-form input[type="date"],
.cares-intake-form select,
.cares-intake-form textarea {
	width: 100%;
	margin: 0;
	padding: 16px;
	border: 1px solid var(--ci-field-border);
	border-radius: var(--ci-radius);
	background-color: var(--ci-field-bg);
	color: var(--ci-field-text);
	font-family: inherit;
	font-size: inherit;
	line-height: 1.4em;
	-webkit-appearance: none;
	appearance: none;
}

/* Keep the native dropdown arrow after appearance:none. */
.cares-intake-form select {
	padding-right: 40px;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	background-size: 12px 8px;
}

.cares-intake-form input[type="date"] { -webkit-appearance: textfield; appearance: textfield; }

.cares-intake-form input:focus,
.cares-intake-form select:focus,
.cares-intake-form textarea:focus {
	outline: 2px solid var(--ci-accent);
	outline-offset: 1px;
}

.cares-intake-form textarea { min-height: 100px; resize: vertical; }

.cares-intake-form ::placeholder { color: #999; opacity: 1; }

/* Choice groups */
.cares-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 22px;
	padding-top: 2px;
}

.cares-choice {
	display: inline-flex;
	align-items: flex-start;
	gap: 8px;
	max-width: 100%;
	font-weight: 400;
	line-height: 1.5em;
	cursor: pointer;
}

/* Long consent statements read as blocks, not inline chips. */
.cares-choice:only-child { display: flex; }

.cares-choice input {
	flex: 0 0 auto;
	width: 17px;
	height: 17px;
	margin: 2px 0 0;
	accent-color: var(--ci-accent);
}

.cares-choice span { flex: 1 1 auto; min-width: 0; }

/* Card field */
.cares-card-group {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
}

.cares-card-part { flex: 1 1 240px; min-width: 0; }
.cares-card-part.cares-card-expiry { flex: 0 1 150px; }

.cares-card-part label {
	display: block;
	margin-bottom: 5px;
	color: var(--ci-label);
	font-size: .88em;
	font-weight: 500;
}

/* Signature pad */
.cares-signature { max-width: 100%; }

.cares-sig-pad {
	display: block;
	width: 100%;
	max-width: 600px;
	height: 150px;
	border: 1px solid rgba(0, 0, 0, .12);
	border-radius: var(--ci-radius);
	background: var(--ci-field-bg);
	touch-action: none;
	cursor: crosshair;
}

.cares-sig-clear {
	margin-top: 8px;
	padding: 6px 16px;
	border: 1px solid rgba(0, 0, 0, .15);
	border-radius: var(--ci-radius);
	background: #fff;
	color: var(--ci-field-text);
	font-family: inherit;
	font-size: .85em;
	cursor: pointer;
}

.cares-sig-clear:hover { background: #f7f7f7; }

.cares-help {
	display: block;
	margin-top: 6px;
	color: #888;
	font-size: .86em;
	line-height: 1.5em;
}

/* Honeypot — offscreen rather than display:none, which some bots detect. */
.cares-intake-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.cares-intake-errors {
	margin-bottom: 24px;
	padding: 16px 20px;
	border-left: 4px solid var(--ci-error);
	border-radius: var(--ci-radius);
	background: #fdeaea;
	color: #8a2020;
}

.cares-intake-errors ul { margin: 8px 0 0 20px; list-style: disc; }

.cares-field-invalid input,
.cares-field-invalid select,
.cares-field-invalid textarea {
	border-color: var(--ci-error) !important;
	background-color: #fdf3f3;
}

.cares-intake-success {
	padding: 22px 24px;
	border-left: 4px solid #38a169;
	border-radius: var(--ci-radius);
	background: #f0fff4;
	color: #22543d;
	font-size: 1.05em;
}

.cares-intake-actions { margin-top: 30px; }

/* Divi's et_pb_button proportions. */
.cares-intake-submit {
	display: inline-block;
	padding: 16px 32px;
	border: 2px solid var(--ci-accent);
	border-radius: var(--ci-radius);
	background: var(--ci-accent);
	color: #fff;
	font-family: inherit;
	font-size: 1.05em;
	font-weight: 500;
	line-height: 1.7em;
	cursor: pointer;
	transition: background .2s ease, color .2s ease;
}

.cares-intake-submit:hover {
	background: transparent;
	color: var(--ci-accent);
}

.cares-intake-submit:disabled {
	opacity: .55;
	cursor: default;
}

.cares-intake-submit:disabled:hover {
	background: var(--ci-accent);
	color: #fff;
}

/* Divi wraps page content in .et_pb_text_inner etc.; keep inherited fonts. */
.cares-intake-form,
.cares-intake-form input,
.cares-intake-form select,
.cares-intake-form textarea,
.cares-intake-form button {
	font-family: inherit;
}
