/**
 * validators.css - Optimized Version
 * Form validation states, radio groups, file uploads, date/time pickers
 */

/* ==================== INLINE ERROR MESSAGES ==================== */

/*span.wrapped {
  display: inline-block;
  width: 100%;
  text-wrap: auto;
  text-align: left;
  padding: 5px;
}*/
/* Let the container shrink so children can wrap in Safari (flex/table quirk). */
.table-info,
.table-info > label,
.table-info .field-label,
.form-control-cell,
.form-group {
  min-width: 0;
}

/*  Cross-browser Label wrapping */
.label.wrapped,
span.wrapped {
  display: block;              /* occupy the full line under the label */
  max-width: 100%;
  white-space: normal !important;  /* <-- critical: defeats Bootstrap nowrap */

  /* Cross-browser wrapping for long tokens/URLs on Safari/iOS + others */
  overflow-wrap: anywhere;     /* modern */
  word-wrap: break-word;       /* legacy alias */
  word-break: break-word;      /* WebKit/Safari quirk fallback */
  hyphens: auto;

  text-align: left;
  padding: 5px;
}

/* Increase only inline validation error text under field labels */
.form-group label > .label.label-danger.wrapped,
[id$="_label"] > .label.label-danger.wrapped {
  font-size: 14px;          /* adjust as needed (e.g., 14px–18px or 1rem) */
  line-height: 1.35;        /* keep multi-line messages readable */
  padding: 0.25em 0.5em;    /* optional: keep the pill comfortable as size grows */
}

/* Optional: slightly larger on small screens */
@media (max-width: 480px) {
  .form-group label > .label.label-danger.wrapped,
  [id$="_label"] > .label.label-danger.wrapped {
    font-size: 17px;
  }
}




/* ==================== DATE/TIME PICKER ERROR STATES ==================== */

/* Hide bound input (accessibility-friendly method) */
.control > input.datetime.form-control {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Paint the visible PP date/time input when invalid */
.form-control-cell .input-group.datetimepicker input.form-control.error,
.form-control-cell .input-group.datetimepicker input.input-text-box.error,
.form-control-cell .input-group.datetimepicker input[aria-invalid="true"] {
  border-color: var(--error-color);
  box-shadow: var(--error-shadow);
}

/* Keep it red while focused */
.form-control-cell .input-group.datetimepicker input.form-control.error:focus,
.form-control-cell .input-group.datetimepicker input.input-text-box.error:focus,
.form-control-cell .input-group.datetimepicker input[aria-invalid="true"]:focus {
  border-color: var(--error-color);
  box-shadow: var(--error-shadow);
  outline: none;
}

/* Wrapper error classes */
.form-control-cell.error .input-group.datetimepicker input.form-control,
.form-control-cell.has-error .input-group.datetimepicker input.form-control,
.form-control-cell.error .input-group.datetimepicker input.input-text-box,
.form-control-cell.has-error .input-group.datetimepicker input.input-text-box {
  border-color: var(--error-color);
  box-shadow: var(--error-shadow);
}

/* ==================== WET-PATCHED RADIO GROUPS ==================== */

/* Fieldset & Legend */
.wet-patched-radio fieldset.wet-radio-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.wet-patched-radio fieldset.wet-radio-fieldset > legend {
  font-size: 16px;
  color: var(--text-dark);
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 0.25rem 0;
  padding: 0;
}

/* Ensure child elements inherit legend styling */
.wet-patched-radio legend .field-label,
.wet-patched-radio legend .field-name {
  font: inherit;
  color: inherit;
  font-weight: inherit;
}

/* Inline layout: "○ No  ○ Yes" */
.wet-patched-radio label.radio-inline {
  display: inline-flex;
  align-items: center;
  margin-right: 1.5rem;
  white-space: nowrap;
}

.wet-patched-radio label.radio-inline input[type="radio"] {
  position: static;
  margin: 0 0.45rem 0 0;
  vertical-align: middle;
}

/* Touch-friendly radio padding */
@media (pointer: coarse) {
  .wet-patched-radio label.radio-inline {
    padding: 0.45rem 0.6rem;
  }
}

@media (max-width: 480px) {
  .wet-patched-radio label.radio-inline { white-space: normal; }
}

/* ==================== FILE UPLOAD CONTROLS ==================== */

/* File name as clickable link */
.file-name--clickable {
  cursor: pointer;
  text-decoration: underline;
}

/* Touch-friendly file buttons */
@media (pointer: coarse) {
  .file-control-container button,
  .container-file-input button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* iOS fix: keep radio options tight and left-aligned in patched groups */
.wet-patched-radio fieldset.wet-radio-fieldset { 
  text-align: left;              /* defeat any right-align at mobile */
}

.wet-patched-radio fieldset.wet-radio-fieldset label.radio-inline {
  display: inline-flex;          /* keep bullet + text together */
  align-items: center;
  white-space: nowrap;
  margin-right: 1.25rem;         /* gap between “No” and “Yes” */
  padding: 0 !important;         /* cancel Bootstrap/WET left padding */
  width: auto !important;        /* avoid 100% width on small screens */
  float: none !important;        /* defeat any inherited floats */
  max-width: none;
}

.wet-patched-radio fieldset.wet-radio-fieldset label.radio-inline input[type="radio"] {
  position: static !important;   /* cancel legacy absolute positioning */
  margin: 0 .45rem 0 0;          /* “○ No  ○ Yes” spacing */
  flex: 0 0 auto;
  vertical-align: middle;
}

/* --- merged additions from custom.css --- */
/* ===== Additions moved from custom.css (validator UI) ===== */
/* == 5) Validation/Error States ============================================== */
.form-control.error,
input.error,
select.error,
textarea.error {
border-color: var(--error-color);
  box-shadow: var(--error-shadow);
  outline: none;
}

/* Container-level error state */
.has-error .form-control,
.has-error .form-control:focus {
border-color: var(--error-color);
  box-shadow: var(--error-shadow);
}

/* Visible validator text */
.validators span[id^="RequiredFieldValidator"],
.validators span[id^="DateFormatValidator"] {
color: var(--error-color);
  font-weight: bold;
}

/* old IE/Edge quirk */

/* == 10) Read-only Summary View ============================================= */
.crmEntityFormView .table-info.required .field-label::after,
.crmEntityFormView label.required::after,
.crmEntityFormView .required .field-label::after,
.crmEntityFormView abbr[title="required"],
.crmEntityFormView abbr[title="(required)"],
.crmEntityFormView .validators span {
content: none !important;
  display: none !important;
}

body.read-only-summary .crmEntityFormView .table-info .validators {
margin: 0 !important;
  padding: 0 !important;
}

/* ==================== ACCESSIBLE FOCUS VISUALS ==================== */
/* 1) Validation summary container: visible keyboard focus */
#ValidationSummaryEntityFormView {
  /* make sure the browser scrolls enough below the fixed GCWeb banner */
  scroll-margin-top: 90px;
}
#ValidationSummaryEntityFormView:focus {
  outline: 3px solid #3b99fc;   /* accessible blue ring */
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(59,153,252,.2);
}

/* Summary links (the list of errors) */
#ValidationSummaryEntityFormView a:focus,
#ValidationSummaryEntityFormView a:focus-visible {
  outline: 3px solid #3b99fc;
  outline-offset: 2px;
  text-decoration: underline;   /* reinforce affordance */
}

/* 2) Radio groups: show focus on the option AND around the group */
.wet-patched-radio fieldset.wet-radio-fieldset:focus-within {
  outline: 3px solid #3b99fc;
  outline-offset: 4px;
  border-radius: 4px;
  /* small padding so the outline doesn't hug the content */
  padding: .15rem;
}

/* highlight the exact option the keyboard is on */
.wet-patched-radio label.radio-inline:has(input[type="radio"]:focus-visible),
.wet-patched-radio label.radio-inline:focus-within {
  outline: 3px solid #3b99fc;
  outline-offset: 3px;
  border-radius: 4px;
}

/* ensure the control itself shows a ring in browsers that only outline the input */
.wet-patched-radio input[type="radio"]:focus,
.wet-patched-radio input[type="radio"]:focus-visible {
  outline: 2px solid #3b99fc;
  outline-offset: 2px;
}
/* Read-only summary pages: suppress radio focus visuals */
body.read-only-summary .boolean-radio:focus-within,
body.read-only-summary .boolean-radio input[type="radio"]:focus,
body.read-only-summary .boolean-radio input[type="radio"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* If you’re using the patched radio markup */
body.read-only-summary .wet-patched-radio fieldset.wet-radio-fieldset:focus-within {
  outline: none !important;
  padding: 0 !important; /* undo the added padding from the focus style */
}
body.read-only-summary .wet-patched-radio label.radio-inline:has(input[type="radio"]:focus-visible),
body.read-only-summary .wet-patched-radio label.radio-inline:focus-within {
  outline: none !important;
}
body.read-only-summary .wet-patched-radio input[type="radio"]:focus,
body.read-only-summary .wet-patched-radio input[type="radio"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
/* === Unified focus style for radios (matches input focus) === */
/* Use the label as the visual target so the ring is large & consistent */
:root{
  /* Fallbacks: GCWeb blue (#1a5a96) if --bs-primary* aren’t defined */
  --pp-focus-border: var(--bs-primary, #1a5a96);
  --pp-focus-ring: rgba(var(--bs-primary-rgb, 26,90,150), .35);
  --pp-focus-radius: .375rem;   /* ~ Bootstrap 5 form-control radius */
  --pp-focus-ring-w: .25rem;    /* ~ 4px ring thickness */
}

/* Radio directly followed by its label (your markup pattern) */
.boolean-radio input[type="radio"]:focus-visible + label,
.form-check-input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--pp-focus-border);
  outline-offset: 2px;
  border-radius: var(--pp-focus-radius);
  box-shadow: 0 0 0 var(--pp-focus-ring-w) var(--pp-focus-ring);
}

/* Optional: also show a subtle ring on the radio dot itself */
.boolean-radio input[type="radio"]:focus-visible,
.form-check-input[type="radio"]:focus-visible {
  outline: none; /* rely on the label ring */
  box-shadow: 0 0 0 var(--pp-focus-ring-w) var(--pp-focus-ring);
  border-color: var(--pp-focus-border);
}

/* Radio groups: if your group container gets :focus-within, make it match too */
.boolean-radio:focus-within {
  outline: 2px solid var(--pp-focus-border);
  outline-offset: 4px;
  border-radius: var(--pp-focus-radius);
  box-shadow: 0 0 0 var(--pp-focus-ring-w) var(--pp-focus-ring);
}

/* Keep summary/read-only pages clean (toggle this class in JS when needed) */
body.read-only-summary .boolean-radio:focus-within,
body.read-only-summary .boolean-radio input[type="radio"]:focus,
body.read-only-summary .boolean-radio input[type="radio"]:focus-visible,
body.read-only-summary .boolean-radio input[type="radio"]:focus-visible + label {
  outline: none !important;
  box-shadow: none !important;
}
/* === Radios: focus only the circle (no group or label rings) === */

/* 1) Kill group/label outlines from earlier rules (patched & legacy groups) */
.wet-patched-radio fieldset.wet-radio-fieldset:focus-within,
.wet-patched-radio label.radio-inline:has(input[type="radio"]:focus-visible),
.wet-patched-radio label.radio-inline:focus-within,
.boolean-radio:focus-within {
  outline: none !important;
  box-shadow: none !important;
  /* if you had padding added for outline spacing earlier, reset it */
  padding: 0 !important;
}

/* 2) Remove any outer outline/shadow from the radio control itself */
.wet-patched-radio input[type="radio"]:focus,
.wet-patched-radio input[type="radio"]:focus-visible,
.boolean-radio input[type="radio"]:focus,
.boolean-radio input[type="radio"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* 3) Show “blue” only on the radio circle */
:root {
  --pp-radio-focus: var(--focus-color, #1a5a96); /* GCWeb blue fallback */
}

/* Use accent-color on focus so only the native dot/border is blue */
.wet-patched-radio input[type="radio"]:focus-visible,
.boolean-radio input[type="radio"]:focus-visible {
  /* Supported in all modern browsers, incl. Safari 15.4+ / iOS 15.4+ */
  accent-color: var(--pp-radio-focus);
}

/* (Optional) For browsers that ignore :focus-visible, also tint on :focus */
@supports selector(:focus-visible) {
  /* nothing extra */
}
@supports not selector(:focus-visible) {
  .wet-patched-radio input[type="radio"]:focus,
  .boolean-radio input[type="radio"]:focus {
    accent-color: var(--pp-radio-focus);
  }
}

/* High-contrast user settings: let the OS draw its own indicator */
@media (forced-colors: active) {
  .wet-patched-radio input[type="radio"]:focus,
  .wet-patched-radio input[type="radio"]:focus-visible,
  .boolean-radio input[type="radio"]:focus,
  .boolean-radio input[type="radio"]:focus-visible {
    accent-color: ButtonText;   /* defer to system palette */
  }
}


