/* Wide change forms: on every add / change page the fields of a section sit side by side in as many columns as
   fit (label above the input), instead of one field per line with the right half of the screen empty.
   Rows that need the room – long texts, tables, lists, several fields in one row – take the full width.
   Loaded after theme.css from templates/admin/base_site.html; bump its ?v= there after editing. */

@media (min-width: 900px) {
    body.change-form #content-main form > div > fieldset.module {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 0 20px;
        align-items: start;
        align-content: start;  /* a section stretched to its neighbour's height keeps its fields at the top */
    }
    body.change-form #content-main form > div > fieldset.module > h2,
    body.change-form #content-main form > div > fieldset.module > .description { grid-column: 1 / -1; }
    body.change-form #content-main form > div > fieldset.module > .description { margin: 0; padding: 8px 12px 0; font-size: 0.8rem; }

    body.change-form #content-main form > div > fieldset.module > .form-row {
        min-width: 0;
        padding: 8px 12px 10px;
        border-bottom: none;
        overflow: visible;
    }

    /* short sections (at most three fields, none of them wide) share a line two by two */
    body.change-form #content-main form > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
    body.change-form #content-main form > div > * { grid-column: 1 / -1; min-width: 0; }
    body.change-form #content-main form > div > fieldset.module:not(:has(> .form-row ~ .form-row ~ .form-row ~ .form-row)):not(
        :has(> .form-row :is(textarea, .readonly table, .readonly ul, .readonly pre))):not(:has(> .form-row > .form-multiline)):not(
        :has(> .description)) { grid-column: span 1; align-self: stretch; }

    /* so do the read-only panels that are a section on their own (előszűrő, pontozás, költségvetés …) */
    body.change-form #content-main form > div > fieldset.module:not(:has(> .form-row ~ .form-row)):not(:has(textarea)) { grid-column: span 1; align-self: stretch; }
    body.change-form #content-main form > div > fieldset.module > .form-row .readonly { overflow-x: auto; }

    /* full-width rows */
    body.change-form #content-main form > div > fieldset.module > .form-row:has(textarea),
    body.change-form #content-main form > div > fieldset.module > .form-row:has(.readonly :is(table, ul, pre)),
    body.change-form #content-main form > div > fieldset.module > .form-row:has(> .form-multiline),
    body.change-form #content-main form > div > fieldset.module > .form-row:has(input[type=checkbox] ~ input[type=checkbox]),
    body.change-form #content-main form > div > fieldset.module > .form-row:has(div[id^="id_"] input[type=checkbox]),
    body.change-form #content-main form > div > fieldset.module > .form-row.errors:has(.errornote) { grid-column: 1 / -1; }

    /* label above the field */
    body.change-form #content-main form > div > fieldset.module > .form-row > div > .flex-container:not(.checkbox-row),
    body.change-form #content-main form > div > fieldset.module .form-multiline .fieldBox:not(.checkbox-row) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    body.change-form #content-main form > div > fieldset.module > .form-row label:not(.vCheckboxLabel) {
        float: none;
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 0;
        font-size: 0.74rem;
        line-height: 1.3;
        color: var(--body-quiet-color);
    }
    /* labels inside a multiple-choice list (e.g. vármegyék) stay normal text next to their box */
    body.change-form #content-main form > div > fieldset.module > .form-row div[id^="id_"] label {
        font-size: 0.85rem;
        color: var(--body-fg);
    }

    /* fields fill their column */
    body.change-form #content-main form > div > fieldset.module > .form-row :is(input[type=text], input[type=email], input[type=url],
        input[type=number], input[type=password], input[type=tel], select, textarea, .vTextField) {
        width: 100%;
        max-width: none;
        box-sizing: border-box;
    }
    body.change-form #content-main form > div > fieldset.module > .form-row .date-field,
    body.change-form #content-main form > div > fieldset.module > .form-row p.date { width: 100%; margin: 0; }
    body.change-form #content-main form > div > fieldset.module > .form-row p.file-upload { margin: 0; overflow-wrap: anywhere; }
    body.change-form #content-main form > div > fieldset.module > .form-row .related-widget-wrapper { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; width: 100%; }
    body.change-form #content-main form > div > fieldset.module > .form-row .related-widget-wrapper > :is(select, .select2) { flex: 1 1 0; min-width: 0; width: auto; }
    body.change-form #content-main form > div > fieldset.module > .form-row .related-widget-wrapper .select2-container { flex: 1 1 0; width: auto !important; min-width: 0; }
    body.change-form #content-main form > div > fieldset.module > .form-row .related-widget-wrapper > a { flex: none; }
    body.change-form #content-main form > div > fieldset.module > .form-row > div > .flex-container > .select2-container { width: 100% !important; min-width: 0; }
    body.change-form #content-main form > div > fieldset.module > .form-row .readonly { margin: 0; padding: 0; overflow-wrap: anywhere; }

    body.change-form #content-main form > div > fieldset.module > .form-row .help,
    body.change-form #content-main form > div > fieldset.module > .form-row p.help {
        margin: 3px 0 0;
        padding: 0;
        font-size: 0.7rem;
        line-height: 1.35;
    }

    /* notes are a few lines high (drag the corner for more); the long texts – drafts, templates, contracts – stay tall */
    body.change-form #content-main form > div > fieldset.module > .form-row textarea { height: 6.5em; min-height: 3.5em; resize: vertical; }
    body.change-form #content-main form > div > fieldset.module > .form-row:is(.field-content, .field-body) textarea { height: 30em; }
    body.change-form #content-main form > div > fieldset.module > .form-row.field-project_summary textarea { height: 10em; }

    /* a single tick box lines up with the inputs of its neighbours */
    body.change-form #content-main form > div > fieldset.module > .form-row > div > .flex-container.checkbox-row { padding-top: 21px; align-items: center; }

    /* several fields in one row (dates, the "ki pályázhat" boxes): spread evenly */
    body.change-form #content-main form > div > fieldset.module > .form-row > .form-multiline {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 8px 20px;
        align-items: start;
    }
    body.change-form #content-main form > div > fieldset.module > .form-row > .form-multiline > div { min-width: 0; margin: 0; }
    body.change-form #content-main form > div > fieldset.module > .form-row > .form-multiline .fieldBox { margin: 0; }

    /* multiple-choice lists flow in columns instead of one long list */
    body.change-form #content-main form > div > fieldset.module > .form-row div[id^="id_"]:has(> div > label > input[type=checkbox]) {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
        gap: 2px 16px;
    }
}

/* Action buttons on every list (templates/admin/actions.html): one button per action. */
#changelist .actions.action-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
#changelist .actions.action-buttons .button { margin: 0; padding: 7px 14px; height: auto; white-space: nowrap; }
#changelist .actions.action-buttons .button.action-danger { background: transparent; color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.5); margin-left: auto; order: 99; }
#changelist .actions.action-buttons .button.action-danger:hover { background: rgba(248, 113, 113, 0.15); }
#changelist .actions.action-buttons .action-counter { margin-left: 4px; }


/* Súgó (config/help.py): the box under the page title and the help page */
details.page-help { margin: -8px 0 16px; border: 1px solid var(--hairline-color); border-radius: 12px; background: var(--card-bg); }
details.page-help > summary { cursor: pointer; padding: 9px 14px; font-weight: 600; font-size: 0.85rem; color: var(--body-medium-color);
    list-style: none; display: flex; align-items: center; gap: 8px; }
details.page-help > summary::-webkit-details-marker { display: none; }
details.page-help[open] > summary { border-bottom: 1px solid var(--hairline-color); }
.ph-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #12141a;
    font-size: 0.75rem; font-weight: 700; }
.ph-body { padding: 10px 16px 12px; font-size: 0.88rem; line-height: 1.5; }
.ph-body p, .help-item p { margin: 0 0 8px; }
.ph-sources { margin: 0 0 8px; padding-left: 18px; }
.ph-sources li { margin: 3px 0; list-style: disc; }
.ph-in b { color: #34d399; } .ph-out b { color: #fbbf24; } .ph-manual b { color: var(--body-quiet-color); }
.ph-more { margin: 0 !important; font-size: 0.8rem; }
.help-page .help-section { margin-bottom: 18px; }
.help-page .help-item { padding: 10px 16px; border-bottom: 1px solid var(--hairline-color); }
.help-page .help-item:last-child { border-bottom: none; }
.help-page .help-item h3 { margin: 0 0 4px; font-size: 0.95rem; text-transform: none; letter-spacing: 0; background: none; padding: 0; }
.help-page .help-item p { line-height: 1.5; }
#user-tools a.help-link { margin-right: 10px; font-weight: 600; }
/* With the Súgó box under the title the object tools (Történet …) are placed on the title band by position, not by the
   negative margin of theme.css, which would land them on the help box. */
html body #content:has(> details.page-help) { position: relative; }
html body #content:has(> details.page-help) .object-tools { position: absolute; top: 40px; right: 52px; margin: 0; min-height: 0; }

.notif-item.kind-feladat .notif-meta { color: #a3e635; }
