/* Tiered (multi-level) menu — PrimeVue-style. Built on .popover-panel; submenus
   cascade to the right on hover. Mirrors the SingleSelect / multiselect look. */

.popover-panel.tiered-menu-popover {
    background-color: var(--card-bg, var(--bg-primary, #ffffff));
    min-width: 100px;
    /* max-height: 300px; */
    /* overflow: auto; */
    display: flex;
    flex-direction: column;
    gap: 2px;
    user-select: none;
}

.tiered-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary, #111827);
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    line-height: 1.2;
    transition: background 0.2s ease-out, color 0.2s ease-out;
}

.tiered-menu-item:hover {
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
}

.tiered-menu-item[data-badge]::before {
    content: attr(data-badge);
    background-color: var(--accent);
    color: white;
    font-size: 9px;
    padding: 3px 5px;
    letter-spacing: 1.5px;
    border-radius: 22px;
    font-weight: 600;
}

.tiered-menu-item.danger {
    color: #dc2626;
}

.tiered-menu-item.danger:hover {
    background: color-mix(in srgb, #dc2626 16%, transparent);
    color: #dc2626;
}

.tiered-menu-item.success {
    color: #4fc74f;
}

.tiered-menu-item.success:hover {
    background: color-mix(in srgb, #4fc74f 16%, transparent);
    color: #4fc74f;
}

.tiered-menu-item.disabled {
    color: var(--text-tertiary, #9ca3af);
    cursor: not-allowed;
}

.tiered-menu-item.disabled:hover {
    background: transparent;
}

.tiered-menu-icon {
    font-size: 0.875rem;
    line-height: 1;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.tiered-menu-label {
    flex: 1;
    white-space: nowrap;
}

.tiered-menu-arrow {
    font-size: 11px;
    line-height: 1;
    flex-shrink: 0;
    color: var(--accent, #9ca3af);
}

.tiered-menu-separator {
    height: 1px;
    margin: 4px 6px;
    background: var(--border-docs);
}

/* Submenu parent + cascading nested panel (same surface as the main panel) */
.tiered-menu-item.has-submenu {
    position: relative;
}

.tiered-menu-submenu {
    position: absolute;
    left: 100%;
    top: -6px;
    min-width: 200px;
    display: none;
    flex-direction: column;
    gap: 2px;
    background-color: var(--card-bg, var(--bg-primary, #ffffff));
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 6px;
    z-index: 1;
}

.tiered-menu-item.has-submenu:hover > .tiered-menu-submenu {
    display: flex;
}

/* Not enough room to the right — cascade to the left instead. Set from Rust
   after measuring the submenu (see fit_submenu). */
.tiered-menu-item.has-submenu.flip-left > .tiered-menu-submenu {
    left: auto;
    right: 100%;
}

/* Custom rows (search picker, headers) rendered inside a menu / submenu */
.tiered-menu-custom {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 200px;
}

.tiered-menu-search {
    width: 100%;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-docs, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #111827);
    font-size: 0.8125rem;
    outline: none;
}

.tiered-menu-search:focus {
    border-color: var(--accent);
}

/* Browse mode: folder rows cascade their file submenus to the right, so this
   container must NOT clip horizontally. */
.tiered-menu-search-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: visible;
}

/* Search mode: a flat list of files with no cascading submenus, safe to scroll. */
.tiered-menu-flat-scroll {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 260px;
    overflow-y: auto;
}

.tiered-menu-hint {
    font-size: 0.7rem;
    color: var(--text-tertiary, #9ca3af);
    margin-left: auto;
    padding-left: 0.5rem;
    flex-shrink: 0;
}
