/**
 * B2B Validator Frontend Styles
 */

/* Select2 container */
.b2b-company-search.select2-hidden-accessible + .select2-container {
	width: 100% !important;
}

/* Field wrappers */
.b2b-company-name,
.b2b-company-regcode,
.b2b-company-vat {
	margin-bottom: 15px;
	transition: opacity 0.3s ease;
}

/* Readonly fields */
.b2b-company-name input[readonly],
.b2b-company-vat input[readonly] {
	background-color: #f5f5f5;
	cursor: not-allowed;
}

/* Select2 styling */
.select2-container--default .select2-selection--single {
	height: 38px;
	/*padding: 5px;*/
	border: 1px solid #ddd;
	border-radius: 4px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: 26px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 36px;
}

.select2-container--default .select2-dropdown {
	border: 1px solid #ddd;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.select2-container--default .select2-results__option {
	padding: 10px 15px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
	background-color: #2271b1;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
	border: 1px solid #ddd;
	padding: 8px;
}

/* Required indicator */
.b2b-company-name .required,
.b2b-company-regcode .required {
	color: #e00;
	font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
	.select2-container--default .select2-results__option {
		padding: 12px 15px;
	}
}

input.disabled {
    background-color: #f5f5f5 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Company name/VAT fields while a saved reg. nr. is being looked up. */
input.b2b-validating {
	font-style: italic;
}

/* Reg. nr. field wrapper while a saved reg. nr. is being auto-validated -
   dims the Select2 to match the disabled company name/VAT fields. */
.b2b-validating .select2-container {
	opacity: 0.7;
	pointer-events: none;
}

#billing_reg_nr_field .select2-container {
	width: 100% !important;
}

/* These account-type fields are managed via My Account > Edit address
   (or checkout), not on the Account details / password page. */
.woocommerce-EditAccountForm #billing_personal_nr_field,
.woocommerce-EditAccountForm #billing_account_nr_field,
.woocommerce-EditAccountForm #billing_bank_name_field,
.woocommerce-EditAccountForm #billing_bank_nr_field {
	display: none;
}

/* On checkout, these fields depend on Company vs. Individual commersant.
   Hide them until frontend.js determines which set to show - otherwise
   the server-rendered default (Company fields) flashes briefly before JS
   runs (it loads after the select2 CDN dependency). */
body.woocommerce-checkout #billing_reg_nr_field,
body.woocommerce-checkout #billing_company_field,
body.woocommerce-checkout #eu_vat_number_field_field,
body.woocommerce-checkout #billing_personal_nr_field {
	display: none;
}

/* For logged-in customers with a saved entity type, show the correct set of
   fields immediately (via the body class added in class-frontend.php),
   instead of waiting for frontend.js to toggle them. Higher specificity than
   the body.woocommerce-checkout rule above (so it wins on first paint), but
   deliberately NOT !important - frontend.js sets inline display styles when
   the user changes the entity type radios afterwards, and those must still
   be able to override this. */
body.woocommerce-checkout.b2b-entity-company #billing_reg_nr_field,
body.woocommerce-checkout.b2b-entity-company #billing_company_field,
body.woocommerce-checkout.b2b-entity-company #eu_vat_number_field_field {
	display: block;
}

body.woocommerce-checkout.b2b-entity-entrepreneur #billing_personal_nr_field {
	display: block;
}

/* On My Account > Edit address, legal_or_natural_person ("Lietotāja tips")
   and entity_type ("Juridiskā informācija") are presented as section
   headings: style the field's own label like the
   .thwcfe-html-field-wrapper h5 elsewhere on this form, and hide the
   "(nav obligāts)" optional-field suffix WooCommerce appends to the label. */
#legal_or_natural_person_field > label,
#entity_type_field > label {
	display: block;
	margin-bottom: 10px;
	margin-top: 15px;
	color: #4D4D4D;
	font-weight: 600;
}

#legal_or_natural_person_field .optional,
#legal_or_natural_person_field .required,
#entity_type_field .optional,
#entity_type_field .required {
	display: none;
}

/* Hide these conditional fields by default - frontend.js (entity_type
   radios + the JS-injected bank fields) can load late, causing them to
   flash visible (and, for the bank fields, appear) before being
   hidden/shown correctly. Show the right set immediately via the body
   class set server-side from the customer's saved entity type
   (add_entity_type_body_class). Deliberately NOT !important - frontend.js
   sets inline display styles when the radios are changed afterwards, and
   those must still be able to override this. */
body.woocommerce-account #billing_reg_nr_field,
body.woocommerce-account #billing_personal_nr_field,
body.woocommerce-account #billing_bank_name_field,
body.woocommerce-account #billing_bank_nr_field {
	display: none;
}

body.woocommerce-account.b2b-entity-company #billing_reg_nr_field,
body.woocommerce-account.b2b-entity-company #billing_bank_name_field,
body.woocommerce-account.b2b-entity-company #billing_bank_nr_field,
body.woocommerce-account.b2b-entity-entrepreneur #billing_personal_nr_field,
body.woocommerce-account.b2b-entity-entrepreneur #billing_bank_name_field,
body.woocommerce-account.b2b-entity-entrepreneur #billing_bank_nr_field {
	display: block;
}
