/*
    forms.css — labels, inputs and the grid that arranges them, plus the filter
    toolbar that sits above most tables.

    .form-grid shares the twelve columns and .span-* helpers defined in
    layout.css, so a field is placed exactly like any other block of content.
*/

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-4);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    grid-column: span 12;
}

.form-label {
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
}

.form-label .required {
    color: var(--danger);
}

.form-control,
.form-select,
input[type="text"].form-control,
input[type="search"],
textarea.form-control {
    width: 100%;
    min-height: 38px;
    padding: 7px var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: 1.5;
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.form-select {
    padding-inline-end: var(--space-8);
    appearance: none;
    background-image: linear-gradient(45deg, transparent 49%, var(--text-subtle) 50%),
                      linear-gradient(-45deg, transparent 49%, var(--text-subtle) 50%);
    background-size: 6px 6px, 6px 6px;
    background-position: calc(100% - var(--space-5)) 17px, calc(100% - var(--space-4)) 17px;
    background-repeat: no-repeat;
}

[dir="rtl"] .form-select {
    background-position: var(--space-4) 17px, var(--space-5) 17px;
}

.form-control:focus,
.form-select:focus,
input[type="search"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--shadow-focus);
}

.form-control:disabled,
.form-select:disabled {
    background: var(--surface-sunken);
    color: var(--text-subtle);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-subtle);
}

textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.field-hint {
    color: var(--text-subtle);
    font-size: var(--text-xs);
}

/* ---- Checkboxes ---- */

.check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-base);
}

.check input[type="checkbox"],
.check input[type="radio"],
.form-check-input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
}

/* A checkbox that is its own field gets the label beside it, not above it. */
.field-check {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
}

.field-check .form-label {
    margin: 0;
    font-weight: var(--weight-regular);
}

/* ---- Validation, as rendered by ASP.NET MVC ---- */

.input-validation-error,
.form-control.input-validation-error {
    border-color: var(--danger);
}

.field-validation-error,
.validation-summary-errors,
.field-error {
    color: var(--danger);
    font-size: var(--text-xs);
}

/* An error slot that is empty until the server fills it takes up no room. */
.field-error:empty {
    display: none;
}

.validation-summary-errors ul {
    margin: 0;
    padding-inline-start: var(--space-5);
    list-style: disc;
}

.validation-summary-valid {
    display: none;
}

/* ---- Password reveal: the sign-in form and the user screen ---- */

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field .form-control {
    padding-inline-end: var(--space-10);
}

.password-toggle {
    position: absolute;
    inset-inline-end: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--brand);
}

.password-toggle .icon-hide,
.password-toggle.is-on .icon-show {
    display: none;
}

.password-toggle.is-on .icon-hide {
    display: inline-flex;
}

/* ---- Filter toolbar ---- */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.toolbar-grow {
    flex: 1 1 280px;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin: 0;
}

.filter-form .form-select {
    flex: 0 1 200px;
}

/* ---- Search field ---- */

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 240px;
    min-width: 0;
}

.search-field .icon {
    position: absolute;
    inset-inline-start: var(--space-3);
    color: var(--text-subtle);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-field input {
    width: 100%;
    padding-inline-start: var(--space-10);
    border-radius: var(--radius-pill);
    background: var(--surface);
}

.search-field input::-webkit-search-cancel-button {
    cursor: pointer;
}

@media (max-width: 575.98px) {
    .filter-form,
    .toolbar {
        width: 100%;
    }

    .filter-form .btn {
        flex: 1 1 auto;
    }
}
