/* ==========================================================================
   Compact data-entry forms (trial)

   Used by form.html and combined_form.html through _form_grid.html:
   fields flow in a responsive grid, grouped in sections, with Save /
   Cancel pinned to the bottom of the window. Loaded after styles.css and
   theme.css. To switch it off, remove the forms.css <link> in base.html
   (the pages then fall back to plain stacked fields).
   ========================================================================== */

.fg-card {
    padding: 18px 22px 20px;
    margin-bottom: 0;
}

.fg-section {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.fg-section + .fg-section {
    margin-top: 18px;
}

/* Small uppercase title with a rule, as on the project overview. */
.fg-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0 0 10px;
    padding: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.fg-legend::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.fg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px 16px;
    align-items: start;
}

.fg-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fg-wide { grid-column: span 2; }
.fg-full { grid-column: 1 / -1; }

.fg-field label {
    margin-bottom: 4px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Required fields get a small marker. */
.fg-field:has(:required) label::after {
    content: " *";
    color: var(--accent, var(--red));
}

.fg-field input:not([type="checkbox"]):not([type="radio"]),
.fg-field select {
    height: 34px;
    padding: 6px 10px;
    font-size: 14px;
}

.fg-field textarea {
    min-height: 68px;
    padding: 7px 10px;
    resize: vertical;
}

/* Checkbox: box and label on one line, aligned with the inputs. */
.fg-check {
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    align-self: end;
    min-height: 34px;
}

.fg-check label { margin: 0; }

/* Help text: one line; the full text shows on hover. */
.fg-help {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fg-error input,
.fg-error select,
.fg-error textarea {
    border-color: var(--red);
    background: var(--red-bg);
}

.fg-msg {
    margin-top: 3px;
    color: var(--red);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

/* Save / Cancel stay visible at the bottom while scrolling. */
.fg-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 0;
    padding: 12px 0;
    background: linear-gradient(to bottom, rgba(242, 245, 249, 0), var(--bg) 35%);
}

@media (max-width: 720px) {
    .fg-card { padding: 16px; }
    .fg-grid { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
    .fg-wide { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
    .fg-grid { grid-template-columns: 1fr; }
}
