/* Viewport-aware dropdown panel. Combines the elevated surface of the rich tooltip
   with the sectional layout of app-modal (help, scrollable body, right-aligned
   button strip). Classes only apply under .rich-dropdown / .rich-dropdown-panel. */

.rich-dropdown {
    display: inline-flex;
    position: relative;
    vertical-align: middle;
}

.rich-dropdown-panel {
    display: none;
    position: fixed;
    z-index: 10000;
    min-width: 20rem;
    max-width: min(28rem, calc(100vw - 16px));
    max-height: min(24rem, calc(100vh - 16px));
    flex-direction: column;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 5px;
    box-shadow: var(--modal-shadow, 0 2px 8px rgba(0, 0, 0, 0.18));
    /* Keep visible so nested widgets (e.g. tags_multiselect) can open outside the panel. */
    overflow: visible;
}

.rich-dropdown.is-active > .rich-dropdown-panel {
    display: flex;
}

/* A form that wraps help/body/buttons must itself be the flex column so the
   body can scroll while the footer stays pinned. */
.rich-dropdown-panel > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
    margin: 0;
    flex: 1 1 auto;
}

.rich-dropdown-help {
    flex-shrink: 0;
    margin: 12px 12px 0;
    padding: 12px 16px;
    background-color: var(--bg-secondary, var(--surface-elevated));
    border: 1px solid var(--border-primary);
    border-radius: 4px;
}

.rich-dropdown-help,
.rich-dropdown-help p {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.rich-dropdown-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

.rich-dropdown-help + .rich-dropdown-body {
    padding-top: 10px;
}

.rich-dropdown-body > :first-child {
    margin-top: 0;
}

.rich-dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 2px;
    color: var(--text-primary);
}

.rich-dropdown-item:hover {
    background-color: var(--bg-secondary, var(--surface-elevated));
}

.rich-dropdown-item input[type="checkbox"] {
    margin-top: 0.2em;
    flex-shrink: 0;
}

.rich-dropdown-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    padding: 10px 12px;
    border-top: 1px solid var(--border-primary);
    background-color: var(--bg-primary);
}

.rich-dropdown-buttons .button,
.rich-dropdown-buttons .button-group {
    float: none;
    margin: 0;
}

/* Force footer actions to the small size used in compact chrome. */
.rich-dropdown-buttons .button:not(.is-small) {
    font-size: 0.75rem;
    height: auto;
    min-height: 1.875em;
    padding-left: 0.75em;
    padding-right: 0.75em;
}
