/*
 * Contact form (dincel_resource.form_contact)
 * Scoped to .df-form so the legacy global input styles in theme_dincel
 * (_forms.scss) keep working for every other form on the site.
 * Typography is inherited from the theme; only layout, borders and
 * validation states are set here. Colours come from
 * theme_dincel/static/src/scss/_variables.scss.
 */

/* design tokens */
.df-form,
.df-success,
.df-form-required-note,
.df-form-signin-note {
	--df-color-text-primary: #2b2a2a;
	--df-color-text-secondary: #575656;   /* $Dincel-DeepGrey */
	--df-color-surface-base: #ffffff;
	--df-color-surface-secondary: #f5f5f5; /* $Dincel-backgroundGrey */
	--df-color-border-default: #a39f9e;   /* $Dincel-LightGrey */
	--df-color-border-strong: #575656;
	--df-color-border-light: #eaeaea;    /* $Dincel-SearchGrey */
	--df-color-action-primary: #dc1415;   /* $Dincel-Red */
	--df-color-success: #258624;          /* $Dincel-Success */
	--df-color-error: #b42318;            /* darker than $Dincel-Error for AA contrast */

	--df-font-size-control: 0.875rem;
	--df-font-size-message: 0.75rem;

	--df-space-1: 4px;
	--df-space-2: 8px;
	--df-space-4: 16px;
	--df-space-5: 24px;
	--df-space-6: 32px;

	--df-radius-xs: 4px;
	--df-control-height: 40px;
	--df-motion-fast: 150ms;
}

.df-form {
	margin-top: var(--df-space-4);
}

/* ---------------------------------------------------------------- layout */

.df-form__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: var(--df-space-5);
	row-gap: var(--df-space-4);
}

.df-form .df-field,
.df-form .df-form__status {
	position: relative;
	margin: 0;
	min-width: 0;
}

.df-form .df-field--full {
	grid-column: 1 / -1;
}

/* server/network errors only - empty until the script writes into it */
.df-form .df-form__status .messages:not(:empty) {
	margin-bottom: var(--df-space-4);
	color: var(--df-color-error);
}

/* ----------------------------------------------------------------- label */

.df-form .df-field__label {
	margin: 0 0 var(--df-space-2);
	line-height: 1.2;
}

.df-form .df-required {
	margin-left: 2px;
	color: var(--df-color-action-primary);
}

/* --------------------------------------------------------------- control */

.df-form .df-field__control {
	display: block;
	width: 100%;
	height: var(--df-control-height);
	margin: 0;
	padding: 0 var(--df-space-2);
	border: 1px solid var(--df-color-border-default);
	border-radius: var(--df-radius-xs);
	background-color: var(--df-color-surface-base);
	color: var(--df-color-text-primary);
	font-family: inherit;
	font-size: var(--df-font-size-control);
	box-shadow: none;
	outline: 0;
	transition: border-color var(--df-motion-fast) ease;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
}

.df-form .df-field__control::placeholder {
	color: var(--df-color-border-default);
}

.df-form .df-field__control:hover {
	border-color: var(--df-color-border-strong);
}

.df-form .df-field__control:focus {
	border-color: var(--df-color-action-primary);
	box-shadow: 0 0 0 1px var(--df-color-action-primary);
	background-color: var(--df-color-surface-base);
}

.df-form .df-field__control--textarea {
	height: auto;
	min-height: 140px;
	padding: var(--df-space-2);
	resize: vertical;
}

.df-form .df-field__control--select {
	padding-right: 32px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23575656' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 10px 6px;
	cursor: pointer;
	text-overflow: ellipsis;
}

.df-form .df-field__control--select::-ms-expand {
	display: none;
}

/* ------------------------------------------------------------ validation */

/* dincel-validate.js toggles .has-error / .has-success on .form-group */
.df-form .has-error .df-field__control {
	border-color: var(--df-color-error);
	background-color: var(--df-color-surface-base);
}

.df-form .has-success .df-field__control {
	border-color: var(--df-color-success);
	background-color: var(--df-color-surface-base);
}

/* legacy PNG icons are positioned for the old layout; state is shown by border + message */
.df-form .form-group .validation-icon {
	display: none !important;
}

.df-form .df-field__message:empty {
	display: none;
}

.df-form .df-field__message {
	margin-top: var(--df-space-1);
	font-size: var(--df-font-size-message);
}

.df-form .df-field__message .help-block.error {
	color: var(--df-color-error);
}

/* the captcha check writes inline red/bold styles - bring it in line */
.df-form .df-field--captcha .messages {
	color: var(--df-color-error) !important;
	font-weight: normal !important;
}

/* --------------------------------------------------------------- actions */

/* button look comes from the theme's .red-btn; these add the states it lacks */
.df-form .df-btn {
	cursor: pointer;
}

.df-form .df-btn:focus-visible {
	outline: 2px solid var(--df-color-action-primary);
	outline-offset: 2px;
}

.df-form .df-btn:disabled,
.df-form .df-btn[aria-busy="true"] {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 767px) {
	.df-form__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 359px) {
	/* reCAPTCHA is a fixed 304px iframe */
	.df-form .g-recaptcha {
		transform: scale(0.9);
		transform-origin: 0 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.df-form .df-field__control {
		transition: none;
	}
}

/* intro text + required note above the form (page_contact) - one size for all,
   overriding the global p (.75rem) and legacy .mandatory-msg (.65rem italic) */
.contact_tabs .tab-content > #contact > p,
.contact_tabs .tab-content > #contact .app-hero__body p,
.contact_tabs #upload.tab-content #estimateIntro > p,
.contact_tabs #upload.tab-content #estimateIntro .app-hero__body p {
	font-size: inherit;
}

.contact_tabs .tab-content .df-form-required-note,
.contact_tabs .tab-content .df-form-signin-note {
	margin: 0;
	color: var(--df-color-text-secondary);
	font-size: inherit;
	font-style: normal;
}

/* a dropdown plus its "Other - please specify" box, kept in one grid cell */
.df-form .df-field-stack {
	display: flex;
	flex-direction: column;
	gap: var(--df-space-4);
	min-width: 0;
}

.df-form .df-field[hidden] {
	display: none;
}

/* ------------------------------------------- estimate form (form_upload) */

/* numbered section cards (estimate form) */
.df-form .df-section {
	min-width: 0;
	margin: 0 0 var(--df-space-4);
	padding: var(--df-space-5);
	border: 1px solid var(--df-color-border-light);
	border-radius: 8px;
	background: var(--df-color-surface-base);
}

/* overrides Bootstrap's 1.5rem full-width legend */
.df-form .df-section__title {
	display: flex;
	align-items: center;
	gap: var(--df-space-2);
	float: none;
	width: auto;
	margin: 0 0 var(--df-space-4);
	padding: 0;
	color: var(--df-color-text-primary);
	font-family: RobotoCondensed, Arial, sans-serif;
	font-size: 1.125rem;
	font-weight: bold;
	line-height: 1.2;
}

/* section numbers come from a counter: sections hidden for a general costing
   request (display: none) don't count, so the rest renumber */
.df-form--sections {
	counter-reset: df-section;
}

.df-form--sections .df-section {
	counter-increment: df-section;
}

.df-form .df-section__title::before {
	content: counter(df-section);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 24px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--df-color-action-primary);
	color: var(--df-color-surface-base);
	font-size: var(--df-font-size-message);
	line-height: 1;
}

/* "Do you have a project to quote?" - two selectable tiles; the selected one gets
   a darker neutral border (no brand-red fill) */
.df-form .df-request-type {
	margin-bottom: var(--df-space-4);
}

.df-form .df-tiles {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--df-space-4);
}

.df-form .df-tile {
	display: flex;
	align-items: center;
	gap: var(--df-space-2);
	margin: 0;
	padding: 14px var(--df-space-4);
	border: 1px solid var(--df-color-border-default);
	border-radius: 8px;
	background: var(--df-color-surface-base);
	color: var(--df-color-text-primary);
	font-size: var(--df-font-size-control);
	font-weight: normal;
	cursor: pointer;
	transition: border-color var(--df-motion-fast) ease;
}

.df-form .df-tile:hover {
	border-color: var(--df-color-border-strong);
}

.df-form .df-tile input[type="radio"] {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	margin: 0;
	/* the only red on the tiles - the selected radio */
	accent-color: var(--df-color-action-primary);
	cursor: pointer;
}

.df-form .df-tile:has(input:checked) {
	border-color: var(--df-color-text-primary);
	box-shadow: 0 0 0 1px var(--df-color-text-primary);
}

.df-form .df-tile:has(input:focus-visible) {
	outline: 2px solid var(--df-color-text-primary);
	outline-offset: 2px;
}

@media (max-width: 575px) {
	.df-form .df-tiles {
		grid-template-columns: minmax(0, 1fr);
	}
}

.df-form .df-form__submit {
	margin-top: var(--df-space-2);
}

/* Harmony address suggestions (jQuery UI menu appended to <body>). Width comes from
   --df-lookup-width, set by address_lookup.js. !important is needed against the
   inline width jQuery UI sets, Odoo's .ui-autocomplete { max-width: 600px }
   (web/static/src/scss/ui.scss) and the jquery-ui.css item padding. */
.ui-autocomplete.ui-menu {
	z-index: 1050;
	box-sizing: border-box;
	width: var(--df-lookup-width, auto) !important;
	max-width: none !important;
	max-height: 300px;
	overflow-x: hidden;
	overflow-y: auto;
	margin: 4px 0 0;
	padding: 4px 0;
	border: 1px solid #d6d3d2;
	border-radius: 4px;
	background: #ffffff;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
	font-family: Roboto, Arial, sans-serif;
	font-size: 0.875rem;
	list-style: none;
}

.ui-autocomplete.ui-menu .ui-menu-item {
	margin: 0;
	padding: 0;
	list-style: none;
	list-style-image: none;
}

.ui-autocomplete.ui-menu .ui-menu-item .ui-menu-item-wrapper {
	position: relative;
	margin: 0;
	display: block;
	padding: 9px 14px 9px 36px !important;
	border: 0;
	border-radius: 0;
	color: #2b2a2a;
	line-height: 1.3 !important;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* map-pin icon (Font Awesome 4, loaded by Odoo) */
.ui-autocomplete.ui-menu .ui-menu-item .ui-menu-item-wrapper::before {
	content: "\f041";
	position: absolute;
	top: 50%;
	left: 14px;
	transform: translateY(-50%);
	color: #a39f9e;
	font-family: FontAwesome;
	font-size: 0.875rem;
}

.ui-autocomplete.ui-menu .ui-menu-item .ui-menu-item-wrapper.ui-state-active,
.ui-autocomplete.ui-menu .ui-menu-item .ui-menu-item-wrapper:hover {
	margin: 0;
	border: 0;
	background: #f5f5f5;
	color: #2b2a2a;
}

.ui-autocomplete.ui-menu .ui-menu-item .ui-menu-item-wrapper.ui-state-active::before {
	color: #dc1415;
}

@media (max-width: 767px) {
	.df-form .df-section {
		padding: var(--df-space-4);
	}
}

.df-form .df-field__hint {
	margin: var(--df-space-1) 0 0;
	color: var(--df-color-text-secondary);
	font-size: var(--df-font-size-message);
}

.df-form .df-field__control--file {
	height: auto;
	padding: var(--df-space-2);
	cursor: pointer;
}

.df-form .df-field__control--file::file-selector-button {
	margin-right: var(--df-space-4);
	padding: 6px 12px;
	border: 1px solid var(--df-color-border-strong);
	border-radius: var(--df-radius-xs);
	background-color: var(--df-color-surface-base);
	color: var(--df-color-text-primary);
	font-family: inherit;
	cursor: pointer;
}

.df-form .df-choice-group {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}


.df-form .df-choice {
	display: inline-flex;
	align-items: center;
	gap: var(--df-space-2);
	margin: 0 var(--df-space-5) var(--df-space-1) 0;
	font-size: var(--df-font-size-control);
	font-weight: normal;
	cursor: pointer;
}

.df-form .df-choice input[type="radio"] {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--df-color-action-primary);
	cursor: pointer;
}

.df-form .df-choice-group .df-field__label {
	display: block;
	margin: 0 0 var(--df-space-2);
	color: var(--df-color-text-primary);
	font-size: var(--df-font-size-control);
	font-weight: bold;
}

.df-form .has-error .df-choice-group .df-field__label {
	color: var(--df-color-error);
}

/* ---------------------------------------- estimate success (form_upload) */

.df-success {
	margin-top: var(--df-space-4);
	padding: var(--df-space-5) var(--df-space-5) var(--df-space-6);
	border: 1px solid var(--df-color-border-light);
	border-radius: 8px;
	background: var(--df-color-surface-base);
	color: var(--df-color-text-primary);
}

.df-success:focus {
	outline: none;
}

.df-success__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin-bottom: var(--df-space-4);
	border-radius: 50%;
	background: #e7f4e7;
	color: var(--df-color-success);
	font-size: 1.375rem;
}

/* overrides the theme's red 1.25rem h2 */
.contact_tabs .df-success .df-success__title {
	margin: 0 0 var(--df-space-2);
	padding: 0;
	color: var(--df-color-text-primary);
	font-family: RobotoCondensed, Arial, sans-serif;
	font-size: 1.5rem;
	font-weight: bold;
	line-height: 1.25;
}

.contact_tabs .df-success .df-success__lead {
	margin: 0 0 var(--df-space-5);
	color: var(--df-color-text-secondary);
	font-size: var(--df-font-size-control);
	line-height: 1.5;
}

.df-success__summary {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--df-space-4) var(--df-space-5);
	margin: 0 0 var(--df-space-5);
	padding: var(--df-space-4);
	border-radius: 6px;
	background: var(--df-color-surface-secondary);
}

.df-success__summary dt {
	margin: 0 0 2px;
	color: var(--df-color-text-secondary);
	font-size: var(--df-font-size-message);
	font-weight: normal;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.df-success__summary dd {
	margin: 0;
	font-size: var(--df-font-size-control);
	font-weight: bold;
	overflow-wrap: anywhere;
}

.df-success__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--df-space-2);
}

.df-success .df-success__btn {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	padding: 0 18px;
	border: 1px solid var(--df-color-action-primary);
	border-radius: 2px;
	font-size: var(--df-font-size-control);
	font-weight: bold;
	text-decoration: none;
}

.df-success .df-success__btn--primary {
	background: var(--df-color-action-primary);
	color: var(--df-color-surface-base);
}

.df-success .df-success__btn--primary:hover {
	background: #b01011;
	border-color: #b01011;
	color: var(--df-color-surface-base);
}

.df-success .df-success__btn--secondary {
	background: var(--df-color-surface-base);
	color: var(--df-color-action-primary);
}

.df-success .df-success__btn--secondary:hover {
	background: var(--df-color-action-primary);
	color: var(--df-color-surface-base);
}

.df-success .df-success__btn:focus-visible {
	outline: 2px solid var(--df-color-action-primary);
	outline-offset: 2px;
}

@media (max-width: 767px) {
	.df-success {
		padding: var(--df-space-4);
	}

	.df-success__summary {
		grid-template-columns: minmax(0, 1fr);
	}

	.df-success .df-success__btn {
		flex: 1 1 100%;
		justify-content: center;
	}
}

/* ------------------------------------ contact page: link to estimate page */

/* "For project estimates, click here" (form_contact.xml estimate_cta_box), in the
   contact sidebar on desktop and above the form on mobile */
.contact_tabs .estimate-cta {
	display: block;
	/* full width of the sidebar like the phone/email box and map; the 20px padding
	   lines its text up with the Hours text below */
	margin: 0;
	padding: 20px;
	border-radius: 0;
	background: #dc1415;       /* $Dincel-Red */
	color: #ffffff;
	text-decoration: none;
	transition: background-color 150ms ease;
}

/* mobile / tablet copy, under the Send enquiry button - stands on its own there */
.contact_tabs .estimate-cta-wrap--below-form .estimate-cta {
	margin: 24px 0 0;
	border-radius: 4px;
}

/* mobile / tablet: the form comes first and the right column (phone/email,
   hours, map, offices) follows it, so show its phone/email box, which the theme
   hides below 992px (it relied on a separate details block above the form) */
@media (max-width: 991px) {
	.row.contact_tabs .contact-sidebar .info-wrapper {
		display: block;
		margin-top: 24px;
	}
}

.contact_tabs .estimate-cta:hover,
.contact_tabs .estimate-cta:focus {
	background: #b01011;
	color: #ffffff;
	text-decoration: none;
}

.contact_tabs .estimate-cta:focus-visible {
	outline: 2px solid #2b2a2a;
	outline-offset: 2px;
}

.contact_tabs .estimate-cta .estimate-cta__title {
	display: block;
	margin-bottom: 6px;
	color: #ffffff;
	font-family: RobotoCondensed, Arial, sans-serif;
	font-size: 1.375rem;
	line-height: 1.15;
	text-transform: uppercase;
}

.contact_tabs .estimate-cta .estimate-cta__text {
	margin: 0 0 12px;
	color: #ffffff;
	font-size: 0.8125rem;
	line-height: 1.45;
}

.contact_tabs .estimate-cta .estimate-cta__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #ffffff;
	font-size: 0.875rem;
}

.contact_tabs .estimate-cta:hover .estimate-cta__link {
	text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
	.contact_tabs .estimate-cta {
		transition: none;
	}
}
