/* ==========================================================================
   Veolia Design System - Drupal Webform Fixes
   Keep existing layout, fix dropdown arrows, buttons, fields and safe hiding.
   ========================================================================== */

/* ==========================================================================
   1. Webform Container
   ========================================================================== */

.webform-ajax-form-wrapper,
form.webform-submission-form {
  background-color: #FFFFFF !important;
  padding: 32px !important;
  border-radius: 8px !important;
  box-sizing: border-box !important;
  width: 100% !important;
  scroll-margin-top: 120px !important;
}

.webform-ajax-form-wrapper form.webform-submission-form {
  padding: 0 !important;
  border-radius: 0 !important;
}

/* ==========================================================================
   2. Form Layout + Labels
   ========================================================================== */

.webform-submission-form .form-item,
.webform-submission-form .js-form-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 4px !important;
  margin-bottom: 20px !important;
  padding: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body .webform-submission-form label {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: max-content !important;
  max-width: 100% !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #333333 !important;
  margin-bottom: 4px !important;
  text-align: left !important;
  background-image: none !important;
}

body .webform-submission-form label .form-required,
body .webform-submission-form label .js-form-required,
body .webform-submission-form label abbr {
  display: inline-block !important;
  position: static !important;
  margin-left: 4px !important;
  color: #333333 !important;
  text-decoration: none !important;
  border: none !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Prevent duplicated Drupal required pseudo marker. */
body .webform-submission-form label.form-required::after,
body .webform-submission-form label.js-form-required::after {
  content: none !important;
  display: none !important;
}

/* ==========================================================================
   3. Text Fields
   ========================================================================== */

.webform-submission-form input.form-text,
.webform-submission-form input.form-email,
.webform-submission-form input.form-tel,
.webform-submission-form input.form-number,
.webform-submission-form input.form-url,
.webform-submission-form input.form-search,
.webform-submission-form textarea.form-textarea {
  background-color: #F2F1F9 !important;
  border: 1px solid #D5D3E3 !important;
  color: #333333 !important;
  border-radius: 4px !important;
  padding: 14px 16px !important;
  width: 100% !important;
  height: 50px !important;
  box-sizing: border-box !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 16px !important;
  line-height: 22px !important;
  box-shadow: none !important;
  outline: none !important;
  transition: border-color 0.2s ease, background-color 0.2s ease !important;
}

.webform-submission-form textarea.form-textarea {
  min-height: 120px !important;
  height: auto !important;
  resize: vertical !important;
}

.webform-submission-form input.form-text:focus,
.webform-submission-form input.form-email:focus,
.webform-submission-form input.form-tel:focus,
.webform-submission-form input.form-number:focus,
.webform-submission-form input.form-url:focus,
.webform-submission-form input.form-search:focus,
.webform-submission-form textarea.form-textarea:focus {
  background-color: #FFFFFF !important;
  border-color: #0072CE !important;
  outline: none !important;
}

/* ==========================================================================
   4. Native Select Dropdowns
   IMPORTANT:
   - Do not style select2-hidden-accessible as a visible select.
   - One small chevron only.
   - Chevron is on the LEFT side.
   ========================================================================== */

.webform-submission-form select.select2-hidden-accessible {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.webform-submission-form select.form-select:not(.select2-hidden-accessible) {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;

  background-color: #F2F1F9 !important;
  border: 1px solid #D5D3E3 !important;
  color: #333333 !important;
  border-radius: 4px !important;

  width: 100% !important;
  height: 50px !important;
  box-sizing: border-box !important;

  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 16px !important;
  line-height: 22px !important;

  padding: 14px 16px 14px 48px !important;

  box-shadow: none !important;
  outline: none !important;
  cursor: pointer !important;

  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23333333' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 18px center !important;
  background-size: 14px 14px !important;

  transition: border-color 0.2s ease, background-color 0.2s ease !important;
}

.webform-submission-form select.form-select:not(.select2-hidden-accessible):focus {
  background-color: #FFFFFF !important;
  border-color: #0072CE !important;
  outline: none !important;

  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%230072CE' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
}

.webform-submission-form select.form-select:not(.select2-hidden-accessible)::-ms-expand {
  display: none !important;
}

/* ==========================================================================
   5. Select2 Dropdowns
   IMPORTANT:
   - Style only the visible Select2 container.
   - Hide the default triangle.
   - Use one small left-side chevron only.
   - No wrappers, overlays, or blocking pseudo-elements.
   ========================================================================== */

.webform-submission-form .select2-container {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
}

.webform-submission-form .select2-container,
.webform-submission-form .select2-container * {
  outline: none !important;
  box-sizing: border-box !important;
}

.webform-submission-form .select2-container--default .select2-selection--single {
  position: relative !important;
  background-color: #F2F1F9 !important;
  border: 1px solid #D5D3E3 !important;
  border-radius: 4px !important;
  height: 50px !important;
  min-height: 50px !important;
  width: 100% !important;
  padding: 0 !important;
  display: block !important;
  box-shadow: none !important;
  outline: none !important;
  cursor: pointer !important;
  transition: border-color 0.2s ease, background-color 0.2s ease !important;
}

.webform-submission-form .select2-container--default.select2-container--focus .select2-selection--single,
.webform-submission-form .select2-container--default.select2-container--open .select2-selection--single {
  background-color: #FFFFFF !important;
  border-color: #0072CE !important;
}

.webform-submission-form .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #333333 !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 16px !important;
  line-height: 48px !important;
  padding-left: 48px !important;
  padding-right: 16px !important;
  height: 48px !important;
}

.webform-submission-form .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #555555 !important;
}

/* Move Select2 arrow to the LEFT and make it non-blocking. */
.webform-submission-form .select2-container--default .select2-selection--single .select2-selection__arrow {
  position: absolute !important;
  top: 50% !important;
  left: 18px !important;
  right: auto !important;
  width: 14px !important;
  height: 14px !important;
  transform: translateY(-50%) !important;
  pointer-events: none !important;
}

/* Remove Select2 default CSS triangle and replace with one SVG chevron. */
.webform-submission-form .select2-container--default .select2-selection--single .select2-selection__arrow b {
  border: 0 !important;
  border-color: transparent !important;
  border-style: none !important;

  display: block !important;
  position: static !important;
  margin: 0 !important;

  width: 14px !important;
  height: 14px !important;

  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23333333' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 14px 14px !important;
}

.webform-submission-form .select2-container--default.select2-container--focus .select2-selection--single .select2-selection__arrow b,
.webform-submission-form .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%230072CE' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
}

/* Make sure no extra pseudo arrow appears. */
.webform-submission-form .select2-container--default .select2-selection--single::before,
.webform-submission-form .select2-container--default .select2-selection--single::after,
.webform-submission-form .select2-container--default .select2-selection__arrow::before,
.webform-submission-form .select2-container--default .select2-selection__arrow::after {
  content: none !important;
  display: none !important;
}

/* Select2 dropdown panel. */
.select2-container--default .select2-dropdown {
  border: 1px solid #D5D3E3 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10) !important;
  border-radius: 0 0 4px 4px !important;
  background-color: #F2F1F9 !important;
  overflow: hidden !important;
  z-index: 9999 !important;
}

.select2-container--default .select2-results,
.select2-container--default .select2-results__options,
.select2-container--default .select2-results__option {
  background-color: #F2F1F9 !important;
  color: #333333 !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 16px !important;
}

.select2-container--default .select2-results__option {
  padding: 10px 16px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected],
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[data-selected="true"] {
  background-color: #D5D3E3 !important;
  color: #333333 !important;
}

/* ==========================================================================
   6. Conditional Field Hidden State
   Controlled by JS only. No MutationObserver.
   ========================================================================== */

.webform-submission-form .veolia-js-hidden {
  display: none !important;
}

/* Hide only the helper text under the "Autres" precision field. */
.webform-submission-form .veolia-hide-description .description,
.webform-submission-form .veolia-hide-description .form-item__description,
.webform-submission-form .veolia-hide-description .webform-element-description,
.webform-submission-form .veolia-hide-description [id$="--description"],
.webform-submission-form .veolia-hide-description [data-drupal-selector$="-description"] {
  display: none !important;
}

/* ==========================================================================
   7. Form Actions + Buttons
   ========================================================================== */

body .webform-submission-form .form-actions {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 32px !important;
  margin-top: 32px !important;
  clear: both !important;
}

body .webform-submission-form .webform-legal-notice {
  flex: 1 1 auto !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 13px !important;
  line-height: 19px !important;
  color: #555555 !important;
  margin-right: auto !important;
  padding-right: 40px !important;
}

body .webform-submission-form .webform-submit-wrapper {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 16px !important;
  flex-wrap: wrap !important;
}

/* Primary/default action buttons. */
.webform-submission-form .form-actions input[type="submit"],
.webform-submission-form .form-actions button,
.webform-submission-form .form-actions .button {
  border-radius: 999px !important;
  border: none !important;
  padding: 12px 48px !important;
  background-color: #EE0000 !important;
  background-image: none !important;
  color: #FFFFFF !important;
  font-family: "Noto Sans", Arial, sans-serif !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 140px !important;
  min-height: 48px !important;
  width: auto !important;
  box-sizing: border-box !important;
  line-height: 24px !important;
  text-decoration: none !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out !important;
}

/* Previous button. */
.webform-submission-form .form-actions input.webform-button--previous,
.webform-submission-form .form-actions button.webform-button--previous,
.webform-submission-form .form-actions .button.webform-button--previous {
  background-color: #D5D3E3 !important;
  background-image: none !important;
  color: #333333 !important;
  border-radius: 999px !important;
}

/* Remove duplicated icons or pseudo-elements from buttons. */
.webform-submission-form .form-actions input::before,
.webform-submission-form .form-actions input::after,
.webform-submission-form .form-actions button::before,
.webform-submission-form .form-actions button::after,
.webform-submission-form .form-actions .button::before,
.webform-submission-form .form-actions .button::after {
  content: none !important;
  display: none !important;
}

.webform-submission-form .form-actions button svg,
.webform-submission-form .form-actions input svg,
.webform-submission-form .form-actions .button svg {
  display: none !important;
}

.webform-submission-form .form-actions input[type="submit"]:hover,
.webform-submission-form .form-actions button:hover,
.webform-submission-form .form-actions .button:hover {
  opacity: 0.85 !important;
}

.webform-submission-form .form-actions input[type="submit"]:focus,
.webform-submission-form .form-actions button:focus,
.webform-submission-form .form-actions .button:focus {
  outline: 2px solid #0072CE !important;
  outline-offset: 3px !important;
}

/* ==========================================================================
   8. Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .webform-ajax-form-wrapper,
  form.webform-submission-form {
    padding: 24px !important;
  }

  body .webform-submission-form .form-actions {
    align-items: stretch !important;
    gap: 20px !important;
  }

  body .webform-submission-form .webform-legal-notice {
    flex: 1 1 100% !important;
    padding-right: 0 !important;
  }

  body .webform-submission-form .webform-submit-wrapper {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  .webform-submission-form .form-actions input[type="submit"],
  .webform-submission-form .form-actions button,
  .webform-submission-form .form-actions .button {
    width: 100% !important;
  }
}