/*
 * form.css
 *
 * Base form element layout — single-column grid with auto-centering.
 * Bridges HTML form elements and the application's spacing conventions.
 * Exists to provide a consistent default form structure across the app.
 */

form {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 2px;
    padding: 20px;
    width: 100%;
    /* max-width: fit-content; */
    margin: auto;
    background-color: var(--bg_color);
    color: var(--text_color);
    border-radius: var(--border_radius_small);
    box-shadow: 0 2px 5px rgb(0 0 0 / 10%);
}

/* The panel above belongs to forms on a page. Inside a dialog the dialog's
   own sheet margins are the only frame (modals.css), so a form there draws
   no padding, surface, rounding or shadow of its own. `:where()` adds no
   specificity: this outranks only the rule above, and a feature's own form
   rule still decides that form. */
:where(.modal) form {
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
}

.form_with_border {
    border: 1px solid var(--border_color);
}

.form-label {
    display: flex;
    flex-direction: column;
    font-weight: bold;
}

/* Native buttons, and links that must look like one (.button-like-link): a
   result card's footer "show more" is a link, so search engines follow it and a
   person can open it in a new tab, but it keeps the look of the card's buttons. */
button,
.button-like-link {
    /* padding: 5px; */
    background-color: var(--button_bg_color);
    color: var(--button_text_color);
    border: 1px solid var(--border_color);
    border-radius: var(--border_radius_small);
    cursor: pointer;
    font-size: 1rem;
    transition:
        background-color var(--interaction-duration-fast, 140ms) ease,
        color var(--interaction-duration-fast, 140ms) ease,
        box-shadow var(--interaction-duration-fast, 140ms) ease,
        filter var(--interaction-duration-fast, 140ms) ease;
}

/* What a browser gives a button by itself and not a link. */
.button-like-link {
    display: inline-block;
    font-weight: normal;
    line-height: normal;
    text-align: center;
    text-decoration: none;
}

.button {
    min-height: 36px;
    background: var(--interaction-control-bg-rest, var(--button_bg_color));
    box-shadow: var(--interaction-control-shadow-rest, none);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.button:hover:not(:disabled) {
    background: var(--interaction-control-bg-hover, var(--button_hover_bg_color));
}

.button:active:not(:disabled) {
    background: var(--interaction-control-bg-active, var(--button_active_bg_color));
    box-shadow: var(--interaction-control-shadow-active, none);
    filter: brightness(.96);
}

.button:focus-visible {
    outline: 3px solid var(--interaction-focus-ring, var(--primary_color));
    outline-offset: 4px;
}


button[type="submit"] {
    align-self: start;
    /* Lähetä-painike vasemmalle */
}

.user_profile_action_button {
    justify-self: start;
    width: auto;
}

.action-value-row {
    display: grid;
    grid-template-columns: 1fr;
    /* Yksi sarake, kaikki elementit allekkain */
    grid-gap: 10px;
    padding: 10px;
    border: 1px solid var(--border_color);
    border-radius: var(--border_radius_small);
    background-color: var(--bg_color);
}

.action-value-row label {
    font-weight: normal;
}

.action-value-row button {
    align-self: start;
    /* Poista-painike vasemmalle */
    background-color: var(--button_bg_color);
    color: var(--button_text_color);
    border: 1px solid var(--border_color);
    border-radius: var(--border_radius_small);
}

#action-values_container {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 10px;
}

#action-values-list {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 10px;
}

#action-values_container > button {
    width: fit-content;
    align-self: start;
}




select {
    background-color: var(--bg_color_2);
    color: var(--text_color);
    /* box-shadow: 0 2px 5px rgb(0 0 0 / 100%); */
}


.management_forms {
    /* Named, because a sticky header inside this scroller offsets itself by it
       to meet the scroller's edge (dataset_form/dataset_form.css). */
    --management-forms-padding: 20px;
    height: 100vh;
    padding: var(--management-forms-padding);
    overflow: auto;
}

.management_forms > form {
    max-width: 768px;
    margin: 20px auto;
}

/* Kehys admin-työkaluille: rajoittaa leveyttä ja keskittää sisällön.
   Käytetään työkaluissa joissa taulukkoa leveämpi näkymä on turha.
   Oletusleveys 1200px — voidaan yliajaa inline-tyylillä tarvittaessa. */
.tool-content-frame {
    max-width: 1200px;
    margin: 0 auto;
}

.shared_asset_file_input_group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shared_asset_file_help {
    color: var(--empty_field_text_color);
    font-size: 0.9rem;
}

.shared_asset_selected_files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shared_asset_selected_file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border_color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg_color_text) 86%, var(--bg_color_extreme) 14%);
    max-width: 100%;
}

.shared_asset_selected_file_label {
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.shared_asset_selected_file_remove {
    min-width: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }
}

@media (width <= 700px) {
    /* Keep the scroller and its dataset sticky-header offset on one inset. */
    .management_forms { --management-forms-padding: 16px; }
    .management_forms > form {
        width: auto;
        max-width: none;
        margin-inline: -16px;
        padding-inline: 16px;
        border-radius: 0;
    }
    .management_forms > form fieldset {
        margin-inline: 0;
        padding-inline: 0;
        border-inline-width: 0;
    }
    /* The fixed menu occupies x=12..56, y=12..56; leave an 8px title gap. */
    .management_forms > :is(h1, h2, h3, h4, h5, h6):first-child {
        display: flex;
        align-items: center;
        min-height: 44px;
        margin-block-start: -4px;
        margin-inline-start: 48px;
    }
}
