/* Application Manager public styles.
 * Self-contained: spacing does not depend on Bootstrap utilities, and directory cards have no colour of
 * their own. Override the variables below in your theme to adjust spacing, lines and accents. */
.appmgr-block {
    --appmgr-accent: var(--bs-primary, #2563eb);
    --appmgr-danger: var(--bs-danger, #b42318);
    --appmgr-success: var(--bs-success, #1f7a3d);
    --appmgr-line: var(--bs-border-color, #d0d5dd);
    --appmgr-muted: var(--bs-secondary-color, #5f6b7a);
    --appmgr-surface: var(--bs-body-bg, #fff);
    --appmgr-sunken: var(--bs-tertiary-bg, #f4f5f7);
    --appmgr-radius: 10px;
    /* Spacing. The package sets its own spacing so forms look right on themes without Bootstrap. */
    --appmgr-field-gap: 1.75rem;   /* between questions */
    --appmgr-label-gap: .5rem;     /* between a label and its input */
    --appmgr-option-gap: .6rem;    /* between radio or checkbox options */
    --appmgr-col-gap: 1.25rem;     /* between half and one-third width questions */
}

/* Question widths: everything is a full row unless set to half or one third. Phones always stack. */
.appmgr-form { display: flex; flex-wrap: wrap; column-gap: var(--appmgr-col-gap); align-items: flex-start; }
.appmgr-form > * { flex: 0 0 100%; min-width: 0; }
.appmgr-form > .appmgr-field.appmgr-w-half { flex-basis: calc((100% - var(--appmgr-col-gap)) / 2); }
.appmgr-form > .appmgr-field.appmgr-w-third { flex-basis: calc((100% - 2 * var(--appmgr-col-gap)) / 3); }
.appmgr-form > .appmgr-submit { flex: 0 0 auto; }
@media (max-width: 640px) {
    .appmgr-form > .appmgr-field.appmgr-w-half,
    .appmgr-form > .appmgr-field.appmgr-w-third { flex-basis: 100%; }
}

/* No max-width: the form fills its container (area, column or layout). To narrow it on a site,
 * add e.g. .appmgr { max-width: 760px; } to the theme. */
.appmgr-title { margin: 0 0 1rem; }
.appmgr-description { margin: 0 0 var(--appmgr-field-gap); color: var(--appmgr-muted); line-height: 1.55; }
.appmgr-back { display: inline-block; margin-bottom: .75rem; font-size: .95em; }
.appmgr-muted, .appmgr-help { color: var(--appmgr-muted); }
.appmgr-req { color: var(--appmgr-danger); }
.appmgr-form > p.appmgr-muted { margin: 0 0 var(--appmgr-field-gap); }

/* Questions */
.appmgr .appmgr-field { margin: 0 0 var(--appmgr-field-gap); }
.appmgr .form-label,
.appmgr .appmgr-legend { display: block; margin: 0 0 var(--appmgr-label-gap); padding: 0; font-size: inherit; font-weight: 600; line-height: 1.4; float: none; width: auto; }
.appmgr fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.appmgr .form-control,
.appmgr .form-select { display: block; width: 100%; max-width: 100%; box-sizing: border-box; margin: 0; }
.appmgr textarea.form-control { min-height: 8rem; resize: vertical; }
.appmgr-help { margin-top: .45rem; font-size: .9em; line-height: 1.45; }

/* Radio buttons and checkboxes: one option per line, input aligned with the first line of its text */
.appmgr .form-check { display: flex; align-items: flex-start; gap: .6rem; margin: 0 0 var(--appmgr-option-gap); padding: 0; min-height: 0; }
.appmgr .form-check:last-child { margin-bottom: 0; }
.appmgr .form-check-input { flex: none; float: none; margin: .2em 0 0; width: 1.1em; height: 1.1em; }
.appmgr .form-check-label { margin: 0; line-height: 1.45; }

.appmgr .appmgr-separator { display: block; height: 0; margin: .25rem 0 0; padding: 0; border: 0; border-top: 1px solid var(--appmgr-line); background: none; color: inherit; opacity: 1; }
/* Section headings. A heading has its own top line only when no separator sits right above it, so a
 * separator + heading pair shows one line, not two. Spacing below the heading is tighter than between
 * questions, so it reads as the title of what follows. */
.appmgr .appmgr-section { margin: .5rem 0 0; padding: 1.25rem 0 0; border-top: 1px solid var(--appmgr-line); font-size: 1.25em; line-height: 1.3; }
.appmgr .appmgr-field[data-type="heading"] { margin-bottom: 1.1rem; }
.appmgr .appmgr-field[data-type="separator"] + .appmgr-field[data-type="heading"] .appmgr-section { margin-top: 0; padding-top: 0; border-top: 0; }
.appmgr-error { color: var(--appmgr-danger); font-weight: 500; margin-top: .45rem; }
.appmgr-bad .form-control, .appmgr-bad .form-select { border-color: var(--appmgr-danger); }
.appmgr-field[hidden] { display: none !important; }
.appmgr-reveal { animation: appmgr-reveal .28s ease-out; }
@keyframes appmgr-reveal { from { opacity: .2; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .appmgr-reveal { animation: none; } }
.appmgr-tag { display: inline-block; font-size: .72em; font-weight: 600; padding: .1em .55em; border-radius: 999px; background: var(--appmgr-sunken); color: var(--appmgr-accent); vertical-align: .15em; margin-left: .35em; }
.appmgr-alert { margin: 0 0 1rem; }
.appmgr-alert[hidden] { display: none !important; }
.appmgr-submit { padding-left: 1.4rem; padding-right: 1.4rem; margin-top: .5rem; }
.appmgr-success { border: 1px solid var(--appmgr-success); border-left-width: 5px; border-radius: var(--appmgr-radius); padding: 1rem 1.25rem; }
.appmgr-success h3 { margin-top: 0; color: var(--appmgr-success); }
.appmgr-notice, .appmgr-empty { padding: 1rem 1.25rem; background: var(--appmgr-sunken); border-radius: var(--appmgr-radius); }

/* Table questions: a table on wider screens, one card per row on phones */
.appmgr-tablewrap { overflow-x: auto; }
.appmgr-tableq { width: 100%; border-collapse: collapse; margin: 0; }
/* Themes often style tables (borders, stripes, backgrounds); the question table is a layout for inputs, so reset that. */
.appmgr-tableq, .appmgr-tableq thead, .appmgr-tableq tbody, .appmgr-tableq tr, .appmgr-tableq th, .appmgr-tableq td { border: 0; background: none; box-shadow: none; }
.appmgr-tableq th { text-align: left; font-weight: 600; font-size: .92em; padding: 0 .5rem .4rem 0; vertical-align: bottom; white-space: nowrap; }
.appmgr-tableq td { padding: 0 .5rem .5rem 0; vertical-align: top; min-width: 7rem; }
.appmgr-tableq td:has(select), .appmgr-tableq td:has(input[type="date"]) { min-width: 9.5rem; }
.appmgr-tableq tr > :last-child { padding-right: 0; }
.appmgr-tableq .appmgr-tq-act { width: 2.75rem; min-width: 0; text-align: right; }
/* Add and remove row buttons: neutral, so they fit any theme with or without Bootstrap. */
.appmgr .appmgr-tq-add, .appmgr .appmgr-tq-remove { font: inherit; font-size: .9em; line-height: 1.2; color: inherit; background: transparent; border: 1px solid var(--appmgr-line); border-radius: 6px; padding: .45rem .9rem; cursor: pointer; }
.appmgr .appmgr-tq-remove { padding: .45rem .65rem; }
.appmgr .appmgr-tq-add:hover:not(:disabled), .appmgr .appmgr-tq-remove:hover:not(:disabled) { border-color: currentColor; }
.appmgr .appmgr-tq-add:disabled, .appmgr .appmgr-tq-remove:disabled { opacity: .5; cursor: default; }
.appmgr-tq-add { margin-top: .25rem; }
.appmgr-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
    .appmgr-tableq thead { position: absolute; left: -10000px; }
    .appmgr-tableq, .appmgr-tableq tbody, .appmgr-tableq tr, .appmgr-tableq td { display: block; width: 100%; box-sizing: border-box; }
    .appmgr-tableq tr { border: 1px solid var(--appmgr-line); border-radius: 8px; padding: .75rem .75rem .25rem; margin-bottom: .75rem; }
    .appmgr-tableq td { padding: 0 0 .6rem; }
    .appmgr-tableq td::before { content: attr(data-label); display: block; font-weight: 600; font-size: .9em; margin-bottom: .3rem; }
    .appmgr-tableq td.appmgr-tq-act { width: auto; text-align: left; }
    .appmgr-tableq td.appmgr-tq-act::before { content: none; }
}

/* Signature pad. touch-action: none stops the page scrolling while someone signs on a phone. */
.appmgr-sig { max-width: 560px; }
.appmgr-sig-pad { display: block; width: 100%; height: 170px; box-sizing: border-box; border: 1px dashed var(--appmgr-line); border-radius: 8px; background: #fff; cursor: crosshair; touch-action: none; }
.appmgr-bad .appmgr-sig-pad { border-color: var(--appmgr-danger); border-style: solid; }
.appmgr-sig-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: .45rem; }
.appmgr-sig-hint { margin: 0; }
.appmgr .appmgr-sig-clear { font: inherit; font-size: .9em; line-height: 1.2; color: inherit; background: transparent; border: 1px solid var(--appmgr-line); border-radius: 6px; padding: .4rem .85rem; cursor: pointer; flex: none; }
.appmgr .appmgr-sig-clear:hover:not(:disabled) { border-color: currentColor; }
.appmgr .appmgr-sig-clear:disabled { opacity: .5; cursor: default; }

/* CAPTCHA: whatever the site's Captcha Setup outputs (a picture and a text box, or a reCAPTCHA widget). */
.appmgr-captcha img { max-width: 100%; height: auto; }
.appmgr-captcha-input br { display: none; } /* SecurImage adds a line break after its text box */
.appmgr-captcha-display + .appmgr-captcha-input { margin-top: var(--appmgr-label-gap); }
.appmgr-captcha-input .form-control, .appmgr-captcha-input input[type="text"] { max-width: 260px; }
.appmgr-bad .appmgr-captcha-input input { border-color: var(--appmgr-danger); }

/* Honeypot: visually hidden, still in the form. */
.appmgr-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* Directory */
.appmgr-dir-intro { max-width: 65ch; }
.appmgr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1rem; }
/* Cards are colourless on purpose: text, borders and focus rings use the site's own text colour,
 * and the background is transparent, so they fit light and dark themes alike. */
.appmgr-card { display: flex; flex-direction: column; gap: .9rem; padding: 1.5rem; border: 1px solid var(--appmgr-line); border-radius: var(--appmgr-radius); background: transparent; color: inherit; text-decoration: none; transition: border-color .15s; }
.appmgr-card:hover { border-color: currentColor; color: inherit; }
.appmgr-card:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; color: inherit; }
.appmgr-card h3 { margin: 0; font-size: 1.2em; color: inherit; }
.appmgr-card p { margin: 0; color: inherit; }
.appmgr-have { font-size: .92em; border-top: 1px solid var(--appmgr-line); padding-top: .9rem; }
.appmgr-have b { display: block; font-size: .78em; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem; }
.appmgr-have ul { margin: 0; padding-left: 1.1rem; }
.appmgr-have li + li { margin-top: .2rem; }
.appmgr-card .appmgr-muted { color: inherit; opacity: .75; }
.appmgr-go { margin-top: auto; padding-top: .25rem; font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: .2em; }
@media (prefers-reduced-motion: reduce) { .appmgr-card { transition: none; } }

/* Fallbacks for themes without Bootstrap.
 * Every rule here is wrapped in :where(), so it has no specificity: Bootstrap and any theme rule for the
 * same element win, and these only replace the browser's bare defaults. Colours come from the variables
 * at the top, which follow Bootstrap's when it's present. */
:where(.appmgr) :where(.form-control, .form-select) {
    padding: .55rem .75rem; font: inherit; line-height: 1.5; color: inherit;
    background-color: var(--appmgr-surface); border: 1px solid var(--appmgr-line); border-radius: 6px;
}
:where(.appmgr) :where(input[type="file"].form-control) { padding: .45rem .6rem; }
:where(.appmgr .form-control:focus-visible, .appmgr .form-select:focus-visible) { outline: 2px solid var(--appmgr-accent); outline-offset: 1px; border-color: var(--appmgr-accent); }
:where(.appmgr) :where(.form-check-input) { accent-color: var(--appmgr-accent); }
:where(.appmgr) :where(.invalid-feedback) { font-size: .9em; }
:where(.appmgr) :where(.alert) { padding: .85rem 1rem; border: 1px solid transparent; border-radius: 8px; }
:where(.appmgr) :where(.alert-danger) {
    color: var(--appmgr-danger); border-color: var(--appmgr-danger);
    background-color: #fef3f2; background-color: color-mix(in srgb, var(--appmgr-danger) 7%, var(--appmgr-surface));
}
:where(.appmgr) :where(.alert-success) {
    color: var(--appmgr-success); border-color: var(--appmgr-success);
    background-color: #f0f9f3; background-color: color-mix(in srgb, var(--appmgr-success) 7%, var(--appmgr-surface));
}
:where(.appmgr) :where(.btn-primary) {
    display: inline-block; padding: .6rem 1.4rem; font: inherit; font-weight: 600; line-height: 1.3;
    color: #fff; background-color: var(--appmgr-accent); border: 1px solid var(--appmgr-accent); border-radius: 6px; cursor: pointer;
}
:where(.appmgr .btn-primary:hover:not(:disabled)) { filter: brightness(.92); }
:where(.appmgr .btn-primary:focus-visible) { outline: 2px solid var(--appmgr-accent); outline-offset: 2px; }
:where(.appmgr .btn-primary:disabled) { opacity: .65; cursor: default; }
