/* Shared floating hover feedback for action and filter buttons.
   Component colors and keyboard focus indicators retain their existing meaning. */
:root {
    --dNDT-action-hover-shadow: 0 8px 16px 0 rgba(0, 0, 0, .2), 0 6px 20px 0 rgba(0, 0, 0, .19);
}

/* Layout: explicit actions, segmented groups and field actions. */
/* Explicit opt-in for actions that use W3's otherwise navigation-oriented button. */
.dNDT-action-button {
    box-sizing: border-box;
    max-width: 100%;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 1rem;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: break-word;
    vertical-align: top;
}

/* The group clips segment corners; draw the focused segment's outline inside. */
.dNDT-btn-group > .dNDT-btn-segment:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -3px;
}

/* gap applies between rows too, without indenting a wrapped delete action. */
.dNDT-field-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 8px;
    margin-block-start: 4px;
}

/* Stored previews must fit the same narrow field column as their actions. */
:is(.field-signature_image, .field-stamp_image) .readonly > img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Signature and stamp actions share the compact account button appearance. */
:is(.field-signature_image, .field-stamp_image) .w3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 1rem;
    line-height: 1.4;
    white-space: normal;
    min-width: 0;
}

:is(.field-signature_image, .field-stamp_image) .w3-btn > span {
    min-width: 0;
    text-transform: none;
    overflow-wrap: anywhere;
}

:is(.field-signature_image, .field-stamp_image) .w3-btn i {
    font-size: .9em;
}

/* Filter bars use flex layout and must not clip the shadow with W3 overflow. */
.w3-bar.dNDT-list-filters {
    overflow: visible;
}

/* Interaction states: hover, native upload overlay, keyboard focus, disabled. */
:where(
    .w3-btn,
    .dNDT-btn,
    .dNDT-action-button,
    .dNDT-filter-button,
    .dNDT-dialog-button,
    .ui-dialog-buttonpane button,
    .scheduler-modal__action,
    .scheduler-calendar__nav > .scheduler-calendar__button--collapsible,
    .scheduler-timeline__nav > .scheduler-timeline__button--collapsible,
    .p-datatable-header .p-button,
    .p-dialog-footer .p-button,
    /* Shadow the wrapper, preserving the segments' clipped corners and dividers. */
    .dNDT-btn-group:has(> .dNDT-btn-segment:hover:not(.w3-hover-none, :disabled, .w3-disabled, .p-disabled, [aria-disabled="true"]))
):hover:not(:where(
    .w3-hover-none, :disabled, .w3-disabled, .p-disabled, [aria-disabled="true"],
    .w3-disabled *, .p-disabled *, [aria-disabled="true"] *,
    .submit-iconbar.dNDT-changeform-actions *, .dNDT-user-settings-dropdown *,
    nav *, [role="navigation"] *, #dNDT-nav-sidebar *, #breadcrumb *,
    tbody *, [role="row"] *, .p-paginator *, .dNDT-pagination :not(.dNDT-list-save),
    .dNDT-period-step, .dNDT-filter-control .w3-dropdown-content *
)) {
    /* Override local flat styles, including independently loaded Vue styles. */
    box-shadow: var(--dNDT-action-hover-shadow) !important;
}

/* The native input receives pointer events. Its focus outline and hover shadow
   are independent, so keyboard focus must not suppress pointer feedback. */
.dNDT-upload-field:hover:not(:has(.dNDT-upload-input:disabled)):not(:where(
    tbody *, [role="row"] *, nav *, #breadcrumb *, #dNDT-nav-sidebar *,
    .w3-disabled, .w3-disabled *, [aria-disabled="true"], [aria-disabled="true"] *
)) .dNDT-upload-button:not(.w3-hover-none, .w3-disabled, [aria-disabled="true"]) {
    box-shadow: var(--dNDT-action-hover-shadow);
}

/* W3 clears link outlines on hover; action links still need a keyboard marker.
   More specific component focus styles retain their own outline treatment. */
:is(.w3-btn, .dNDT-btn, .dNDT-action-button, .dNDT-filter-button):focus-visible:not(:where(
    :disabled, .w3-disabled, [aria-disabled="true"],
    nav *, #breadcrumb *, #dNDT-nav-sidebar *, .dNDT-user-settings-dropdown *,
    .submit-iconbar.dNDT-changeform-actions *
)) {
    outline: 1px solid var(--body-quiet-color, #666);
    outline-offset: 1px;
}

/* These components use box-shadow for focus. When hover replaces that shadow,
   retain a distinct keyboard indicator without changing their focus-only style. */
:is(
    .scheduler-modal__action,
    .scheduler-calendar__nav > .scheduler-calendar__button--collapsible,
    .scheduler-timeline__nav > .scheduler-timeline__button--collapsible,
    .p-datatable-header .p-button,
    .p-dialog-footer .p-button
):focus-visible:hover:not(:disabled, .p-disabled, [aria-disabled="true"]) {
    outline: 2px solid var(--body-quiet-color, #666) !important;
    outline-offset: 2px !important;
}

:is(.w3-btn, .dNDT-btn, .dNDT-dialog-button, .ui-dialog-buttonpane button):is(
    :disabled, .w3-disabled, [aria-disabled="true"]
):hover {
    box-shadow: none !important;
}
