/**
 * Forms
 *
 * Inputs are flat: white face, hairline border, 10px radius, 46px tall. The
 * inset double-shadow the previous build used is gone — it read as a well the
 * text had fallen into, and it made the placeholder harder to see, not easier.
 *
 * Placeholder and help text sit at the muted floor. The 0.55 alpha used
 * throughout the old build was 3.2:1.
 */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.form-label,
label.form-label {
    display: block;
    margin-bottom: var(--space-2);
    color: inherit;
    font-family: var(--font-body);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    letter-spacing: normal;
}

.form-input,
.form-control,
.form-select,
.form-textarea,
input[type='text'].form-control,
input[type='email'].form-control,
input[type='password'].form-control,
input[type='date'].form-control,
input[type='number'].form-control,
select.form-select,
textarea.form-control {
    width: 100%;
    height: 46px;
    padding: 0 var(--space-4);
    border: 1px solid var(--border-on-light-input);
    border-radius: var(--radius-md);
    background: var(--color-white);
    box-shadow: none;
    color: var(--text-on-light);
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: 1;
    transition: border-color var(--duration-fast) var(--easing),
                box-shadow var(--duration-fast) var(--easing);
}

.form-textarea,
textarea.form-control {
    height: auto;
    min-height: 120px;
    padding: var(--space-3) var(--space-4);
    line-height: var(--line-height-normal);
    resize: vertical;
}

.form-textarea-no-resize {
    resize: none;
}

.form-input::placeholder,
.form-control::placeholder,
.form-textarea::placeholder,
textarea.form-control::placeholder {
    color: var(--text-on-light-muted);
    opacity: 1;
}

.form-input:focus,
.form-control:focus,
.form-select:focus,
.form-textarea:focus,
select.form-select:focus,
textarea.form-control:focus {
    border-color: var(--color-gold);
    box-shadow: var(--focus-ring);
    outline: none;
}

.form-input:disabled,
.form-control:disabled,
.form-select:disabled {
    background: rgba(26, 77, 77, 0.04);
    color: var(--text-on-light-muted);
    cursor: not-allowed;
}

.form-select,
select.form-select {
    padding-right: var(--space-10);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none' stroke='%230D3B2E' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
}

.form-input-sm { height: 38px; font-size: var(--font-size-sm); }
.form-input-lg { height: 52px; }

/* ============================================
   HELP AND ERRORS

   Errors sit under the field and recolour its border. Validation runs on blur,
   never on keystroke — see public/assets/js/script.js.
   ============================================ */

.form-help-text,
.form-text,
.form-text.text-muted {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-on-light-muted);
    font-size: 0.78125rem;   /* 12.5px */
}

/* The asterisk beside a required label. Bootstrap's .text-danger is #dc3545,
   which is 4.0:1 on the cream card. */
.required-mark {
    color: var(--color-danger);
}

.form-error-message,
.invalid-feedback {
    display: block;
    margin-top: var(--space-1);
    color: var(--color-danger);
    font-size: var(--font-size-sm);
}

.form-success-message,
.valid-feedback {
    display: block;
    margin-top: var(--space-1);
    color: var(--color-success);
    font-size: var(--font-size-sm);
}

.form-control.is-invalid,
.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--color-danger);
}

.form-control.is-valid,
.form-input.is-valid {
    border-color: var(--color-success);
}

/* ============================================
   CHECKBOXES AND RADIOS
   ============================================ */

.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    padding-left: 0;
}

.form-check .form-check-input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    border: 1px solid var(--border-on-light);
    border-radius: 6px;
    background: var(--color-white);
    appearance: none;
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--easing),
                border-color var(--duration-fast) var(--easing);
}

.form-check .form-check-input[type='radio'] {
    border-radius: var(--radius-full);
}

.form-check .form-check-input:checked {
    border-color: var(--color-red-dark);
    background-color: var(--color-red-dark);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none' stroke='%23ffffff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10.5l4 4 8-9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.form-check .form-check-input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.form-check .form-check-label {
    color: inherit;
    cursor: pointer;
    font-size: var(--font-size-base);
}

.form-checkbox,
.form-radio {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ============================================
   GROUPS AND ROWS
   ============================================ */

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

.form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 640px) {
    .form-row,
    .form-row-3 { grid-template-columns: minmax(0, 1fr); }
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group > .form-control,
.input-group > .form-input,
.input-group > .form-select {
    flex: 1 1 auto;
    width: 1%;
    border-radius: 0;
}

.input-group > :first-child {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.input-group > :last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.input-group-text {
    display: flex;
    align-items: center;
    height: 46px;
    padding: 0 var(--space-4);
    border: 1px solid var(--border-on-light);
    background: rgba(26, 77, 77, 0.05);
    color: var(--text-on-light-muted);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

.input-group .btn {
    height: 46px;
    border-radius: 0;
}

.input-group .btn:last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* ============================================
   FIELDS ON THE TEAL GROUND

   A form sitting straight on the page — the participant search box, the
   toolbar filter — keeps the white face but needs a border that reads against
   teal rather than against cream.
   ============================================ */

body > .container .form-control:not(.card .form-control),
.on-dark .form-control,
.on-dark .form-input,
.on-dark .form-select {
    border-color: rgba(247, 243, 232, 0.30);
}

.on-dark .form-label,
.on-dark .form-check-label {
    color: var(--color-cream);
}

.on-dark .form-text,
.on-dark .form-help-text {
    color: var(--text-on-dark-muted);
}

/* ============================================
   PASSWORD STRENGTH

   Three segments and a word. Colour alone never carries the meaning.
   ============================================ */

.password-strength {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.password-strength-track {
    display: flex;
    gap: var(--space-1);
}

.password-strength-segment {
    flex: 1;
    height: 5px;
    border-radius: var(--radius-full);
    background: rgba(26, 77, 77, 0.14);
    transition: background-color var(--duration-base) var(--easing);
}

.password-strength[data-strength='1'] .password-strength-segment:nth-child(1) { background: var(--color-danger); }
.password-strength[data-strength='2'] .password-strength-segment:nth-child(-n+2) { background: var(--color-warning-fill); }
.password-strength[data-strength='3'] .password-strength-segment { background: var(--color-success-fill); }

.password-strength-label {
    color: var(--text-on-light-muted);
    font-size: 0.78125rem;
}

/* A disclosure button turns its chevron over rather than rewriting the icon's
   paths from script. Which way the arrow points is the state, so it follows
   aria-expanded instead of becoming a second source of truth. */
.disclosure-toggle .icon-chevron {
    transition: transform var(--duration-base) var(--easing);
}

.disclosure-toggle[aria-expanded="true"] .icon-chevron {
    transform: rotate(180deg);
}

/*
 * Checkboxes and radios take the product's colour.
 *
 * There was no checkbox styling anywhere in this stylesheet set, so every one
 * rendered in the browser's own blue — #0075FF, the only saturated blue in a
 * cream, forest-green, gold and red page, appearing twice on the event page
 * and again on create-event. accent-color is one line and leaves the native
 * control, its focus ring and its keyboard behaviour exactly as they were.
 */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--color-primary);
}
